babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361
  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. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. 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>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. 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;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by 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. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * 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".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * 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"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * 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)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * 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
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. 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;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. 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;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * 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"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * 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".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4415. /**
  4416. * 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"
  4417. * This function works in right handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * 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".
  4426. * This function works in right handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-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 right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-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 PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  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 PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * 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.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * 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)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @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
  4940. * @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
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. 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);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of float in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 of float in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 of float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. 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;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. 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;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. 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;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. 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);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * 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;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * 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).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * 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).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets the global Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * 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.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * 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.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * 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.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * 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.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * 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).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * 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).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets the highlights Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * 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.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * 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.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * 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.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * 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.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * 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).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * 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).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets the midtones Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * 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.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * 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.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * 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.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * 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.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * 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).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * 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).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * 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.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets the shadows Density value.
  8157. * 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.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * 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.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * 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.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * 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.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * 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.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * 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)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * 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
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @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
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @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
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @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
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @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
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @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
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. 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;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. 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;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * 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.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * 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.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * 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.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** 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 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * 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)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * 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.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * 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.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * 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.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * 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)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * 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.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * 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.
  11851. * 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: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. /**
  11865. * Specifies if the particles are updated in emitter local space or world space
  11866. */
  11867. isLocal: boolean;
  11868. private _rootParticleSystem;
  11869. /**
  11870. * Gets the current list of active particles
  11871. */
  11872. get particles(): Particle[];
  11873. /**
  11874. * Returns the string "ParticleSystem"
  11875. * @returns a string containing the class name
  11876. */
  11877. getClassName(): string;
  11878. /**
  11879. * Instantiates a particle system.
  11880. * 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.
  11881. * @param name The name of the particle system
  11882. * @param capacity The max number of particles alive at the same time
  11883. * @param scene The scene the particle system belongs to
  11884. * @param customEffect a custom effect used to change the way particles are rendered by default
  11885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11886. * @param epsilon Offset used to render the particles
  11887. */
  11888. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11889. private _addFactorGradient;
  11890. private _removeFactorGradient;
  11891. /**
  11892. * Adds a new life time gradient
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param factor defines the life time factor to affect to the specified gradient
  11895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11896. * @returns the current particle system
  11897. */
  11898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11899. /**
  11900. * Remove a specific life time gradient
  11901. * @param gradient defines the gradient to remove
  11902. * @returns the current particle system
  11903. */
  11904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11905. /**
  11906. * Adds a new size gradient
  11907. * @param gradient defines the gradient to use (between 0 and 1)
  11908. * @param factor defines the size factor to affect to the specified gradient
  11909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11910. * @returns the current particle system
  11911. */
  11912. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11913. /**
  11914. * Remove a specific size gradient
  11915. * @param gradient defines the gradient to remove
  11916. * @returns the current particle system
  11917. */
  11918. removeSizeGradient(gradient: number): IParticleSystem;
  11919. /**
  11920. * Adds a new color remap gradient
  11921. * @param gradient defines the gradient to use (between 0 and 1)
  11922. * @param min defines the color remap minimal range
  11923. * @param max defines the color remap maximal range
  11924. * @returns the current particle system
  11925. */
  11926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11927. /**
  11928. * Remove a specific color remap gradient
  11929. * @param gradient defines the gradient to remove
  11930. * @returns the current particle system
  11931. */
  11932. removeColorRemapGradient(gradient: number): IParticleSystem;
  11933. /**
  11934. * Adds a new alpha remap gradient
  11935. * @param gradient defines the gradient to use (between 0 and 1)
  11936. * @param min defines the alpha remap minimal range
  11937. * @param max defines the alpha remap maximal range
  11938. * @returns the current particle system
  11939. */
  11940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11941. /**
  11942. * Remove a specific alpha remap gradient
  11943. * @param gradient defines the gradient to remove
  11944. * @returns the current particle system
  11945. */
  11946. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11947. /**
  11948. * Adds a new angular speed gradient
  11949. * @param gradient defines the gradient to use (between 0 and 1)
  11950. * @param factor defines the angular speed to affect to the specified gradient
  11951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11952. * @returns the current particle system
  11953. */
  11954. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11955. /**
  11956. * Remove a specific angular speed gradient
  11957. * @param gradient defines the gradient to remove
  11958. * @returns the current particle system
  11959. */
  11960. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11961. /**
  11962. * Adds a new velocity gradient
  11963. * @param gradient defines the gradient to use (between 0 and 1)
  11964. * @param factor defines the velocity to affect to the specified gradient
  11965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11966. * @returns the current particle system
  11967. */
  11968. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11969. /**
  11970. * Remove a specific velocity gradient
  11971. * @param gradient defines the gradient to remove
  11972. * @returns the current particle system
  11973. */
  11974. removeVelocityGradient(gradient: number): IParticleSystem;
  11975. /**
  11976. * Adds a new limit velocity gradient
  11977. * @param gradient defines the gradient to use (between 0 and 1)
  11978. * @param factor defines the limit velocity value to affect to the specified gradient
  11979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11980. * @returns the current particle system
  11981. */
  11982. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11983. /**
  11984. * Remove a specific limit velocity gradient
  11985. * @param gradient defines the gradient to remove
  11986. * @returns the current particle system
  11987. */
  11988. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11989. /**
  11990. * Adds a new drag gradient
  11991. * @param gradient defines the gradient to use (between 0 and 1)
  11992. * @param factor defines the drag value to affect to the specified gradient
  11993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11994. * @returns the current particle system
  11995. */
  11996. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11997. /**
  11998. * Remove a specific drag gradient
  11999. * @param gradient defines the gradient to remove
  12000. * @returns the current particle system
  12001. */
  12002. removeDragGradient(gradient: number): IParticleSystem;
  12003. /**
  12004. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12005. * @param gradient defines the gradient to use (between 0 and 1)
  12006. * @param factor defines the emit rate value to affect to the specified gradient
  12007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12008. * @returns the current particle system
  12009. */
  12010. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12011. /**
  12012. * Remove a specific emit rate gradient
  12013. * @param gradient defines the gradient to remove
  12014. * @returns the current particle system
  12015. */
  12016. removeEmitRateGradient(gradient: number): IParticleSystem;
  12017. /**
  12018. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12019. * @param gradient defines the gradient to use (between 0 and 1)
  12020. * @param factor defines the start size value to affect to the specified gradient
  12021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12022. * @returns the current particle system
  12023. */
  12024. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12025. /**
  12026. * Remove a specific start size gradient
  12027. * @param gradient defines the gradient to remove
  12028. * @returns the current particle system
  12029. */
  12030. removeStartSizeGradient(gradient: number): IParticleSystem;
  12031. private _createRampGradientTexture;
  12032. /**
  12033. * Gets the current list of ramp gradients.
  12034. * You must use addRampGradient and removeRampGradient to udpate this list
  12035. * @returns the list of ramp gradients
  12036. */
  12037. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12038. /**
  12039. * Adds a new ramp gradient used to remap particle colors
  12040. * @param gradient defines the gradient to use (between 0 and 1)
  12041. * @param color defines the color to affect to the specified gradient
  12042. * @returns the current particle system
  12043. */
  12044. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12045. /**
  12046. * Remove a specific ramp gradient
  12047. * @param gradient defines the gradient to remove
  12048. * @returns the current particle system
  12049. */
  12050. removeRampGradient(gradient: number): ParticleSystem;
  12051. /**
  12052. * Adds a new color gradient
  12053. * @param gradient defines the gradient to use (between 0 and 1)
  12054. * @param color1 defines the color to affect to the specified gradient
  12055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12056. * @returns this particle system
  12057. */
  12058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12059. /**
  12060. * Remove a specific color gradient
  12061. * @param gradient defines the gradient to remove
  12062. * @returns this particle system
  12063. */
  12064. removeColorGradient(gradient: number): IParticleSystem;
  12065. private _fetchR;
  12066. protected _reset(): void;
  12067. private _resetEffect;
  12068. private _createVertexBuffers;
  12069. private _createIndexBuffer;
  12070. /**
  12071. * Gets the maximum number of particles active at the same time.
  12072. * @returns The max number of active particles.
  12073. */
  12074. getCapacity(): number;
  12075. /**
  12076. * Gets whether there are still active particles in the system.
  12077. * @returns True if it is alive, otherwise false.
  12078. */
  12079. isAlive(): boolean;
  12080. /**
  12081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12082. * @returns True if it has been started, otherwise false.
  12083. */
  12084. isStarted(): boolean;
  12085. private _prepareSubEmitterInternalArray;
  12086. /**
  12087. * Starts the particle system and begins to emit
  12088. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12089. */
  12090. start(delay?: number): void;
  12091. /**
  12092. * Stops the particle system.
  12093. * @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.
  12094. */
  12095. stop(stopSubEmitters?: boolean): void;
  12096. /**
  12097. * Remove all active particles
  12098. */
  12099. reset(): void;
  12100. /**
  12101. * @hidden (for internal use only)
  12102. */
  12103. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12104. /**
  12105. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12106. * Its lifetime will start back at 0.
  12107. */
  12108. recycleParticle: (particle: Particle) => void;
  12109. private _stopSubEmitters;
  12110. private _createParticle;
  12111. private _removeFromRoot;
  12112. private _emitFromParticle;
  12113. private _update;
  12114. /** @hidden */
  12115. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12116. /** @hidden */
  12117. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12118. /** @hidden */
  12119. private _getEffect;
  12120. /**
  12121. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12122. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12123. */
  12124. animate(preWarmOnly?: boolean): void;
  12125. private _appendParticleVertices;
  12126. /**
  12127. * Rebuilds the particle system.
  12128. */
  12129. rebuild(): void;
  12130. /**
  12131. * Is this system ready to be used/rendered
  12132. * @return true if the system is ready
  12133. */
  12134. isReady(): boolean;
  12135. private _render;
  12136. /**
  12137. * Renders the particle system in its current state.
  12138. * @returns the current number of particles
  12139. */
  12140. render(): number;
  12141. /**
  12142. * Disposes the particle system and free the associated resources
  12143. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12144. */
  12145. dispose(disposeTexture?: boolean): void;
  12146. /**
  12147. * Clones the particle system.
  12148. * @param name The name of the cloned object
  12149. * @param newEmitter The new emitter to use
  12150. * @returns the cloned particle system
  12151. */
  12152. clone(name: string, newEmitter: any): ParticleSystem;
  12153. /**
  12154. * Serializes the particle system to a JSON object.
  12155. * @returns the JSON object
  12156. */
  12157. serialize(): any;
  12158. /** @hidden */
  12159. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12160. /** @hidden */
  12161. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12162. /**
  12163. * Parses a JSON object to create a particle system.
  12164. * @param parsedParticleSystem The JSON object to parse
  12165. * @param scene The scene to create the particle system in
  12166. * @param rootUrl The root url to use to load external dependencies like texture
  12167. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12168. * @returns the Parsed particle system
  12169. */
  12170. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12171. }
  12172. }
  12173. declare module "babylonjs/Particles/particle" {
  12174. import { Nullable } from "babylonjs/types";
  12175. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12176. import { Color4 } from "babylonjs/Maths/math.color";
  12177. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12178. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12179. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12180. /**
  12181. * A particle represents one of the element emitted by a particle system.
  12182. * This is mainly define by its coordinates, direction, velocity and age.
  12183. */
  12184. export class Particle {
  12185. /**
  12186. * The particle system the particle belongs to.
  12187. */
  12188. particleSystem: ParticleSystem;
  12189. private static _Count;
  12190. /**
  12191. * Unique ID of the particle
  12192. */
  12193. id: number;
  12194. /**
  12195. * The world position of the particle in the scene.
  12196. */
  12197. position: Vector3;
  12198. /**
  12199. * The world direction of the particle in the scene.
  12200. */
  12201. direction: Vector3;
  12202. /**
  12203. * The color of the particle.
  12204. */
  12205. color: Color4;
  12206. /**
  12207. * The color change of the particle per step.
  12208. */
  12209. colorStep: Color4;
  12210. /**
  12211. * Defines how long will the life of the particle be.
  12212. */
  12213. lifeTime: number;
  12214. /**
  12215. * The current age of the particle.
  12216. */
  12217. age: number;
  12218. /**
  12219. * The current size of the particle.
  12220. */
  12221. size: number;
  12222. /**
  12223. * The current scale of the particle.
  12224. */
  12225. scale: Vector2;
  12226. /**
  12227. * The current angle of the particle.
  12228. */
  12229. angle: number;
  12230. /**
  12231. * Defines how fast is the angle changing.
  12232. */
  12233. angularSpeed: number;
  12234. /**
  12235. * Defines the cell index used by the particle to be rendered from a sprite.
  12236. */
  12237. cellIndex: number;
  12238. /**
  12239. * The information required to support color remapping
  12240. */
  12241. remapData: Vector4;
  12242. /** @hidden */
  12243. _randomCellOffset?: number;
  12244. /** @hidden */
  12245. _initialDirection: Nullable<Vector3>;
  12246. /** @hidden */
  12247. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12248. /** @hidden */
  12249. _initialStartSpriteCellID: number;
  12250. /** @hidden */
  12251. _initialEndSpriteCellID: number;
  12252. /** @hidden */
  12253. _currentColorGradient: Nullable<ColorGradient>;
  12254. /** @hidden */
  12255. _currentColor1: Color4;
  12256. /** @hidden */
  12257. _currentColor2: Color4;
  12258. /** @hidden */
  12259. _currentSizeGradient: Nullable<FactorGradient>;
  12260. /** @hidden */
  12261. _currentSize1: number;
  12262. /** @hidden */
  12263. _currentSize2: number;
  12264. /** @hidden */
  12265. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12266. /** @hidden */
  12267. _currentAngularSpeed1: number;
  12268. /** @hidden */
  12269. _currentAngularSpeed2: number;
  12270. /** @hidden */
  12271. _currentVelocityGradient: Nullable<FactorGradient>;
  12272. /** @hidden */
  12273. _currentVelocity1: number;
  12274. /** @hidden */
  12275. _currentVelocity2: number;
  12276. /** @hidden */
  12277. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12278. /** @hidden */
  12279. _currentLimitVelocity1: number;
  12280. /** @hidden */
  12281. _currentLimitVelocity2: number;
  12282. /** @hidden */
  12283. _currentDragGradient: Nullable<FactorGradient>;
  12284. /** @hidden */
  12285. _currentDrag1: number;
  12286. /** @hidden */
  12287. _currentDrag2: number;
  12288. /** @hidden */
  12289. _randomNoiseCoordinates1: Vector3;
  12290. /** @hidden */
  12291. _randomNoiseCoordinates2: Vector3;
  12292. /** @hidden */
  12293. _localPosition?: Vector3;
  12294. /**
  12295. * Creates a new instance Particle
  12296. * @param particleSystem the particle system the particle belongs to
  12297. */
  12298. constructor(
  12299. /**
  12300. * The particle system the particle belongs to.
  12301. */
  12302. particleSystem: ParticleSystem);
  12303. private updateCellInfoFromSystem;
  12304. /**
  12305. * Defines how the sprite cell index is updated for the particle
  12306. */
  12307. updateCellIndex(): void;
  12308. /** @hidden */
  12309. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12310. /** @hidden */
  12311. _inheritParticleInfoToSubEmitters(): void;
  12312. /** @hidden */
  12313. _reset(): void;
  12314. /**
  12315. * Copy the properties of particle to another one.
  12316. * @param other the particle to copy the information to.
  12317. */
  12318. copyTo(other: Particle): void;
  12319. }
  12320. }
  12321. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12322. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12323. import { Effect } from "babylonjs/Materials/effect";
  12324. import { Particle } from "babylonjs/Particles/particle";
  12325. import { Scene } from "babylonjs/scene";
  12326. /**
  12327. * Particle emitter represents a volume emitting particles.
  12328. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12329. */
  12330. export interface IParticleEmitterType {
  12331. /**
  12332. * Called by the particle System when the direction is computed for the created particle.
  12333. * @param worldMatrix is the world matrix of the particle system
  12334. * @param directionToUpdate is the direction vector to update with the result
  12335. * @param particle is the particle we are computed the direction for
  12336. * @param isLocal defines if the direction should be set in local space
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. * @param isLocal defines if the position should be set in local space
  12345. */
  12346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12347. /**
  12348. * Clones the current emitter and returns a copy of it
  12349. * @returns the new emitter
  12350. */
  12351. clone(): IParticleEmitterType;
  12352. /**
  12353. * Called by the GPUParticleSystem to setup the update shader
  12354. * @param effect defines the update shader
  12355. */
  12356. applyToShader(effect: Effect): void;
  12357. /**
  12358. * Returns a string to use to update the GPU particles update shader
  12359. * @returns the effect defines string
  12360. */
  12361. getEffectDefines(): string;
  12362. /**
  12363. * Returns a string representing the class name
  12364. * @returns a string containing the class name
  12365. */
  12366. getClassName(): string;
  12367. /**
  12368. * Serializes the particle system to a JSON object.
  12369. * @returns the JSON object
  12370. */
  12371. serialize(): any;
  12372. /**
  12373. * Parse properties from a JSON object
  12374. * @param serializationObject defines the JSON object
  12375. * @param scene defines the hosting scene
  12376. */
  12377. parse(serializationObject: any, scene: Scene): void;
  12378. }
  12379. }
  12380. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12382. import { Effect } from "babylonjs/Materials/effect";
  12383. import { Particle } from "babylonjs/Particles/particle";
  12384. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12385. /**
  12386. * Particle emitter emitting particles from the inside of a box.
  12387. * It emits the particles randomly between 2 given directions.
  12388. */
  12389. export class BoxParticleEmitter implements IParticleEmitterType {
  12390. /**
  12391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12392. */
  12393. direction1: Vector3;
  12394. /**
  12395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12396. */
  12397. direction2: Vector3;
  12398. /**
  12399. * 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.
  12400. */
  12401. minEmitBox: Vector3;
  12402. /**
  12403. * 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.
  12404. */
  12405. maxEmitBox: Vector3;
  12406. /**
  12407. * Creates a new instance BoxParticleEmitter
  12408. */
  12409. constructor();
  12410. /**
  12411. * Called by the particle System when the direction is computed for the created particle.
  12412. * @param worldMatrix is the world matrix of the particle system
  12413. * @param directionToUpdate is the direction vector to update with the result
  12414. * @param particle is the particle we are computed the direction for
  12415. * @param isLocal defines if the direction should be set in local space
  12416. */
  12417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12418. /**
  12419. * Called by the particle System when the position is computed for the created particle.
  12420. * @param worldMatrix is the world matrix of the particle system
  12421. * @param positionToUpdate is the position vector to update with the result
  12422. * @param particle is the particle we are computed the position for
  12423. * @param isLocal defines if the position should be set in local space
  12424. */
  12425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12426. /**
  12427. * Clones the current emitter and returns a copy of it
  12428. * @returns the new emitter
  12429. */
  12430. clone(): BoxParticleEmitter;
  12431. /**
  12432. * Called by the GPUParticleSystem to setup the update shader
  12433. * @param effect defines the update shader
  12434. */
  12435. applyToShader(effect: Effect): void;
  12436. /**
  12437. * Returns a string to use to update the GPU particles update shader
  12438. * @returns a string containng the defines string
  12439. */
  12440. getEffectDefines(): string;
  12441. /**
  12442. * Returns the string "BoxParticleEmitter"
  12443. * @returns a string containing the class name
  12444. */
  12445. getClassName(): string;
  12446. /**
  12447. * Serializes the particle system to a JSON object.
  12448. * @returns the JSON object
  12449. */
  12450. serialize(): any;
  12451. /**
  12452. * Parse properties from a JSON object
  12453. * @param serializationObject defines the JSON object
  12454. */
  12455. parse(serializationObject: any): void;
  12456. }
  12457. }
  12458. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12460. import { Effect } from "babylonjs/Materials/effect";
  12461. import { Particle } from "babylonjs/Particles/particle";
  12462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12463. /**
  12464. * Particle emitter emitting particles from the inside of a cone.
  12465. * It emits the particles alongside the cone volume from the base to the particle.
  12466. * The emission direction might be randomized.
  12467. */
  12468. export class ConeParticleEmitter implements IParticleEmitterType {
  12469. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12470. directionRandomizer: number;
  12471. private _radius;
  12472. private _angle;
  12473. private _height;
  12474. /**
  12475. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12476. */
  12477. radiusRange: number;
  12478. /**
  12479. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12480. */
  12481. heightRange: number;
  12482. /**
  12483. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12484. */
  12485. emitFromSpawnPointOnly: boolean;
  12486. /**
  12487. * Gets or sets the radius of the emission cone
  12488. */
  12489. get radius(): number;
  12490. set radius(value: number);
  12491. /**
  12492. * Gets or sets the angle of the emission cone
  12493. */
  12494. get angle(): number;
  12495. set angle(value: number);
  12496. private _buildHeight;
  12497. /**
  12498. * Creates a new instance ConeParticleEmitter
  12499. * @param radius the radius of the emission cone (1 by default)
  12500. * @param angle the cone base angle (PI by default)
  12501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12502. */
  12503. constructor(radius?: number, angle?: number,
  12504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12505. directionRandomizer?: number);
  12506. /**
  12507. * Called by the particle System when the direction is computed for the created particle.
  12508. * @param worldMatrix is the world matrix of the particle system
  12509. * @param directionToUpdate is the direction vector to update with the result
  12510. * @param particle is the particle we are computed the direction for
  12511. * @param isLocal defines if the direction should be set in local space
  12512. */
  12513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12514. /**
  12515. * Called by the particle System when the position is computed for the created particle.
  12516. * @param worldMatrix is the world matrix of the particle system
  12517. * @param positionToUpdate is the position vector to update with the result
  12518. * @param particle is the particle we are computed the position for
  12519. * @param isLocal defines if the position should be set in local space
  12520. */
  12521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12522. /**
  12523. * Clones the current emitter and returns a copy of it
  12524. * @returns the new emitter
  12525. */
  12526. clone(): ConeParticleEmitter;
  12527. /**
  12528. * Called by the GPUParticleSystem to setup the update shader
  12529. * @param effect defines the update shader
  12530. */
  12531. applyToShader(effect: Effect): void;
  12532. /**
  12533. * Returns a string to use to update the GPU particles update shader
  12534. * @returns a string containng the defines string
  12535. */
  12536. getEffectDefines(): string;
  12537. /**
  12538. * Returns the string "ConeParticleEmitter"
  12539. * @returns a string containing the class name
  12540. */
  12541. getClassName(): string;
  12542. /**
  12543. * Serializes the particle system to a JSON object.
  12544. * @returns the JSON object
  12545. */
  12546. serialize(): any;
  12547. /**
  12548. * Parse properties from a JSON object
  12549. * @param serializationObject defines the JSON object
  12550. */
  12551. parse(serializationObject: any): void;
  12552. }
  12553. }
  12554. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12555. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12556. import { Effect } from "babylonjs/Materials/effect";
  12557. import { Particle } from "babylonjs/Particles/particle";
  12558. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12559. /**
  12560. * Particle emitter emitting particles from the inside of a cylinder.
  12561. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12562. */
  12563. export class CylinderParticleEmitter implements IParticleEmitterType {
  12564. /**
  12565. * The radius of the emission cylinder.
  12566. */
  12567. radius: number;
  12568. /**
  12569. * The height of the emission cylinder.
  12570. */
  12571. height: number;
  12572. /**
  12573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12574. */
  12575. radiusRange: number;
  12576. /**
  12577. * How much to randomize the particle direction [0-1].
  12578. */
  12579. directionRandomizer: number;
  12580. /**
  12581. * Creates a new instance CylinderParticleEmitter
  12582. * @param radius the radius of the emission cylinder (1 by default)
  12583. * @param height the height of the emission cylinder (1 by default)
  12584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12586. */
  12587. constructor(
  12588. /**
  12589. * The radius of the emission cylinder.
  12590. */
  12591. radius?: number,
  12592. /**
  12593. * The height of the emission cylinder.
  12594. */
  12595. height?: number,
  12596. /**
  12597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12598. */
  12599. radiusRange?: number,
  12600. /**
  12601. * How much to randomize the particle direction [0-1].
  12602. */
  12603. directionRandomizer?: number);
  12604. /**
  12605. * Called by the particle System when the direction is computed for the created particle.
  12606. * @param worldMatrix is the world matrix of the particle system
  12607. * @param directionToUpdate is the direction vector to update with the result
  12608. * @param particle is the particle we are computed the direction for
  12609. * @param isLocal defines if the direction should be set in local space
  12610. */
  12611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12612. /**
  12613. * Called by the particle System when the position is computed for the created particle.
  12614. * @param worldMatrix is the world matrix of the particle system
  12615. * @param positionToUpdate is the position vector to update with the result
  12616. * @param particle is the particle we are computed the position for
  12617. * @param isLocal defines if the position should be set in local space
  12618. */
  12619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12620. /**
  12621. * Clones the current emitter and returns a copy of it
  12622. * @returns the new emitter
  12623. */
  12624. clone(): CylinderParticleEmitter;
  12625. /**
  12626. * Called by the GPUParticleSystem to setup the update shader
  12627. * @param effect defines the update shader
  12628. */
  12629. applyToShader(effect: Effect): void;
  12630. /**
  12631. * Returns a string to use to update the GPU particles update shader
  12632. * @returns a string containng the defines string
  12633. */
  12634. getEffectDefines(): string;
  12635. /**
  12636. * Returns the string "CylinderParticleEmitter"
  12637. * @returns a string containing the class name
  12638. */
  12639. getClassName(): string;
  12640. /**
  12641. * Serializes the particle system to a JSON object.
  12642. * @returns the JSON object
  12643. */
  12644. serialize(): any;
  12645. /**
  12646. * Parse properties from a JSON object
  12647. * @param serializationObject defines the JSON object
  12648. */
  12649. parse(serializationObject: any): void;
  12650. }
  12651. /**
  12652. * Particle emitter emitting particles from the inside of a cylinder.
  12653. * It emits the particles randomly between two vectors.
  12654. */
  12655. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12656. /**
  12657. * The min limit of the emission direction.
  12658. */
  12659. direction1: Vector3;
  12660. /**
  12661. * The max limit of the emission direction.
  12662. */
  12663. direction2: Vector3;
  12664. /**
  12665. * Creates a new instance CylinderDirectedParticleEmitter
  12666. * @param radius the radius of the emission cylinder (1 by default)
  12667. * @param height the height of the emission cylinder (1 by default)
  12668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12669. * @param direction1 the min limit of the emission direction (up vector by default)
  12670. * @param direction2 the max limit of the emission direction (up vector by default)
  12671. */
  12672. constructor(radius?: number, height?: number, radiusRange?: number,
  12673. /**
  12674. * The min limit of the emission direction.
  12675. */
  12676. direction1?: Vector3,
  12677. /**
  12678. * The max limit of the emission direction.
  12679. */
  12680. direction2?: Vector3);
  12681. /**
  12682. * Called by the particle System when the direction is computed for the created particle.
  12683. * @param worldMatrix is the world matrix of the particle system
  12684. * @param directionToUpdate is the direction vector to update with the result
  12685. * @param particle is the particle we are computed the direction for
  12686. */
  12687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12688. /**
  12689. * Clones the current emitter and returns a copy of it
  12690. * @returns the new emitter
  12691. */
  12692. clone(): CylinderDirectedParticleEmitter;
  12693. /**
  12694. * Called by the GPUParticleSystem to setup the update shader
  12695. * @param effect defines the update shader
  12696. */
  12697. applyToShader(effect: Effect): void;
  12698. /**
  12699. * Returns a string to use to update the GPU particles update shader
  12700. * @returns a string containng the defines string
  12701. */
  12702. getEffectDefines(): string;
  12703. /**
  12704. * Returns the string "CylinderDirectedParticleEmitter"
  12705. * @returns a string containing the class name
  12706. */
  12707. getClassName(): string;
  12708. /**
  12709. * Serializes the particle system to a JSON object.
  12710. * @returns the JSON object
  12711. */
  12712. serialize(): any;
  12713. /**
  12714. * Parse properties from a JSON object
  12715. * @param serializationObject defines the JSON object
  12716. */
  12717. parse(serializationObject: any): void;
  12718. }
  12719. }
  12720. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12721. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Particle } from "babylonjs/Particles/particle";
  12724. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12725. /**
  12726. * Particle emitter emitting particles from the inside of a hemisphere.
  12727. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12728. */
  12729. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12730. /**
  12731. * The radius of the emission hemisphere.
  12732. */
  12733. radius: number;
  12734. /**
  12735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12736. */
  12737. radiusRange: number;
  12738. /**
  12739. * How much to randomize the particle direction [0-1].
  12740. */
  12741. directionRandomizer: number;
  12742. /**
  12743. * Creates a new instance HemisphericParticleEmitter
  12744. * @param radius the radius of the emission hemisphere (1 by default)
  12745. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12747. */
  12748. constructor(
  12749. /**
  12750. * The radius of the emission hemisphere.
  12751. */
  12752. radius?: number,
  12753. /**
  12754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12755. */
  12756. radiusRange?: number,
  12757. /**
  12758. * How much to randomize the particle direction [0-1].
  12759. */
  12760. directionRandomizer?: number);
  12761. /**
  12762. * Called by the particle System when the direction is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param directionToUpdate is the direction vector to update with the result
  12765. * @param particle is the particle we are computed the direction for
  12766. * @param isLocal defines if the direction should be set in local space
  12767. */
  12768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12769. /**
  12770. * Called by the particle System when the position is computed for the created particle.
  12771. * @param worldMatrix is the world matrix of the particle system
  12772. * @param positionToUpdate is the position vector to update with the result
  12773. * @param particle is the particle we are computed the position for
  12774. * @param isLocal defines if the position should be set in local space
  12775. */
  12776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12777. /**
  12778. * Clones the current emitter and returns a copy of it
  12779. * @returns the new emitter
  12780. */
  12781. clone(): HemisphericParticleEmitter;
  12782. /**
  12783. * Called by the GPUParticleSystem to setup the update shader
  12784. * @param effect defines the update shader
  12785. */
  12786. applyToShader(effect: Effect): void;
  12787. /**
  12788. * Returns a string to use to update the GPU particles update shader
  12789. * @returns a string containng the defines string
  12790. */
  12791. getEffectDefines(): string;
  12792. /**
  12793. * Returns the string "HemisphericParticleEmitter"
  12794. * @returns a string containing the class name
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Serializes the particle system to a JSON object.
  12799. * @returns the JSON object
  12800. */
  12801. serialize(): any;
  12802. /**
  12803. * Parse properties from a JSON object
  12804. * @param serializationObject defines the JSON object
  12805. */
  12806. parse(serializationObject: any): void;
  12807. }
  12808. }
  12809. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12811. import { Effect } from "babylonjs/Materials/effect";
  12812. import { Particle } from "babylonjs/Particles/particle";
  12813. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12814. /**
  12815. * Particle emitter emitting particles from a point.
  12816. * It emits the particles randomly between 2 given directions.
  12817. */
  12818. export class PointParticleEmitter implements IParticleEmitterType {
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Creates a new instance PointParticleEmitter
  12829. */
  12830. constructor();
  12831. /**
  12832. * Called by the particle System when the direction is computed for the created particle.
  12833. * @param worldMatrix is the world matrix of the particle system
  12834. * @param directionToUpdate is the direction vector to update with the result
  12835. * @param particle is the particle we are computed the direction for
  12836. * @param isLocal defines if the direction should be set in local space
  12837. */
  12838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12839. /**
  12840. * Called by the particle System when the position is computed for the created particle.
  12841. * @param worldMatrix is the world matrix of the particle system
  12842. * @param positionToUpdate is the position vector to update with the result
  12843. * @param particle is the particle we are computed the position for
  12844. * @param isLocal defines if the position should be set in local space
  12845. */
  12846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12847. /**
  12848. * Clones the current emitter and returns a copy of it
  12849. * @returns the new emitter
  12850. */
  12851. clone(): PointParticleEmitter;
  12852. /**
  12853. * Called by the GPUParticleSystem to setup the update shader
  12854. * @param effect defines the update shader
  12855. */
  12856. applyToShader(effect: Effect): void;
  12857. /**
  12858. * Returns a string to use to update the GPU particles update shader
  12859. * @returns a string containng the defines string
  12860. */
  12861. getEffectDefines(): string;
  12862. /**
  12863. * Returns the string "PointParticleEmitter"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Serializes the particle system to a JSON object.
  12869. * @returns the JSON object
  12870. */
  12871. serialize(): any;
  12872. /**
  12873. * Parse properties from a JSON object
  12874. * @param serializationObject defines the JSON object
  12875. */
  12876. parse(serializationObject: any): void;
  12877. }
  12878. }
  12879. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12881. import { Effect } from "babylonjs/Materials/effect";
  12882. import { Particle } from "babylonjs/Particles/particle";
  12883. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12884. /**
  12885. * Particle emitter emitting particles from the inside of a sphere.
  12886. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12887. */
  12888. export class SphereParticleEmitter implements IParticleEmitterType {
  12889. /**
  12890. * The radius of the emission sphere.
  12891. */
  12892. radius: number;
  12893. /**
  12894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12895. */
  12896. radiusRange: number;
  12897. /**
  12898. * How much to randomize the particle direction [0-1].
  12899. */
  12900. directionRandomizer: number;
  12901. /**
  12902. * Creates a new instance SphereParticleEmitter
  12903. * @param radius the radius of the emission sphere (1 by default)
  12904. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12905. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12906. */
  12907. constructor(
  12908. /**
  12909. * The radius of the emission sphere.
  12910. */
  12911. radius?: number,
  12912. /**
  12913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12914. */
  12915. radiusRange?: number,
  12916. /**
  12917. * How much to randomize the particle direction [0-1].
  12918. */
  12919. directionRandomizer?: number);
  12920. /**
  12921. * Called by the particle System when the direction is computed for the created particle.
  12922. * @param worldMatrix is the world matrix of the particle system
  12923. * @param directionToUpdate is the direction vector to update with the result
  12924. * @param particle is the particle we are computed the direction for
  12925. * @param isLocal defines if the direction should be set in local space
  12926. */
  12927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12928. /**
  12929. * Called by the particle System when the position is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param positionToUpdate is the position vector to update with the result
  12932. * @param particle is the particle we are computed the position for
  12933. * @param isLocal defines if the position should be set in local space
  12934. */
  12935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): SphereParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "SphereParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. /**
  12968. * Particle emitter emitting particles from the inside of a sphere.
  12969. * It emits the particles randomly between two vectors.
  12970. */
  12971. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12972. /**
  12973. * The min limit of the emission direction.
  12974. */
  12975. direction1: Vector3;
  12976. /**
  12977. * The max limit of the emission direction.
  12978. */
  12979. direction2: Vector3;
  12980. /**
  12981. * Creates a new instance SphereDirectedParticleEmitter
  12982. * @param radius the radius of the emission sphere (1 by default)
  12983. * @param direction1 the min limit of the emission direction (up vector by default)
  12984. * @param direction2 the max limit of the emission direction (up vector by default)
  12985. */
  12986. constructor(radius?: number,
  12987. /**
  12988. * The min limit of the emission direction.
  12989. */
  12990. direction1?: Vector3,
  12991. /**
  12992. * The max limit of the emission direction.
  12993. */
  12994. direction2?: Vector3);
  12995. /**
  12996. * Called by the particle System when the direction is computed for the created particle.
  12997. * @param worldMatrix is the world matrix of the particle system
  12998. * @param directionToUpdate is the direction vector to update with the result
  12999. * @param particle is the particle we are computed the direction for
  13000. */
  13001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13002. /**
  13003. * Clones the current emitter and returns a copy of it
  13004. * @returns the new emitter
  13005. */
  13006. clone(): SphereDirectedParticleEmitter;
  13007. /**
  13008. * Called by the GPUParticleSystem to setup the update shader
  13009. * @param effect defines the update shader
  13010. */
  13011. applyToShader(effect: Effect): void;
  13012. /**
  13013. * Returns a string to use to update the GPU particles update shader
  13014. * @returns a string containng the defines string
  13015. */
  13016. getEffectDefines(): string;
  13017. /**
  13018. * Returns the string "SphereDirectedParticleEmitter"
  13019. * @returns a string containing the class name
  13020. */
  13021. getClassName(): string;
  13022. /**
  13023. * Serializes the particle system to a JSON object.
  13024. * @returns the JSON object
  13025. */
  13026. serialize(): any;
  13027. /**
  13028. * Parse properties from a JSON object
  13029. * @param serializationObject defines the JSON object
  13030. */
  13031. parse(serializationObject: any): void;
  13032. }
  13033. }
  13034. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13035. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13036. import { Effect } from "babylonjs/Materials/effect";
  13037. import { Particle } from "babylonjs/Particles/particle";
  13038. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13039. import { Nullable } from "babylonjs/types";
  13040. /**
  13041. * Particle emitter emitting particles from a custom list of positions.
  13042. */
  13043. export class CustomParticleEmitter implements IParticleEmitterType {
  13044. /**
  13045. * Gets or sets the position generator that will create the inital position of each particle.
  13046. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13047. */
  13048. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13049. /**
  13050. * Gets or sets the destination generator that will create the final destination of each particle.
  13051. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13052. */
  13053. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13054. /**
  13055. * Creates a new instance CustomParticleEmitter
  13056. */
  13057. constructor();
  13058. /**
  13059. * Called by the particle System when the direction is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param directionToUpdate is the direction vector to update with the result
  13062. * @param particle is the particle we are computed the direction for
  13063. * @param isLocal defines if the direction should be set in local space
  13064. */
  13065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Called by the particle System when the position is computed for the created particle.
  13068. * @param worldMatrix is the world matrix of the particle system
  13069. * @param positionToUpdate is the position vector to update with the result
  13070. * @param particle is the particle we are computed the position for
  13071. * @param isLocal defines if the position should be set in local space
  13072. */
  13073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13074. /**
  13075. * Clones the current emitter and returns a copy of it
  13076. * @returns the new emitter
  13077. */
  13078. clone(): CustomParticleEmitter;
  13079. /**
  13080. * Called by the GPUParticleSystem to setup the update shader
  13081. * @param effect defines the update shader
  13082. */
  13083. applyToShader(effect: Effect): void;
  13084. /**
  13085. * Returns a string to use to update the GPU particles update shader
  13086. * @returns a string containng the defines string
  13087. */
  13088. getEffectDefines(): string;
  13089. /**
  13090. * Returns the string "PointParticleEmitter"
  13091. * @returns a string containing the class name
  13092. */
  13093. getClassName(): string;
  13094. /**
  13095. * Serializes the particle system to a JSON object.
  13096. * @returns the JSON object
  13097. */
  13098. serialize(): any;
  13099. /**
  13100. * Parse properties from a JSON object
  13101. * @param serializationObject defines the JSON object
  13102. */
  13103. parse(serializationObject: any): void;
  13104. }
  13105. }
  13106. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13108. import { Effect } from "babylonjs/Materials/effect";
  13109. import { Particle } from "babylonjs/Particles/particle";
  13110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13111. import { Scene } from "babylonjs/scene";
  13112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13113. /**
  13114. * Particle emitter emitting particles from the inside of a box.
  13115. * It emits the particles randomly between 2 given directions.
  13116. */
  13117. export class MeshParticleEmitter implements IParticleEmitterType {
  13118. /** Defines the mesh to use as source */
  13119. mesh?: AbstractMesh | undefined;
  13120. private _indices;
  13121. private _positions;
  13122. private _normals;
  13123. private _storedNormal;
  13124. /**
  13125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13126. */
  13127. direction1: Vector3;
  13128. /**
  13129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13130. */
  13131. direction2: Vector3;
  13132. /**
  13133. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13134. */
  13135. useMeshNormalsForDirection: boolean;
  13136. /**
  13137. * Creates a new instance MeshParticleEmitter
  13138. * @param mesh defines the mesh to use as source
  13139. */
  13140. constructor(
  13141. /** Defines the mesh to use as source */
  13142. mesh?: AbstractMesh | undefined);
  13143. /**
  13144. * Called by the particle System when the direction is computed for the created particle.
  13145. * @param worldMatrix is the world matrix of the particle system
  13146. * @param directionToUpdate is the direction vector to update with the result
  13147. * @param particle is the particle we are computed the direction for
  13148. * @param isLocal defines if the direction should be set in local space
  13149. */
  13150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13151. /**
  13152. * Called by the particle System when the position is computed for the created particle.
  13153. * @param worldMatrix is the world matrix of the particle system
  13154. * @param positionToUpdate is the position vector to update with the result
  13155. * @param particle is the particle we are computed the position for
  13156. * @param isLocal defines if the position should be set in local space
  13157. */
  13158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13159. /**
  13160. * Clones the current emitter and returns a copy of it
  13161. * @returns the new emitter
  13162. */
  13163. clone(): MeshParticleEmitter;
  13164. /**
  13165. * Called by the GPUParticleSystem to setup the update shader
  13166. * @param effect defines the update shader
  13167. */
  13168. applyToShader(effect: Effect): void;
  13169. /**
  13170. * Returns a string to use to update the GPU particles update shader
  13171. * @returns a string containng the defines string
  13172. */
  13173. getEffectDefines(): string;
  13174. /**
  13175. * Returns the string "BoxParticleEmitter"
  13176. * @returns a string containing the class name
  13177. */
  13178. getClassName(): string;
  13179. /**
  13180. * Serializes the particle system to a JSON object.
  13181. * @returns the JSON object
  13182. */
  13183. serialize(): any;
  13184. /**
  13185. * Parse properties from a JSON object
  13186. * @param serializationObject defines the JSON object
  13187. * @param scene defines the hosting scene
  13188. */
  13189. parse(serializationObject: any, scene: Scene): void;
  13190. }
  13191. }
  13192. declare module "babylonjs/Particles/EmitterTypes/index" {
  13193. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13194. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13195. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13196. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13197. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13198. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13199. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13200. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13201. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13202. }
  13203. declare module "babylonjs/Particles/IParticleSystem" {
  13204. import { Nullable } from "babylonjs/types";
  13205. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13206. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13209. import { Texture } from "babylonjs/Materials/Textures/texture";
  13210. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13211. import { Scene } from "babylonjs/scene";
  13212. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13213. import { Animation } from "babylonjs/Animations/animation";
  13214. /**
  13215. * Interface representing a particle system in Babylon.js.
  13216. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13217. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13218. */
  13219. export interface IParticleSystem {
  13220. /**
  13221. * List of animations used by the particle system.
  13222. */
  13223. animations: Animation[];
  13224. /**
  13225. * The id of the Particle system.
  13226. */
  13227. id: string;
  13228. /**
  13229. * The name of the Particle system.
  13230. */
  13231. name: string;
  13232. /**
  13233. * The emitter represents the Mesh or position we are attaching the particle system to.
  13234. */
  13235. emitter: Nullable<AbstractMesh | Vector3>;
  13236. /**
  13237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13238. */
  13239. isBillboardBased: boolean;
  13240. /**
  13241. * The rendering group used by the Particle system to chose when to render.
  13242. */
  13243. renderingGroupId: number;
  13244. /**
  13245. * The layer mask we are rendering the particles through.
  13246. */
  13247. layerMask: number;
  13248. /**
  13249. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13250. */
  13251. updateSpeed: number;
  13252. /**
  13253. * The amount of time the particle system is running (depends of the overall update speed).
  13254. */
  13255. targetStopDuration: number;
  13256. /**
  13257. * The texture used to render each particle. (this can be a spritesheet)
  13258. */
  13259. particleTexture: Nullable<Texture>;
  13260. /**
  13261. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13262. */
  13263. blendMode: number;
  13264. /**
  13265. * Minimum life time of emitting particles.
  13266. */
  13267. minLifeTime: number;
  13268. /**
  13269. * Maximum life time of emitting particles.
  13270. */
  13271. maxLifeTime: number;
  13272. /**
  13273. * Minimum Size of emitting particles.
  13274. */
  13275. minSize: number;
  13276. /**
  13277. * Maximum Size of emitting particles.
  13278. */
  13279. maxSize: number;
  13280. /**
  13281. * Minimum scale of emitting particles on X axis.
  13282. */
  13283. minScaleX: number;
  13284. /**
  13285. * Maximum scale of emitting particles on X axis.
  13286. */
  13287. maxScaleX: number;
  13288. /**
  13289. * Minimum scale of emitting particles on Y axis.
  13290. */
  13291. minScaleY: number;
  13292. /**
  13293. * Maximum scale of emitting particles on Y axis.
  13294. */
  13295. maxScaleY: number;
  13296. /**
  13297. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13298. */
  13299. color1: Color4;
  13300. /**
  13301. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13302. */
  13303. color2: Color4;
  13304. /**
  13305. * Color the particle will have at the end of its lifetime.
  13306. */
  13307. colorDead: Color4;
  13308. /**
  13309. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13310. */
  13311. emitRate: number;
  13312. /**
  13313. * You can use gravity if you want to give an orientation to your particles.
  13314. */
  13315. gravity: Vector3;
  13316. /**
  13317. * Minimum power of emitting particles.
  13318. */
  13319. minEmitPower: number;
  13320. /**
  13321. * Maximum power of emitting particles.
  13322. */
  13323. maxEmitPower: number;
  13324. /**
  13325. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13326. */
  13327. minAngularSpeed: number;
  13328. /**
  13329. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13330. */
  13331. maxAngularSpeed: number;
  13332. /**
  13333. * Gets or sets the minimal initial rotation in radians.
  13334. */
  13335. minInitialRotation: number;
  13336. /**
  13337. * Gets or sets the maximal initial rotation in radians.
  13338. */
  13339. maxInitialRotation: number;
  13340. /**
  13341. * The particle emitter type defines the emitter used by the particle system.
  13342. * It can be for example box, sphere, or cone...
  13343. */
  13344. particleEmitterType: Nullable<IParticleEmitterType>;
  13345. /**
  13346. * Defines the delay in milliseconds before starting the system (0 by default)
  13347. */
  13348. startDelay: number;
  13349. /**
  13350. * 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
  13351. */
  13352. preWarmCycles: number;
  13353. /**
  13354. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13355. */
  13356. preWarmStepOffset: number;
  13357. /**
  13358. * 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)
  13359. */
  13360. spriteCellChangeSpeed: number;
  13361. /**
  13362. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13363. */
  13364. startSpriteCellID: number;
  13365. /**
  13366. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13367. */
  13368. endSpriteCellID: number;
  13369. /**
  13370. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13371. */
  13372. spriteCellWidth: number;
  13373. /**
  13374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13375. */
  13376. spriteCellHeight: number;
  13377. /**
  13378. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13379. */
  13380. spriteRandomStartCell: boolean;
  13381. /**
  13382. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13383. */
  13384. isAnimationSheetEnabled: boolean;
  13385. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13386. translationPivot: Vector2;
  13387. /**
  13388. * Gets or sets a texture used to add random noise to particle positions
  13389. */
  13390. noiseTexture: Nullable<BaseTexture>;
  13391. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13392. noiseStrength: Vector3;
  13393. /**
  13394. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13395. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13396. */
  13397. billboardMode: number;
  13398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13399. limitVelocityDamping: number;
  13400. /**
  13401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13402. */
  13403. beginAnimationOnStart: boolean;
  13404. /**
  13405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13406. */
  13407. beginAnimationFrom: number;
  13408. /**
  13409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13410. */
  13411. beginAnimationTo: number;
  13412. /**
  13413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13414. */
  13415. beginAnimationLoop: boolean;
  13416. /**
  13417. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13418. */
  13419. disposeOnStop: boolean;
  13420. /**
  13421. * Specifies if the particles are updated in emitter local space or world space
  13422. */
  13423. isLocal: boolean;
  13424. /**
  13425. * Gets the maximum number of particles active at the same time.
  13426. * @returns The max number of active particles.
  13427. */
  13428. getCapacity(): number;
  13429. /**
  13430. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13431. * @returns True if it has been started, otherwise false.
  13432. */
  13433. isStarted(): boolean;
  13434. /**
  13435. * Animates the particle system for this frame.
  13436. */
  13437. animate(): void;
  13438. /**
  13439. * Renders the particle system in its current state.
  13440. * @returns the current number of particles
  13441. */
  13442. render(): number;
  13443. /**
  13444. * Dispose the particle system and frees its associated resources.
  13445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13446. */
  13447. dispose(disposeTexture?: boolean): void;
  13448. /**
  13449. * Clones the particle system.
  13450. * @param name The name of the cloned object
  13451. * @param newEmitter The new emitter to use
  13452. * @returns the cloned particle system
  13453. */
  13454. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13455. /**
  13456. * Serializes the particle system to a JSON object.
  13457. * @returns the JSON object
  13458. */
  13459. serialize(): any;
  13460. /**
  13461. * Rebuild the particle system
  13462. */
  13463. rebuild(): void;
  13464. /**
  13465. * Starts the particle system and begins to emit
  13466. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13467. */
  13468. start(delay?: number): void;
  13469. /**
  13470. * Stops the particle system.
  13471. */
  13472. stop(): void;
  13473. /**
  13474. * Remove all active particles
  13475. */
  13476. reset(): void;
  13477. /**
  13478. * Is this system ready to be used/rendered
  13479. * @return true if the system is ready
  13480. */
  13481. isReady(): boolean;
  13482. /**
  13483. * Adds a new color gradient
  13484. * @param gradient defines the gradient to use (between 0 and 1)
  13485. * @param color1 defines the color to affect to the specified gradient
  13486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13487. * @returns the current particle system
  13488. */
  13489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13490. /**
  13491. * Remove a specific color gradient
  13492. * @param gradient defines the gradient to remove
  13493. * @returns the current particle system
  13494. */
  13495. removeColorGradient(gradient: number): IParticleSystem;
  13496. /**
  13497. * Adds a new size gradient
  13498. * @param gradient defines the gradient to use (between 0 and 1)
  13499. * @param factor defines the size factor to affect to the specified gradient
  13500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13501. * @returns the current particle system
  13502. */
  13503. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13504. /**
  13505. * Remove a specific size gradient
  13506. * @param gradient defines the gradient to remove
  13507. * @returns the current particle system
  13508. */
  13509. removeSizeGradient(gradient: number): IParticleSystem;
  13510. /**
  13511. * Gets the current list of color gradients.
  13512. * You must use addColorGradient and removeColorGradient to udpate this list
  13513. * @returns the list of color gradients
  13514. */
  13515. getColorGradients(): Nullable<Array<ColorGradient>>;
  13516. /**
  13517. * Gets the current list of size gradients.
  13518. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13519. * @returns the list of size gradients
  13520. */
  13521. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13522. /**
  13523. * Gets the current list of angular speed gradients.
  13524. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13525. * @returns the list of angular speed gradients
  13526. */
  13527. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13528. /**
  13529. * Adds a new angular speed gradient
  13530. * @param gradient defines the gradient to use (between 0 and 1)
  13531. * @param factor defines the angular speed to affect to the specified gradient
  13532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13533. * @returns the current particle system
  13534. */
  13535. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13536. /**
  13537. * Remove a specific angular speed gradient
  13538. * @param gradient defines the gradient to remove
  13539. * @returns the current particle system
  13540. */
  13541. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13542. /**
  13543. * Gets the current list of velocity gradients.
  13544. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13545. * @returns the list of velocity gradients
  13546. */
  13547. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13548. /**
  13549. * Adds a new velocity gradient
  13550. * @param gradient defines the gradient to use (between 0 and 1)
  13551. * @param factor defines the velocity to affect to the specified gradient
  13552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13553. * @returns the current particle system
  13554. */
  13555. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13556. /**
  13557. * Remove a specific velocity gradient
  13558. * @param gradient defines the gradient to remove
  13559. * @returns the current particle system
  13560. */
  13561. removeVelocityGradient(gradient: number): IParticleSystem;
  13562. /**
  13563. * Gets the current list of limit velocity gradients.
  13564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13565. * @returns the list of limit velocity gradients
  13566. */
  13567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13568. /**
  13569. * Adds a new limit velocity gradient
  13570. * @param gradient defines the gradient to use (between 0 and 1)
  13571. * @param factor defines the limit velocity to affect to the specified gradient
  13572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13573. * @returns the current particle system
  13574. */
  13575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13576. /**
  13577. * Remove a specific limit velocity gradient
  13578. * @param gradient defines the gradient to remove
  13579. * @returns the current particle system
  13580. */
  13581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13582. /**
  13583. * Adds a new drag gradient
  13584. * @param gradient defines the gradient to use (between 0 and 1)
  13585. * @param factor defines the drag to affect to the specified gradient
  13586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13587. * @returns the current particle system
  13588. */
  13589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13590. /**
  13591. * Remove a specific drag gradient
  13592. * @param gradient defines the gradient to remove
  13593. * @returns the current particle system
  13594. */
  13595. removeDragGradient(gradient: number): IParticleSystem;
  13596. /**
  13597. * Gets the current list of drag gradients.
  13598. * You must use addDragGradient and removeDragGradient to udpate this list
  13599. * @returns the list of drag gradients
  13600. */
  13601. getDragGradients(): Nullable<Array<FactorGradient>>;
  13602. /**
  13603. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13604. * @param gradient defines the gradient to use (between 0 and 1)
  13605. * @param factor defines the emit rate to affect to the specified gradient
  13606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13607. * @returns the current particle system
  13608. */
  13609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13610. /**
  13611. * Remove a specific emit rate gradient
  13612. * @param gradient defines the gradient to remove
  13613. * @returns the current particle system
  13614. */
  13615. removeEmitRateGradient(gradient: number): IParticleSystem;
  13616. /**
  13617. * Gets the current list of emit rate gradients.
  13618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13619. * @returns the list of emit rate gradients
  13620. */
  13621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13622. /**
  13623. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13624. * @param gradient defines the gradient to use (between 0 and 1)
  13625. * @param factor defines the start size to affect to the specified gradient
  13626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13627. * @returns the current particle system
  13628. */
  13629. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13630. /**
  13631. * Remove a specific start size gradient
  13632. * @param gradient defines the gradient to remove
  13633. * @returns the current particle system
  13634. */
  13635. removeStartSizeGradient(gradient: number): IParticleSystem;
  13636. /**
  13637. * Gets the current list of start size gradients.
  13638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13639. * @returns the list of start size gradients
  13640. */
  13641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13642. /**
  13643. * Adds a new life time gradient
  13644. * @param gradient defines the gradient to use (between 0 and 1)
  13645. * @param factor defines the life time factor to affect to the specified gradient
  13646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13647. * @returns the current particle system
  13648. */
  13649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13650. /**
  13651. * Remove a specific life time gradient
  13652. * @param gradient defines the gradient to remove
  13653. * @returns the current particle system
  13654. */
  13655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13656. /**
  13657. * Gets the current list of life time gradients.
  13658. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13659. * @returns the list of life time gradients
  13660. */
  13661. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13662. /**
  13663. * Gets the current list of color gradients.
  13664. * You must use addColorGradient and removeColorGradient to udpate this list
  13665. * @returns the list of color gradients
  13666. */
  13667. getColorGradients(): Nullable<Array<ColorGradient>>;
  13668. /**
  13669. * Adds a new ramp gradient used to remap particle colors
  13670. * @param gradient defines the gradient to use (between 0 and 1)
  13671. * @param color defines the color to affect to the specified gradient
  13672. * @returns the current particle system
  13673. */
  13674. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13675. /**
  13676. * Gets the current list of ramp gradients.
  13677. * You must use addRampGradient and removeRampGradient to udpate this list
  13678. * @returns the list of ramp gradients
  13679. */
  13680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13681. /** Gets or sets a boolean indicating that ramp gradients must be used
  13682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13683. */
  13684. useRampGradients: boolean;
  13685. /**
  13686. * Adds a new color remap gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param min defines the color remap minimal range
  13689. * @param max defines the color remap maximal range
  13690. * @returns the current particle system
  13691. */
  13692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13693. /**
  13694. * Gets the current list of color remap gradients.
  13695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13696. * @returns the list of color remap gradients
  13697. */
  13698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13699. /**
  13700. * Adds a new alpha remap gradient
  13701. * @param gradient defines the gradient to use (between 0 and 1)
  13702. * @param min defines the alpha remap minimal range
  13703. * @param max defines the alpha remap maximal range
  13704. * @returns the current particle system
  13705. */
  13706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13707. /**
  13708. * Gets the current list of alpha remap gradients.
  13709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13710. * @returns the list of alpha remap gradients
  13711. */
  13712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13713. /**
  13714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13717. * @returns the emitter
  13718. */
  13719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13720. /**
  13721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13722. * @param radius The radius of the hemisphere to emit from
  13723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13724. * @returns the emitter
  13725. */
  13726. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13727. /**
  13728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13729. * @param radius The radius of the sphere to emit from
  13730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13731. * @returns the emitter
  13732. */
  13733. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13734. /**
  13735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13736. * @param radius The radius of the sphere to emit from
  13737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13739. * @returns the emitter
  13740. */
  13741. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13742. /**
  13743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13744. * @param radius The radius of the emission cylinder
  13745. * @param height The height of the emission cylinder
  13746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13748. * @returns the emitter
  13749. */
  13750. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13751. /**
  13752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13753. * @param radius The radius of the cylinder to emit from
  13754. * @param height The height of the emission cylinder
  13755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13758. * @returns the emitter
  13759. */
  13760. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13761. /**
  13762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13763. * @param radius The radius of the cone to emit from
  13764. * @param angle The base angle of the cone
  13765. * @returns the emitter
  13766. */
  13767. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13768. /**
  13769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13774. * @returns the emitter
  13775. */
  13776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13777. /**
  13778. * Get hosting scene
  13779. * @returns the scene
  13780. */
  13781. getScene(): Scene;
  13782. }
  13783. }
  13784. declare module "babylonjs/Meshes/transformNode" {
  13785. import { DeepImmutable } from "babylonjs/types";
  13786. import { Observable } from "babylonjs/Misc/observable";
  13787. import { Nullable } from "babylonjs/types";
  13788. import { Camera } from "babylonjs/Cameras/camera";
  13789. import { Scene } from "babylonjs/scene";
  13790. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13791. import { Node } from "babylonjs/node";
  13792. import { Bone } from "babylonjs/Bones/bone";
  13793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13794. import { Space } from "babylonjs/Maths/math.axis";
  13795. /**
  13796. * 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.
  13797. * @see https://doc.babylonjs.com/how_to/transformnode
  13798. */
  13799. export class TransformNode extends Node {
  13800. /**
  13801. * Object will not rotate to face the camera
  13802. */
  13803. static BILLBOARDMODE_NONE: number;
  13804. /**
  13805. * Object will rotate to face the camera but only on the x axis
  13806. */
  13807. static BILLBOARDMODE_X: number;
  13808. /**
  13809. * Object will rotate to face the camera but only on the y axis
  13810. */
  13811. static BILLBOARDMODE_Y: number;
  13812. /**
  13813. * Object will rotate to face the camera but only on the z axis
  13814. */
  13815. static BILLBOARDMODE_Z: number;
  13816. /**
  13817. * Object will rotate to face the camera
  13818. */
  13819. static BILLBOARDMODE_ALL: number;
  13820. /**
  13821. * Object will rotate to face the camera's position instead of orientation
  13822. */
  13823. static BILLBOARDMODE_USE_POSITION: number;
  13824. private _forward;
  13825. private _forwardInverted;
  13826. private _up;
  13827. private _right;
  13828. private _rightInverted;
  13829. private _position;
  13830. private _rotation;
  13831. private _rotationQuaternion;
  13832. protected _scaling: Vector3;
  13833. protected _isDirty: boolean;
  13834. private _transformToBoneReferal;
  13835. private _isAbsoluteSynced;
  13836. private _billboardMode;
  13837. /**
  13838. * Gets or sets the billboard mode. Default is 0.
  13839. *
  13840. * | Value | Type | Description |
  13841. * | --- | --- | --- |
  13842. * | 0 | BILLBOARDMODE_NONE | |
  13843. * | 1 | BILLBOARDMODE_X | |
  13844. * | 2 | BILLBOARDMODE_Y | |
  13845. * | 4 | BILLBOARDMODE_Z | |
  13846. * | 7 | BILLBOARDMODE_ALL | |
  13847. *
  13848. */
  13849. get billboardMode(): number;
  13850. set billboardMode(value: number);
  13851. private _preserveParentRotationForBillboard;
  13852. /**
  13853. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13854. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13855. */
  13856. get preserveParentRotationForBillboard(): boolean;
  13857. set preserveParentRotationForBillboard(value: boolean);
  13858. /**
  13859. * 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
  13860. */
  13861. scalingDeterminant: number;
  13862. private _infiniteDistance;
  13863. /**
  13864. * Gets or sets the distance of the object to max, often used by skybox
  13865. */
  13866. get infiniteDistance(): boolean;
  13867. set infiniteDistance(value: boolean);
  13868. /**
  13869. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13870. * By default the system will update normals to compensate
  13871. */
  13872. ignoreNonUniformScaling: boolean;
  13873. /**
  13874. * 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
  13875. */
  13876. reIntegrateRotationIntoRotationQuaternion: boolean;
  13877. /** @hidden */
  13878. _poseMatrix: Nullable<Matrix>;
  13879. /** @hidden */
  13880. _localMatrix: Matrix;
  13881. private _usePivotMatrix;
  13882. private _absolutePosition;
  13883. private _absoluteScaling;
  13884. private _absoluteRotationQuaternion;
  13885. private _pivotMatrix;
  13886. private _pivotMatrixInverse;
  13887. protected _postMultiplyPivotMatrix: boolean;
  13888. protected _isWorldMatrixFrozen: boolean;
  13889. /** @hidden */
  13890. _indexInSceneTransformNodesArray: number;
  13891. /**
  13892. * An event triggered after the world matrix is updated
  13893. */
  13894. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13895. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13896. /**
  13897. * Gets a string identifying the name of the class
  13898. * @returns "TransformNode" string
  13899. */
  13900. getClassName(): string;
  13901. /**
  13902. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13903. */
  13904. get position(): Vector3;
  13905. set position(newPosition: Vector3);
  13906. /**
  13907. * 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)).
  13908. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13909. */
  13910. get rotation(): Vector3;
  13911. set rotation(newRotation: Vector3);
  13912. /**
  13913. * 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)).
  13914. */
  13915. get scaling(): Vector3;
  13916. set scaling(newScaling: Vector3);
  13917. /**
  13918. * 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).
  13919. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13920. */
  13921. get rotationQuaternion(): Nullable<Quaternion>;
  13922. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13923. /**
  13924. * The forward direction of that transform in world space.
  13925. */
  13926. get forward(): Vector3;
  13927. /**
  13928. * The up direction of that transform in world space.
  13929. */
  13930. get up(): Vector3;
  13931. /**
  13932. * The right direction of that transform in world space.
  13933. */
  13934. get right(): Vector3;
  13935. /**
  13936. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13937. * @param matrix the matrix to copy the pose from
  13938. * @returns this TransformNode.
  13939. */
  13940. updatePoseMatrix(matrix: Matrix): TransformNode;
  13941. /**
  13942. * Returns the mesh Pose matrix.
  13943. * @returns the pose matrix
  13944. */
  13945. getPoseMatrix(): Matrix;
  13946. /** @hidden */
  13947. _isSynchronized(): boolean;
  13948. /** @hidden */
  13949. _initCache(): void;
  13950. /**
  13951. * Flag the transform node as dirty (Forcing it to update everything)
  13952. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13953. * @returns this transform node
  13954. */
  13955. markAsDirty(property: string): TransformNode;
  13956. /**
  13957. * Returns the current mesh absolute position.
  13958. * Returns a Vector3.
  13959. */
  13960. get absolutePosition(): Vector3;
  13961. /**
  13962. * Returns the current mesh absolute scaling.
  13963. * Returns a Vector3.
  13964. */
  13965. get absoluteScaling(): Vector3;
  13966. /**
  13967. * Returns the current mesh absolute rotation.
  13968. * Returns a Quaternion.
  13969. */
  13970. get absoluteRotationQuaternion(): Quaternion;
  13971. /**
  13972. * Sets a new matrix to apply before all other transformation
  13973. * @param matrix defines the transform matrix
  13974. * @returns the current TransformNode
  13975. */
  13976. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13977. /**
  13978. * Sets a new pivot matrix to the current node
  13979. * @param matrix defines the new pivot matrix to use
  13980. * @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
  13981. * @returns the current TransformNode
  13982. */
  13983. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13984. /**
  13985. * Returns the mesh pivot matrix.
  13986. * Default : Identity.
  13987. * @returns the matrix
  13988. */
  13989. getPivotMatrix(): Matrix;
  13990. /**
  13991. * Instantiate (when possible) or clone that node with its hierarchy
  13992. * @param newParent defines the new parent to use for the instance (or clone)
  13993. * @param options defines options to configure how copy is done
  13994. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13995. * @returns an instance (or a clone) of the current node with its hiearchy
  13996. */
  13997. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13998. doNotInstantiate: boolean;
  13999. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14000. /**
  14001. * Prevents the World matrix to be computed any longer
  14002. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14003. * @returns the TransformNode.
  14004. */
  14005. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14006. /**
  14007. * Allows back the World matrix computation.
  14008. * @returns the TransformNode.
  14009. */
  14010. unfreezeWorldMatrix(): this;
  14011. /**
  14012. * True if the World matrix has been frozen.
  14013. */
  14014. get isWorldMatrixFrozen(): boolean;
  14015. /**
  14016. * Retuns the mesh absolute position in the World.
  14017. * @returns a Vector3.
  14018. */
  14019. getAbsolutePosition(): Vector3;
  14020. /**
  14021. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14022. * @param absolutePosition the absolute position to set
  14023. * @returns the TransformNode.
  14024. */
  14025. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14026. /**
  14027. * Sets the mesh position in its local space.
  14028. * @param vector3 the position to set in localspace
  14029. * @returns the TransformNode.
  14030. */
  14031. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14032. /**
  14033. * Returns the mesh position in the local space from the current World matrix values.
  14034. * @returns a new Vector3.
  14035. */
  14036. getPositionExpressedInLocalSpace(): Vector3;
  14037. /**
  14038. * Translates the mesh along the passed Vector3 in its local space.
  14039. * @param vector3 the distance to translate in localspace
  14040. * @returns the TransformNode.
  14041. */
  14042. locallyTranslate(vector3: Vector3): TransformNode;
  14043. private static _lookAtVectorCache;
  14044. /**
  14045. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14046. * @param targetPoint the position (must be in same space as current mesh) to look at
  14047. * @param yawCor optional yaw (y-axis) correction in radians
  14048. * @param pitchCor optional pitch (x-axis) correction in radians
  14049. * @param rollCor optional roll (z-axis) correction in radians
  14050. * @param space the choosen space of the target
  14051. * @returns the TransformNode.
  14052. */
  14053. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14054. /**
  14055. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14056. * This Vector3 is expressed in the World space.
  14057. * @param localAxis axis to rotate
  14058. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14059. */
  14060. getDirection(localAxis: Vector3): Vector3;
  14061. /**
  14062. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14063. * localAxis is expressed in the mesh local space.
  14064. * result is computed in the Wordl space from the mesh World matrix.
  14065. * @param localAxis axis to rotate
  14066. * @param result the resulting transformnode
  14067. * @returns this TransformNode.
  14068. */
  14069. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14070. /**
  14071. * Sets this transform node rotation to the given local axis.
  14072. * @param localAxis the axis in local space
  14073. * @param yawCor optional yaw (y-axis) correction in radians
  14074. * @param pitchCor optional pitch (x-axis) correction in radians
  14075. * @param rollCor optional roll (z-axis) correction in radians
  14076. * @returns this TransformNode
  14077. */
  14078. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14079. /**
  14080. * Sets a new pivot point to the current node
  14081. * @param point defines the new pivot point to use
  14082. * @param space defines if the point is in world or local space (local by default)
  14083. * @returns the current TransformNode
  14084. */
  14085. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14086. /**
  14087. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14088. * @returns the pivot point
  14089. */
  14090. getPivotPoint(): Vector3;
  14091. /**
  14092. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14093. * @param result the vector3 to store the result
  14094. * @returns this TransformNode.
  14095. */
  14096. getPivotPointToRef(result: Vector3): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14099. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14100. */
  14101. getAbsolutePivotPoint(): Vector3;
  14102. /**
  14103. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14104. * @param result vector3 to store the result
  14105. * @returns this TransformNode.
  14106. */
  14107. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14108. /**
  14109. * Defines the passed node as the parent of the current node.
  14110. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14111. * @see https://doc.babylonjs.com/how_to/parenting
  14112. * @param node the node ot set as the parent
  14113. * @returns this TransformNode.
  14114. */
  14115. setParent(node: Nullable<Node>): TransformNode;
  14116. private _nonUniformScaling;
  14117. /**
  14118. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14119. */
  14120. get nonUniformScaling(): boolean;
  14121. /** @hidden */
  14122. _updateNonUniformScalingState(value: boolean): boolean;
  14123. /**
  14124. * Attach the current TransformNode to another TransformNode associated with a bone
  14125. * @param bone Bone affecting the TransformNode
  14126. * @param affectedTransformNode TransformNode associated with the bone
  14127. * @returns this object
  14128. */
  14129. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14130. /**
  14131. * Detach the transform node if its associated with a bone
  14132. * @returns this object
  14133. */
  14134. detachFromBone(): TransformNode;
  14135. private static _rotationAxisCache;
  14136. /**
  14137. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14138. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14139. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14140. * The passed axis is also normalized.
  14141. * @param axis the axis to rotate around
  14142. * @param amount the amount to rotate in radians
  14143. * @param space Space to rotate in (Default: local)
  14144. * @returns the TransformNode.
  14145. */
  14146. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14147. /**
  14148. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14149. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14150. * The passed axis is also normalized. .
  14151. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14152. * @param point the point to rotate around
  14153. * @param axis the axis to rotate around
  14154. * @param amount the amount to rotate in radians
  14155. * @returns the TransformNode
  14156. */
  14157. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14158. /**
  14159. * Translates the mesh along the axis vector for the passed distance in the given space.
  14160. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14161. * @param axis the axis to translate in
  14162. * @param distance the distance to translate
  14163. * @param space Space to rotate in (Default: local)
  14164. * @returns the TransformNode.
  14165. */
  14166. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14167. /**
  14168. * Adds a rotation step to the mesh current rotation.
  14169. * x, y, z are Euler angles expressed in radians.
  14170. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14171. * This means this rotation is made in the mesh local space only.
  14172. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14173. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14174. * ```javascript
  14175. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14176. * ```
  14177. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14178. * 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.
  14179. * @param x Rotation to add
  14180. * @param y Rotation to add
  14181. * @param z Rotation to add
  14182. * @returns the TransformNode.
  14183. */
  14184. addRotation(x: number, y: number, z: number): TransformNode;
  14185. /**
  14186. * @hidden
  14187. */
  14188. protected _getEffectiveParent(): Nullable<Node>;
  14189. /**
  14190. * Computes the world matrix of the node
  14191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14192. * @returns the world matrix
  14193. */
  14194. computeWorldMatrix(force?: boolean): Matrix;
  14195. /**
  14196. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14197. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14198. */
  14199. resetLocalMatrix(independentOfChildren?: boolean): void;
  14200. protected _afterComputeWorldMatrix(): void;
  14201. /**
  14202. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14203. * @param func callback function to add
  14204. *
  14205. * @returns the TransformNode.
  14206. */
  14207. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14208. /**
  14209. * Removes a registered callback function.
  14210. * @param func callback function to remove
  14211. * @returns the TransformNode.
  14212. */
  14213. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14214. /**
  14215. * Gets the position of the current mesh in camera space
  14216. * @param camera defines the camera to use
  14217. * @returns a position
  14218. */
  14219. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14220. /**
  14221. * Returns the distance from the mesh to the active camera
  14222. * @param camera defines the camera to use
  14223. * @returns the distance
  14224. */
  14225. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14226. /**
  14227. * Clone the current transform node
  14228. * @param name Name of the new clone
  14229. * @param newParent New parent for the clone
  14230. * @param doNotCloneChildren Do not clone children hierarchy
  14231. * @returns the new transform node
  14232. */
  14233. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14234. /**
  14235. * Serializes the objects information.
  14236. * @param currentSerializationObject defines the object to serialize in
  14237. * @returns the serialized object
  14238. */
  14239. serialize(currentSerializationObject?: any): any;
  14240. /**
  14241. * Returns a new TransformNode object parsed from the source provided.
  14242. * @param parsedTransformNode is the source.
  14243. * @param scene the scne the object belongs to
  14244. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14245. * @returns a new TransformNode object parsed from the source provided.
  14246. */
  14247. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14248. /**
  14249. * Get all child-transformNodes of this node
  14250. * @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
  14251. * @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
  14252. * @returns an array of TransformNode
  14253. */
  14254. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14255. /**
  14256. * Releases resources associated with this transform node.
  14257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14259. */
  14260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14261. /**
  14262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14266. * @returns the current mesh
  14267. */
  14268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14269. private _syncAbsoluteScalingAndRotation;
  14270. }
  14271. }
  14272. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14273. /**
  14274. * Class used to override all child animations of a given target
  14275. */
  14276. export class AnimationPropertiesOverride {
  14277. /**
  14278. * Gets or sets a value indicating if animation blending must be used
  14279. */
  14280. enableBlending: boolean;
  14281. /**
  14282. * Gets or sets the blending speed to use when enableBlending is true
  14283. */
  14284. blendingSpeed: number;
  14285. /**
  14286. * Gets or sets the default loop mode to use
  14287. */
  14288. loopMode: number;
  14289. }
  14290. }
  14291. declare module "babylonjs/Bones/bone" {
  14292. import { Skeleton } from "babylonjs/Bones/skeleton";
  14293. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14294. import { Nullable } from "babylonjs/types";
  14295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14297. import { Node } from "babylonjs/node";
  14298. import { Space } from "babylonjs/Maths/math.axis";
  14299. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14300. /**
  14301. * Class used to store bone information
  14302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14303. */
  14304. export class Bone extends Node {
  14305. /**
  14306. * defines the bone name
  14307. */
  14308. name: string;
  14309. private static _tmpVecs;
  14310. private static _tmpQuat;
  14311. private static _tmpMats;
  14312. /**
  14313. * Gets the list of child bones
  14314. */
  14315. children: Bone[];
  14316. /** Gets the animations associated with this bone */
  14317. animations: import("babylonjs/Animations/animation").Animation[];
  14318. /**
  14319. * Gets or sets bone length
  14320. */
  14321. length: number;
  14322. /**
  14323. * @hidden Internal only
  14324. * Set this value to map this bone to a different index in the transform matrices
  14325. * Set this value to -1 to exclude the bone from the transform matrices
  14326. */
  14327. _index: Nullable<number>;
  14328. private _skeleton;
  14329. private _localMatrix;
  14330. private _restPose;
  14331. private _baseMatrix;
  14332. private _absoluteTransform;
  14333. private _invertedAbsoluteTransform;
  14334. private _parent;
  14335. private _scalingDeterminant;
  14336. private _worldTransform;
  14337. private _localScaling;
  14338. private _localRotation;
  14339. private _localPosition;
  14340. private _needToDecompose;
  14341. private _needToCompose;
  14342. /** @hidden */
  14343. _linkedTransformNode: Nullable<TransformNode>;
  14344. /** @hidden */
  14345. _waitingTransformNodeId: Nullable<string>;
  14346. /** @hidden */
  14347. get _matrix(): Matrix;
  14348. /** @hidden */
  14349. set _matrix(value: Matrix);
  14350. /**
  14351. * Create a new bone
  14352. * @param name defines the bone name
  14353. * @param skeleton defines the parent skeleton
  14354. * @param parentBone defines the parent (can be null if the bone is the root)
  14355. * @param localMatrix defines the local matrix
  14356. * @param restPose defines the rest pose matrix
  14357. * @param baseMatrix defines the base matrix
  14358. * @param index defines index of the bone in the hiearchy
  14359. */
  14360. constructor(
  14361. /**
  14362. * defines the bone name
  14363. */
  14364. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14365. /**
  14366. * Gets the current object class name.
  14367. * @return the class name
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Gets the parent skeleton
  14372. * @returns a skeleton
  14373. */
  14374. getSkeleton(): Skeleton;
  14375. /**
  14376. * Gets parent bone
  14377. * @returns a bone or null if the bone is the root of the bone hierarchy
  14378. */
  14379. getParent(): Nullable<Bone>;
  14380. /**
  14381. * Returns an array containing the root bones
  14382. * @returns an array containing the root bones
  14383. */
  14384. getChildren(): Array<Bone>;
  14385. /**
  14386. * Gets the node index in matrix array generated for rendering
  14387. * @returns the node index
  14388. */
  14389. getIndex(): number;
  14390. /**
  14391. * Sets the parent bone
  14392. * @param parent defines the parent (can be null if the bone is the root)
  14393. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14394. */
  14395. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14396. /**
  14397. * Gets the local matrix
  14398. * @returns a matrix
  14399. */
  14400. getLocalMatrix(): Matrix;
  14401. /**
  14402. * Gets the base matrix (initial matrix which remains unchanged)
  14403. * @returns a matrix
  14404. */
  14405. getBaseMatrix(): Matrix;
  14406. /**
  14407. * Gets the rest pose matrix
  14408. * @returns a matrix
  14409. */
  14410. getRestPose(): Matrix;
  14411. /**
  14412. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14413. */
  14414. getWorldMatrix(): Matrix;
  14415. /**
  14416. * Sets the local matrix to rest pose matrix
  14417. */
  14418. returnToRest(): void;
  14419. /**
  14420. * Gets the inverse of the absolute transform matrix.
  14421. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14422. * @returns a matrix
  14423. */
  14424. getInvertedAbsoluteTransform(): Matrix;
  14425. /**
  14426. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14427. * @returns a matrix
  14428. */
  14429. getAbsoluteTransform(): Matrix;
  14430. /**
  14431. * Links with the given transform node.
  14432. * The local matrix of this bone is copied from the transform node every frame.
  14433. * @param transformNode defines the transform node to link to
  14434. */
  14435. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14436. /**
  14437. * Gets the node used to drive the bone's transformation
  14438. * @returns a transform node or null
  14439. */
  14440. getTransformNode(): Nullable<TransformNode>;
  14441. /** Gets or sets current position (in local space) */
  14442. get position(): Vector3;
  14443. set position(newPosition: Vector3);
  14444. /** Gets or sets current rotation (in local space) */
  14445. get rotation(): Vector3;
  14446. set rotation(newRotation: Vector3);
  14447. /** Gets or sets current rotation quaternion (in local space) */
  14448. get rotationQuaternion(): Quaternion;
  14449. set rotationQuaternion(newRotation: Quaternion);
  14450. /** Gets or sets current scaling (in local space) */
  14451. get scaling(): Vector3;
  14452. set scaling(newScaling: Vector3);
  14453. /**
  14454. * Gets the animation properties override
  14455. */
  14456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14457. private _decompose;
  14458. private _compose;
  14459. /**
  14460. * Update the base and local matrices
  14461. * @param matrix defines the new base or local matrix
  14462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14463. * @param updateLocalMatrix defines if the local matrix should be updated
  14464. */
  14465. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14466. /** @hidden */
  14467. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14468. /**
  14469. * Flag the bone as dirty (Forcing it to update everything)
  14470. */
  14471. markAsDirty(): void;
  14472. /** @hidden */
  14473. _markAsDirtyAndCompose(): void;
  14474. private _markAsDirtyAndDecompose;
  14475. /**
  14476. * Translate the bone in local or world space
  14477. * @param vec The amount to translate the bone
  14478. * @param space The space that the translation is in
  14479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14480. */
  14481. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14482. /**
  14483. * Set the postion of the bone in local or world space
  14484. * @param position The position to set the bone
  14485. * @param space The space that the position is in
  14486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14487. */
  14488. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14489. /**
  14490. * Set the absolute position of the bone (world space)
  14491. * @param position The position to set the bone
  14492. * @param mesh The mesh that this bone is attached to
  14493. */
  14494. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14495. /**
  14496. * Scale the bone on the x, y and z axes (in local space)
  14497. * @param x The amount to scale the bone on the x axis
  14498. * @param y The amount to scale the bone on the y axis
  14499. * @param z The amount to scale the bone on the z axis
  14500. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14501. */
  14502. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14503. /**
  14504. * Set the bone scaling in local space
  14505. * @param scale defines the scaling vector
  14506. */
  14507. setScale(scale: Vector3): void;
  14508. /**
  14509. * Gets the current scaling in local space
  14510. * @returns the current scaling vector
  14511. */
  14512. getScale(): Vector3;
  14513. /**
  14514. * Gets the current scaling in local space and stores it in a target vector
  14515. * @param result defines the target vector
  14516. */
  14517. getScaleToRef(result: Vector3): void;
  14518. /**
  14519. * Set the yaw, pitch, and roll of the bone in local or world space
  14520. * @param yaw The rotation of the bone on the y axis
  14521. * @param pitch The rotation of the bone on the x axis
  14522. * @param roll The rotation of the bone on the z axis
  14523. * @param space The space that the axes of rotation are in
  14524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14525. */
  14526. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14527. /**
  14528. * Add a rotation to the bone on an axis in local or world space
  14529. * @param axis The axis to rotate the bone on
  14530. * @param amount The amount to rotate the bone
  14531. * @param space The space that the axis is in
  14532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14533. */
  14534. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14535. /**
  14536. * Set the rotation of the bone to a particular axis angle in local or world space
  14537. * @param axis The axis to rotate the bone on
  14538. * @param angle The angle that the bone should be rotated to
  14539. * @param space The space that the axis is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14543. /**
  14544. * Set the euler rotation of the bone in local of world space
  14545. * @param rotation The euler rotation that the bone should be set to
  14546. * @param space The space that the rotation is in
  14547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14548. */
  14549. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14550. /**
  14551. * Set the quaternion rotation of the bone in local of world space
  14552. * @param quat The quaternion rotation that the bone should be set to
  14553. * @param space The space that the rotation is in
  14554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14555. */
  14556. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14557. /**
  14558. * Set the rotation matrix of the bone in local of world space
  14559. * @param rotMat The rotation matrix that the bone should be set to
  14560. * @param space The space that the rotation is in
  14561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14562. */
  14563. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14564. private _rotateWithMatrix;
  14565. private _getNegativeRotationToRef;
  14566. /**
  14567. * Get the position of the bone in local or world space
  14568. * @param space The space that the returned position is in
  14569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14570. * @returns The position of the bone
  14571. */
  14572. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14573. /**
  14574. * Copy the position of the bone to a vector3 in local or world space
  14575. * @param space The space that the returned position is in
  14576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14577. * @param result The vector3 to copy the position to
  14578. */
  14579. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14580. /**
  14581. * Get the absolute position of the bone (world space)
  14582. * @param mesh The mesh that this bone is attached to
  14583. * @returns The absolute position of the bone
  14584. */
  14585. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14586. /**
  14587. * Copy the absolute position of the bone (world space) to the result param
  14588. * @param mesh The mesh that this bone is attached to
  14589. * @param result The vector3 to copy the absolute position to
  14590. */
  14591. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14592. /**
  14593. * Compute the absolute transforms of this bone and its children
  14594. */
  14595. computeAbsoluteTransforms(): void;
  14596. /**
  14597. * Get the world direction from an axis that is in the local space of the bone
  14598. * @param localAxis The local direction that is used to compute the world direction
  14599. * @param mesh The mesh that this bone is attached to
  14600. * @returns The world direction
  14601. */
  14602. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14603. /**
  14604. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14605. * @param localAxis The local direction that is used to compute the world direction
  14606. * @param mesh The mesh that this bone is attached to
  14607. * @param result The vector3 that the world direction will be copied to
  14608. */
  14609. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14610. /**
  14611. * Get the euler rotation of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The euler rotation
  14615. */
  14616. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14617. /**
  14618. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The vector3 that the rotation should be copied to
  14622. */
  14623. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14624. /**
  14625. * Get the quaternion rotation of the bone in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @returns The quaternion rotation
  14629. */
  14630. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14631. /**
  14632. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14633. * @param space The space that the rotation should be in
  14634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14635. * @param result The quaternion that the rotation should be copied to
  14636. */
  14637. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14638. /**
  14639. * Get the rotation matrix of the bone in local or world space
  14640. * @param space The space that the rotation should be in
  14641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14642. * @returns The rotation matrix
  14643. */
  14644. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14645. /**
  14646. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14647. * @param space The space that the rotation should be in
  14648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14649. * @param result The quaternion that the rotation should be copied to
  14650. */
  14651. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14652. /**
  14653. * Get the world position of a point that is in the local space of the bone
  14654. * @param position The local position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @returns The world position
  14657. */
  14658. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14659. /**
  14660. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14661. * @param position The local position
  14662. * @param mesh The mesh that this bone is attached to
  14663. * @param result The vector3 that the world position should be copied to
  14664. */
  14665. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14666. /**
  14667. * Get the local position of a point that is in world space
  14668. * @param position The world position
  14669. * @param mesh The mesh that this bone is attached to
  14670. * @returns The local position
  14671. */
  14672. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14673. /**
  14674. * Get the local position of a point that is in world space and copy it to the result param
  14675. * @param position The world position
  14676. * @param mesh The mesh that this bone is attached to
  14677. * @param result The vector3 that the local position should be copied to
  14678. */
  14679. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14680. }
  14681. }
  14682. declare module "babylonjs/Animations/runtimeAnimation" {
  14683. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14684. import { Animatable } from "babylonjs/Animations/animatable";
  14685. import { Scene } from "babylonjs/scene";
  14686. /**
  14687. * Defines a runtime animation
  14688. */
  14689. export class RuntimeAnimation {
  14690. private _events;
  14691. /**
  14692. * The current frame of the runtime animation
  14693. */
  14694. private _currentFrame;
  14695. /**
  14696. * The animation used by the runtime animation
  14697. */
  14698. private _animation;
  14699. /**
  14700. * The target of the runtime animation
  14701. */
  14702. private _target;
  14703. /**
  14704. * The initiating animatable
  14705. */
  14706. private _host;
  14707. /**
  14708. * The original value of the runtime animation
  14709. */
  14710. private _originalValue;
  14711. /**
  14712. * The original blend value of the runtime animation
  14713. */
  14714. private _originalBlendValue;
  14715. /**
  14716. * The offsets cache of the runtime animation
  14717. */
  14718. private _offsetsCache;
  14719. /**
  14720. * The high limits cache of the runtime animation
  14721. */
  14722. private _highLimitsCache;
  14723. /**
  14724. * Specifies if the runtime animation has been stopped
  14725. */
  14726. private _stopped;
  14727. /**
  14728. * The blending factor of the runtime animation
  14729. */
  14730. private _blendingFactor;
  14731. /**
  14732. * The BabylonJS scene
  14733. */
  14734. private _scene;
  14735. /**
  14736. * The current value of the runtime animation
  14737. */
  14738. private _currentValue;
  14739. /** @hidden */
  14740. _animationState: _IAnimationState;
  14741. /**
  14742. * The active target of the runtime animation
  14743. */
  14744. private _activeTargets;
  14745. private _currentActiveTarget;
  14746. private _directTarget;
  14747. /**
  14748. * The target path of the runtime animation
  14749. */
  14750. private _targetPath;
  14751. /**
  14752. * The weight of the runtime animation
  14753. */
  14754. private _weight;
  14755. /**
  14756. * The ratio offset of the runtime animation
  14757. */
  14758. private _ratioOffset;
  14759. /**
  14760. * The previous delay of the runtime animation
  14761. */
  14762. private _previousDelay;
  14763. /**
  14764. * The previous ratio of the runtime animation
  14765. */
  14766. private _previousRatio;
  14767. private _enableBlending;
  14768. private _keys;
  14769. private _minFrame;
  14770. private _maxFrame;
  14771. private _minValue;
  14772. private _maxValue;
  14773. private _targetIsArray;
  14774. /**
  14775. * Gets the current frame of the runtime animation
  14776. */
  14777. get currentFrame(): number;
  14778. /**
  14779. * Gets the weight of the runtime animation
  14780. */
  14781. get weight(): number;
  14782. /**
  14783. * Gets the current value of the runtime animation
  14784. */
  14785. get currentValue(): any;
  14786. /**
  14787. * Gets the target path of the runtime animation
  14788. */
  14789. get targetPath(): string;
  14790. /**
  14791. * Gets the actual target of the runtime animation
  14792. */
  14793. get target(): any;
  14794. /** @hidden */
  14795. _onLoop: () => void;
  14796. /**
  14797. * Create a new RuntimeAnimation object
  14798. * @param target defines the target of the animation
  14799. * @param animation defines the source animation object
  14800. * @param scene defines the hosting scene
  14801. * @param host defines the initiating Animatable
  14802. */
  14803. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14804. private _preparePath;
  14805. /**
  14806. * Gets the animation from the runtime animation
  14807. */
  14808. get animation(): Animation;
  14809. /**
  14810. * Resets the runtime animation to the beginning
  14811. * @param restoreOriginal defines whether to restore the target property to the original value
  14812. */
  14813. reset(restoreOriginal?: boolean): void;
  14814. /**
  14815. * Specifies if the runtime animation is stopped
  14816. * @returns Boolean specifying if the runtime animation is stopped
  14817. */
  14818. isStopped(): boolean;
  14819. /**
  14820. * Disposes of the runtime animation
  14821. */
  14822. dispose(): void;
  14823. /**
  14824. * Apply the interpolated value to the target
  14825. * @param currentValue defines the value computed by the animation
  14826. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14827. */
  14828. setValue(currentValue: any, weight: number): void;
  14829. private _getOriginalValues;
  14830. private _setValue;
  14831. /**
  14832. * Gets the loop pmode of the runtime animation
  14833. * @returns Loop Mode
  14834. */
  14835. private _getCorrectLoopMode;
  14836. /**
  14837. * Move the current animation to a given frame
  14838. * @param frame defines the frame to move to
  14839. */
  14840. goToFrame(frame: number): void;
  14841. /**
  14842. * @hidden Internal use only
  14843. */
  14844. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14845. /**
  14846. * Execute the current animation
  14847. * @param delay defines the delay to add to the current frame
  14848. * @param from defines the lower bound of the animation range
  14849. * @param to defines the upper bound of the animation range
  14850. * @param loop defines if the current animation must loop
  14851. * @param speedRatio defines the current speed ratio
  14852. * @param weight defines the weight of the animation (default is -1 so no weight)
  14853. * @param onLoop optional callback called when animation loops
  14854. * @returns a boolean indicating if the animation is running
  14855. */
  14856. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14857. }
  14858. }
  14859. declare module "babylonjs/Animations/animatable" {
  14860. import { Animation } from "babylonjs/Animations/animation";
  14861. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14862. import { Nullable } from "babylonjs/types";
  14863. import { Observable } from "babylonjs/Misc/observable";
  14864. import { Scene } from "babylonjs/scene";
  14865. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14866. import { Node } from "babylonjs/node";
  14867. /**
  14868. * Class used to store an actual running animation
  14869. */
  14870. export class Animatable {
  14871. /** defines the target object */
  14872. target: any;
  14873. /** defines the starting frame number (default is 0) */
  14874. fromFrame: number;
  14875. /** defines the ending frame number (default is 100) */
  14876. toFrame: number;
  14877. /** defines if the animation must loop (default is false) */
  14878. loopAnimation: boolean;
  14879. /** defines a callback to call when animation ends if it is not looping */
  14880. onAnimationEnd?: (() => void) | null | undefined;
  14881. /** defines a callback to call when animation loops */
  14882. onAnimationLoop?: (() => void) | null | undefined;
  14883. private _localDelayOffset;
  14884. private _pausedDelay;
  14885. private _runtimeAnimations;
  14886. private _paused;
  14887. private _scene;
  14888. private _speedRatio;
  14889. private _weight;
  14890. private _syncRoot;
  14891. /**
  14892. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14893. * This will only apply for non looping animation (default is true)
  14894. */
  14895. disposeOnEnd: boolean;
  14896. /**
  14897. * Gets a boolean indicating if the animation has started
  14898. */
  14899. animationStarted: boolean;
  14900. /**
  14901. * Observer raised when the animation ends
  14902. */
  14903. onAnimationEndObservable: Observable<Animatable>;
  14904. /**
  14905. * Observer raised when the animation loops
  14906. */
  14907. onAnimationLoopObservable: Observable<Animatable>;
  14908. /**
  14909. * Gets the root Animatable used to synchronize and normalize animations
  14910. */
  14911. get syncRoot(): Nullable<Animatable>;
  14912. /**
  14913. * Gets the current frame of the first RuntimeAnimation
  14914. * Used to synchronize Animatables
  14915. */
  14916. get masterFrame(): number;
  14917. /**
  14918. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14919. */
  14920. get weight(): number;
  14921. set weight(value: number);
  14922. /**
  14923. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14924. */
  14925. get speedRatio(): number;
  14926. set speedRatio(value: number);
  14927. /**
  14928. * Creates a new Animatable
  14929. * @param scene defines the hosting scene
  14930. * @param target defines the target object
  14931. * @param fromFrame defines the starting frame number (default is 0)
  14932. * @param toFrame defines the ending frame number (default is 100)
  14933. * @param loopAnimation defines if the animation must loop (default is false)
  14934. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14935. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14936. * @param animations defines a group of animation to add to the new Animatable
  14937. * @param onAnimationLoop defines a callback to call when animation loops
  14938. */
  14939. constructor(scene: Scene,
  14940. /** defines the target object */
  14941. target: any,
  14942. /** defines the starting frame number (default is 0) */
  14943. fromFrame?: number,
  14944. /** defines the ending frame number (default is 100) */
  14945. toFrame?: number,
  14946. /** defines if the animation must loop (default is false) */
  14947. loopAnimation?: boolean, speedRatio?: number,
  14948. /** defines a callback to call when animation ends if it is not looping */
  14949. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14950. /** defines a callback to call when animation loops */
  14951. onAnimationLoop?: (() => void) | null | undefined);
  14952. /**
  14953. * Synchronize and normalize current Animatable with a source Animatable
  14954. * This is useful when using animation weights and when animations are not of the same length
  14955. * @param root defines the root Animatable to synchronize with
  14956. * @returns the current Animatable
  14957. */
  14958. syncWith(root: Animatable): Animatable;
  14959. /**
  14960. * Gets the list of runtime animations
  14961. * @returns an array of RuntimeAnimation
  14962. */
  14963. getAnimations(): RuntimeAnimation[];
  14964. /**
  14965. * Adds more animations to the current animatable
  14966. * @param target defines the target of the animations
  14967. * @param animations defines the new animations to add
  14968. */
  14969. appendAnimations(target: any, animations: Animation[]): void;
  14970. /**
  14971. * Gets the source animation for a specific property
  14972. * @param property defines the propertyu to look for
  14973. * @returns null or the source animation for the given property
  14974. */
  14975. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14976. /**
  14977. * Gets the runtime animation for a specific property
  14978. * @param property defines the propertyu to look for
  14979. * @returns null or the runtime animation for the given property
  14980. */
  14981. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14982. /**
  14983. * Resets the animatable to its original state
  14984. */
  14985. reset(): void;
  14986. /**
  14987. * Allows the animatable to blend with current running animations
  14988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14989. * @param blendingSpeed defines the blending speed to use
  14990. */
  14991. enableBlending(blendingSpeed: number): void;
  14992. /**
  14993. * Disable animation blending
  14994. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14995. */
  14996. disableBlending(): void;
  14997. /**
  14998. * Jump directly to a given frame
  14999. * @param frame defines the frame to jump to
  15000. */
  15001. goToFrame(frame: number): void;
  15002. /**
  15003. * Pause the animation
  15004. */
  15005. pause(): void;
  15006. /**
  15007. * Restart the animation
  15008. */
  15009. restart(): void;
  15010. private _raiseOnAnimationEnd;
  15011. /**
  15012. * Stop and delete the current animation
  15013. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15014. * @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)
  15015. */
  15016. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15017. /**
  15018. * Wait asynchronously for the animation to end
  15019. * @returns a promise which will be fullfilled when the animation ends
  15020. */
  15021. waitAsync(): Promise<Animatable>;
  15022. /** @hidden */
  15023. _animate(delay: number): boolean;
  15024. }
  15025. module "babylonjs/scene" {
  15026. interface Scene {
  15027. /** @hidden */
  15028. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15029. /** @hidden */
  15030. _processLateAnimationBindingsForMatrices(holder: {
  15031. totalWeight: number;
  15032. animations: RuntimeAnimation[];
  15033. originalValue: Matrix;
  15034. }): any;
  15035. /** @hidden */
  15036. _processLateAnimationBindingsForQuaternions(holder: {
  15037. totalWeight: number;
  15038. animations: RuntimeAnimation[];
  15039. originalValue: Quaternion;
  15040. }, refQuaternion: Quaternion): Quaternion;
  15041. /** @hidden */
  15042. _processLateAnimationBindings(): void;
  15043. /**
  15044. * Will start the animation sequence of a given target
  15045. * @param target defines the target
  15046. * @param from defines from which frame should animation start
  15047. * @param to defines until which frame should animation run.
  15048. * @param weight defines the weight to apply to the animation (1.0 by default)
  15049. * @param loop defines if the animation loops
  15050. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15051. * @param onAnimationEnd defines the function to be executed when the animation ends
  15052. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15053. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15054. * @param onAnimationLoop defines the callback to call when an animation loops
  15055. * @returns the animatable object created for this animation
  15056. */
  15057. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15058. /**
  15059. * Will start the animation sequence of a given target
  15060. * @param target defines the target
  15061. * @param from defines from which frame should animation start
  15062. * @param to defines until which frame should animation run.
  15063. * @param loop defines if the animation loops
  15064. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15065. * @param onAnimationEnd defines the function to be executed when the animation ends
  15066. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15067. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15068. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15069. * @param onAnimationLoop defines the callback to call when an animation loops
  15070. * @returns the animatable object created for this animation
  15071. */
  15072. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15073. /**
  15074. * Will start the animation sequence of a given target and its hierarchy
  15075. * @param target defines the target
  15076. * @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.
  15077. * @param from defines from which frame should animation start
  15078. * @param to defines until which frame should animation run.
  15079. * @param loop defines if the animation loops
  15080. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15081. * @param onAnimationEnd defines the function to be executed when the animation ends
  15082. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15083. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15084. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15085. * @param onAnimationLoop defines the callback to call when an animation loops
  15086. * @returns the list of created animatables
  15087. */
  15088. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  15089. /**
  15090. * Begin a new animation on a given node
  15091. * @param target defines the target where the animation will take place
  15092. * @param animations defines the list of animations to start
  15093. * @param from defines the initial value
  15094. * @param to defines the final value
  15095. * @param loop defines if you want animation to loop (off by default)
  15096. * @param speedRatio defines the speed ratio to apply to all animations
  15097. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15098. * @param onAnimationLoop defines the callback to call when an animation loops
  15099. * @returns the list of created animatables
  15100. */
  15101. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15102. /**
  15103. * Begin a new animation on a given node and its hierarchy
  15104. * @param target defines the root node where the animation will take place
  15105. * @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.
  15106. * @param animations defines the list of animations to start
  15107. * @param from defines the initial value
  15108. * @param to defines the final value
  15109. * @param loop defines if you want animation to loop (off by default)
  15110. * @param speedRatio defines the speed ratio to apply to all animations
  15111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the list of animatables created for all nodes
  15114. */
  15115. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15116. /**
  15117. * Gets the animatable associated with a specific target
  15118. * @param target defines the target of the animatable
  15119. * @returns the required animatable if found
  15120. */
  15121. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15122. /**
  15123. * Gets all animatables associated with a given target
  15124. * @param target defines the target to look animatables for
  15125. * @returns an array of Animatables
  15126. */
  15127. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15128. /**
  15129. * Stops and removes all animations that have been applied to the scene
  15130. */
  15131. stopAllAnimations(): void;
  15132. /**
  15133. * Gets the current delta time used by animation engine
  15134. */
  15135. deltaTime: number;
  15136. }
  15137. }
  15138. module "babylonjs/Bones/bone" {
  15139. interface Bone {
  15140. /**
  15141. * Copy an animation range from another bone
  15142. * @param source defines the source bone
  15143. * @param rangeName defines the range name to copy
  15144. * @param frameOffset defines the frame offset
  15145. * @param rescaleAsRequired defines if rescaling must be applied if required
  15146. * @param skelDimensionsRatio defines the scaling ratio
  15147. * @returns true if operation was successful
  15148. */
  15149. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15150. }
  15151. }
  15152. }
  15153. declare module "babylonjs/Bones/skeleton" {
  15154. import { Bone } from "babylonjs/Bones/bone";
  15155. import { Observable } from "babylonjs/Misc/observable";
  15156. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15157. import { Scene } from "babylonjs/scene";
  15158. import { Nullable } from "babylonjs/types";
  15159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15161. import { Animatable } from "babylonjs/Animations/animatable";
  15162. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15163. import { Animation } from "babylonjs/Animations/animation";
  15164. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15165. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15167. /**
  15168. * Class used to handle skinning animations
  15169. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15170. */
  15171. export class Skeleton implements IAnimatable {
  15172. /** defines the skeleton name */
  15173. name: string;
  15174. /** defines the skeleton Id */
  15175. id: string;
  15176. /**
  15177. * Defines the list of child bones
  15178. */
  15179. bones: Bone[];
  15180. /**
  15181. * Defines an estimate of the dimension of the skeleton at rest
  15182. */
  15183. dimensionsAtRest: Vector3;
  15184. /**
  15185. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15186. */
  15187. needInitialSkinMatrix: boolean;
  15188. /**
  15189. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15190. */
  15191. overrideMesh: Nullable<AbstractMesh>;
  15192. /**
  15193. * Gets the list of animations attached to this skeleton
  15194. */
  15195. animations: Array<Animation>;
  15196. private _scene;
  15197. private _isDirty;
  15198. private _transformMatrices;
  15199. private _transformMatrixTexture;
  15200. private _meshesWithPoseMatrix;
  15201. private _animatables;
  15202. private _identity;
  15203. private _synchronizedWithMesh;
  15204. private _ranges;
  15205. private _lastAbsoluteTransformsUpdateId;
  15206. private _canUseTextureForBones;
  15207. private _uniqueId;
  15208. /** @hidden */
  15209. _numBonesWithLinkedTransformNode: number;
  15210. /** @hidden */
  15211. _hasWaitingData: Nullable<boolean>;
  15212. /**
  15213. * Specifies if the skeleton should be serialized
  15214. */
  15215. doNotSerialize: boolean;
  15216. private _useTextureToStoreBoneMatrices;
  15217. /**
  15218. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15219. * Please note that this option is not available if the hardware does not support it
  15220. */
  15221. get useTextureToStoreBoneMatrices(): boolean;
  15222. set useTextureToStoreBoneMatrices(value: boolean);
  15223. private _animationPropertiesOverride;
  15224. /**
  15225. * Gets or sets the animation properties override
  15226. */
  15227. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15228. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15229. /**
  15230. * List of inspectable custom properties (used by the Inspector)
  15231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15232. */
  15233. inspectableCustomProperties: IInspectable[];
  15234. /**
  15235. * An observable triggered before computing the skeleton's matrices
  15236. */
  15237. onBeforeComputeObservable: Observable<Skeleton>;
  15238. /**
  15239. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15240. */
  15241. get isUsingTextureForMatrices(): boolean;
  15242. /**
  15243. * Gets the unique ID of this skeleton
  15244. */
  15245. get uniqueId(): number;
  15246. /**
  15247. * Creates a new skeleton
  15248. * @param name defines the skeleton name
  15249. * @param id defines the skeleton Id
  15250. * @param scene defines the hosting scene
  15251. */
  15252. constructor(
  15253. /** defines the skeleton name */
  15254. name: string,
  15255. /** defines the skeleton Id */
  15256. id: string, scene: Scene);
  15257. /**
  15258. * Gets the current object class name.
  15259. * @return the class name
  15260. */
  15261. getClassName(): string;
  15262. /**
  15263. * Returns an array containing the root bones
  15264. * @returns an array containing the root bones
  15265. */
  15266. getChildren(): Array<Bone>;
  15267. /**
  15268. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15269. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15270. * @returns a Float32Array containing matrices data
  15271. */
  15272. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15273. /**
  15274. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15276. * @returns a raw texture containing the data
  15277. */
  15278. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15279. /**
  15280. * Gets the current hosting scene
  15281. * @returns a scene object
  15282. */
  15283. getScene(): Scene;
  15284. /**
  15285. * Gets a string representing the current skeleton data
  15286. * @param fullDetails defines a boolean indicating if we want a verbose version
  15287. * @returns a string representing the current skeleton data
  15288. */
  15289. toString(fullDetails?: boolean): string;
  15290. /**
  15291. * Get bone's index searching by name
  15292. * @param name defines bone's name to search for
  15293. * @return the indice of the bone. Returns -1 if not found
  15294. */
  15295. getBoneIndexByName(name: string): number;
  15296. /**
  15297. * Creater a new animation range
  15298. * @param name defines the name of the range
  15299. * @param from defines the start key
  15300. * @param to defines the end key
  15301. */
  15302. createAnimationRange(name: string, from: number, to: number): void;
  15303. /**
  15304. * Delete a specific animation range
  15305. * @param name defines the name of the range
  15306. * @param deleteFrames defines if frames must be removed as well
  15307. */
  15308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15309. /**
  15310. * Gets a specific animation range
  15311. * @param name defines the name of the range to look for
  15312. * @returns the requested animation range or null if not found
  15313. */
  15314. getAnimationRange(name: string): Nullable<AnimationRange>;
  15315. /**
  15316. * Gets the list of all animation ranges defined on this skeleton
  15317. * @returns an array
  15318. */
  15319. getAnimationRanges(): Nullable<AnimationRange>[];
  15320. /**
  15321. * Copy animation range from a source skeleton.
  15322. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15323. * @param source defines the source skeleton
  15324. * @param name defines the name of the range to copy
  15325. * @param rescaleAsRequired defines if rescaling must be applied if required
  15326. * @returns true if operation was successful
  15327. */
  15328. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15329. /**
  15330. * Forces the skeleton to go to rest pose
  15331. */
  15332. returnToRest(): void;
  15333. private _getHighestAnimationFrame;
  15334. /**
  15335. * Begin a specific animation range
  15336. * @param name defines the name of the range to start
  15337. * @param loop defines if looping must be turned on (false by default)
  15338. * @param speedRatio defines the speed ratio to apply (1 by default)
  15339. * @param onAnimationEnd defines a callback which will be called when animation will end
  15340. * @returns a new animatable
  15341. */
  15342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15343. /** @hidden */
  15344. _markAsDirty(): void;
  15345. /** @hidden */
  15346. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15347. /** @hidden */
  15348. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15349. private _computeTransformMatrices;
  15350. /**
  15351. * Build all resources required to render a skeleton
  15352. */
  15353. prepare(): void;
  15354. /**
  15355. * Gets the list of animatables currently running for this skeleton
  15356. * @returns an array of animatables
  15357. */
  15358. getAnimatables(): IAnimatable[];
  15359. /**
  15360. * Clone the current skeleton
  15361. * @param name defines the name of the new skeleton
  15362. * @param id defines the id of the new skeleton
  15363. * @returns the new skeleton
  15364. */
  15365. clone(name: string, id?: string): Skeleton;
  15366. /**
  15367. * Enable animation blending for this skeleton
  15368. * @param blendingSpeed defines the blending speed to apply
  15369. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15370. */
  15371. enableBlending(blendingSpeed?: number): void;
  15372. /**
  15373. * Releases all resources associated with the current skeleton
  15374. */
  15375. dispose(): void;
  15376. /**
  15377. * Serialize the skeleton in a JSON object
  15378. * @returns a JSON object
  15379. */
  15380. serialize(): any;
  15381. /**
  15382. * Creates a new skeleton from serialized data
  15383. * @param parsedSkeleton defines the serialized data
  15384. * @param scene defines the hosting scene
  15385. * @returns a new skeleton
  15386. */
  15387. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15388. /**
  15389. * Compute all node absolute transforms
  15390. * @param forceUpdate defines if computation must be done even if cache is up to date
  15391. */
  15392. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15393. /**
  15394. * Gets the root pose matrix
  15395. * @returns a matrix
  15396. */
  15397. getPoseMatrix(): Nullable<Matrix>;
  15398. /**
  15399. * Sorts bones per internal index
  15400. */
  15401. sortBones(): void;
  15402. private _sortBones;
  15403. }
  15404. }
  15405. declare module "babylonjs/Meshes/instancedMesh" {
  15406. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15407. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15408. import { Camera } from "babylonjs/Cameras/camera";
  15409. import { Node } from "babylonjs/node";
  15410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15411. import { Mesh } from "babylonjs/Meshes/mesh";
  15412. import { Material } from "babylonjs/Materials/material";
  15413. import { Skeleton } from "babylonjs/Bones/skeleton";
  15414. import { Light } from "babylonjs/Lights/light";
  15415. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15416. /**
  15417. * Creates an instance based on a source mesh.
  15418. */
  15419. export class InstancedMesh extends AbstractMesh {
  15420. private _sourceMesh;
  15421. private _currentLOD;
  15422. /** @hidden */
  15423. _indexInSourceMeshInstanceArray: number;
  15424. constructor(name: string, source: Mesh);
  15425. /**
  15426. * Returns the string "InstancedMesh".
  15427. */
  15428. getClassName(): string;
  15429. /** Gets the list of lights affecting that mesh */
  15430. get lightSources(): Light[];
  15431. _resyncLightSources(): void;
  15432. _resyncLightSource(light: Light): void;
  15433. _removeLightSource(light: Light, dispose: boolean): void;
  15434. /**
  15435. * If the source mesh receives shadows
  15436. */
  15437. get receiveShadows(): boolean;
  15438. /**
  15439. * The material of the source mesh
  15440. */
  15441. get material(): Nullable<Material>;
  15442. /**
  15443. * Visibility of the source mesh
  15444. */
  15445. get visibility(): number;
  15446. /**
  15447. * Skeleton of the source mesh
  15448. */
  15449. get skeleton(): Nullable<Skeleton>;
  15450. /**
  15451. * Rendering ground id of the source mesh
  15452. */
  15453. get renderingGroupId(): number;
  15454. set renderingGroupId(value: number);
  15455. /**
  15456. * Returns the total number of vertices (integer).
  15457. */
  15458. getTotalVertices(): number;
  15459. /**
  15460. * Returns a positive integer : the total number of indices in this mesh geometry.
  15461. * @returns the numner of indices or zero if the mesh has no geometry.
  15462. */
  15463. getTotalIndices(): number;
  15464. /**
  15465. * The source mesh of the instance
  15466. */
  15467. get sourceMesh(): Mesh;
  15468. /**
  15469. * Is this node ready to be used/rendered
  15470. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15471. * @return {boolean} is it ready
  15472. */
  15473. isReady(completeCheck?: boolean): boolean;
  15474. /**
  15475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15476. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15477. * @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.
  15478. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15479. */
  15480. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15481. /**
  15482. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15483. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15484. * The `data` are either a numeric array either a Float32Array.
  15485. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15486. * 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).
  15487. * Note that a new underlying VertexBuffer object is created each call.
  15488. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15489. *
  15490. * Possible `kind` values :
  15491. * - VertexBuffer.PositionKind
  15492. * - VertexBuffer.UVKind
  15493. * - VertexBuffer.UV2Kind
  15494. * - VertexBuffer.UV3Kind
  15495. * - VertexBuffer.UV4Kind
  15496. * - VertexBuffer.UV5Kind
  15497. * - VertexBuffer.UV6Kind
  15498. * - VertexBuffer.ColorKind
  15499. * - VertexBuffer.MatricesIndicesKind
  15500. * - VertexBuffer.MatricesIndicesExtraKind
  15501. * - VertexBuffer.MatricesWeightsKind
  15502. * - VertexBuffer.MatricesWeightsExtraKind
  15503. *
  15504. * Returns the Mesh.
  15505. */
  15506. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15507. /**
  15508. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15509. * If the mesh has no geometry, it is simply returned as it is.
  15510. * The `data` are either a numeric array either a Float32Array.
  15511. * No new underlying VertexBuffer object is created.
  15512. * 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.
  15513. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15514. *
  15515. * Possible `kind` values :
  15516. * - VertexBuffer.PositionKind
  15517. * - VertexBuffer.UVKind
  15518. * - VertexBuffer.UV2Kind
  15519. * - VertexBuffer.UV3Kind
  15520. * - VertexBuffer.UV4Kind
  15521. * - VertexBuffer.UV5Kind
  15522. * - VertexBuffer.UV6Kind
  15523. * - VertexBuffer.ColorKind
  15524. * - VertexBuffer.MatricesIndicesKind
  15525. * - VertexBuffer.MatricesIndicesExtraKind
  15526. * - VertexBuffer.MatricesWeightsKind
  15527. * - VertexBuffer.MatricesWeightsExtraKind
  15528. *
  15529. * Returns the Mesh.
  15530. */
  15531. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15532. /**
  15533. * Sets the mesh indices.
  15534. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15535. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15536. * This method creates a new index buffer each call.
  15537. * Returns the Mesh.
  15538. */
  15539. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15540. /**
  15541. * Boolean : True if the mesh owns the requested kind of data.
  15542. */
  15543. isVerticesDataPresent(kind: string): boolean;
  15544. /**
  15545. * Returns an array of indices (IndicesArray).
  15546. */
  15547. getIndices(): Nullable<IndicesArray>;
  15548. get _positions(): Nullable<Vector3[]>;
  15549. /**
  15550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15551. * This means the mesh underlying bounding box and sphere are recomputed.
  15552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15553. * @returns the current mesh
  15554. */
  15555. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15556. /** @hidden */
  15557. _preActivate(): InstancedMesh;
  15558. /** @hidden */
  15559. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15560. /** @hidden */
  15561. _postActivate(): void;
  15562. getWorldMatrix(): Matrix;
  15563. get isAnInstance(): boolean;
  15564. /**
  15565. * Returns the current associated LOD AbstractMesh.
  15566. */
  15567. getLOD(camera: Camera): AbstractMesh;
  15568. /** @hidden */
  15569. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15570. /** @hidden */
  15571. _syncSubMeshes(): InstancedMesh;
  15572. /** @hidden */
  15573. _generatePointsArray(): boolean;
  15574. /**
  15575. * Creates a new InstancedMesh from the current mesh.
  15576. * - name (string) : the cloned mesh name
  15577. * - newParent (optional Node) : the optional Node to parent the clone to.
  15578. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15579. *
  15580. * Returns the clone.
  15581. */
  15582. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15583. /**
  15584. * Disposes the InstancedMesh.
  15585. * Returns nothing.
  15586. */
  15587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15588. }
  15589. module "babylonjs/Meshes/mesh" {
  15590. interface Mesh {
  15591. /**
  15592. * Register a custom buffer that will be instanced
  15593. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15594. * @param kind defines the buffer kind
  15595. * @param stride defines the stride in floats
  15596. */
  15597. registerInstancedBuffer(kind: string, stride: number): void;
  15598. /** @hidden */
  15599. _userInstancedBuffersStorage: {
  15600. data: {
  15601. [key: string]: Float32Array;
  15602. };
  15603. sizes: {
  15604. [key: string]: number;
  15605. };
  15606. vertexBuffers: {
  15607. [key: string]: Nullable<VertexBuffer>;
  15608. };
  15609. strides: {
  15610. [key: string]: number;
  15611. };
  15612. };
  15613. }
  15614. }
  15615. module "babylonjs/Meshes/abstractMesh" {
  15616. interface AbstractMesh {
  15617. /**
  15618. * Object used to store instanced buffers defined by user
  15619. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15620. */
  15621. instancedBuffers: {
  15622. [key: string]: any;
  15623. };
  15624. }
  15625. }
  15626. }
  15627. declare module "babylonjs/Materials/shaderMaterial" {
  15628. import { Scene } from "babylonjs/scene";
  15629. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15631. import { Mesh } from "babylonjs/Meshes/mesh";
  15632. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15634. import { Texture } from "babylonjs/Materials/Textures/texture";
  15635. import { Material } from "babylonjs/Materials/material";
  15636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15637. /**
  15638. * Defines the options associated with the creation of a shader material.
  15639. */
  15640. export interface IShaderMaterialOptions {
  15641. /**
  15642. * Does the material work in alpha blend mode
  15643. */
  15644. needAlphaBlending: boolean;
  15645. /**
  15646. * Does the material work in alpha test mode
  15647. */
  15648. needAlphaTesting: boolean;
  15649. /**
  15650. * The list of attribute names used in the shader
  15651. */
  15652. attributes: string[];
  15653. /**
  15654. * The list of unifrom names used in the shader
  15655. */
  15656. uniforms: string[];
  15657. /**
  15658. * The list of UBO names used in the shader
  15659. */
  15660. uniformBuffers: string[];
  15661. /**
  15662. * The list of sampler names used in the shader
  15663. */
  15664. samplers: string[];
  15665. /**
  15666. * The list of defines used in the shader
  15667. */
  15668. defines: string[];
  15669. }
  15670. /**
  15671. * 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.
  15672. *
  15673. * This returned material effects how the mesh will look based on the code in the shaders.
  15674. *
  15675. * @see http://doc.babylonjs.com/how_to/shader_material
  15676. */
  15677. export class ShaderMaterial extends Material {
  15678. private _shaderPath;
  15679. private _options;
  15680. private _textures;
  15681. private _textureArrays;
  15682. private _floats;
  15683. private _ints;
  15684. private _floatsArrays;
  15685. private _colors3;
  15686. private _colors3Arrays;
  15687. private _colors4;
  15688. private _colors4Arrays;
  15689. private _vectors2;
  15690. private _vectors3;
  15691. private _vectors4;
  15692. private _matrices;
  15693. private _matrixArrays;
  15694. private _matrices3x3;
  15695. private _matrices2x2;
  15696. private _vectors2Arrays;
  15697. private _vectors3Arrays;
  15698. private _vectors4Arrays;
  15699. private _cachedWorldViewMatrix;
  15700. private _cachedWorldViewProjectionMatrix;
  15701. private _renderId;
  15702. private _multiview;
  15703. /**
  15704. * Instantiate a new shader material.
  15705. * 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.
  15706. * This returned material effects how the mesh will look based on the code in the shaders.
  15707. * @see http://doc.babylonjs.com/how_to/shader_material
  15708. * @param name Define the name of the material in the scene
  15709. * @param scene Define the scene the material belongs to
  15710. * @param shaderPath Defines the route to the shader code in one of three ways:
  15711. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15712. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15713. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15714. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15715. * @param options Define the options used to create the shader
  15716. */
  15717. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15718. /**
  15719. * Gets the shader path used to define the shader code
  15720. * It can be modified to trigger a new compilation
  15721. */
  15722. get shaderPath(): any;
  15723. /**
  15724. * Sets the shader path used to define the shader code
  15725. * It can be modified to trigger a new compilation
  15726. */
  15727. set shaderPath(shaderPath: any);
  15728. /**
  15729. * Gets the options used to compile the shader.
  15730. * They can be modified to trigger a new compilation
  15731. */
  15732. get options(): IShaderMaterialOptions;
  15733. /**
  15734. * Gets the current class name of the material e.g. "ShaderMaterial"
  15735. * Mainly use in serialization.
  15736. * @returns the class name
  15737. */
  15738. getClassName(): string;
  15739. /**
  15740. * Specifies if the material will require alpha blending
  15741. * @returns a boolean specifying if alpha blending is needed
  15742. */
  15743. needAlphaBlending(): boolean;
  15744. /**
  15745. * Specifies if this material should be rendered in alpha test mode
  15746. * @returns a boolean specifying if an alpha test is needed.
  15747. */
  15748. needAlphaTesting(): boolean;
  15749. private _checkUniform;
  15750. /**
  15751. * Set a texture in the shader.
  15752. * @param name Define the name of the uniform samplers as defined in the shader
  15753. * @param texture Define the texture to bind to this sampler
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setTexture(name: string, texture: Texture): ShaderMaterial;
  15757. /**
  15758. * Set a texture array in the shader.
  15759. * @param name Define the name of the uniform sampler array as defined in the shader
  15760. * @param textures Define the list of textures to bind to this sampler
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15764. /**
  15765. * Set a float in the shader.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setFloat(name: string, value: number): ShaderMaterial;
  15771. /**
  15772. * Set a int in the shader.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setInt(name: string, value: number): ShaderMaterial;
  15778. /**
  15779. * Set an array of floats in the shader.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setFloats(name: string, value: number[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec3 in the shader from a Color3.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setColor3(name: string, value: Color3): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 array in the shader from a Color3 array.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Color4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setColor4(name: string, value: Color4): ShaderMaterial;
  15806. /**
  15807. * Set a vec4 array in the shader from a Color4 array.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15813. /**
  15814. * Set a vec2 in the shader from a Vector2.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setVector2(name: string, value: Vector2): ShaderMaterial;
  15820. /**
  15821. * Set a vec3 in the shader from a Vector3.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setVector3(name: string, value: Vector3): ShaderMaterial;
  15827. /**
  15828. * Set a vec4 in the shader from a Vector4.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setVector4(name: string, value: Vector4): ShaderMaterial;
  15834. /**
  15835. * Set a mat4 in the shader from a Matrix.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15841. /**
  15842. * Set a float32Array in the shader from a matrix array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15848. /**
  15849. * Set a mat3 in the shader from a Float32Array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15855. /**
  15856. * Set a mat2 in the shader from a Float32Array.
  15857. * @param name Define the name of the uniform as defined in the shader
  15858. * @param value Define the value to give to the uniform
  15859. * @return the material itself allowing "fluent" like uniform updates
  15860. */
  15861. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15862. /**
  15863. * Set a vec2 array in the shader from a number array.
  15864. * @param name Define the name of the uniform as defined in the shader
  15865. * @param value Define the value to give to the uniform
  15866. * @return the material itself allowing "fluent" like uniform updates
  15867. */
  15868. setArray2(name: string, value: number[]): ShaderMaterial;
  15869. /**
  15870. * Set a vec3 array in the shader from a number array.
  15871. * @param name Define the name of the uniform as defined in the shader
  15872. * @param value Define the value to give to the uniform
  15873. * @return the material itself allowing "fluent" like uniform updates
  15874. */
  15875. setArray3(name: string, value: number[]): ShaderMaterial;
  15876. /**
  15877. * Set a vec4 array in the shader from a number array.
  15878. * @param name Define the name of the uniform as defined in the shader
  15879. * @param value Define the value to give to the uniform
  15880. * @return the material itself allowing "fluent" like uniform updates
  15881. */
  15882. setArray4(name: string, value: number[]): ShaderMaterial;
  15883. private _checkCache;
  15884. /**
  15885. * Specifies that the submesh is ready to be used
  15886. * @param mesh defines the mesh to check
  15887. * @param subMesh defines which submesh to check
  15888. * @param useInstances specifies that instances should be used
  15889. * @returns a boolean indicating that the submesh is ready or not
  15890. */
  15891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15892. /**
  15893. * Checks if the material is ready to render the requested mesh
  15894. * @param mesh Define the mesh to render
  15895. * @param useInstances Define whether or not the material is used with instances
  15896. * @returns true if ready, otherwise false
  15897. */
  15898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15899. /**
  15900. * Binds the world matrix to the material
  15901. * @param world defines the world transformation matrix
  15902. */
  15903. bindOnlyWorldMatrix(world: Matrix): void;
  15904. /**
  15905. * Binds the material to the mesh
  15906. * @param world defines the world transformation matrix
  15907. * @param mesh defines the mesh to bind the material to
  15908. */
  15909. bind(world: Matrix, mesh?: Mesh): void;
  15910. /**
  15911. * Gets the active textures from the material
  15912. * @returns an array of textures
  15913. */
  15914. getActiveTextures(): BaseTexture[];
  15915. /**
  15916. * Specifies if the material uses a texture
  15917. * @param texture defines the texture to check against the material
  15918. * @returns a boolean specifying if the material uses the texture
  15919. */
  15920. hasTexture(texture: BaseTexture): boolean;
  15921. /**
  15922. * Makes a duplicate of the material, and gives it a new name
  15923. * @param name defines the new name for the duplicated material
  15924. * @returns the cloned material
  15925. */
  15926. clone(name: string): ShaderMaterial;
  15927. /**
  15928. * Disposes the material
  15929. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15930. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15931. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15932. */
  15933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15934. /**
  15935. * Serializes this material in a JSON representation
  15936. * @returns the serialized material object
  15937. */
  15938. serialize(): any;
  15939. /**
  15940. * Creates a shader material from parsed shader material data
  15941. * @param source defines the JSON represnetation of the material
  15942. * @param scene defines the hosting scene
  15943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15944. * @returns a new material
  15945. */
  15946. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15947. }
  15948. }
  15949. declare module "babylonjs/Shaders/color.fragment" {
  15950. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15951. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15952. /** @hidden */
  15953. export var colorPixelShader: {
  15954. name: string;
  15955. shader: string;
  15956. };
  15957. }
  15958. declare module "babylonjs/Shaders/color.vertex" {
  15959. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15961. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15962. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15963. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15965. /** @hidden */
  15966. export var colorVertexShader: {
  15967. name: string;
  15968. shader: string;
  15969. };
  15970. }
  15971. declare module "babylonjs/Meshes/linesMesh" {
  15972. import { Nullable } from "babylonjs/types";
  15973. import { Scene } from "babylonjs/scene";
  15974. import { Color3 } from "babylonjs/Maths/math.color";
  15975. import { Node } from "babylonjs/node";
  15976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15977. import { Mesh } from "babylonjs/Meshes/mesh";
  15978. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15979. import { Effect } from "babylonjs/Materials/effect";
  15980. import { Material } from "babylonjs/Materials/material";
  15981. import "babylonjs/Shaders/color.fragment";
  15982. import "babylonjs/Shaders/color.vertex";
  15983. /**
  15984. * Line mesh
  15985. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15986. */
  15987. export class LinesMesh extends Mesh {
  15988. /**
  15989. * If vertex color should be applied to the mesh
  15990. */
  15991. readonly useVertexColor?: boolean | undefined;
  15992. /**
  15993. * If vertex alpha should be applied to the mesh
  15994. */
  15995. readonly useVertexAlpha?: boolean | undefined;
  15996. /**
  15997. * Color of the line (Default: White)
  15998. */
  15999. color: Color3;
  16000. /**
  16001. * Alpha of the line (Default: 1)
  16002. */
  16003. alpha: number;
  16004. /**
  16005. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16006. * This margin is expressed in world space coordinates, so its value may vary.
  16007. * Default value is 0.1
  16008. */
  16009. intersectionThreshold: number;
  16010. private _colorShader;
  16011. private color4;
  16012. /**
  16013. * Creates a new LinesMesh
  16014. * @param name defines the name
  16015. * @param scene defines the hosting scene
  16016. * @param parent defines the parent mesh if any
  16017. * @param source defines the optional source LinesMesh used to clone data from
  16018. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16019. * When false, achieved by calling a clone(), also passing False.
  16020. * This will make creation of children, recursive.
  16021. * @param useVertexColor defines if this LinesMesh supports vertex color
  16022. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16023. */
  16024. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16025. /**
  16026. * If vertex color should be applied to the mesh
  16027. */
  16028. useVertexColor?: boolean | undefined,
  16029. /**
  16030. * If vertex alpha should be applied to the mesh
  16031. */
  16032. useVertexAlpha?: boolean | undefined);
  16033. private _addClipPlaneDefine;
  16034. private _removeClipPlaneDefine;
  16035. isReady(): boolean;
  16036. /**
  16037. * Returns the string "LineMesh"
  16038. */
  16039. getClassName(): string;
  16040. /**
  16041. * @hidden
  16042. */
  16043. get material(): Material;
  16044. /**
  16045. * @hidden
  16046. */
  16047. set material(value: Material);
  16048. /**
  16049. * @hidden
  16050. */
  16051. get checkCollisions(): boolean;
  16052. /** @hidden */
  16053. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16054. /** @hidden */
  16055. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16056. /**
  16057. * Disposes of the line mesh
  16058. * @param doNotRecurse If children should be disposed
  16059. */
  16060. dispose(doNotRecurse?: boolean): void;
  16061. /**
  16062. * Returns a new LineMesh object cloned from the current one.
  16063. */
  16064. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16065. /**
  16066. * Creates a new InstancedLinesMesh object from the mesh model.
  16067. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16068. * @param name defines the name of the new instance
  16069. * @returns a new InstancedLinesMesh
  16070. */
  16071. createInstance(name: string): InstancedLinesMesh;
  16072. }
  16073. /**
  16074. * Creates an instance based on a source LinesMesh
  16075. */
  16076. export class InstancedLinesMesh extends InstancedMesh {
  16077. /**
  16078. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16079. * This margin is expressed in world space coordinates, so its value may vary.
  16080. * Initilized with the intersectionThreshold value of the source LinesMesh
  16081. */
  16082. intersectionThreshold: number;
  16083. constructor(name: string, source: LinesMesh);
  16084. /**
  16085. * Returns the string "InstancedLinesMesh".
  16086. */
  16087. getClassName(): string;
  16088. }
  16089. }
  16090. declare module "babylonjs/Shaders/line.fragment" {
  16091. /** @hidden */
  16092. export var linePixelShader: {
  16093. name: string;
  16094. shader: string;
  16095. };
  16096. }
  16097. declare module "babylonjs/Shaders/line.vertex" {
  16098. /** @hidden */
  16099. export var lineVertexShader: {
  16100. name: string;
  16101. shader: string;
  16102. };
  16103. }
  16104. declare module "babylonjs/Rendering/edgesRenderer" {
  16105. import { Nullable } from "babylonjs/types";
  16106. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16108. import { Vector3 } from "babylonjs/Maths/math.vector";
  16109. import { IDisposable } from "babylonjs/scene";
  16110. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16111. import "babylonjs/Shaders/line.fragment";
  16112. import "babylonjs/Shaders/line.vertex";
  16113. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16114. module "babylonjs/Meshes/abstractMesh" {
  16115. interface AbstractMesh {
  16116. /**
  16117. * Gets the edgesRenderer associated with the mesh
  16118. */
  16119. edgesRenderer: Nullable<EdgesRenderer>;
  16120. }
  16121. }
  16122. module "babylonjs/Meshes/linesMesh" {
  16123. interface LinesMesh {
  16124. /**
  16125. * Enables the edge rendering mode on the mesh.
  16126. * This mode makes the mesh edges visible
  16127. * @param epsilon defines the maximal distance between two angles to detect a face
  16128. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16129. * @returns the currentAbstractMesh
  16130. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16131. */
  16132. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16133. }
  16134. }
  16135. module "babylonjs/Meshes/linesMesh" {
  16136. interface InstancedLinesMesh {
  16137. /**
  16138. * Enables the edge rendering mode on the mesh.
  16139. * This mode makes the mesh edges visible
  16140. * @param epsilon defines the maximal distance between two angles to detect a face
  16141. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16142. * @returns the current InstancedLinesMesh
  16143. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16144. */
  16145. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16146. }
  16147. }
  16148. /**
  16149. * Defines the minimum contract an Edges renderer should follow.
  16150. */
  16151. export interface IEdgesRenderer extends IDisposable {
  16152. /**
  16153. * Gets or sets a boolean indicating if the edgesRenderer is active
  16154. */
  16155. isEnabled: boolean;
  16156. /**
  16157. * Renders the edges of the attached mesh,
  16158. */
  16159. render(): void;
  16160. /**
  16161. * Checks wether or not the edges renderer is ready to render.
  16162. * @return true if ready, otherwise false.
  16163. */
  16164. isReady(): boolean;
  16165. }
  16166. /**
  16167. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16168. */
  16169. export class EdgesRenderer implements IEdgesRenderer {
  16170. /**
  16171. * Define the size of the edges with an orthographic camera
  16172. */
  16173. edgesWidthScalerForOrthographic: number;
  16174. /**
  16175. * Define the size of the edges with a perspective camera
  16176. */
  16177. edgesWidthScalerForPerspective: number;
  16178. protected _source: AbstractMesh;
  16179. protected _linesPositions: number[];
  16180. protected _linesNormals: number[];
  16181. protected _linesIndices: number[];
  16182. protected _epsilon: number;
  16183. protected _indicesCount: number;
  16184. protected _lineShader: ShaderMaterial;
  16185. protected _ib: DataBuffer;
  16186. protected _buffers: {
  16187. [key: string]: Nullable<VertexBuffer>;
  16188. };
  16189. protected _checkVerticesInsteadOfIndices: boolean;
  16190. private _meshRebuildObserver;
  16191. private _meshDisposeObserver;
  16192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16193. isEnabled: boolean;
  16194. /**
  16195. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16196. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16197. * @param source Mesh used to create edges
  16198. * @param epsilon sum of angles in adjacency to check for edge
  16199. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16200. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16201. */
  16202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16203. protected _prepareRessources(): void;
  16204. /** @hidden */
  16205. _rebuild(): void;
  16206. /**
  16207. * Releases the required resources for the edges renderer
  16208. */
  16209. dispose(): void;
  16210. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16211. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16212. /**
  16213. * Checks if the pair of p0 and p1 is en edge
  16214. * @param faceIndex
  16215. * @param edge
  16216. * @param faceNormals
  16217. * @param p0
  16218. * @param p1
  16219. * @private
  16220. */
  16221. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16222. /**
  16223. * push line into the position, normal and index buffer
  16224. * @protected
  16225. */
  16226. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16227. /**
  16228. * Generates lines edges from adjacencjes
  16229. * @private
  16230. */
  16231. _generateEdgesLines(): void;
  16232. /**
  16233. * Checks wether or not the edges renderer is ready to render.
  16234. * @return true if ready, otherwise false.
  16235. */
  16236. isReady(): boolean;
  16237. /**
  16238. * Renders the edges of the attached mesh,
  16239. */
  16240. render(): void;
  16241. }
  16242. /**
  16243. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16244. */
  16245. export class LineEdgesRenderer extends EdgesRenderer {
  16246. /**
  16247. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16248. * @param source LineMesh used to generate edges
  16249. * @param epsilon not important (specified angle for edge detection)
  16250. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16251. */
  16252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16253. /**
  16254. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16255. */
  16256. _generateEdgesLines(): void;
  16257. }
  16258. }
  16259. declare module "babylonjs/Rendering/renderingGroup" {
  16260. import { SmartArray } from "babylonjs/Misc/smartArray";
  16261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16263. import { Nullable } from "babylonjs/types";
  16264. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16265. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16266. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16267. import { Material } from "babylonjs/Materials/material";
  16268. import { Scene } from "babylonjs/scene";
  16269. /**
  16270. * This represents the object necessary to create a rendering group.
  16271. * This is exclusively used and created by the rendering manager.
  16272. * To modify the behavior, you use the available helpers in your scene or meshes.
  16273. * @hidden
  16274. */
  16275. export class RenderingGroup {
  16276. index: number;
  16277. private static _zeroVector;
  16278. private _scene;
  16279. private _opaqueSubMeshes;
  16280. private _transparentSubMeshes;
  16281. private _alphaTestSubMeshes;
  16282. private _depthOnlySubMeshes;
  16283. private _particleSystems;
  16284. private _spriteManagers;
  16285. private _opaqueSortCompareFn;
  16286. private _alphaTestSortCompareFn;
  16287. private _transparentSortCompareFn;
  16288. private _renderOpaque;
  16289. private _renderAlphaTest;
  16290. private _renderTransparent;
  16291. /** @hidden */
  16292. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16293. onBeforeTransparentRendering: () => void;
  16294. /**
  16295. * Set the opaque sort comparison function.
  16296. * If null the sub meshes will be render in the order they were created
  16297. */
  16298. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16299. /**
  16300. * Set the alpha test sort comparison function.
  16301. * If null the sub meshes will be render in the order they were created
  16302. */
  16303. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16304. /**
  16305. * Set the transparent sort comparison function.
  16306. * If null the sub meshes will be render in the order they were created
  16307. */
  16308. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16309. /**
  16310. * Creates a new rendering group.
  16311. * @param index The rendering group index
  16312. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16313. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16314. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16315. */
  16316. 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>);
  16317. /**
  16318. * Render all the sub meshes contained in the group.
  16319. * @param customRenderFunction Used to override the default render behaviour of the group.
  16320. * @returns true if rendered some submeshes.
  16321. */
  16322. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16323. /**
  16324. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private renderOpaqueSorted;
  16328. /**
  16329. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16330. * @param subMeshes The submeshes to render
  16331. */
  16332. private renderAlphaTestSorted;
  16333. /**
  16334. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16335. * @param subMeshes The submeshes to render
  16336. */
  16337. private renderTransparentSorted;
  16338. /**
  16339. * Renders the submeshes in a specified order.
  16340. * @param subMeshes The submeshes to sort before render
  16341. * @param sortCompareFn The comparison function use to sort
  16342. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16343. * @param transparent Specifies to activate blending if true
  16344. */
  16345. private static renderSorted;
  16346. /**
  16347. * Renders the submeshes in the order they were dispatched (no sort applied).
  16348. * @param subMeshes The submeshes to render
  16349. */
  16350. private static renderUnsorted;
  16351. /**
  16352. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16353. * are rendered back to front if in the same alpha index.
  16354. *
  16355. * @param a The first submesh
  16356. * @param b The second submesh
  16357. * @returns The result of the comparison
  16358. */
  16359. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16360. /**
  16361. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16362. * are rendered back to front.
  16363. *
  16364. * @param a The first submesh
  16365. * @param b The second submesh
  16366. * @returns The result of the comparison
  16367. */
  16368. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16369. /**
  16370. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16371. * are rendered front to back (prevent overdraw).
  16372. *
  16373. * @param a The first submesh
  16374. * @param b The second submesh
  16375. * @returns The result of the comparison
  16376. */
  16377. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16378. /**
  16379. * Resets the different lists of submeshes to prepare a new frame.
  16380. */
  16381. prepare(): void;
  16382. dispose(): void;
  16383. /**
  16384. * Inserts the submesh in its correct queue depending on its material.
  16385. * @param subMesh The submesh to dispatch
  16386. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16387. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16388. */
  16389. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16390. dispatchSprites(spriteManager: ISpriteManager): void;
  16391. dispatchParticles(particleSystem: IParticleSystem): void;
  16392. private _renderParticles;
  16393. private _renderSprites;
  16394. }
  16395. }
  16396. declare module "babylonjs/Rendering/renderingManager" {
  16397. import { Nullable } from "babylonjs/types";
  16398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16400. import { SmartArray } from "babylonjs/Misc/smartArray";
  16401. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16403. import { Material } from "babylonjs/Materials/material";
  16404. import { Scene } from "babylonjs/scene";
  16405. import { Camera } from "babylonjs/Cameras/camera";
  16406. /**
  16407. * Interface describing the different options available in the rendering manager
  16408. * regarding Auto Clear between groups.
  16409. */
  16410. export interface IRenderingManagerAutoClearSetup {
  16411. /**
  16412. * Defines whether or not autoclear is enable.
  16413. */
  16414. autoClear: boolean;
  16415. /**
  16416. * Defines whether or not to autoclear the depth buffer.
  16417. */
  16418. depth: boolean;
  16419. /**
  16420. * Defines whether or not to autoclear the stencil buffer.
  16421. */
  16422. stencil: boolean;
  16423. }
  16424. /**
  16425. * This class is used by the onRenderingGroupObservable
  16426. */
  16427. export class RenderingGroupInfo {
  16428. /**
  16429. * The Scene that being rendered
  16430. */
  16431. scene: Scene;
  16432. /**
  16433. * The camera currently used for the rendering pass
  16434. */
  16435. camera: Nullable<Camera>;
  16436. /**
  16437. * The ID of the renderingGroup being processed
  16438. */
  16439. renderingGroupId: number;
  16440. }
  16441. /**
  16442. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16443. * It is enable to manage the different groups as well as the different necessary sort functions.
  16444. * This should not be used directly aside of the few static configurations
  16445. */
  16446. export class RenderingManager {
  16447. /**
  16448. * The max id used for rendering groups (not included)
  16449. */
  16450. static MAX_RENDERINGGROUPS: number;
  16451. /**
  16452. * The min id used for rendering groups (included)
  16453. */
  16454. static MIN_RENDERINGGROUPS: number;
  16455. /**
  16456. * Used to globally prevent autoclearing scenes.
  16457. */
  16458. static AUTOCLEAR: boolean;
  16459. /**
  16460. * @hidden
  16461. */
  16462. _useSceneAutoClearSetup: boolean;
  16463. private _scene;
  16464. private _renderingGroups;
  16465. private _depthStencilBufferAlreadyCleaned;
  16466. private _autoClearDepthStencil;
  16467. private _customOpaqueSortCompareFn;
  16468. private _customAlphaTestSortCompareFn;
  16469. private _customTransparentSortCompareFn;
  16470. private _renderingGroupInfo;
  16471. /**
  16472. * Instantiates a new rendering group for a particular scene
  16473. * @param scene Defines the scene the groups belongs to
  16474. */
  16475. constructor(scene: Scene);
  16476. private _clearDepthStencilBuffer;
  16477. /**
  16478. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16479. * @hidden
  16480. */
  16481. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16482. /**
  16483. * Resets the different information of the group to prepare a new frame
  16484. * @hidden
  16485. */
  16486. reset(): void;
  16487. /**
  16488. * Dispose and release the group and its associated resources.
  16489. * @hidden
  16490. */
  16491. dispose(): void;
  16492. /**
  16493. * Clear the info related to rendering groups preventing retention points during dispose.
  16494. */
  16495. freeRenderingGroups(): void;
  16496. private _prepareRenderingGroup;
  16497. /**
  16498. * Add a sprite manager to the rendering manager in order to render it this frame.
  16499. * @param spriteManager Define the sprite manager to render
  16500. */
  16501. dispatchSprites(spriteManager: ISpriteManager): void;
  16502. /**
  16503. * Add a particle system to the rendering manager in order to render it this frame.
  16504. * @param particleSystem Define the particle system to render
  16505. */
  16506. dispatchParticles(particleSystem: IParticleSystem): void;
  16507. /**
  16508. * Add a submesh to the manager in order to render it this frame
  16509. * @param subMesh The submesh to dispatch
  16510. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16511. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16512. */
  16513. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16514. /**
  16515. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16516. * This allowed control for front to back rendering or reversly depending of the special needs.
  16517. *
  16518. * @param renderingGroupId The rendering group id corresponding to its index
  16519. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16520. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16521. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16522. */
  16523. 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;
  16524. /**
  16525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16526. *
  16527. * @param renderingGroupId The rendering group id corresponding to its index
  16528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16529. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16530. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16531. */
  16532. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16533. /**
  16534. * Gets the current auto clear configuration for one rendering group of the rendering
  16535. * manager.
  16536. * @param index the rendering group index to get the information for
  16537. * @returns The auto clear setup for the requested rendering group
  16538. */
  16539. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16540. }
  16541. }
  16542. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16543. import { SmartArray } from "babylonjs/Misc/smartArray";
  16544. import { Nullable } from "babylonjs/types";
  16545. import { Scene } from "babylonjs/scene";
  16546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16549. import { Mesh } from "babylonjs/Meshes/mesh";
  16550. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16551. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16552. import { Effect } from "babylonjs/Materials/effect";
  16553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16555. import "babylonjs/Shaders/shadowMap.fragment";
  16556. import "babylonjs/Shaders/shadowMap.vertex";
  16557. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16558. import { Observable } from "babylonjs/Misc/observable";
  16559. /**
  16560. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16561. */
  16562. export interface ICustomShaderOptions {
  16563. /**
  16564. * Gets or sets the custom shader name to use
  16565. */
  16566. shaderName: string;
  16567. /**
  16568. * The list of attribute names used in the shader
  16569. */
  16570. attributes?: string[];
  16571. /**
  16572. * The list of unifrom names used in the shader
  16573. */
  16574. uniforms?: string[];
  16575. /**
  16576. * The list of sampler names used in the shader
  16577. */
  16578. samplers?: string[];
  16579. /**
  16580. * The list of defines used in the shader
  16581. */
  16582. defines?: string[];
  16583. }
  16584. /**
  16585. * Interface to implement to create a shadow generator compatible with BJS.
  16586. */
  16587. export interface IShadowGenerator {
  16588. /**
  16589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16590. * @returns The render target texture if present otherwise, null
  16591. */
  16592. getShadowMap(): Nullable<RenderTargetTexture>;
  16593. /**
  16594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16595. * @param subMesh The submesh we want to render in the shadow map
  16596. * @param useInstances Defines wether will draw in the map using instances
  16597. * @returns true if ready otherwise, false
  16598. */
  16599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16600. /**
  16601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16602. * @param defines Defines of the material we want to update
  16603. * @param lightIndex Index of the light in the enabled light list of the material
  16604. */
  16605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16606. /**
  16607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16608. * defined in the generator but impacting the effect).
  16609. * It implies the unifroms available on the materials are the standard BJS ones.
  16610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16611. * @param effect The effect we are binfing the information for
  16612. */
  16613. bindShadowLight(lightIndex: string, effect: Effect): void;
  16614. /**
  16615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16616. * (eq to shadow prjection matrix * light transform matrix)
  16617. * @returns The transform matrix used to create the shadow map
  16618. */
  16619. getTransformMatrix(): Matrix;
  16620. /**
  16621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16622. * Cube and 2D textures for instance.
  16623. */
  16624. recreateShadowMap(): void;
  16625. /**
  16626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16627. * @param onCompiled Callback triggered at the and of the effects compilation
  16628. * @param options Sets of optional options forcing the compilation with different modes
  16629. */
  16630. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16631. useInstances: boolean;
  16632. }>): void;
  16633. /**
  16634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16635. * @param options Sets of optional options forcing the compilation with different modes
  16636. * @returns A promise that resolves when the compilation completes
  16637. */
  16638. forceCompilationAsync(options?: Partial<{
  16639. useInstances: boolean;
  16640. }>): Promise<void>;
  16641. /**
  16642. * Serializes the shadow generator setup to a json object.
  16643. * @returns The serialized JSON object
  16644. */
  16645. serialize(): any;
  16646. /**
  16647. * Disposes the Shadow map and related Textures and effects.
  16648. */
  16649. dispose(): void;
  16650. }
  16651. /**
  16652. * Default implementation IShadowGenerator.
  16653. * This is the main object responsible of generating shadows in the framework.
  16654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16655. */
  16656. export class ShadowGenerator implements IShadowGenerator {
  16657. /**
  16658. * Name of the shadow generator class
  16659. */
  16660. static CLASSNAME: string;
  16661. /**
  16662. * Shadow generator mode None: no filtering applied.
  16663. */
  16664. static readonly FILTER_NONE: number;
  16665. /**
  16666. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16667. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16668. */
  16669. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16670. /**
  16671. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16672. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16673. */
  16674. static readonly FILTER_POISSONSAMPLING: number;
  16675. /**
  16676. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16677. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16678. */
  16679. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16680. /**
  16681. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16682. * edge artifacts on steep falloff.
  16683. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16684. */
  16685. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16686. /**
  16687. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16688. * edge artifacts on steep falloff.
  16689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16690. */
  16691. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16692. /**
  16693. * Shadow generator mode PCF: Percentage Closer Filtering
  16694. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16695. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16696. */
  16697. static readonly FILTER_PCF: number;
  16698. /**
  16699. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16700. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16701. * Contact Hardening
  16702. */
  16703. static readonly FILTER_PCSS: number;
  16704. /**
  16705. * Reserved for PCF and PCSS
  16706. * Highest Quality.
  16707. *
  16708. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16709. *
  16710. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16711. */
  16712. static readonly QUALITY_HIGH: number;
  16713. /**
  16714. * Reserved for PCF and PCSS
  16715. * Good tradeoff for quality/perf cross devices
  16716. *
  16717. * Execute PCF on a 3*3 kernel.
  16718. *
  16719. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16720. */
  16721. static readonly QUALITY_MEDIUM: number;
  16722. /**
  16723. * Reserved for PCF and PCSS
  16724. * The lowest quality but the fastest.
  16725. *
  16726. * Execute PCF on a 1*1 kernel.
  16727. *
  16728. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16729. */
  16730. static readonly QUALITY_LOW: number;
  16731. /** Gets or sets the custom shader name to use */
  16732. customShaderOptions: ICustomShaderOptions;
  16733. /**
  16734. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16735. */
  16736. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16737. /**
  16738. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16739. */
  16740. onAfterShadowMapRenderObservable: Observable<Effect>;
  16741. /**
  16742. * Observable triggered before a mesh is rendered in the shadow map.
  16743. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16744. */
  16745. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16746. /**
  16747. * Observable triggered after a mesh is rendered in the shadow map.
  16748. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16749. */
  16750. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16751. protected _bias: number;
  16752. /**
  16753. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16754. */
  16755. get bias(): number;
  16756. /**
  16757. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16758. */
  16759. set bias(bias: number);
  16760. protected _normalBias: number;
  16761. /**
  16762. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16763. */
  16764. get normalBias(): number;
  16765. /**
  16766. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16767. */
  16768. set normalBias(normalBias: number);
  16769. protected _blurBoxOffset: number;
  16770. /**
  16771. * Gets the blur box offset: offset applied during the blur pass.
  16772. * Only useful if useKernelBlur = false
  16773. */
  16774. get blurBoxOffset(): number;
  16775. /**
  16776. * Sets the blur box offset: offset applied during the blur pass.
  16777. * Only useful if useKernelBlur = false
  16778. */
  16779. set blurBoxOffset(value: number);
  16780. protected _blurScale: number;
  16781. /**
  16782. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16783. * 2 means half of the size.
  16784. */
  16785. get blurScale(): number;
  16786. /**
  16787. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16788. * 2 means half of the size.
  16789. */
  16790. set blurScale(value: number);
  16791. protected _blurKernel: number;
  16792. /**
  16793. * Gets the blur kernel: kernel size of the blur pass.
  16794. * Only useful if useKernelBlur = true
  16795. */
  16796. get blurKernel(): number;
  16797. /**
  16798. * Sets the blur kernel: kernel size of the blur pass.
  16799. * Only useful if useKernelBlur = true
  16800. */
  16801. set blurKernel(value: number);
  16802. protected _useKernelBlur: boolean;
  16803. /**
  16804. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16805. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16806. */
  16807. get useKernelBlur(): boolean;
  16808. /**
  16809. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16810. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16811. */
  16812. set useKernelBlur(value: boolean);
  16813. protected _depthScale: number;
  16814. /**
  16815. * Gets the depth scale used in ESM mode.
  16816. */
  16817. get depthScale(): number;
  16818. /**
  16819. * Sets the depth scale used in ESM mode.
  16820. * This can override the scale stored on the light.
  16821. */
  16822. set depthScale(value: number);
  16823. protected _validateFilter(filter: number): number;
  16824. protected _filter: number;
  16825. /**
  16826. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16827. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16828. */
  16829. get filter(): number;
  16830. /**
  16831. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16832. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16833. */
  16834. set filter(value: number);
  16835. /**
  16836. * Gets if the current filter is set to Poisson Sampling.
  16837. */
  16838. get usePoissonSampling(): boolean;
  16839. /**
  16840. * Sets the current filter to Poisson Sampling.
  16841. */
  16842. set usePoissonSampling(value: boolean);
  16843. /**
  16844. * Gets if the current filter is set to ESM.
  16845. */
  16846. get useExponentialShadowMap(): boolean;
  16847. /**
  16848. * Sets the current filter is to ESM.
  16849. */
  16850. set useExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to filtered ESM.
  16853. */
  16854. get useBlurExponentialShadowMap(): boolean;
  16855. /**
  16856. * Gets if the current filter is set to filtered ESM.
  16857. */
  16858. set useBlurExponentialShadowMap(value: boolean);
  16859. /**
  16860. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16861. * exponential to prevent steep falloff artifacts).
  16862. */
  16863. get useCloseExponentialShadowMap(): boolean;
  16864. /**
  16865. * Sets the current filter to "close ESM" (using the inverse of the
  16866. * exponential to prevent steep falloff artifacts).
  16867. */
  16868. set useCloseExponentialShadowMap(value: boolean);
  16869. /**
  16870. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16871. * exponential to prevent steep falloff artifacts).
  16872. */
  16873. get useBlurCloseExponentialShadowMap(): boolean;
  16874. /**
  16875. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16876. * exponential to prevent steep falloff artifacts).
  16877. */
  16878. set useBlurCloseExponentialShadowMap(value: boolean);
  16879. /**
  16880. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16881. */
  16882. get usePercentageCloserFiltering(): boolean;
  16883. /**
  16884. * Sets the current filter to "PCF" (percentage closer filtering).
  16885. */
  16886. set usePercentageCloserFiltering(value: boolean);
  16887. protected _filteringQuality: number;
  16888. /**
  16889. * Gets the PCF or PCSS Quality.
  16890. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16891. */
  16892. get filteringQuality(): number;
  16893. /**
  16894. * Sets the PCF or PCSS Quality.
  16895. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16896. */
  16897. set filteringQuality(filteringQuality: number);
  16898. /**
  16899. * Gets if the current filter is set to "PCSS" (contact hardening).
  16900. */
  16901. get useContactHardeningShadow(): boolean;
  16902. /**
  16903. * Sets the current filter to "PCSS" (contact hardening).
  16904. */
  16905. set useContactHardeningShadow(value: boolean);
  16906. protected _contactHardeningLightSizeUVRatio: number;
  16907. /**
  16908. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16909. * Using a ratio helps keeping shape stability independently of the map size.
  16910. *
  16911. * It does not account for the light projection as it was having too much
  16912. * instability during the light setup or during light position changes.
  16913. *
  16914. * Only valid if useContactHardeningShadow is true.
  16915. */
  16916. get contactHardeningLightSizeUVRatio(): number;
  16917. /**
  16918. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16919. * Using a ratio helps keeping shape stability independently of the map size.
  16920. *
  16921. * It does not account for the light projection as it was having too much
  16922. * instability during the light setup or during light position changes.
  16923. *
  16924. * Only valid if useContactHardeningShadow is true.
  16925. */
  16926. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16927. protected _darkness: number;
  16928. /** Gets or sets the actual darkness of a shadow */
  16929. get darkness(): number;
  16930. set darkness(value: number);
  16931. /**
  16932. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16933. * 0 means strongest and 1 would means no shadow.
  16934. * @returns the darkness.
  16935. */
  16936. getDarkness(): number;
  16937. /**
  16938. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16939. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16940. * @returns the shadow generator allowing fluent coding.
  16941. */
  16942. setDarkness(darkness: number): ShadowGenerator;
  16943. protected _transparencyShadow: boolean;
  16944. /** Gets or sets the ability to have transparent shadow */
  16945. get transparencyShadow(): boolean;
  16946. set transparencyShadow(value: boolean);
  16947. /**
  16948. * Sets the ability to have transparent shadow (boolean).
  16949. * @param transparent True if transparent else False
  16950. * @returns the shadow generator allowing fluent coding
  16951. */
  16952. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16953. protected _shadowMap: Nullable<RenderTargetTexture>;
  16954. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16955. /**
  16956. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16957. * @returns The render target texture if present otherwise, null
  16958. */
  16959. getShadowMap(): Nullable<RenderTargetTexture>;
  16960. /**
  16961. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16962. * @returns The render target texture if the shadow map is present otherwise, null
  16963. */
  16964. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16965. /**
  16966. * Gets the class name of that object
  16967. * @returns "ShadowGenerator"
  16968. */
  16969. getClassName(): string;
  16970. /**
  16971. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16972. * @param mesh Mesh to add
  16973. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16974. * @returns the Shadow Generator itself
  16975. */
  16976. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16977. /**
  16978. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16979. * @param mesh Mesh to remove
  16980. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16981. * @returns the Shadow Generator itself
  16982. */
  16983. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16984. /**
  16985. * Controls the extent to which the shadows fade out at the edge of the frustum
  16986. */
  16987. frustumEdgeFalloff: number;
  16988. protected _light: IShadowLight;
  16989. /**
  16990. * Returns the associated light object.
  16991. * @returns the light generating the shadow
  16992. */
  16993. getLight(): IShadowLight;
  16994. /**
  16995. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16996. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16997. * It might on the other hand introduce peter panning.
  16998. */
  16999. forceBackFacesOnly: boolean;
  17000. protected _scene: Scene;
  17001. protected _lightDirection: Vector3;
  17002. protected _effect: Effect;
  17003. protected _viewMatrix: Matrix;
  17004. protected _projectionMatrix: Matrix;
  17005. protected _transformMatrix: Matrix;
  17006. protected _cachedPosition: Vector3;
  17007. protected _cachedDirection: Vector3;
  17008. protected _cachedDefines: string;
  17009. protected _currentRenderID: number;
  17010. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17011. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17012. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17013. protected _blurPostProcesses: PostProcess[];
  17014. protected _mapSize: number;
  17015. protected _currentFaceIndex: number;
  17016. protected _currentFaceIndexCache: number;
  17017. protected _textureType: number;
  17018. protected _defaultTextureMatrix: Matrix;
  17019. protected _storedUniqueId: Nullable<number>;
  17020. /** @hidden */
  17021. static _SceneComponentInitialization: (scene: Scene) => void;
  17022. /**
  17023. * Creates a ShadowGenerator object.
  17024. * A ShadowGenerator is the required tool to use the shadows.
  17025. * Each light casting shadows needs to use its own ShadowGenerator.
  17026. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17027. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17028. * @param light The light object generating the shadows.
  17029. * @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.
  17030. */
  17031. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17032. protected _initializeGenerator(): void;
  17033. protected _createTargetRenderTexture(): void;
  17034. protected _initializeShadowMap(): void;
  17035. protected _initializeBlurRTTAndPostProcesses(): void;
  17036. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17037. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17038. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17039. protected _applyFilterValues(): void;
  17040. /**
  17041. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17042. * @param onCompiled Callback triggered at the and of the effects compilation
  17043. * @param options Sets of optional options forcing the compilation with different modes
  17044. */
  17045. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17046. useInstances: boolean;
  17047. }>): void;
  17048. /**
  17049. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17050. * @param options Sets of optional options forcing the compilation with different modes
  17051. * @returns A promise that resolves when the compilation completes
  17052. */
  17053. forceCompilationAsync(options?: Partial<{
  17054. useInstances: boolean;
  17055. }>): Promise<void>;
  17056. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17057. /**
  17058. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17059. * @param subMesh The submesh we want to render in the shadow map
  17060. * @param useInstances Defines wether will draw in the map using instances
  17061. * @returns true if ready otherwise, false
  17062. */
  17063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17064. /**
  17065. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17066. * @param defines Defines of the material we want to update
  17067. * @param lightIndex Index of the light in the enabled light list of the material
  17068. */
  17069. prepareDefines(defines: any, lightIndex: number): void;
  17070. /**
  17071. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17072. * defined in the generator but impacting the effect).
  17073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17074. * @param effect The effect we are binfing the information for
  17075. */
  17076. bindShadowLight(lightIndex: string, effect: Effect): void;
  17077. /**
  17078. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17079. * (eq to shadow prjection matrix * light transform matrix)
  17080. * @returns The transform matrix used to create the shadow map
  17081. */
  17082. getTransformMatrix(): Matrix;
  17083. /**
  17084. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17085. * Cube and 2D textures for instance.
  17086. */
  17087. recreateShadowMap(): void;
  17088. protected _disposeBlurPostProcesses(): void;
  17089. protected _disposeRTTandPostProcesses(): void;
  17090. /**
  17091. * Disposes the ShadowGenerator.
  17092. * Returns nothing.
  17093. */
  17094. dispose(): void;
  17095. /**
  17096. * Serializes the shadow generator setup to a json object.
  17097. * @returns The serialized JSON object
  17098. */
  17099. serialize(): any;
  17100. /**
  17101. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17102. * @param parsedShadowGenerator The JSON object to parse
  17103. * @param scene The scene to create the shadow map for
  17104. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17105. * @returns The parsed shadow generator
  17106. */
  17107. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17108. }
  17109. }
  17110. declare module "babylonjs/Lights/light" {
  17111. import { Nullable } from "babylonjs/types";
  17112. import { Scene } from "babylonjs/scene";
  17113. import { Vector3 } from "babylonjs/Maths/math.vector";
  17114. import { Color3 } from "babylonjs/Maths/math.color";
  17115. import { Node } from "babylonjs/node";
  17116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17119. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17120. /**
  17121. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17122. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17123. * 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.
  17124. */
  17125. export abstract class Light extends Node {
  17126. /**
  17127. * Falloff Default: light is falling off following the material specification:
  17128. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17129. */
  17130. static readonly FALLOFF_DEFAULT: number;
  17131. /**
  17132. * Falloff Physical: light is falling off following the inverse squared distance law.
  17133. */
  17134. static readonly FALLOFF_PHYSICAL: number;
  17135. /**
  17136. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17137. * to enhance interoperability with other engines.
  17138. */
  17139. static readonly FALLOFF_GLTF: number;
  17140. /**
  17141. * Falloff Standard: light is falling off like in the standard material
  17142. * to enhance interoperability with other materials.
  17143. */
  17144. static readonly FALLOFF_STANDARD: number;
  17145. /**
  17146. * If every light affecting the material is in this lightmapMode,
  17147. * material.lightmapTexture adds or multiplies
  17148. * (depends on material.useLightmapAsShadowmap)
  17149. * after every other light calculations.
  17150. */
  17151. static readonly LIGHTMAP_DEFAULT: number;
  17152. /**
  17153. * material.lightmapTexture as only diffuse lighting from this light
  17154. * adds only specular lighting from this light
  17155. * adds dynamic shadows
  17156. */
  17157. static readonly LIGHTMAP_SPECULAR: number;
  17158. /**
  17159. * material.lightmapTexture as only lighting
  17160. * no light calculation from this light
  17161. * only adds dynamic shadows from this light
  17162. */
  17163. static readonly LIGHTMAP_SHADOWSONLY: number;
  17164. /**
  17165. * Each light type uses the default quantity according to its type:
  17166. * point/spot lights use luminous intensity
  17167. * directional lights use illuminance
  17168. */
  17169. static readonly INTENSITYMODE_AUTOMATIC: number;
  17170. /**
  17171. * lumen (lm)
  17172. */
  17173. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17174. /**
  17175. * candela (lm/sr)
  17176. */
  17177. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17178. /**
  17179. * lux (lm/m^2)
  17180. */
  17181. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17182. /**
  17183. * nit (cd/m^2)
  17184. */
  17185. static readonly INTENSITYMODE_LUMINANCE: number;
  17186. /**
  17187. * Light type const id of the point light.
  17188. */
  17189. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17190. /**
  17191. * Light type const id of the directional light.
  17192. */
  17193. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17194. /**
  17195. * Light type const id of the spot light.
  17196. */
  17197. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17198. /**
  17199. * Light type const id of the hemispheric light.
  17200. */
  17201. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17202. /**
  17203. * Diffuse gives the basic color to an object.
  17204. */
  17205. diffuse: Color3;
  17206. /**
  17207. * Specular produces a highlight color on an object.
  17208. * Note: This is note affecting PBR materials.
  17209. */
  17210. specular: Color3;
  17211. /**
  17212. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17213. * falling off base on range or angle.
  17214. * This can be set to any values in Light.FALLOFF_x.
  17215. *
  17216. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17217. * other types of materials.
  17218. */
  17219. falloffType: number;
  17220. /**
  17221. * Strength of the light.
  17222. * Note: By default it is define in the framework own unit.
  17223. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17224. */
  17225. intensity: number;
  17226. private _range;
  17227. protected _inverseSquaredRange: number;
  17228. /**
  17229. * Defines how far from the source the light is impacting in scene units.
  17230. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17231. */
  17232. get range(): number;
  17233. /**
  17234. * Defines how far from the source the light is impacting in scene units.
  17235. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17236. */
  17237. set range(value: number);
  17238. /**
  17239. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17240. * of light.
  17241. */
  17242. private _photometricScale;
  17243. private _intensityMode;
  17244. /**
  17245. * Gets the photometric scale used to interpret the intensity.
  17246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17247. */
  17248. get intensityMode(): number;
  17249. /**
  17250. * Sets the photometric scale used to interpret the intensity.
  17251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17252. */
  17253. set intensityMode(value: number);
  17254. private _radius;
  17255. /**
  17256. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17257. */
  17258. get radius(): number;
  17259. /**
  17260. * sets the light radius used by PBR Materials to simulate soft area lights.
  17261. */
  17262. set radius(value: number);
  17263. private _renderPriority;
  17264. /**
  17265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17266. * exceeding the number allowed of the materials.
  17267. */
  17268. renderPriority: number;
  17269. private _shadowEnabled;
  17270. /**
  17271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17272. * the current shadow generator.
  17273. */
  17274. get shadowEnabled(): boolean;
  17275. /**
  17276. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17277. * the current shadow generator.
  17278. */
  17279. set shadowEnabled(value: boolean);
  17280. private _includedOnlyMeshes;
  17281. /**
  17282. * Gets the only meshes impacted by this light.
  17283. */
  17284. get includedOnlyMeshes(): AbstractMesh[];
  17285. /**
  17286. * Sets the only meshes impacted by this light.
  17287. */
  17288. set includedOnlyMeshes(value: AbstractMesh[]);
  17289. private _excludedMeshes;
  17290. /**
  17291. * Gets the meshes not impacted by this light.
  17292. */
  17293. get excludedMeshes(): AbstractMesh[];
  17294. /**
  17295. * Sets the meshes not impacted by this light.
  17296. */
  17297. set excludedMeshes(value: AbstractMesh[]);
  17298. private _excludeWithLayerMask;
  17299. /**
  17300. * Gets the layer id use to find what meshes are not impacted by the light.
  17301. * Inactive if 0
  17302. */
  17303. get excludeWithLayerMask(): number;
  17304. /**
  17305. * Sets the layer id use to find what meshes are not impacted by the light.
  17306. * Inactive if 0
  17307. */
  17308. set excludeWithLayerMask(value: number);
  17309. private _includeOnlyWithLayerMask;
  17310. /**
  17311. * Gets the layer id use to find what meshes are impacted by the light.
  17312. * Inactive if 0
  17313. */
  17314. get includeOnlyWithLayerMask(): number;
  17315. /**
  17316. * Sets the layer id use to find what meshes are impacted by the light.
  17317. * Inactive if 0
  17318. */
  17319. set includeOnlyWithLayerMask(value: number);
  17320. private _lightmapMode;
  17321. /**
  17322. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17323. */
  17324. get lightmapMode(): number;
  17325. /**
  17326. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17327. */
  17328. set lightmapMode(value: number);
  17329. /**
  17330. * Shadow generator associted to the light.
  17331. * @hidden Internal use only.
  17332. */
  17333. _shadowGenerator: Nullable<IShadowGenerator>;
  17334. /**
  17335. * @hidden Internal use only.
  17336. */
  17337. _excludedMeshesIds: string[];
  17338. /**
  17339. * @hidden Internal use only.
  17340. */
  17341. _includedOnlyMeshesIds: string[];
  17342. /**
  17343. * The current light unifom buffer.
  17344. * @hidden Internal use only.
  17345. */
  17346. _uniformBuffer: UniformBuffer;
  17347. /** @hidden */
  17348. _renderId: number;
  17349. /**
  17350. * Creates a Light object in the scene.
  17351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17352. * @param name The firendly name of the light
  17353. * @param scene The scene the light belongs too
  17354. */
  17355. constructor(name: string, scene: Scene);
  17356. protected abstract _buildUniformLayout(): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightIndex The index of the light in the effect to update
  17361. * @returns The light
  17362. */
  17363. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17364. /**
  17365. * Sets the passed Effect "effect" with the Light textures.
  17366. * @param effect The effect to update
  17367. * @param lightIndex The index of the light in the effect to update
  17368. * @returns The light
  17369. */
  17370. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17371. /**
  17372. * Binds the lights information from the scene to the effect for the given mesh.
  17373. * @param lightIndex Light index
  17374. * @param scene The scene where the light belongs to
  17375. * @param effect The effect we are binding the data to
  17376. * @param useSpecular Defines if specular is supported
  17377. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17378. */
  17379. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17380. /**
  17381. * Sets the passed Effect "effect" with the Light information.
  17382. * @param effect The effect to update
  17383. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17384. * @returns The light
  17385. */
  17386. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17387. /**
  17388. * Returns the string "Light".
  17389. * @returns the class name
  17390. */
  17391. getClassName(): string;
  17392. /** @hidden */
  17393. readonly _isLight: boolean;
  17394. /**
  17395. * Converts the light information to a readable string for debug purpose.
  17396. * @param fullDetails Supports for multiple levels of logging within scene loading
  17397. * @returns the human readable light info
  17398. */
  17399. toString(fullDetails?: boolean): string;
  17400. /** @hidden */
  17401. protected _syncParentEnabledState(): void;
  17402. /**
  17403. * Set the enabled state of this node.
  17404. * @param value - the new enabled state
  17405. */
  17406. setEnabled(value: boolean): void;
  17407. /**
  17408. * Returns the Light associated shadow generator if any.
  17409. * @return the associated shadow generator.
  17410. */
  17411. getShadowGenerator(): Nullable<IShadowGenerator>;
  17412. /**
  17413. * Returns a Vector3, the absolute light position in the World.
  17414. * @returns the world space position of the light
  17415. */
  17416. getAbsolutePosition(): Vector3;
  17417. /**
  17418. * Specifies if the light will affect the passed mesh.
  17419. * @param mesh The mesh to test against the light
  17420. * @return true the mesh is affected otherwise, false.
  17421. */
  17422. canAffectMesh(mesh: AbstractMesh): boolean;
  17423. /**
  17424. * Sort function to order lights for rendering.
  17425. * @param a First Light object to compare to second.
  17426. * @param b Second Light object to compare first.
  17427. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17428. */
  17429. static CompareLightsPriority(a: Light, b: Light): number;
  17430. /**
  17431. * Releases resources associated with this node.
  17432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17434. */
  17435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17436. /**
  17437. * Returns the light type ID (integer).
  17438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17439. */
  17440. getTypeID(): number;
  17441. /**
  17442. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17443. * @returns the scaled intensity in intensity mode unit
  17444. */
  17445. getScaledIntensity(): number;
  17446. /**
  17447. * Returns a new Light object, named "name", from the current one.
  17448. * @param name The name of the cloned light
  17449. * @returns the new created light
  17450. */
  17451. clone(name: string): Nullable<Light>;
  17452. /**
  17453. * Serializes the current light into a Serialization object.
  17454. * @returns the serialized object.
  17455. */
  17456. serialize(): any;
  17457. /**
  17458. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17459. * This new light is named "name" and added to the passed scene.
  17460. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17461. * @param name The friendly name of the light
  17462. * @param scene The scene the new light will belong to
  17463. * @returns the constructor function
  17464. */
  17465. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17466. /**
  17467. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17468. * @param parsedLight The JSON representation of the light
  17469. * @param scene The scene to create the parsed light in
  17470. * @returns the created light after parsing
  17471. */
  17472. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17473. private _hookArrayForExcluded;
  17474. private _hookArrayForIncludedOnly;
  17475. private _resyncMeshes;
  17476. /**
  17477. * Forces the meshes to update their light related information in their rendering used effects
  17478. * @hidden Internal Use Only
  17479. */
  17480. _markMeshesAsLightDirty(): void;
  17481. /**
  17482. * Recomputes the cached photometric scale if needed.
  17483. */
  17484. private _computePhotometricScale;
  17485. /**
  17486. * Returns the Photometric Scale according to the light type and intensity mode.
  17487. */
  17488. private _getPhotometricScale;
  17489. /**
  17490. * Reorder the light in the scene according to their defined priority.
  17491. * @hidden Internal Use Only
  17492. */
  17493. _reorderLightsInScene(): void;
  17494. /**
  17495. * Prepares the list of defines specific to the light type.
  17496. * @param defines the list of defines
  17497. * @param lightIndex defines the index of the light for the effect
  17498. */
  17499. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17500. }
  17501. }
  17502. declare module "babylonjs/Actions/action" {
  17503. import { Observable } from "babylonjs/Misc/observable";
  17504. import { Condition } from "babylonjs/Actions/condition";
  17505. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17506. import { ActionManager } from "babylonjs/Actions/actionManager";
  17507. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17508. /**
  17509. * Interface used to define Action
  17510. */
  17511. export interface IAction {
  17512. /**
  17513. * Trigger for the action
  17514. */
  17515. trigger: number;
  17516. /** Options of the trigger */
  17517. triggerOptions: any;
  17518. /**
  17519. * Gets the trigger parameters
  17520. * @returns the trigger parameters
  17521. */
  17522. getTriggerParameter(): any;
  17523. /**
  17524. * Internal only - executes current action event
  17525. * @hidden
  17526. */
  17527. _executeCurrent(evt?: ActionEvent): void;
  17528. /**
  17529. * Serialize placeholder for child classes
  17530. * @param parent of child
  17531. * @returns the serialized object
  17532. */
  17533. serialize(parent: any): any;
  17534. /**
  17535. * Internal only
  17536. * @hidden
  17537. */
  17538. _prepare(): void;
  17539. /**
  17540. * Internal only - manager for action
  17541. * @hidden
  17542. */
  17543. _actionManager: AbstractActionManager;
  17544. /**
  17545. * Adds action to chain of actions, may be a DoNothingAction
  17546. * @param action defines the next action to execute
  17547. * @returns The action passed in
  17548. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17549. */
  17550. then(action: IAction): IAction;
  17551. }
  17552. /**
  17553. * The action to be carried out following a trigger
  17554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17555. */
  17556. export class Action implements IAction {
  17557. /** the trigger, with or without parameters, for the action */
  17558. triggerOptions: any;
  17559. /**
  17560. * Trigger for the action
  17561. */
  17562. trigger: number;
  17563. /**
  17564. * Internal only - manager for action
  17565. * @hidden
  17566. */
  17567. _actionManager: ActionManager;
  17568. private _nextActiveAction;
  17569. private _child;
  17570. private _condition?;
  17571. private _triggerParameter;
  17572. /**
  17573. * An event triggered prior to action being executed.
  17574. */
  17575. onBeforeExecuteObservable: Observable<Action>;
  17576. /**
  17577. * Creates a new Action
  17578. * @param triggerOptions the trigger, with or without parameters, for the action
  17579. * @param condition an optional determinant of action
  17580. */
  17581. constructor(
  17582. /** the trigger, with or without parameters, for the action */
  17583. triggerOptions: any, condition?: Condition);
  17584. /**
  17585. * Internal only
  17586. * @hidden
  17587. */
  17588. _prepare(): void;
  17589. /**
  17590. * Gets the trigger parameters
  17591. * @returns the trigger parameters
  17592. */
  17593. getTriggerParameter(): any;
  17594. /**
  17595. * Internal only - executes current action event
  17596. * @hidden
  17597. */
  17598. _executeCurrent(evt?: ActionEvent): void;
  17599. /**
  17600. * Execute placeholder for child classes
  17601. * @param evt optional action event
  17602. */
  17603. execute(evt?: ActionEvent): void;
  17604. /**
  17605. * Skips to next active action
  17606. */
  17607. skipToNextActiveAction(): void;
  17608. /**
  17609. * Adds action to chain of actions, may be a DoNothingAction
  17610. * @param action defines the next action to execute
  17611. * @returns The action passed in
  17612. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17613. */
  17614. then(action: Action): Action;
  17615. /**
  17616. * Internal only
  17617. * @hidden
  17618. */
  17619. _getProperty(propertyPath: string): string;
  17620. /**
  17621. * Internal only
  17622. * @hidden
  17623. */
  17624. _getEffectiveTarget(target: any, propertyPath: string): any;
  17625. /**
  17626. * Serialize placeholder for child classes
  17627. * @param parent of child
  17628. * @returns the serialized object
  17629. */
  17630. serialize(parent: any): any;
  17631. /**
  17632. * Internal only called by serialize
  17633. * @hidden
  17634. */
  17635. protected _serialize(serializedAction: any, parent?: any): any;
  17636. /**
  17637. * Internal only
  17638. * @hidden
  17639. */
  17640. static _SerializeValueAsString: (value: any) => string;
  17641. /**
  17642. * Internal only
  17643. * @hidden
  17644. */
  17645. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17646. name: string;
  17647. targetType: string;
  17648. value: string;
  17649. };
  17650. }
  17651. }
  17652. declare module "babylonjs/Actions/condition" {
  17653. import { ActionManager } from "babylonjs/Actions/actionManager";
  17654. /**
  17655. * A Condition applied to an Action
  17656. */
  17657. export class Condition {
  17658. /**
  17659. * Internal only - manager for action
  17660. * @hidden
  17661. */
  17662. _actionManager: ActionManager;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _evaluationId: number;
  17668. /**
  17669. * Internal only
  17670. * @hidden
  17671. */
  17672. _currentResult: boolean;
  17673. /**
  17674. * Creates a new Condition
  17675. * @param actionManager the manager of the action the condition is applied to
  17676. */
  17677. constructor(actionManager: ActionManager);
  17678. /**
  17679. * Check if the current condition is valid
  17680. * @returns a boolean
  17681. */
  17682. isValid(): boolean;
  17683. /**
  17684. * Internal only
  17685. * @hidden
  17686. */
  17687. _getProperty(propertyPath: string): string;
  17688. /**
  17689. * Internal only
  17690. * @hidden
  17691. */
  17692. _getEffectiveTarget(target: any, propertyPath: string): any;
  17693. /**
  17694. * Serialize placeholder for child classes
  17695. * @returns the serialized object
  17696. */
  17697. serialize(): any;
  17698. /**
  17699. * Internal only
  17700. * @hidden
  17701. */
  17702. protected _serialize(serializedCondition: any): any;
  17703. }
  17704. /**
  17705. * Defines specific conditional operators as extensions of Condition
  17706. */
  17707. export class ValueCondition extends Condition {
  17708. /** path to specify the property of the target the conditional operator uses */
  17709. propertyPath: string;
  17710. /** the value compared by the conditional operator against the current value of the property */
  17711. value: any;
  17712. /** the conditional operator, default ValueCondition.IsEqual */
  17713. operator: number;
  17714. /**
  17715. * Internal only
  17716. * @hidden
  17717. */
  17718. private static _IsEqual;
  17719. /**
  17720. * Internal only
  17721. * @hidden
  17722. */
  17723. private static _IsDifferent;
  17724. /**
  17725. * Internal only
  17726. * @hidden
  17727. */
  17728. private static _IsGreater;
  17729. /**
  17730. * Internal only
  17731. * @hidden
  17732. */
  17733. private static _IsLesser;
  17734. /**
  17735. * returns the number for IsEqual
  17736. */
  17737. static get IsEqual(): number;
  17738. /**
  17739. * Returns the number for IsDifferent
  17740. */
  17741. static get IsDifferent(): number;
  17742. /**
  17743. * Returns the number for IsGreater
  17744. */
  17745. static get IsGreater(): number;
  17746. /**
  17747. * Returns the number for IsLesser
  17748. */
  17749. static get IsLesser(): number;
  17750. /**
  17751. * Internal only The action manager for the condition
  17752. * @hidden
  17753. */
  17754. _actionManager: ActionManager;
  17755. /**
  17756. * Internal only
  17757. * @hidden
  17758. */
  17759. private _target;
  17760. /**
  17761. * Internal only
  17762. * @hidden
  17763. */
  17764. private _effectiveTarget;
  17765. /**
  17766. * Internal only
  17767. * @hidden
  17768. */
  17769. private _property;
  17770. /**
  17771. * Creates a new ValueCondition
  17772. * @param actionManager manager for the action the condition applies to
  17773. * @param target for the action
  17774. * @param propertyPath path to specify the property of the target the conditional operator uses
  17775. * @param value the value compared by the conditional operator against the current value of the property
  17776. * @param operator the conditional operator, default ValueCondition.IsEqual
  17777. */
  17778. constructor(actionManager: ActionManager, target: any,
  17779. /** path to specify the property of the target the conditional operator uses */
  17780. propertyPath: string,
  17781. /** the value compared by the conditional operator against the current value of the property */
  17782. value: any,
  17783. /** the conditional operator, default ValueCondition.IsEqual */
  17784. operator?: number);
  17785. /**
  17786. * Compares the given value with the property value for the specified conditional operator
  17787. * @returns the result of the comparison
  17788. */
  17789. isValid(): boolean;
  17790. /**
  17791. * Serialize the ValueCondition into a JSON compatible object
  17792. * @returns serialization object
  17793. */
  17794. serialize(): any;
  17795. /**
  17796. * Gets the name of the conditional operator for the ValueCondition
  17797. * @param operator the conditional operator
  17798. * @returns the name
  17799. */
  17800. static GetOperatorName(operator: number): string;
  17801. }
  17802. /**
  17803. * Defines a predicate condition as an extension of Condition
  17804. */
  17805. export class PredicateCondition extends Condition {
  17806. /** defines the predicate function used to validate the condition */
  17807. predicate: () => boolean;
  17808. /**
  17809. * Internal only - manager for action
  17810. * @hidden
  17811. */
  17812. _actionManager: ActionManager;
  17813. /**
  17814. * Creates a new PredicateCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param predicate defines the predicate function used to validate the condition
  17817. */
  17818. constructor(actionManager: ActionManager,
  17819. /** defines the predicate function used to validate the condition */
  17820. predicate: () => boolean);
  17821. /**
  17822. * @returns the validity of the predicate condition
  17823. */
  17824. isValid(): boolean;
  17825. }
  17826. /**
  17827. * Defines a state condition as an extension of Condition
  17828. */
  17829. export class StateCondition extends Condition {
  17830. /** Value to compare with target state */
  17831. value: string;
  17832. /**
  17833. * Internal only - manager for action
  17834. * @hidden
  17835. */
  17836. _actionManager: ActionManager;
  17837. /**
  17838. * Internal only
  17839. * @hidden
  17840. */
  17841. private _target;
  17842. /**
  17843. * Creates a new StateCondition
  17844. * @param actionManager manager for the action the condition applies to
  17845. * @param target of the condition
  17846. * @param value to compare with target state
  17847. */
  17848. constructor(actionManager: ActionManager, target: any,
  17849. /** Value to compare with target state */
  17850. value: string);
  17851. /**
  17852. * Gets a boolean indicating if the current condition is met
  17853. * @returns the validity of the state
  17854. */
  17855. isValid(): boolean;
  17856. /**
  17857. * Serialize the StateCondition into a JSON compatible object
  17858. * @returns serialization object
  17859. */
  17860. serialize(): any;
  17861. }
  17862. }
  17863. declare module "babylonjs/Actions/directActions" {
  17864. import { Action } from "babylonjs/Actions/action";
  17865. import { Condition } from "babylonjs/Actions/condition";
  17866. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17867. /**
  17868. * This defines an action responsible to toggle a boolean once triggered.
  17869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17870. */
  17871. export class SwitchBooleanAction extends Action {
  17872. /**
  17873. * The path to the boolean property in the target object
  17874. */
  17875. propertyPath: string;
  17876. private _target;
  17877. private _effectiveTarget;
  17878. private _property;
  17879. /**
  17880. * Instantiate the action
  17881. * @param triggerOptions defines the trigger options
  17882. * @param target defines the object containing the boolean
  17883. * @param propertyPath defines the path to the boolean property in the target object
  17884. * @param condition defines the trigger related conditions
  17885. */
  17886. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17887. /** @hidden */
  17888. _prepare(): void;
  17889. /**
  17890. * Execute the action toggle the boolean value.
  17891. */
  17892. execute(): void;
  17893. /**
  17894. * Serializes the actions and its related information.
  17895. * @param parent defines the object to serialize in
  17896. * @returns the serialized object
  17897. */
  17898. serialize(parent: any): any;
  17899. }
  17900. /**
  17901. * This defines an action responsible to set a the state field of the target
  17902. * to a desired value once triggered.
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17904. */
  17905. export class SetStateAction extends Action {
  17906. /**
  17907. * The value to store in the state field.
  17908. */
  17909. value: string;
  17910. private _target;
  17911. /**
  17912. * Instantiate the action
  17913. * @param triggerOptions defines the trigger options
  17914. * @param target defines the object containing the state property
  17915. * @param value defines the value to store in the state field
  17916. * @param condition defines the trigger related conditions
  17917. */
  17918. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17919. /**
  17920. * Execute the action and store the value on the target state property.
  17921. */
  17922. execute(): void;
  17923. /**
  17924. * Serializes the actions and its related information.
  17925. * @param parent defines the object to serialize in
  17926. * @returns the serialized object
  17927. */
  17928. serialize(parent: any): any;
  17929. }
  17930. /**
  17931. * This defines an action responsible to set a property of the target
  17932. * to a desired value once triggered.
  17933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17934. */
  17935. export class SetValueAction extends Action {
  17936. /**
  17937. * The path of the property to set in the target.
  17938. */
  17939. propertyPath: string;
  17940. /**
  17941. * The value to set in the property
  17942. */
  17943. value: any;
  17944. private _target;
  17945. private _effectiveTarget;
  17946. private _property;
  17947. /**
  17948. * Instantiate the action
  17949. * @param triggerOptions defines the trigger options
  17950. * @param target defines the object containing the property
  17951. * @param propertyPath defines the path of the property to set in the target
  17952. * @param value defines the value to set in the property
  17953. * @param condition defines the trigger related conditions
  17954. */
  17955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17956. /** @hidden */
  17957. _prepare(): void;
  17958. /**
  17959. * Execute the action and set the targetted property to the desired value.
  17960. */
  17961. execute(): void;
  17962. /**
  17963. * Serializes the actions and its related information.
  17964. * @param parent defines the object to serialize in
  17965. * @returns the serialized object
  17966. */
  17967. serialize(parent: any): any;
  17968. }
  17969. /**
  17970. * This defines an action responsible to increment the target value
  17971. * to a desired value once triggered.
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17973. */
  17974. export class IncrementValueAction extends Action {
  17975. /**
  17976. * The path of the property to increment in the target.
  17977. */
  17978. propertyPath: string;
  17979. /**
  17980. * The value we should increment the property by.
  17981. */
  17982. value: any;
  17983. private _target;
  17984. private _effectiveTarget;
  17985. private _property;
  17986. /**
  17987. * Instantiate the action
  17988. * @param triggerOptions defines the trigger options
  17989. * @param target defines the object containing the property
  17990. * @param propertyPath defines the path of the property to increment in the target
  17991. * @param value defines the value value we should increment the property by
  17992. * @param condition defines the trigger related conditions
  17993. */
  17994. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17995. /** @hidden */
  17996. _prepare(): void;
  17997. /**
  17998. * Execute the action and increment the target of the value amount.
  17999. */
  18000. execute(): void;
  18001. /**
  18002. * Serializes the actions and its related information.
  18003. * @param parent defines the object to serialize in
  18004. * @returns the serialized object
  18005. */
  18006. serialize(parent: any): any;
  18007. }
  18008. /**
  18009. * This defines an action responsible to start an animation once triggered.
  18010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18011. */
  18012. export class PlayAnimationAction extends Action {
  18013. /**
  18014. * Where the animation should start (animation frame)
  18015. */
  18016. from: number;
  18017. /**
  18018. * Where the animation should stop (animation frame)
  18019. */
  18020. to: number;
  18021. /**
  18022. * Define if the animation should loop or stop after the first play.
  18023. */
  18024. loop?: boolean;
  18025. private _target;
  18026. /**
  18027. * Instantiate the action
  18028. * @param triggerOptions defines the trigger options
  18029. * @param target defines the target animation or animation name
  18030. * @param from defines from where the animation should start (animation frame)
  18031. * @param end defines where the animation should stop (animation frame)
  18032. * @param loop defines if the animation should loop or stop after the first play
  18033. * @param condition defines the trigger related conditions
  18034. */
  18035. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18036. /** @hidden */
  18037. _prepare(): void;
  18038. /**
  18039. * Execute the action and play the animation.
  18040. */
  18041. execute(): void;
  18042. /**
  18043. * Serializes the actions and its related information.
  18044. * @param parent defines the object to serialize in
  18045. * @returns the serialized object
  18046. */
  18047. serialize(parent: any): any;
  18048. }
  18049. /**
  18050. * This defines an action responsible to stop an animation once triggered.
  18051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18052. */
  18053. export class StopAnimationAction extends Action {
  18054. private _target;
  18055. /**
  18056. * Instantiate the action
  18057. * @param triggerOptions defines the trigger options
  18058. * @param target defines the target animation or animation name
  18059. * @param condition defines the trigger related conditions
  18060. */
  18061. constructor(triggerOptions: any, target: any, condition?: Condition);
  18062. /** @hidden */
  18063. _prepare(): void;
  18064. /**
  18065. * Execute the action and stop the animation.
  18066. */
  18067. execute(): void;
  18068. /**
  18069. * Serializes the actions and its related information.
  18070. * @param parent defines the object to serialize in
  18071. * @returns the serialized object
  18072. */
  18073. serialize(parent: any): any;
  18074. }
  18075. /**
  18076. * This defines an action responsible that does nothing once triggered.
  18077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18078. */
  18079. export class DoNothingAction extends Action {
  18080. /**
  18081. * Instantiate the action
  18082. * @param triggerOptions defines the trigger options
  18083. * @param condition defines the trigger related conditions
  18084. */
  18085. constructor(triggerOptions?: any, condition?: Condition);
  18086. /**
  18087. * Execute the action and do nothing.
  18088. */
  18089. execute(): void;
  18090. /**
  18091. * Serializes the actions and its related information.
  18092. * @param parent defines the object to serialize in
  18093. * @returns the serialized object
  18094. */
  18095. serialize(parent: any): any;
  18096. }
  18097. /**
  18098. * This defines an action responsible to trigger several actions once triggered.
  18099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18100. */
  18101. export class CombineAction extends Action {
  18102. /**
  18103. * The list of aggregated animations to run.
  18104. */
  18105. children: Action[];
  18106. /**
  18107. * Instantiate the action
  18108. * @param triggerOptions defines the trigger options
  18109. * @param children defines the list of aggregated animations to run
  18110. * @param condition defines the trigger related conditions
  18111. */
  18112. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18113. /** @hidden */
  18114. _prepare(): void;
  18115. /**
  18116. * Execute the action and executes all the aggregated actions.
  18117. */
  18118. execute(evt: ActionEvent): void;
  18119. /**
  18120. * Serializes the actions and its related information.
  18121. * @param parent defines the object to serialize in
  18122. * @returns the serialized object
  18123. */
  18124. serialize(parent: any): any;
  18125. }
  18126. /**
  18127. * This defines an action responsible to run code (external event) once triggered.
  18128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18129. */
  18130. export class ExecuteCodeAction extends Action {
  18131. /**
  18132. * The callback function to run.
  18133. */
  18134. func: (evt: ActionEvent) => void;
  18135. /**
  18136. * Instantiate the action
  18137. * @param triggerOptions defines the trigger options
  18138. * @param func defines the callback function to run
  18139. * @param condition defines the trigger related conditions
  18140. */
  18141. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18142. /**
  18143. * Execute the action and run the attached code.
  18144. */
  18145. execute(evt: ActionEvent): void;
  18146. }
  18147. /**
  18148. * This defines an action responsible to set the parent property of the target once triggered.
  18149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18150. */
  18151. export class SetParentAction extends Action {
  18152. private _parent;
  18153. private _target;
  18154. /**
  18155. * Instantiate the action
  18156. * @param triggerOptions defines the trigger options
  18157. * @param target defines the target containing the parent property
  18158. * @param parent defines from where the animation should start (animation frame)
  18159. * @param condition defines the trigger related conditions
  18160. */
  18161. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18162. /** @hidden */
  18163. _prepare(): void;
  18164. /**
  18165. * Execute the action and set the parent property.
  18166. */
  18167. execute(): void;
  18168. /**
  18169. * Serializes the actions and its related information.
  18170. * @param parent defines the object to serialize in
  18171. * @returns the serialized object
  18172. */
  18173. serialize(parent: any): any;
  18174. }
  18175. }
  18176. declare module "babylonjs/Actions/actionManager" {
  18177. import { Nullable } from "babylonjs/types";
  18178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18179. import { Scene } from "babylonjs/scene";
  18180. import { IAction } from "babylonjs/Actions/action";
  18181. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18183. /**
  18184. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18185. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18187. */
  18188. export class ActionManager extends AbstractActionManager {
  18189. /**
  18190. * Nothing
  18191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18192. */
  18193. static readonly NothingTrigger: number;
  18194. /**
  18195. * On pick
  18196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18197. */
  18198. static readonly OnPickTrigger: number;
  18199. /**
  18200. * On left pick
  18201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18202. */
  18203. static readonly OnLeftPickTrigger: number;
  18204. /**
  18205. * On right pick
  18206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18207. */
  18208. static readonly OnRightPickTrigger: number;
  18209. /**
  18210. * On center pick
  18211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18212. */
  18213. static readonly OnCenterPickTrigger: number;
  18214. /**
  18215. * On pick down
  18216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18217. */
  18218. static readonly OnPickDownTrigger: number;
  18219. /**
  18220. * On double pick
  18221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18222. */
  18223. static readonly OnDoublePickTrigger: number;
  18224. /**
  18225. * On pick up
  18226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18227. */
  18228. static readonly OnPickUpTrigger: number;
  18229. /**
  18230. * On pick out.
  18231. * This trigger will only be raised if you also declared a OnPickDown
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnPickOutTrigger: number;
  18235. /**
  18236. * On long press
  18237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18238. */
  18239. static readonly OnLongPressTrigger: number;
  18240. /**
  18241. * On pointer over
  18242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18243. */
  18244. static readonly OnPointerOverTrigger: number;
  18245. /**
  18246. * On pointer out
  18247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18248. */
  18249. static readonly OnPointerOutTrigger: number;
  18250. /**
  18251. * On every frame
  18252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18253. */
  18254. static readonly OnEveryFrameTrigger: number;
  18255. /**
  18256. * On intersection enter
  18257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18258. */
  18259. static readonly OnIntersectionEnterTrigger: number;
  18260. /**
  18261. * On intersection exit
  18262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18263. */
  18264. static readonly OnIntersectionExitTrigger: number;
  18265. /**
  18266. * On key down
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18268. */
  18269. static readonly OnKeyDownTrigger: number;
  18270. /**
  18271. * On key up
  18272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18273. */
  18274. static readonly OnKeyUpTrigger: number;
  18275. private _scene;
  18276. /**
  18277. * Creates a new action manager
  18278. * @param scene defines the hosting scene
  18279. */
  18280. constructor(scene: Scene);
  18281. /**
  18282. * Releases all associated resources
  18283. */
  18284. dispose(): void;
  18285. /**
  18286. * Gets hosting scene
  18287. * @returns the hosting scene
  18288. */
  18289. getScene(): Scene;
  18290. /**
  18291. * Does this action manager handles actions of any of the given triggers
  18292. * @param triggers defines the triggers to be tested
  18293. * @return a boolean indicating whether one (or more) of the triggers is handled
  18294. */
  18295. hasSpecificTriggers(triggers: number[]): boolean;
  18296. /**
  18297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18298. * speed.
  18299. * @param triggerA defines the trigger to be tested
  18300. * @param triggerB defines the trigger to be tested
  18301. * @return a boolean indicating whether one (or more) of the triggers is handled
  18302. */
  18303. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18304. /**
  18305. * Does this action manager handles actions of a given trigger
  18306. * @param trigger defines the trigger to be tested
  18307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18308. * @return whether the trigger is handled
  18309. */
  18310. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18311. /**
  18312. * Does this action manager has pointer triggers
  18313. */
  18314. get hasPointerTriggers(): boolean;
  18315. /**
  18316. * Does this action manager has pick triggers
  18317. */
  18318. get hasPickTriggers(): boolean;
  18319. /**
  18320. * Registers an action to this action manager
  18321. * @param action defines the action to be registered
  18322. * @return the action amended (prepared) after registration
  18323. */
  18324. registerAction(action: IAction): Nullable<IAction>;
  18325. /**
  18326. * Unregisters an action to this action manager
  18327. * @param action defines the action to be unregistered
  18328. * @return a boolean indicating whether the action has been unregistered
  18329. */
  18330. unregisterAction(action: IAction): Boolean;
  18331. /**
  18332. * Process a specific trigger
  18333. * @param trigger defines the trigger to process
  18334. * @param evt defines the event details to be processed
  18335. */
  18336. processTrigger(trigger: number, evt?: IActionEvent): void;
  18337. /** @hidden */
  18338. _getEffectiveTarget(target: any, propertyPath: string): any;
  18339. /** @hidden */
  18340. _getProperty(propertyPath: string): string;
  18341. /**
  18342. * Serialize this manager to a JSON object
  18343. * @param name defines the property name to store this manager
  18344. * @returns a JSON representation of this manager
  18345. */
  18346. serialize(name: string): any;
  18347. /**
  18348. * Creates a new ActionManager from a JSON data
  18349. * @param parsedActions defines the JSON data to read from
  18350. * @param object defines the hosting mesh
  18351. * @param scene defines the hosting scene
  18352. */
  18353. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18354. /**
  18355. * Get a trigger name by index
  18356. * @param trigger defines the trigger index
  18357. * @returns a trigger name
  18358. */
  18359. static GetTriggerName(trigger: number): string;
  18360. }
  18361. }
  18362. declare module "babylonjs/Sprites/sprite" {
  18363. import { Vector3 } from "babylonjs/Maths/math.vector";
  18364. import { Nullable } from "babylonjs/types";
  18365. import { ActionManager } from "babylonjs/Actions/actionManager";
  18366. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18367. import { Color4 } from "babylonjs/Maths/math.color";
  18368. /**
  18369. * Class used to represent a sprite
  18370. * @see http://doc.babylonjs.com/babylon101/sprites
  18371. */
  18372. export class Sprite {
  18373. /** defines the name */
  18374. name: string;
  18375. /** Gets or sets the current world position */
  18376. position: Vector3;
  18377. /** Gets or sets the main color */
  18378. color: Color4;
  18379. /** Gets or sets the width */
  18380. width: number;
  18381. /** Gets or sets the height */
  18382. height: number;
  18383. /** Gets or sets rotation angle */
  18384. angle: number;
  18385. /** Gets or sets the cell index in the sprite sheet */
  18386. cellIndex: number;
  18387. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18388. cellRef: string;
  18389. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18390. invertU: number;
  18391. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18392. invertV: number;
  18393. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18394. disposeWhenFinishedAnimating: boolean;
  18395. /** Gets the list of attached animations */
  18396. animations: Animation[];
  18397. /** Gets or sets a boolean indicating if the sprite can be picked */
  18398. isPickable: boolean;
  18399. /**
  18400. * Gets or sets the associated action manager
  18401. */
  18402. actionManager: Nullable<ActionManager>;
  18403. private _animationStarted;
  18404. private _loopAnimation;
  18405. private _fromIndex;
  18406. private _toIndex;
  18407. private _delay;
  18408. private _direction;
  18409. private _manager;
  18410. private _time;
  18411. private _onAnimationEnd;
  18412. /**
  18413. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18414. */
  18415. isVisible: boolean;
  18416. /**
  18417. * Gets or sets the sprite size
  18418. */
  18419. get size(): number;
  18420. set size(value: number);
  18421. /**
  18422. * Creates a new Sprite
  18423. * @param name defines the name
  18424. * @param manager defines the manager
  18425. */
  18426. constructor(
  18427. /** defines the name */
  18428. name: string, manager: ISpriteManager);
  18429. /**
  18430. * Starts an animation
  18431. * @param from defines the initial key
  18432. * @param to defines the end key
  18433. * @param loop defines if the animation must loop
  18434. * @param delay defines the start delay (in ms)
  18435. * @param onAnimationEnd defines a callback to call when animation ends
  18436. */
  18437. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18438. /** Stops current animation (if any) */
  18439. stopAnimation(): void;
  18440. /** @hidden */
  18441. _animate(deltaTime: number): void;
  18442. /** Release associated resources */
  18443. dispose(): void;
  18444. }
  18445. }
  18446. declare module "babylonjs/Collisions/pickingInfo" {
  18447. import { Nullable } from "babylonjs/types";
  18448. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18450. import { Sprite } from "babylonjs/Sprites/sprite";
  18451. import { Ray } from "babylonjs/Culling/ray";
  18452. /**
  18453. * Information about the result of picking within a scene
  18454. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18455. */
  18456. export class PickingInfo {
  18457. /** @hidden */
  18458. _pickingUnavailable: boolean;
  18459. /**
  18460. * If the pick collided with an object
  18461. */
  18462. hit: boolean;
  18463. /**
  18464. * Distance away where the pick collided
  18465. */
  18466. distance: number;
  18467. /**
  18468. * The location of pick collision
  18469. */
  18470. pickedPoint: Nullable<Vector3>;
  18471. /**
  18472. * The mesh corresponding the the pick collision
  18473. */
  18474. pickedMesh: Nullable<AbstractMesh>;
  18475. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18476. bu: number;
  18477. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18478. bv: number;
  18479. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18480. faceId: number;
  18481. /** Id of the the submesh that was picked */
  18482. subMeshId: number;
  18483. /** If a sprite was picked, this will be the sprite the pick collided with */
  18484. pickedSprite: Nullable<Sprite>;
  18485. /**
  18486. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18487. */
  18488. originMesh: Nullable<AbstractMesh>;
  18489. /**
  18490. * The ray that was used to perform the picking.
  18491. */
  18492. ray: Nullable<Ray>;
  18493. /**
  18494. * Gets the normal correspodning to the face the pick collided with
  18495. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18496. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18497. * @returns The normal correspodning to the face the pick collided with
  18498. */
  18499. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18500. /**
  18501. * Gets the texture coordinates of where the pick occured
  18502. * @returns the vector containing the coordnates of the texture
  18503. */
  18504. getTextureCoordinates(): Nullable<Vector2>;
  18505. }
  18506. }
  18507. declare module "babylonjs/Events/pointerEvents" {
  18508. import { Nullable } from "babylonjs/types";
  18509. import { Vector2 } from "babylonjs/Maths/math.vector";
  18510. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18511. import { Ray } from "babylonjs/Culling/ray";
  18512. /**
  18513. * Gather the list of pointer event types as constants.
  18514. */
  18515. export class PointerEventTypes {
  18516. /**
  18517. * 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.
  18518. */
  18519. static readonly POINTERDOWN: number;
  18520. /**
  18521. * The pointerup event is fired when a pointer is no longer active.
  18522. */
  18523. static readonly POINTERUP: number;
  18524. /**
  18525. * The pointermove event is fired when a pointer changes coordinates.
  18526. */
  18527. static readonly POINTERMOVE: number;
  18528. /**
  18529. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18530. */
  18531. static readonly POINTERWHEEL: number;
  18532. /**
  18533. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18534. */
  18535. static readonly POINTERPICK: number;
  18536. /**
  18537. * The pointertap event is fired when a the object has been touched and released without drag.
  18538. */
  18539. static readonly POINTERTAP: number;
  18540. /**
  18541. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18542. */
  18543. static readonly POINTERDOUBLETAP: number;
  18544. }
  18545. /**
  18546. * Base class of pointer info types.
  18547. */
  18548. export class PointerInfoBase {
  18549. /**
  18550. * Defines the type of event (PointerEventTypes)
  18551. */
  18552. type: number;
  18553. /**
  18554. * Defines the related dom event
  18555. */
  18556. event: PointerEvent | MouseWheelEvent;
  18557. /**
  18558. * Instantiates the base class of pointers info.
  18559. * @param type Defines the type of event (PointerEventTypes)
  18560. * @param event Defines the related dom event
  18561. */
  18562. constructor(
  18563. /**
  18564. * Defines the type of event (PointerEventTypes)
  18565. */
  18566. type: number,
  18567. /**
  18568. * Defines the related dom event
  18569. */
  18570. event: PointerEvent | MouseWheelEvent);
  18571. }
  18572. /**
  18573. * This class is used to store pointer related info for the onPrePointerObservable event.
  18574. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18575. */
  18576. export class PointerInfoPre extends PointerInfoBase {
  18577. /**
  18578. * Ray from a pointer if availible (eg. 6dof controller)
  18579. */
  18580. ray: Nullable<Ray>;
  18581. /**
  18582. * Defines the local position of the pointer on the canvas.
  18583. */
  18584. localPosition: Vector2;
  18585. /**
  18586. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18587. */
  18588. skipOnPointerObservable: boolean;
  18589. /**
  18590. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18591. * @param type Defines the type of event (PointerEventTypes)
  18592. * @param event Defines the related dom event
  18593. * @param localX Defines the local x coordinates of the pointer when the event occured
  18594. * @param localY Defines the local y coordinates of the pointer when the event occured
  18595. */
  18596. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18597. }
  18598. /**
  18599. * This type contains all the data related to a pointer event in Babylon.js.
  18600. * 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.
  18601. */
  18602. export class PointerInfo extends PointerInfoBase {
  18603. /**
  18604. * Defines the picking info associated to the info (if any)\
  18605. */
  18606. pickInfo: Nullable<PickingInfo>;
  18607. /**
  18608. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18609. * @param type Defines the type of event (PointerEventTypes)
  18610. * @param event Defines the related dom event
  18611. * @param pickInfo Defines the picking info associated to the info (if any)\
  18612. */
  18613. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18614. /**
  18615. * Defines the picking info associated to the info (if any)\
  18616. */
  18617. pickInfo: Nullable<PickingInfo>);
  18618. }
  18619. /**
  18620. * Data relating to a touch event on the screen.
  18621. */
  18622. export interface PointerTouch {
  18623. /**
  18624. * X coordinate of touch.
  18625. */
  18626. x: number;
  18627. /**
  18628. * Y coordinate of touch.
  18629. */
  18630. y: number;
  18631. /**
  18632. * Id of touch. Unique for each finger.
  18633. */
  18634. pointerId: number;
  18635. /**
  18636. * Event type passed from DOM.
  18637. */
  18638. type: any;
  18639. }
  18640. }
  18641. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18642. import { Observable } from "babylonjs/Misc/observable";
  18643. import { Nullable } from "babylonjs/types";
  18644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18646. /**
  18647. * Manage the mouse inputs to control the movement of a free camera.
  18648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18649. */
  18650. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18651. /**
  18652. * Define if touch is enabled in the mouse input
  18653. */
  18654. touchEnabled: boolean;
  18655. /**
  18656. * Defines the camera the input is attached to.
  18657. */
  18658. camera: FreeCamera;
  18659. /**
  18660. * Defines the buttons associated with the input to handle camera move.
  18661. */
  18662. buttons: number[];
  18663. /**
  18664. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18665. */
  18666. angularSensibility: number;
  18667. private _pointerInput;
  18668. private _onMouseMove;
  18669. private _observer;
  18670. private previousPosition;
  18671. /**
  18672. * Observable for when a pointer move event occurs containing the move offset
  18673. */
  18674. onPointerMovedObservable: Observable<{
  18675. offsetX: number;
  18676. offsetY: number;
  18677. }>;
  18678. /**
  18679. * @hidden
  18680. * If the camera should be rotated automatically based on pointer movement
  18681. */
  18682. _allowCameraRotation: boolean;
  18683. /**
  18684. * Manage the mouse inputs to control the movement of a free camera.
  18685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18686. * @param touchEnabled Defines if touch is enabled or not
  18687. */
  18688. constructor(
  18689. /**
  18690. * Define if touch is enabled in the mouse input
  18691. */
  18692. touchEnabled?: boolean);
  18693. /**
  18694. * Attach the input controls to a specific dom element to get the input from.
  18695. * @param element Defines the element the controls should be listened from
  18696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18697. */
  18698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18699. /**
  18700. * Called on JS contextmenu event.
  18701. * Override this method to provide functionality.
  18702. */
  18703. protected onContextMenu(evt: PointerEvent): void;
  18704. /**
  18705. * Detach the current controls from the specified dom element.
  18706. * @param element Defines the element to stop listening the inputs from
  18707. */
  18708. detachControl(element: Nullable<HTMLElement>): void;
  18709. /**
  18710. * Gets the class name of the current intput.
  18711. * @returns the class name
  18712. */
  18713. getClassName(): string;
  18714. /**
  18715. * Get the friendly name associated with the input class.
  18716. * @returns the input friendly name
  18717. */
  18718. getSimpleName(): string;
  18719. }
  18720. }
  18721. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18722. import { Nullable } from "babylonjs/types";
  18723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18725. /**
  18726. * Manage the touch inputs to control the movement of a free camera.
  18727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18728. */
  18729. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18730. /**
  18731. * Defines the camera the input is attached to.
  18732. */
  18733. camera: FreeCamera;
  18734. /**
  18735. * Defines the touch sensibility for rotation.
  18736. * The higher the faster.
  18737. */
  18738. touchAngularSensibility: number;
  18739. /**
  18740. * Defines the touch sensibility for move.
  18741. * The higher the faster.
  18742. */
  18743. touchMoveSensibility: number;
  18744. private _offsetX;
  18745. private _offsetY;
  18746. private _pointerPressed;
  18747. private _pointerInput;
  18748. private _observer;
  18749. private _onLostFocus;
  18750. /**
  18751. * Attach the input controls to a specific dom element to get the input from.
  18752. * @param element Defines the element the controls should be listened from
  18753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18754. */
  18755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18756. /**
  18757. * Detach the current controls from the specified dom element.
  18758. * @param element Defines the element to stop listening the inputs from
  18759. */
  18760. detachControl(element: Nullable<HTMLElement>): void;
  18761. /**
  18762. * Update the current camera state depending on the inputs that have been used this frame.
  18763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18764. */
  18765. checkInputs(): void;
  18766. /**
  18767. * Gets the class name of the current intput.
  18768. * @returns the class name
  18769. */
  18770. getClassName(): string;
  18771. /**
  18772. * Get the friendly name associated with the input class.
  18773. * @returns the input friendly name
  18774. */
  18775. getSimpleName(): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18779. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18780. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18781. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18782. import { Nullable } from "babylonjs/types";
  18783. /**
  18784. * Default Inputs manager for the FreeCamera.
  18785. * It groups all the default supported inputs for ease of use.
  18786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18787. */
  18788. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18789. /**
  18790. * @hidden
  18791. */
  18792. _mouseInput: Nullable<FreeCameraMouseInput>;
  18793. /**
  18794. * Instantiates a new FreeCameraInputsManager.
  18795. * @param camera Defines the camera the inputs belong to
  18796. */
  18797. constructor(camera: FreeCamera);
  18798. /**
  18799. * Add keyboard input support to the input manager.
  18800. * @returns the current input manager
  18801. */
  18802. addKeyboard(): FreeCameraInputsManager;
  18803. /**
  18804. * Add mouse input support to the input manager.
  18805. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18806. * @returns the current input manager
  18807. */
  18808. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18809. /**
  18810. * Removes the mouse input support from the manager
  18811. * @returns the current input manager
  18812. */
  18813. removeMouse(): FreeCameraInputsManager;
  18814. /**
  18815. * Add touch input support to the input manager.
  18816. * @returns the current input manager
  18817. */
  18818. addTouch(): FreeCameraInputsManager;
  18819. /**
  18820. * Remove all attached input methods from a camera
  18821. */
  18822. clear(): void;
  18823. }
  18824. }
  18825. declare module "babylonjs/Cameras/freeCamera" {
  18826. import { Vector3 } from "babylonjs/Maths/math.vector";
  18827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18828. import { Scene } from "babylonjs/scene";
  18829. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18830. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18831. /**
  18832. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18833. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18835. */
  18836. export class FreeCamera extends TargetCamera {
  18837. /**
  18838. * Define the collision ellipsoid of the camera.
  18839. * This is helpful to simulate a camera body like the player body around the camera
  18840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18841. */
  18842. ellipsoid: Vector3;
  18843. /**
  18844. * Define an offset for the position of the ellipsoid around the camera.
  18845. * This can be helpful to determine the center of the body near the gravity center of the body
  18846. * instead of its head.
  18847. */
  18848. ellipsoidOffset: Vector3;
  18849. /**
  18850. * Enable or disable collisions of the camera with the rest of the scene objects.
  18851. */
  18852. checkCollisions: boolean;
  18853. /**
  18854. * Enable or disable gravity on the camera.
  18855. */
  18856. applyGravity: boolean;
  18857. /**
  18858. * Define the input manager associated to the camera.
  18859. */
  18860. inputs: FreeCameraInputsManager;
  18861. /**
  18862. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18863. * Higher values reduce sensitivity.
  18864. */
  18865. get angularSensibility(): number;
  18866. /**
  18867. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18868. * Higher values reduce sensitivity.
  18869. */
  18870. set angularSensibility(value: number);
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18873. */
  18874. get keysUp(): number[];
  18875. set keysUp(value: number[]);
  18876. /**
  18877. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18878. */
  18879. get keysDown(): number[];
  18880. set keysDown(value: number[]);
  18881. /**
  18882. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18883. */
  18884. get keysLeft(): number[];
  18885. set keysLeft(value: number[]);
  18886. /**
  18887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18888. */
  18889. get keysRight(): number[];
  18890. set keysRight(value: number[]);
  18891. /**
  18892. * Event raised when the camera collide with a mesh in the scene.
  18893. */
  18894. onCollide: (collidedMesh: AbstractMesh) => void;
  18895. private _collider;
  18896. private _needMoveForGravity;
  18897. private _oldPosition;
  18898. private _diffPosition;
  18899. private _newPosition;
  18900. /** @hidden */
  18901. _localDirection: Vector3;
  18902. /** @hidden */
  18903. _transformedDirection: Vector3;
  18904. /**
  18905. * Instantiates a Free Camera.
  18906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18907. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18909. * @param name Define the name of the camera in the scene
  18910. * @param position Define the start position of the camera in the scene
  18911. * @param scene Define the scene the camera belongs to
  18912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18913. */
  18914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18915. /**
  18916. * Attached controls to the current camera.
  18917. * @param element Defines the element the controls should be listened from
  18918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18919. */
  18920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18921. /**
  18922. * Detach the current controls from the camera.
  18923. * The camera will stop reacting to inputs.
  18924. * @param element Defines the element to stop listening the inputs from
  18925. */
  18926. detachControl(element: HTMLElement): void;
  18927. private _collisionMask;
  18928. /**
  18929. * Define a collision mask to limit the list of object the camera can collide with
  18930. */
  18931. get collisionMask(): number;
  18932. set collisionMask(mask: number);
  18933. /** @hidden */
  18934. _collideWithWorld(displacement: Vector3): void;
  18935. private _onCollisionPositionChange;
  18936. /** @hidden */
  18937. _checkInputs(): void;
  18938. /** @hidden */
  18939. _decideIfNeedsToMove(): boolean;
  18940. /** @hidden */
  18941. _updatePosition(): void;
  18942. /**
  18943. * Destroy the camera and release the current resources hold by it.
  18944. */
  18945. dispose(): void;
  18946. /**
  18947. * Gets the current object class name.
  18948. * @return the class name
  18949. */
  18950. getClassName(): string;
  18951. }
  18952. }
  18953. declare module "babylonjs/Gamepads/gamepad" {
  18954. import { Observable } from "babylonjs/Misc/observable";
  18955. /**
  18956. * Represents a gamepad control stick position
  18957. */
  18958. export class StickValues {
  18959. /**
  18960. * The x component of the control stick
  18961. */
  18962. x: number;
  18963. /**
  18964. * The y component of the control stick
  18965. */
  18966. y: number;
  18967. /**
  18968. * Initializes the gamepad x and y control stick values
  18969. * @param x The x component of the gamepad control stick value
  18970. * @param y The y component of the gamepad control stick value
  18971. */
  18972. constructor(
  18973. /**
  18974. * The x component of the control stick
  18975. */
  18976. x: number,
  18977. /**
  18978. * The y component of the control stick
  18979. */
  18980. y: number);
  18981. }
  18982. /**
  18983. * An interface which manages callbacks for gamepad button changes
  18984. */
  18985. export interface GamepadButtonChanges {
  18986. /**
  18987. * Called when a gamepad has been changed
  18988. */
  18989. changed: boolean;
  18990. /**
  18991. * Called when a gamepad press event has been triggered
  18992. */
  18993. pressChanged: boolean;
  18994. /**
  18995. * Called when a touch event has been triggered
  18996. */
  18997. touchChanged: boolean;
  18998. /**
  18999. * Called when a value has changed
  19000. */
  19001. valueChanged: boolean;
  19002. }
  19003. /**
  19004. * Represents a gamepad
  19005. */
  19006. export class Gamepad {
  19007. /**
  19008. * The id of the gamepad
  19009. */
  19010. id: string;
  19011. /**
  19012. * The index of the gamepad
  19013. */
  19014. index: number;
  19015. /**
  19016. * The browser gamepad
  19017. */
  19018. browserGamepad: any;
  19019. /**
  19020. * Specifies what type of gamepad this represents
  19021. */
  19022. type: number;
  19023. private _leftStick;
  19024. private _rightStick;
  19025. /** @hidden */
  19026. _isConnected: boolean;
  19027. private _leftStickAxisX;
  19028. private _leftStickAxisY;
  19029. private _rightStickAxisX;
  19030. private _rightStickAxisY;
  19031. /**
  19032. * Triggered when the left control stick has been changed
  19033. */
  19034. private _onleftstickchanged;
  19035. /**
  19036. * Triggered when the right control stick has been changed
  19037. */
  19038. private _onrightstickchanged;
  19039. /**
  19040. * Represents a gamepad controller
  19041. */
  19042. static GAMEPAD: number;
  19043. /**
  19044. * Represents a generic controller
  19045. */
  19046. static GENERIC: number;
  19047. /**
  19048. * Represents an XBox controller
  19049. */
  19050. static XBOX: number;
  19051. /**
  19052. * Represents a pose-enabled controller
  19053. */
  19054. static POSE_ENABLED: number;
  19055. /**
  19056. * Represents an Dual Shock controller
  19057. */
  19058. static DUALSHOCK: number;
  19059. /**
  19060. * Specifies whether the left control stick should be Y-inverted
  19061. */
  19062. protected _invertLeftStickY: boolean;
  19063. /**
  19064. * Specifies if the gamepad has been connected
  19065. */
  19066. get isConnected(): boolean;
  19067. /**
  19068. * Initializes the gamepad
  19069. * @param id The id of the gamepad
  19070. * @param index The index of the gamepad
  19071. * @param browserGamepad The browser gamepad
  19072. * @param leftStickX The x component of the left joystick
  19073. * @param leftStickY The y component of the left joystick
  19074. * @param rightStickX The x component of the right joystick
  19075. * @param rightStickY The y component of the right joystick
  19076. */
  19077. constructor(
  19078. /**
  19079. * The id of the gamepad
  19080. */
  19081. id: string,
  19082. /**
  19083. * The index of the gamepad
  19084. */
  19085. index: number,
  19086. /**
  19087. * The browser gamepad
  19088. */
  19089. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19090. /**
  19091. * Callback triggered when the left joystick has changed
  19092. * @param callback
  19093. */
  19094. onleftstickchanged(callback: (values: StickValues) => void): void;
  19095. /**
  19096. * Callback triggered when the right joystick has changed
  19097. * @param callback
  19098. */
  19099. onrightstickchanged(callback: (values: StickValues) => void): void;
  19100. /**
  19101. * Gets the left joystick
  19102. */
  19103. get leftStick(): StickValues;
  19104. /**
  19105. * Sets the left joystick values
  19106. */
  19107. set leftStick(newValues: StickValues);
  19108. /**
  19109. * Gets the right joystick
  19110. */
  19111. get rightStick(): StickValues;
  19112. /**
  19113. * Sets the right joystick value
  19114. */
  19115. set rightStick(newValues: StickValues);
  19116. /**
  19117. * Updates the gamepad joystick positions
  19118. */
  19119. update(): void;
  19120. /**
  19121. * Disposes the gamepad
  19122. */
  19123. dispose(): void;
  19124. }
  19125. /**
  19126. * Represents a generic gamepad
  19127. */
  19128. export class GenericPad extends Gamepad {
  19129. private _buttons;
  19130. private _onbuttondown;
  19131. private _onbuttonup;
  19132. /**
  19133. * Observable triggered when a button has been pressed
  19134. */
  19135. onButtonDownObservable: Observable<number>;
  19136. /**
  19137. * Observable triggered when a button has been released
  19138. */
  19139. onButtonUpObservable: Observable<number>;
  19140. /**
  19141. * Callback triggered when a button has been pressed
  19142. * @param callback Called when a button has been pressed
  19143. */
  19144. onbuttondown(callback: (buttonPressed: number) => void): void;
  19145. /**
  19146. * Callback triggered when a button has been released
  19147. * @param callback Called when a button has been released
  19148. */
  19149. onbuttonup(callback: (buttonReleased: number) => void): void;
  19150. /**
  19151. * Initializes the generic gamepad
  19152. * @param id The id of the generic gamepad
  19153. * @param index The index of the generic gamepad
  19154. * @param browserGamepad The browser gamepad
  19155. */
  19156. constructor(id: string, index: number, browserGamepad: any);
  19157. private _setButtonValue;
  19158. /**
  19159. * Updates the generic gamepad
  19160. */
  19161. update(): void;
  19162. /**
  19163. * Disposes the generic gamepad
  19164. */
  19165. dispose(): void;
  19166. }
  19167. }
  19168. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19169. import { Observable } from "babylonjs/Misc/observable";
  19170. import { Nullable } from "babylonjs/types";
  19171. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19174. import { Ray } from "babylonjs/Culling/ray";
  19175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19176. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19177. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19178. /**
  19179. * Defines the types of pose enabled controllers that are supported
  19180. */
  19181. export enum PoseEnabledControllerType {
  19182. /**
  19183. * HTC Vive
  19184. */
  19185. VIVE = 0,
  19186. /**
  19187. * Oculus Rift
  19188. */
  19189. OCULUS = 1,
  19190. /**
  19191. * Windows mixed reality
  19192. */
  19193. WINDOWS = 2,
  19194. /**
  19195. * Samsung gear VR
  19196. */
  19197. GEAR_VR = 3,
  19198. /**
  19199. * Google Daydream
  19200. */
  19201. DAYDREAM = 4,
  19202. /**
  19203. * Generic
  19204. */
  19205. GENERIC = 5
  19206. }
  19207. /**
  19208. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19209. */
  19210. export interface MutableGamepadButton {
  19211. /**
  19212. * Value of the button/trigger
  19213. */
  19214. value: number;
  19215. /**
  19216. * If the button/trigger is currently touched
  19217. */
  19218. touched: boolean;
  19219. /**
  19220. * If the button/trigger is currently pressed
  19221. */
  19222. pressed: boolean;
  19223. }
  19224. /**
  19225. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19226. * @hidden
  19227. */
  19228. export interface ExtendedGamepadButton extends GamepadButton {
  19229. /**
  19230. * If the button/trigger is currently pressed
  19231. */
  19232. readonly pressed: boolean;
  19233. /**
  19234. * If the button/trigger is currently touched
  19235. */
  19236. readonly touched: boolean;
  19237. /**
  19238. * Value of the button/trigger
  19239. */
  19240. readonly value: number;
  19241. }
  19242. /** @hidden */
  19243. export interface _GamePadFactory {
  19244. /**
  19245. * Returns whether or not the current gamepad can be created for this type of controller.
  19246. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19247. * @returns true if it can be created, otherwise false
  19248. */
  19249. canCreate(gamepadInfo: any): boolean;
  19250. /**
  19251. * Creates a new instance of the Gamepad.
  19252. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19253. * @returns the new gamepad instance
  19254. */
  19255. create(gamepadInfo: any): Gamepad;
  19256. }
  19257. /**
  19258. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19259. */
  19260. export class PoseEnabledControllerHelper {
  19261. /** @hidden */
  19262. static _ControllerFactories: _GamePadFactory[];
  19263. /** @hidden */
  19264. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19265. /**
  19266. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19267. * @param vrGamepad the gamepad to initialized
  19268. * @returns a vr controller of the type the gamepad identified as
  19269. */
  19270. static InitiateController(vrGamepad: any): Gamepad;
  19271. }
  19272. /**
  19273. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19274. */
  19275. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19276. /**
  19277. * If the controller is used in a webXR session
  19278. */
  19279. isXR: boolean;
  19280. private _deviceRoomPosition;
  19281. private _deviceRoomRotationQuaternion;
  19282. /**
  19283. * The device position in babylon space
  19284. */
  19285. devicePosition: Vector3;
  19286. /**
  19287. * The device rotation in babylon space
  19288. */
  19289. deviceRotationQuaternion: Quaternion;
  19290. /**
  19291. * The scale factor of the device in babylon space
  19292. */
  19293. deviceScaleFactor: number;
  19294. /**
  19295. * (Likely devicePosition should be used instead) The device position in its room space
  19296. */
  19297. position: Vector3;
  19298. /**
  19299. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19300. */
  19301. rotationQuaternion: Quaternion;
  19302. /**
  19303. * The type of controller (Eg. Windows mixed reality)
  19304. */
  19305. controllerType: PoseEnabledControllerType;
  19306. protected _calculatedPosition: Vector3;
  19307. private _calculatedRotation;
  19308. /**
  19309. * The raw pose from the device
  19310. */
  19311. rawPose: DevicePose;
  19312. private _trackPosition;
  19313. private _maxRotationDistFromHeadset;
  19314. private _draggedRoomRotation;
  19315. /**
  19316. * @hidden
  19317. */
  19318. _disableTrackPosition(fixedPosition: Vector3): void;
  19319. /**
  19320. * Internal, the mesh attached to the controller
  19321. * @hidden
  19322. */
  19323. _mesh: Nullable<AbstractMesh>;
  19324. private _poseControlledCamera;
  19325. private _leftHandSystemQuaternion;
  19326. /**
  19327. * Internal, matrix used to convert room space to babylon space
  19328. * @hidden
  19329. */
  19330. _deviceToWorld: Matrix;
  19331. /**
  19332. * Node to be used when casting a ray from the controller
  19333. * @hidden
  19334. */
  19335. _pointingPoseNode: Nullable<TransformNode>;
  19336. /**
  19337. * Name of the child mesh that can be used to cast a ray from the controller
  19338. */
  19339. static readonly POINTING_POSE: string;
  19340. /**
  19341. * Creates a new PoseEnabledController from a gamepad
  19342. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19343. */
  19344. constructor(browserGamepad: any);
  19345. private _workingMatrix;
  19346. /**
  19347. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19348. */
  19349. update(): void;
  19350. /**
  19351. * Updates only the pose device and mesh without doing any button event checking
  19352. */
  19353. protected _updatePoseAndMesh(): void;
  19354. /**
  19355. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19356. * @param poseData raw pose fromthe device
  19357. */
  19358. updateFromDevice(poseData: DevicePose): void;
  19359. /**
  19360. * @hidden
  19361. */
  19362. _meshAttachedObservable: Observable<AbstractMesh>;
  19363. /**
  19364. * Attaches a mesh to the controller
  19365. * @param mesh the mesh to be attached
  19366. */
  19367. attachToMesh(mesh: AbstractMesh): void;
  19368. /**
  19369. * Attaches the controllers mesh to a camera
  19370. * @param camera the camera the mesh should be attached to
  19371. */
  19372. attachToPoseControlledCamera(camera: TargetCamera): void;
  19373. /**
  19374. * Disposes of the controller
  19375. */
  19376. dispose(): void;
  19377. /**
  19378. * The mesh that is attached to the controller
  19379. */
  19380. get mesh(): Nullable<AbstractMesh>;
  19381. /**
  19382. * Gets the ray of the controller in the direction the controller is pointing
  19383. * @param length the length the resulting ray should be
  19384. * @returns a ray in the direction the controller is pointing
  19385. */
  19386. getForwardRay(length?: number): Ray;
  19387. }
  19388. }
  19389. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19390. import { Observable } from "babylonjs/Misc/observable";
  19391. import { Scene } from "babylonjs/scene";
  19392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19393. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19394. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19395. import { Nullable } from "babylonjs/types";
  19396. /**
  19397. * Defines the WebVRController object that represents controllers tracked in 3D space
  19398. */
  19399. export abstract class WebVRController extends PoseEnabledController {
  19400. /**
  19401. * Internal, the default controller model for the controller
  19402. */
  19403. protected _defaultModel: Nullable<AbstractMesh>;
  19404. /**
  19405. * Fired when the trigger state has changed
  19406. */
  19407. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19408. /**
  19409. * Fired when the main button state has changed
  19410. */
  19411. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19412. /**
  19413. * Fired when the secondary button state has changed
  19414. */
  19415. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19416. /**
  19417. * Fired when the pad state has changed
  19418. */
  19419. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19420. /**
  19421. * Fired when controllers stick values have changed
  19422. */
  19423. onPadValuesChangedObservable: Observable<StickValues>;
  19424. /**
  19425. * Array of button availible on the controller
  19426. */
  19427. protected _buttons: Array<MutableGamepadButton>;
  19428. private _onButtonStateChange;
  19429. /**
  19430. * Fired when a controller button's state has changed
  19431. * @param callback the callback containing the button that was modified
  19432. */
  19433. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19434. /**
  19435. * X and Y axis corresponding to the controllers joystick
  19436. */
  19437. pad: StickValues;
  19438. /**
  19439. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19440. */
  19441. hand: string;
  19442. /**
  19443. * The default controller model for the controller
  19444. */
  19445. get defaultModel(): Nullable<AbstractMesh>;
  19446. /**
  19447. * Creates a new WebVRController from a gamepad
  19448. * @param vrGamepad the gamepad that the WebVRController should be created from
  19449. */
  19450. constructor(vrGamepad: any);
  19451. /**
  19452. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19453. */
  19454. update(): void;
  19455. /**
  19456. * Function to be called when a button is modified
  19457. */
  19458. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19459. /**
  19460. * Loads a mesh and attaches it to the controller
  19461. * @param scene the scene the mesh should be added to
  19462. * @param meshLoaded callback for when the mesh has been loaded
  19463. */
  19464. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19465. private _setButtonValue;
  19466. private _changes;
  19467. private _checkChanges;
  19468. /**
  19469. * Disposes of th webVRCOntroller
  19470. */
  19471. dispose(): void;
  19472. }
  19473. }
  19474. declare module "babylonjs/Lights/hemisphericLight" {
  19475. import { Nullable } from "babylonjs/types";
  19476. import { Scene } from "babylonjs/scene";
  19477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19478. import { Color3 } from "babylonjs/Maths/math.color";
  19479. import { Effect } from "babylonjs/Materials/effect";
  19480. import { Light } from "babylonjs/Lights/light";
  19481. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19482. /**
  19483. * The HemisphericLight simulates the ambient environment light,
  19484. * so the passed direction is the light reflection direction, not the incoming direction.
  19485. */
  19486. export class HemisphericLight extends Light {
  19487. /**
  19488. * The groundColor is the light in the opposite direction to the one specified during creation.
  19489. * 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.
  19490. */
  19491. groundColor: Color3;
  19492. /**
  19493. * The light reflection direction, not the incoming direction.
  19494. */
  19495. direction: Vector3;
  19496. /**
  19497. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19498. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19499. * The HemisphericLight can't cast shadows.
  19500. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19501. * @param name The friendly name of the light
  19502. * @param direction The direction of the light reflection
  19503. * @param scene The scene the light belongs to
  19504. */
  19505. constructor(name: string, direction: Vector3, scene: Scene);
  19506. protected _buildUniformLayout(): void;
  19507. /**
  19508. * Returns the string "HemisphericLight".
  19509. * @return The class name
  19510. */
  19511. getClassName(): string;
  19512. /**
  19513. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19514. * Returns the updated direction.
  19515. * @param target The target the direction should point to
  19516. * @return The computed direction
  19517. */
  19518. setDirectionToTarget(target: Vector3): Vector3;
  19519. /**
  19520. * Returns the shadow generator associated to the light.
  19521. * @returns Always null for hemispheric lights because it does not support shadows.
  19522. */
  19523. getShadowGenerator(): Nullable<IShadowGenerator>;
  19524. /**
  19525. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19526. * @param effect The effect to update
  19527. * @param lightIndex The index of the light in the effect to update
  19528. * @returns The hemispheric light
  19529. */
  19530. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19532. /**
  19533. * Computes the world matrix of the node
  19534. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19535. * @param useWasUpdatedFlag defines a reserved property
  19536. * @returns the world matrix
  19537. */
  19538. computeWorldMatrix(): Matrix;
  19539. /**
  19540. * Returns the integer 3.
  19541. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19542. */
  19543. getTypeID(): number;
  19544. /**
  19545. * Prepares the list of defines specific to the light type.
  19546. * @param defines the list of defines
  19547. * @param lightIndex defines the index of the light for the effect
  19548. */
  19549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19550. }
  19551. }
  19552. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19553. /** @hidden */
  19554. export var vrMultiviewToSingleviewPixelShader: {
  19555. name: string;
  19556. shader: string;
  19557. };
  19558. }
  19559. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19561. import { Scene } from "babylonjs/scene";
  19562. /**
  19563. * Renders to multiple views with a single draw call
  19564. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19565. */
  19566. export class MultiviewRenderTarget extends RenderTargetTexture {
  19567. /**
  19568. * Creates a multiview render target
  19569. * @param scene scene used with the render target
  19570. * @param size the size of the render target (used for each view)
  19571. */
  19572. constructor(scene: Scene, size?: number | {
  19573. width: number;
  19574. height: number;
  19575. } | {
  19576. ratio: number;
  19577. });
  19578. /**
  19579. * @hidden
  19580. * @param faceIndex the face index, if its a cube texture
  19581. */
  19582. _bindFrameBuffer(faceIndex?: number): void;
  19583. /**
  19584. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19585. * @returns the view count
  19586. */
  19587. getViewCount(): number;
  19588. }
  19589. }
  19590. declare module "babylonjs/Maths/math.frustum" {
  19591. import { Matrix } from "babylonjs/Maths/math.vector";
  19592. import { DeepImmutable } from "babylonjs/types";
  19593. import { Plane } from "babylonjs/Maths/math.plane";
  19594. /**
  19595. * Represents a camera frustum
  19596. */
  19597. export class Frustum {
  19598. /**
  19599. * Gets the planes representing the frustum
  19600. * @param transform matrix to be applied to the returned planes
  19601. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19602. */
  19603. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19604. /**
  19605. * Gets the near frustum plane transformed by the transform matrix
  19606. * @param transform transformation matrix to be applied to the resulting frustum plane
  19607. * @param frustumPlane the resuling frustum plane
  19608. */
  19609. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19610. /**
  19611. * Gets the far frustum plane transformed by the transform matrix
  19612. * @param transform transformation matrix to be applied to the resulting frustum plane
  19613. * @param frustumPlane the resuling frustum plane
  19614. */
  19615. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19616. /**
  19617. * Gets the left frustum plane transformed by the transform matrix
  19618. * @param transform transformation matrix to be applied to the resulting frustum plane
  19619. * @param frustumPlane the resuling frustum plane
  19620. */
  19621. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19622. /**
  19623. * Gets the right frustum plane transformed by the transform matrix
  19624. * @param transform transformation matrix to be applied to the resulting frustum plane
  19625. * @param frustumPlane the resuling frustum plane
  19626. */
  19627. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19628. /**
  19629. * Gets the top frustum plane transformed by the transform matrix
  19630. * @param transform transformation matrix to be applied to the resulting frustum plane
  19631. * @param frustumPlane the resuling frustum plane
  19632. */
  19633. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19634. /**
  19635. * Gets the bottom frustum plane transformed by the transform matrix
  19636. * @param transform transformation matrix to be applied to the resulting frustum plane
  19637. * @param frustumPlane the resuling frustum plane
  19638. */
  19639. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19640. /**
  19641. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19642. * @param transform transformation matrix to be applied to the resulting frustum planes
  19643. * @param frustumPlanes the resuling frustum planes
  19644. */
  19645. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19646. }
  19647. }
  19648. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19649. import { Camera } from "babylonjs/Cameras/camera";
  19650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19651. import { Nullable } from "babylonjs/types";
  19652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19653. import { Matrix } from "babylonjs/Maths/math.vector";
  19654. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19655. module "babylonjs/Engines/engine" {
  19656. interface Engine {
  19657. /**
  19658. * Creates a new multiview render target
  19659. * @param width defines the width of the texture
  19660. * @param height defines the height of the texture
  19661. * @returns the created multiview texture
  19662. */
  19663. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19664. /**
  19665. * Binds a multiview framebuffer to be drawn to
  19666. * @param multiviewTexture texture to bind
  19667. */
  19668. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19669. }
  19670. }
  19671. module "babylonjs/Cameras/camera" {
  19672. interface Camera {
  19673. /**
  19674. * @hidden
  19675. * 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)
  19676. */
  19677. _useMultiviewToSingleView: boolean;
  19678. /**
  19679. * @hidden
  19680. * 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)
  19681. */
  19682. _multiviewTexture: Nullable<RenderTargetTexture>;
  19683. /**
  19684. * @hidden
  19685. * ensures the multiview texture of the camera exists and has the specified width/height
  19686. * @param width height to set on the multiview texture
  19687. * @param height width to set on the multiview texture
  19688. */
  19689. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19690. }
  19691. }
  19692. module "babylonjs/scene" {
  19693. interface Scene {
  19694. /** @hidden */
  19695. _transformMatrixR: Matrix;
  19696. /** @hidden */
  19697. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19698. /** @hidden */
  19699. _createMultiviewUbo(): void;
  19700. /** @hidden */
  19701. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19702. /** @hidden */
  19703. _renderMultiviewToSingleView(camera: Camera): void;
  19704. }
  19705. }
  19706. }
  19707. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19708. import { Camera } from "babylonjs/Cameras/camera";
  19709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19710. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19711. import "babylonjs/Engines/Extensions/engine.multiview";
  19712. /**
  19713. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19714. * This will not be used for webXR as it supports displaying texture arrays directly
  19715. */
  19716. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19717. /**
  19718. * Initializes a VRMultiviewToSingleview
  19719. * @param name name of the post process
  19720. * @param camera camera to be applied to
  19721. * @param scaleFactor scaling factor to the size of the output texture
  19722. */
  19723. constructor(name: string, camera: Camera, scaleFactor: number);
  19724. }
  19725. }
  19726. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19727. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19728. import { Nullable } from "babylonjs/types";
  19729. import { Size } from "babylonjs/Maths/math.size";
  19730. import { Observable } from "babylonjs/Misc/observable";
  19731. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19732. /**
  19733. * Interface used to define additional presentation attributes
  19734. */
  19735. export interface IVRPresentationAttributes {
  19736. /**
  19737. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19738. */
  19739. highRefreshRate: boolean;
  19740. /**
  19741. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19742. */
  19743. foveationLevel: number;
  19744. }
  19745. module "babylonjs/Engines/engine" {
  19746. interface Engine {
  19747. /** @hidden */
  19748. _vrDisplay: any;
  19749. /** @hidden */
  19750. _vrSupported: boolean;
  19751. /** @hidden */
  19752. _oldSize: Size;
  19753. /** @hidden */
  19754. _oldHardwareScaleFactor: number;
  19755. /** @hidden */
  19756. _vrExclusivePointerMode: boolean;
  19757. /** @hidden */
  19758. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19759. /** @hidden */
  19760. _onVRDisplayPointerRestricted: () => void;
  19761. /** @hidden */
  19762. _onVRDisplayPointerUnrestricted: () => void;
  19763. /** @hidden */
  19764. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19765. /** @hidden */
  19766. _onVrDisplayDisconnect: Nullable<() => void>;
  19767. /** @hidden */
  19768. _onVrDisplayPresentChange: Nullable<() => void>;
  19769. /**
  19770. * Observable signaled when VR display mode changes
  19771. */
  19772. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19773. /**
  19774. * Observable signaled when VR request present is complete
  19775. */
  19776. onVRRequestPresentComplete: Observable<boolean>;
  19777. /**
  19778. * Observable signaled when VR request present starts
  19779. */
  19780. onVRRequestPresentStart: Observable<Engine>;
  19781. /**
  19782. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19783. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19784. */
  19785. isInVRExclusivePointerMode: boolean;
  19786. /**
  19787. * Gets a boolean indicating if a webVR device was detected
  19788. * @returns true if a webVR device was detected
  19789. */
  19790. isVRDevicePresent(): boolean;
  19791. /**
  19792. * Gets the current webVR device
  19793. * @returns the current webVR device (or null)
  19794. */
  19795. getVRDevice(): any;
  19796. /**
  19797. * Initializes a webVR display and starts listening to display change events
  19798. * The onVRDisplayChangedObservable will be notified upon these changes
  19799. * @returns A promise containing a VRDisplay and if vr is supported
  19800. */
  19801. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19802. /** @hidden */
  19803. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19804. /**
  19805. * Gets or sets the presentation attributes used to configure VR rendering
  19806. */
  19807. vrPresentationAttributes?: IVRPresentationAttributes;
  19808. /**
  19809. * Call this function to switch to webVR mode
  19810. * Will do nothing if webVR is not supported or if there is no webVR device
  19811. * @param options the webvr options provided to the camera. mainly used for multiview
  19812. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19813. */
  19814. enableVR(options: WebVROptions): void;
  19815. /** @hidden */
  19816. _onVRFullScreenTriggered(): void;
  19817. }
  19818. }
  19819. }
  19820. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19821. import { Nullable } from "babylonjs/types";
  19822. import { Observable } from "babylonjs/Misc/observable";
  19823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19824. import { Scene } from "babylonjs/scene";
  19825. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19826. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19827. import { Node } from "babylonjs/node";
  19828. import { Ray } from "babylonjs/Culling/ray";
  19829. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19830. import "babylonjs/Engines/Extensions/engine.webVR";
  19831. /**
  19832. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19833. * IMPORTANT!! The data is right-hand data.
  19834. * @export
  19835. * @interface DevicePose
  19836. */
  19837. export interface DevicePose {
  19838. /**
  19839. * The position of the device, values in array are [x,y,z].
  19840. */
  19841. readonly position: Nullable<Float32Array>;
  19842. /**
  19843. * The linearVelocity of the device, values in array are [x,y,z].
  19844. */
  19845. readonly linearVelocity: Nullable<Float32Array>;
  19846. /**
  19847. * The linearAcceleration of the device, values in array are [x,y,z].
  19848. */
  19849. readonly linearAcceleration: Nullable<Float32Array>;
  19850. /**
  19851. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19852. */
  19853. readonly orientation: Nullable<Float32Array>;
  19854. /**
  19855. * The angularVelocity of the device, values in array are [x,y,z].
  19856. */
  19857. readonly angularVelocity: Nullable<Float32Array>;
  19858. /**
  19859. * The angularAcceleration of the device, values in array are [x,y,z].
  19860. */
  19861. readonly angularAcceleration: Nullable<Float32Array>;
  19862. }
  19863. /**
  19864. * Interface representing a pose controlled object in Babylon.
  19865. * A pose controlled object has both regular pose values as well as pose values
  19866. * from an external device such as a VR head mounted display
  19867. */
  19868. export interface PoseControlled {
  19869. /**
  19870. * The position of the object in babylon space.
  19871. */
  19872. position: Vector3;
  19873. /**
  19874. * The rotation quaternion of the object in babylon space.
  19875. */
  19876. rotationQuaternion: Quaternion;
  19877. /**
  19878. * The position of the device in babylon space.
  19879. */
  19880. devicePosition?: Vector3;
  19881. /**
  19882. * The rotation quaternion of the device in babylon space.
  19883. */
  19884. deviceRotationQuaternion: Quaternion;
  19885. /**
  19886. * The raw pose coming from the device.
  19887. */
  19888. rawPose: Nullable<DevicePose>;
  19889. /**
  19890. * The scale of the device to be used when translating from device space to babylon space.
  19891. */
  19892. deviceScaleFactor: number;
  19893. /**
  19894. * Updates the poseControlled values based on the input device pose.
  19895. * @param poseData the pose data to update the object with
  19896. */
  19897. updateFromDevice(poseData: DevicePose): void;
  19898. }
  19899. /**
  19900. * Set of options to customize the webVRCamera
  19901. */
  19902. export interface WebVROptions {
  19903. /**
  19904. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19905. */
  19906. trackPosition?: boolean;
  19907. /**
  19908. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19909. */
  19910. positionScale?: number;
  19911. /**
  19912. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19913. */
  19914. displayName?: string;
  19915. /**
  19916. * Should the native controller meshes be initialized. (default: true)
  19917. */
  19918. controllerMeshes?: boolean;
  19919. /**
  19920. * Creating a default HemiLight only on controllers. (default: true)
  19921. */
  19922. defaultLightingOnControllers?: boolean;
  19923. /**
  19924. * If you don't want to use the default VR button of the helper. (default: false)
  19925. */
  19926. useCustomVRButton?: boolean;
  19927. /**
  19928. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19929. */
  19930. customVRButton?: HTMLButtonElement;
  19931. /**
  19932. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19933. */
  19934. rayLength?: number;
  19935. /**
  19936. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19937. */
  19938. defaultHeight?: number;
  19939. /**
  19940. * If multiview should be used if availible (default: false)
  19941. */
  19942. useMultiview?: boolean;
  19943. }
  19944. /**
  19945. * This represents a WebVR camera.
  19946. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19947. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19948. */
  19949. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19950. private webVROptions;
  19951. /**
  19952. * @hidden
  19953. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19954. */
  19955. _vrDevice: any;
  19956. /**
  19957. * The rawPose of the vrDevice.
  19958. */
  19959. rawPose: Nullable<DevicePose>;
  19960. private _onVREnabled;
  19961. private _specsVersion;
  19962. private _attached;
  19963. private _frameData;
  19964. protected _descendants: Array<Node>;
  19965. private _deviceRoomPosition;
  19966. /** @hidden */
  19967. _deviceRoomRotationQuaternion: Quaternion;
  19968. private _standingMatrix;
  19969. /**
  19970. * Represents device position in babylon space.
  19971. */
  19972. devicePosition: Vector3;
  19973. /**
  19974. * Represents device rotation in babylon space.
  19975. */
  19976. deviceRotationQuaternion: Quaternion;
  19977. /**
  19978. * The scale of the device to be used when translating from device space to babylon space.
  19979. */
  19980. deviceScaleFactor: number;
  19981. private _deviceToWorld;
  19982. private _worldToDevice;
  19983. /**
  19984. * References to the webVR controllers for the vrDevice.
  19985. */
  19986. controllers: Array<WebVRController>;
  19987. /**
  19988. * Emits an event when a controller is attached.
  19989. */
  19990. onControllersAttachedObservable: Observable<WebVRController[]>;
  19991. /**
  19992. * Emits an event when a controller's mesh has been loaded;
  19993. */
  19994. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19995. /**
  19996. * Emits an event when the HMD's pose has been updated.
  19997. */
  19998. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19999. private _poseSet;
  20000. /**
  20001. * If the rig cameras be used as parent instead of this camera.
  20002. */
  20003. rigParenting: boolean;
  20004. private _lightOnControllers;
  20005. private _defaultHeight?;
  20006. /**
  20007. * Instantiates a WebVRFreeCamera.
  20008. * @param name The name of the WebVRFreeCamera
  20009. * @param position The starting anchor position for the camera
  20010. * @param scene The scene the camera belongs to
  20011. * @param webVROptions a set of customizable options for the webVRCamera
  20012. */
  20013. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20014. /**
  20015. * Gets the device distance from the ground in meters.
  20016. * @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.
  20017. */
  20018. deviceDistanceToRoomGround(): number;
  20019. /**
  20020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20021. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20022. */
  20023. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20024. /**
  20025. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20026. * @returns A promise with a boolean set to if the standing matrix is supported.
  20027. */
  20028. useStandingMatrixAsync(): Promise<boolean>;
  20029. /**
  20030. * Disposes the camera
  20031. */
  20032. dispose(): void;
  20033. /**
  20034. * Gets a vrController by name.
  20035. * @param name The name of the controller to retreive
  20036. * @returns the controller matching the name specified or null if not found
  20037. */
  20038. getControllerByName(name: string): Nullable<WebVRController>;
  20039. private _leftController;
  20040. /**
  20041. * The controller corresponding to the users left hand.
  20042. */
  20043. get leftController(): Nullable<WebVRController>;
  20044. private _rightController;
  20045. /**
  20046. * The controller corresponding to the users right hand.
  20047. */
  20048. get rightController(): Nullable<WebVRController>;
  20049. /**
  20050. * Casts a ray forward from the vrCamera's gaze.
  20051. * @param length Length of the ray (default: 100)
  20052. * @returns the ray corresponding to the gaze
  20053. */
  20054. getForwardRay(length?: number): Ray;
  20055. /**
  20056. * @hidden
  20057. * Updates the camera based on device's frame data
  20058. */
  20059. _checkInputs(): void;
  20060. /**
  20061. * Updates the poseControlled values based on the input device pose.
  20062. * @param poseData Pose coming from the device
  20063. */
  20064. updateFromDevice(poseData: DevicePose): void;
  20065. private _htmlElementAttached;
  20066. private _detachIfAttached;
  20067. /**
  20068. * WebVR's attach control will start broadcasting frames to the device.
  20069. * Note that in certain browsers (chrome for example) this function must be called
  20070. * within a user-interaction callback. Example:
  20071. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20072. *
  20073. * @param element html element to attach the vrDevice to
  20074. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20075. */
  20076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20077. /**
  20078. * Detaches the camera from the html element and disables VR
  20079. *
  20080. * @param element html element to detach from
  20081. */
  20082. detachControl(element: HTMLElement): void;
  20083. /**
  20084. * @returns the name of this class
  20085. */
  20086. getClassName(): string;
  20087. /**
  20088. * Calls resetPose on the vrDisplay
  20089. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20090. */
  20091. resetToCurrentRotation(): void;
  20092. /**
  20093. * @hidden
  20094. * Updates the rig cameras (left and right eye)
  20095. */
  20096. _updateRigCameras(): void;
  20097. private _workingVector;
  20098. private _oneVector;
  20099. private _workingMatrix;
  20100. private updateCacheCalled;
  20101. private _correctPositionIfNotTrackPosition;
  20102. /**
  20103. * @hidden
  20104. * Updates the cached values of the camera
  20105. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20106. */
  20107. _updateCache(ignoreParentClass?: boolean): void;
  20108. /**
  20109. * @hidden
  20110. * Get current device position in babylon world
  20111. */
  20112. _computeDevicePosition(): void;
  20113. /**
  20114. * Updates the current device position and rotation in the babylon world
  20115. */
  20116. update(): void;
  20117. /**
  20118. * @hidden
  20119. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20120. * @returns an identity matrix
  20121. */
  20122. _getViewMatrix(): Matrix;
  20123. private _tmpMatrix;
  20124. /**
  20125. * This function is called by the two RIG cameras.
  20126. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20127. * @hidden
  20128. */
  20129. _getWebVRViewMatrix(): Matrix;
  20130. /** @hidden */
  20131. _getWebVRProjectionMatrix(): Matrix;
  20132. private _onGamepadConnectedObserver;
  20133. private _onGamepadDisconnectedObserver;
  20134. private _updateCacheWhenTrackingDisabledObserver;
  20135. /**
  20136. * Initializes the controllers and their meshes
  20137. */
  20138. initControllers(): void;
  20139. }
  20140. }
  20141. declare module "babylonjs/PostProcesses/postProcess" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { SmartArray } from "babylonjs/Misc/smartArray";
  20144. import { Observable } from "babylonjs/Misc/observable";
  20145. import { Vector2 } from "babylonjs/Maths/math.vector";
  20146. import { Camera } from "babylonjs/Cameras/camera";
  20147. import { Effect } from "babylonjs/Materials/effect";
  20148. import "babylonjs/Shaders/postprocess.vertex";
  20149. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20150. import { Engine } from "babylonjs/Engines/engine";
  20151. import { Color4 } from "babylonjs/Maths/math.color";
  20152. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20154. /**
  20155. * Size options for a post process
  20156. */
  20157. export type PostProcessOptions = {
  20158. width: number;
  20159. height: number;
  20160. };
  20161. /**
  20162. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20163. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20164. */
  20165. export class PostProcess {
  20166. /** Name of the PostProcess. */
  20167. name: string;
  20168. /**
  20169. * Gets or sets the unique id of the post process
  20170. */
  20171. uniqueId: number;
  20172. /**
  20173. * Width of the texture to apply the post process on
  20174. */
  20175. width: number;
  20176. /**
  20177. * Height of the texture to apply the post process on
  20178. */
  20179. height: number;
  20180. /**
  20181. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20182. * @hidden
  20183. */
  20184. _outputTexture: Nullable<InternalTexture>;
  20185. /**
  20186. * Sampling mode used by the shader
  20187. * See https://doc.babylonjs.com/classes/3.1/texture
  20188. */
  20189. renderTargetSamplingMode: number;
  20190. /**
  20191. * Clear color to use when screen clearing
  20192. */
  20193. clearColor: Color4;
  20194. /**
  20195. * If the buffer needs to be cleared before applying the post process. (default: true)
  20196. * Should be set to false if shader will overwrite all previous pixels.
  20197. */
  20198. autoClear: boolean;
  20199. /**
  20200. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20201. */
  20202. alphaMode: number;
  20203. /**
  20204. * Sets the setAlphaBlendConstants of the babylon engine
  20205. */
  20206. alphaConstants: Color4;
  20207. /**
  20208. * Animations to be used for the post processing
  20209. */
  20210. animations: import("babylonjs/Animations/animation").Animation[];
  20211. /**
  20212. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20213. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20214. */
  20215. enablePixelPerfectMode: boolean;
  20216. /**
  20217. * Force the postprocess to be applied without taking in account viewport
  20218. */
  20219. forceFullscreenViewport: boolean;
  20220. /**
  20221. * List of inspectable custom properties (used by the Inspector)
  20222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20223. */
  20224. inspectableCustomProperties: IInspectable[];
  20225. /**
  20226. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20227. *
  20228. * | Value | Type | Description |
  20229. * | ----- | ----------------------------------- | ----------- |
  20230. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20231. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20232. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20233. *
  20234. */
  20235. scaleMode: number;
  20236. /**
  20237. * Force textures to be a power of two (default: false)
  20238. */
  20239. alwaysForcePOT: boolean;
  20240. private _samples;
  20241. /**
  20242. * Number of sample textures (default: 1)
  20243. */
  20244. get samples(): number;
  20245. set samples(n: number);
  20246. /**
  20247. * Modify the scale of the post process to be the same as the viewport (default: false)
  20248. */
  20249. adaptScaleToCurrentViewport: boolean;
  20250. private _camera;
  20251. private _scene;
  20252. private _engine;
  20253. private _options;
  20254. private _reusable;
  20255. private _textureType;
  20256. private _textureFormat;
  20257. /**
  20258. * Smart array of input and output textures for the post process.
  20259. * @hidden
  20260. */
  20261. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20262. /**
  20263. * The index in _textures that corresponds to the output texture.
  20264. * @hidden
  20265. */
  20266. _currentRenderTextureInd: number;
  20267. private _effect;
  20268. private _samplers;
  20269. private _fragmentUrl;
  20270. private _vertexUrl;
  20271. private _parameters;
  20272. private _scaleRatio;
  20273. protected _indexParameters: any;
  20274. private _shareOutputWithPostProcess;
  20275. private _texelSize;
  20276. private _forcedOutputTexture;
  20277. /**
  20278. * Returns the fragment url or shader name used in the post process.
  20279. * @returns the fragment url or name in the shader store.
  20280. */
  20281. getEffectName(): string;
  20282. /**
  20283. * An event triggered when the postprocess is activated.
  20284. */
  20285. onActivateObservable: Observable<Camera>;
  20286. private _onActivateObserver;
  20287. /**
  20288. * A function that is added to the onActivateObservable
  20289. */
  20290. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20291. /**
  20292. * An event triggered when the postprocess changes its size.
  20293. */
  20294. onSizeChangedObservable: Observable<PostProcess>;
  20295. private _onSizeChangedObserver;
  20296. /**
  20297. * A function that is added to the onSizeChangedObservable
  20298. */
  20299. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20300. /**
  20301. * An event triggered when the postprocess applies its effect.
  20302. */
  20303. onApplyObservable: Observable<Effect>;
  20304. private _onApplyObserver;
  20305. /**
  20306. * A function that is added to the onApplyObservable
  20307. */
  20308. set onApply(callback: (effect: Effect) => void);
  20309. /**
  20310. * An event triggered before rendering the postprocess
  20311. */
  20312. onBeforeRenderObservable: Observable<Effect>;
  20313. private _onBeforeRenderObserver;
  20314. /**
  20315. * A function that is added to the onBeforeRenderObservable
  20316. */
  20317. set onBeforeRender(callback: (effect: Effect) => void);
  20318. /**
  20319. * An event triggered after rendering the postprocess
  20320. */
  20321. onAfterRenderObservable: Observable<Effect>;
  20322. private _onAfterRenderObserver;
  20323. /**
  20324. * A function that is added to the onAfterRenderObservable
  20325. */
  20326. set onAfterRender(callback: (efect: Effect) => void);
  20327. /**
  20328. * 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
  20329. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20330. */
  20331. get inputTexture(): InternalTexture;
  20332. set inputTexture(value: InternalTexture);
  20333. /**
  20334. * Gets the camera which post process is applied to.
  20335. * @returns The camera the post process is applied to.
  20336. */
  20337. getCamera(): Camera;
  20338. /**
  20339. * Gets the texel size of the postprocess.
  20340. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20341. */
  20342. get texelSize(): Vector2;
  20343. /**
  20344. * Creates a new instance PostProcess
  20345. * @param name The name of the PostProcess.
  20346. * @param fragmentUrl The url of the fragment shader to be used.
  20347. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20348. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20349. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20350. * @param camera The camera to apply the render pass to.
  20351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20352. * @param engine The engine which the post process will be applied. (default: current engine)
  20353. * @param reusable If the post process can be reused on the same frame. (default: false)
  20354. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20355. * @param textureType Type of textures used when performing the post process. (default: 0)
  20356. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20357. * @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
  20358. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20359. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20360. */
  20361. constructor(
  20362. /** Name of the PostProcess. */
  20363. 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);
  20364. /**
  20365. * Gets a string idenfifying the name of the class
  20366. * @returns "PostProcess" string
  20367. */
  20368. getClassName(): string;
  20369. /**
  20370. * Gets the engine which this post process belongs to.
  20371. * @returns The engine the post process was enabled with.
  20372. */
  20373. getEngine(): Engine;
  20374. /**
  20375. * The effect that is created when initializing the post process.
  20376. * @returns The created effect corresponding the the postprocess.
  20377. */
  20378. getEffect(): Effect;
  20379. /**
  20380. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20381. * @param postProcess The post process to share the output with.
  20382. * @returns This post process.
  20383. */
  20384. shareOutputWith(postProcess: PostProcess): PostProcess;
  20385. /**
  20386. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20387. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20388. */
  20389. useOwnOutput(): void;
  20390. /**
  20391. * Updates the effect with the current post process compile time values and recompiles the shader.
  20392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20395. * @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
  20396. * @param onCompiled Called when the shader has been compiled.
  20397. * @param onError Called if there is an error when compiling a shader.
  20398. */
  20399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20400. /**
  20401. * The post process is reusable if it can be used multiple times within one frame.
  20402. * @returns If the post process is reusable
  20403. */
  20404. isReusable(): boolean;
  20405. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20406. markTextureDirty(): void;
  20407. /**
  20408. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20409. * 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.
  20410. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20411. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20412. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20413. * @returns The target texture that was bound to be written to.
  20414. */
  20415. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20416. /**
  20417. * If the post process is supported.
  20418. */
  20419. get isSupported(): boolean;
  20420. /**
  20421. * The aspect ratio of the output texture.
  20422. */
  20423. get aspectRatio(): number;
  20424. /**
  20425. * Get a value indicating if the post-process is ready to be used
  20426. * @returns true if the post-process is ready (shader is compiled)
  20427. */
  20428. isReady(): boolean;
  20429. /**
  20430. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20431. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20432. */
  20433. apply(): Nullable<Effect>;
  20434. private _disposeTextures;
  20435. /**
  20436. * Disposes the post process.
  20437. * @param camera The camera to dispose the post process on.
  20438. */
  20439. dispose(camera?: Camera): void;
  20440. }
  20441. }
  20442. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20443. /** @hidden */
  20444. export var kernelBlurVaryingDeclaration: {
  20445. name: string;
  20446. shader: string;
  20447. };
  20448. }
  20449. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20450. /** @hidden */
  20451. export var kernelBlurFragment: {
  20452. name: string;
  20453. shader: string;
  20454. };
  20455. }
  20456. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20457. /** @hidden */
  20458. export var kernelBlurFragment2: {
  20459. name: string;
  20460. shader: string;
  20461. };
  20462. }
  20463. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20464. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20466. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20467. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20468. /** @hidden */
  20469. export var kernelBlurPixelShader: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20475. /** @hidden */
  20476. export var kernelBlurVertex: {
  20477. name: string;
  20478. shader: string;
  20479. };
  20480. }
  20481. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20482. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20483. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20484. /** @hidden */
  20485. export var kernelBlurVertexShader: {
  20486. name: string;
  20487. shader: string;
  20488. };
  20489. }
  20490. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20491. import { Vector2 } from "babylonjs/Maths/math.vector";
  20492. import { Nullable } from "babylonjs/types";
  20493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20494. import { Camera } from "babylonjs/Cameras/camera";
  20495. import { Effect } from "babylonjs/Materials/effect";
  20496. import { Engine } from "babylonjs/Engines/engine";
  20497. import "babylonjs/Shaders/kernelBlur.fragment";
  20498. import "babylonjs/Shaders/kernelBlur.vertex";
  20499. /**
  20500. * The Blur Post Process which blurs an image based on a kernel and direction.
  20501. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20502. */
  20503. export class BlurPostProcess extends PostProcess {
  20504. /** The direction in which to blur the image. */
  20505. direction: Vector2;
  20506. private blockCompilation;
  20507. protected _kernel: number;
  20508. protected _idealKernel: number;
  20509. protected _packedFloat: boolean;
  20510. private _staticDefines;
  20511. /**
  20512. * Sets the length in pixels of the blur sample region
  20513. */
  20514. set kernel(v: number);
  20515. /**
  20516. * Gets the length in pixels of the blur sample region
  20517. */
  20518. get kernel(): number;
  20519. /**
  20520. * Sets wether or not the blur needs to unpack/repack floats
  20521. */
  20522. set packedFloat(v: boolean);
  20523. /**
  20524. * Gets wether or not the blur is unpacking/repacking floats
  20525. */
  20526. get packedFloat(): boolean;
  20527. /**
  20528. * Creates a new instance BlurPostProcess
  20529. * @param name The name of the effect.
  20530. * @param direction The direction in which to blur the image.
  20531. * @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.
  20532. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20533. * @param camera The camera to apply the render pass to.
  20534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20535. * @param engine The engine which the post process will be applied. (default: current engine)
  20536. * @param reusable If the post process can be reused on the same frame. (default: false)
  20537. * @param textureType Type of textures used when performing the post process. (default: 0)
  20538. * @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)
  20539. */
  20540. constructor(name: string,
  20541. /** The direction in which to blur the image. */
  20542. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20543. /**
  20544. * Updates the effect with the current post process compile time values and recompiles the shader.
  20545. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20546. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20547. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20548. * @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
  20549. * @param onCompiled Called when the shader has been compiled.
  20550. * @param onError Called if there is an error when compiling a shader.
  20551. */
  20552. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20553. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20554. /**
  20555. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20556. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20557. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20558. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20559. * The gaps between physical kernels are compensated for in the weighting of the samples
  20560. * @param idealKernel Ideal blur kernel.
  20561. * @return Nearest best kernel.
  20562. */
  20563. protected _nearestBestKernel(idealKernel: number): number;
  20564. /**
  20565. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20566. * @param x The point on the Gaussian distribution to sample.
  20567. * @return the value of the Gaussian function at x.
  20568. */
  20569. protected _gaussianWeight(x: number): number;
  20570. /**
  20571. * Generates a string that can be used as a floating point number in GLSL.
  20572. * @param x Value to print.
  20573. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20574. * @return GLSL float string.
  20575. */
  20576. protected _glslFloat(x: number, decimalFigures?: number): string;
  20577. }
  20578. }
  20579. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20580. import { Scene } from "babylonjs/scene";
  20581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20582. import { Plane } from "babylonjs/Maths/math.plane";
  20583. /**
  20584. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20585. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20586. * You can then easily use it as a reflectionTexture on a flat surface.
  20587. * In case the surface is not a plane, please consider relying on reflection probes.
  20588. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20589. */
  20590. export class MirrorTexture extends RenderTargetTexture {
  20591. private scene;
  20592. /**
  20593. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20594. * 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.
  20595. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20596. */
  20597. mirrorPlane: Plane;
  20598. /**
  20599. * Define the blur ratio used to blur the reflection if needed.
  20600. */
  20601. set blurRatio(value: number);
  20602. get blurRatio(): number;
  20603. /**
  20604. * Define the adaptive blur kernel used to blur the reflection if needed.
  20605. * This will autocompute the closest best match for the `blurKernel`
  20606. */
  20607. set adaptiveBlurKernel(value: number);
  20608. /**
  20609. * Define the blur kernel used to blur the reflection if needed.
  20610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20611. */
  20612. set blurKernel(value: number);
  20613. /**
  20614. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20616. */
  20617. set blurKernelX(value: number);
  20618. get blurKernelX(): number;
  20619. /**
  20620. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20621. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20622. */
  20623. set blurKernelY(value: number);
  20624. get blurKernelY(): number;
  20625. private _autoComputeBlurKernel;
  20626. protected _onRatioRescale(): void;
  20627. private _updateGammaSpace;
  20628. private _imageProcessingConfigChangeObserver;
  20629. private _transformMatrix;
  20630. private _mirrorMatrix;
  20631. private _savedViewMatrix;
  20632. private _blurX;
  20633. private _blurY;
  20634. private _adaptiveBlurKernel;
  20635. private _blurKernelX;
  20636. private _blurKernelY;
  20637. private _blurRatio;
  20638. /**
  20639. * Instantiates a Mirror Texture.
  20640. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20641. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20642. * You can then easily use it as a reflectionTexture on a flat surface.
  20643. * In case the surface is not a plane, please consider relying on reflection probes.
  20644. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20645. * @param name
  20646. * @param size
  20647. * @param scene
  20648. * @param generateMipMaps
  20649. * @param type
  20650. * @param samplingMode
  20651. * @param generateDepthBuffer
  20652. */
  20653. constructor(name: string, size: number | {
  20654. width: number;
  20655. height: number;
  20656. } | {
  20657. ratio: number;
  20658. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20659. private _preparePostProcesses;
  20660. /**
  20661. * Clone the mirror texture.
  20662. * @returns the cloned texture
  20663. */
  20664. clone(): MirrorTexture;
  20665. /**
  20666. * Serialize the texture to a JSON representation you could use in Parse later on
  20667. * @returns the serialized JSON representation
  20668. */
  20669. serialize(): any;
  20670. /**
  20671. * Dispose the texture and release its associated resources.
  20672. */
  20673. dispose(): void;
  20674. }
  20675. }
  20676. declare module "babylonjs/Materials/Textures/texture" {
  20677. import { Observable } from "babylonjs/Misc/observable";
  20678. import { Nullable } from "babylonjs/types";
  20679. import { Matrix } from "babylonjs/Maths/math.vector";
  20680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20681. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20682. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20683. import { Scene } from "babylonjs/scene";
  20684. /**
  20685. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20686. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20687. */
  20688. export class Texture extends BaseTexture {
  20689. /**
  20690. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20691. */
  20692. static SerializeBuffers: boolean;
  20693. /** @hidden */
  20694. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20695. /** @hidden */
  20696. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20697. /** @hidden */
  20698. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20699. /** nearest is mag = nearest and min = nearest and mip = linear */
  20700. static readonly NEAREST_SAMPLINGMODE: number;
  20701. /** nearest is mag = nearest and min = nearest and mip = linear */
  20702. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20703. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20704. static readonly BILINEAR_SAMPLINGMODE: number;
  20705. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20706. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20707. /** Trilinear is mag = linear and min = linear and mip = linear */
  20708. static readonly TRILINEAR_SAMPLINGMODE: number;
  20709. /** Trilinear is mag = linear and min = linear and mip = linear */
  20710. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20711. /** mag = nearest and min = nearest and mip = nearest */
  20712. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20713. /** mag = nearest and min = linear and mip = nearest */
  20714. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20715. /** mag = nearest and min = linear and mip = linear */
  20716. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20717. /** mag = nearest and min = linear and mip = none */
  20718. static readonly NEAREST_LINEAR: number;
  20719. /** mag = nearest and min = nearest and mip = none */
  20720. static readonly NEAREST_NEAREST: number;
  20721. /** mag = linear and min = nearest and mip = nearest */
  20722. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20723. /** mag = linear and min = nearest and mip = linear */
  20724. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20725. /** mag = linear and min = linear and mip = none */
  20726. static readonly LINEAR_LINEAR: number;
  20727. /** mag = linear and min = nearest and mip = none */
  20728. static readonly LINEAR_NEAREST: number;
  20729. /** Explicit coordinates mode */
  20730. static readonly EXPLICIT_MODE: number;
  20731. /** Spherical coordinates mode */
  20732. static readonly SPHERICAL_MODE: number;
  20733. /** Planar coordinates mode */
  20734. static readonly PLANAR_MODE: number;
  20735. /** Cubic coordinates mode */
  20736. static readonly CUBIC_MODE: number;
  20737. /** Projection coordinates mode */
  20738. static readonly PROJECTION_MODE: number;
  20739. /** Inverse Cubic coordinates mode */
  20740. static readonly SKYBOX_MODE: number;
  20741. /** Inverse Cubic coordinates mode */
  20742. static readonly INVCUBIC_MODE: number;
  20743. /** Equirectangular coordinates mode */
  20744. static readonly EQUIRECTANGULAR_MODE: number;
  20745. /** Equirectangular Fixed coordinates mode */
  20746. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20747. /** Equirectangular Fixed Mirrored coordinates mode */
  20748. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20749. /** Texture is not repeating outside of 0..1 UVs */
  20750. static readonly CLAMP_ADDRESSMODE: number;
  20751. /** Texture is repeating outside of 0..1 UVs */
  20752. static readonly WRAP_ADDRESSMODE: number;
  20753. /** Texture is repeating and mirrored */
  20754. static readonly MIRROR_ADDRESSMODE: number;
  20755. /**
  20756. * 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
  20757. */
  20758. static UseSerializedUrlIfAny: boolean;
  20759. /**
  20760. * Define the url of the texture.
  20761. */
  20762. url: Nullable<string>;
  20763. /**
  20764. * Define an offset on the texture to offset the u coordinates of the UVs
  20765. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20766. */
  20767. uOffset: number;
  20768. /**
  20769. * Define an offset on the texture to offset the v coordinates of the UVs
  20770. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20771. */
  20772. vOffset: number;
  20773. /**
  20774. * Define an offset on the texture to scale the u coordinates of the UVs
  20775. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20776. */
  20777. uScale: number;
  20778. /**
  20779. * Define an offset on the texture to scale the v coordinates of the UVs
  20780. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20781. */
  20782. vScale: number;
  20783. /**
  20784. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20785. * @see http://doc.babylonjs.com/how_to/more_materials
  20786. */
  20787. uAng: number;
  20788. /**
  20789. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20790. * @see http://doc.babylonjs.com/how_to/more_materials
  20791. */
  20792. vAng: number;
  20793. /**
  20794. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20795. * @see http://doc.babylonjs.com/how_to/more_materials
  20796. */
  20797. wAng: number;
  20798. /**
  20799. * Defines the center of rotation (U)
  20800. */
  20801. uRotationCenter: number;
  20802. /**
  20803. * Defines the center of rotation (V)
  20804. */
  20805. vRotationCenter: number;
  20806. /**
  20807. * Defines the center of rotation (W)
  20808. */
  20809. wRotationCenter: number;
  20810. /**
  20811. * Are mip maps generated for this texture or not.
  20812. */
  20813. get noMipmap(): boolean;
  20814. /**
  20815. * List of inspectable custom properties (used by the Inspector)
  20816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20817. */
  20818. inspectableCustomProperties: Nullable<IInspectable[]>;
  20819. private _noMipmap;
  20820. /** @hidden */
  20821. _invertY: boolean;
  20822. private _rowGenerationMatrix;
  20823. private _cachedTextureMatrix;
  20824. private _projectionModeMatrix;
  20825. private _t0;
  20826. private _t1;
  20827. private _t2;
  20828. private _cachedUOffset;
  20829. private _cachedVOffset;
  20830. private _cachedUScale;
  20831. private _cachedVScale;
  20832. private _cachedUAng;
  20833. private _cachedVAng;
  20834. private _cachedWAng;
  20835. private _cachedProjectionMatrixId;
  20836. private _cachedCoordinatesMode;
  20837. /** @hidden */
  20838. protected _initialSamplingMode: number;
  20839. /** @hidden */
  20840. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20841. private _deleteBuffer;
  20842. protected _format: Nullable<number>;
  20843. private _delayedOnLoad;
  20844. private _delayedOnError;
  20845. private _mimeType?;
  20846. /**
  20847. * Observable triggered once the texture has been loaded.
  20848. */
  20849. onLoadObservable: Observable<Texture>;
  20850. protected _isBlocking: boolean;
  20851. /**
  20852. * Is the texture preventing material to render while loading.
  20853. * If false, a default texture will be used instead of the loading one during the preparation step.
  20854. */
  20855. set isBlocking(value: boolean);
  20856. get isBlocking(): boolean;
  20857. /**
  20858. * Get the current sampling mode associated with the texture.
  20859. */
  20860. get samplingMode(): number;
  20861. /**
  20862. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20863. */
  20864. get invertY(): boolean;
  20865. /**
  20866. * Instantiates a new texture.
  20867. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20868. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20869. * @param url defines the url of the picture to load as a texture
  20870. * @param scene defines the scene or engine the texture will belong to
  20871. * @param noMipmap defines if the texture will require mip maps or not
  20872. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20873. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20874. * @param onLoad defines a callback triggered when the texture has been loaded
  20875. * @param onError defines a callback triggered when an error occurred during the loading session
  20876. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20877. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20878. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20879. * @param mimeType defines an optional mime type information
  20880. */
  20881. 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);
  20882. /**
  20883. * Update the url (and optional buffer) of this texture if url was null during construction.
  20884. * @param url the url of the texture
  20885. * @param buffer the buffer of the texture (defaults to null)
  20886. * @param onLoad callback called when the texture is loaded (defaults to null)
  20887. */
  20888. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20889. /**
  20890. * Finish the loading sequence of a texture flagged as delayed load.
  20891. * @hidden
  20892. */
  20893. delayLoad(): void;
  20894. private _prepareRowForTextureGeneration;
  20895. /**
  20896. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20897. * @returns the transform matrix of the texture.
  20898. */
  20899. getTextureMatrix(uBase?: number): Matrix;
  20900. /**
  20901. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20902. * @returns The reflection texture transform
  20903. */
  20904. getReflectionTextureMatrix(): Matrix;
  20905. /**
  20906. * Clones the texture.
  20907. * @returns the cloned texture
  20908. */
  20909. clone(): Texture;
  20910. /**
  20911. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20912. * @returns The JSON representation of the texture
  20913. */
  20914. serialize(): any;
  20915. /**
  20916. * Get the current class name of the texture useful for serialization or dynamic coding.
  20917. * @returns "Texture"
  20918. */
  20919. getClassName(): string;
  20920. /**
  20921. * Dispose the texture and release its associated resources.
  20922. */
  20923. dispose(): void;
  20924. /**
  20925. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20926. * @param parsedTexture Define the JSON representation of the texture
  20927. * @param scene Define the scene the parsed texture should be instantiated in
  20928. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20929. * @returns The parsed texture if successful
  20930. */
  20931. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20932. /**
  20933. * Creates a texture from its base 64 representation.
  20934. * @param data Define the base64 payload without the data: prefix
  20935. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20936. * @param scene Define the scene the texture should belong to
  20937. * @param noMipmap Forces the texture to not create mip map information if true
  20938. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20939. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20940. * @param onLoad define a callback triggered when the texture has been loaded
  20941. * @param onError define a callback triggered when an error occurred during the loading session
  20942. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20943. * @returns the created texture
  20944. */
  20945. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20946. /**
  20947. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20948. * @param data Define the base64 payload without the data: prefix
  20949. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20950. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20951. * @param scene Define the scene the texture should belong to
  20952. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20953. * @param noMipmap Forces the texture to not create mip map information if true
  20954. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20955. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20956. * @param onLoad define a callback triggered when the texture has been loaded
  20957. * @param onError define a callback triggered when an error occurred during the loading session
  20958. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20959. * @returns the created texture
  20960. */
  20961. 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;
  20962. }
  20963. }
  20964. declare module "babylonjs/PostProcesses/postProcessManager" {
  20965. import { Nullable } from "babylonjs/types";
  20966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20968. import { Scene } from "babylonjs/scene";
  20969. /**
  20970. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20971. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20972. */
  20973. export class PostProcessManager {
  20974. private _scene;
  20975. private _indexBuffer;
  20976. private _vertexBuffers;
  20977. /**
  20978. * Creates a new instance PostProcess
  20979. * @param scene The scene that the post process is associated with.
  20980. */
  20981. constructor(scene: Scene);
  20982. private _prepareBuffers;
  20983. private _buildIndexBuffer;
  20984. /**
  20985. * Rebuilds the vertex buffers of the manager.
  20986. * @hidden
  20987. */
  20988. _rebuild(): void;
  20989. /**
  20990. * Prepares a frame to be run through a post process.
  20991. * @param sourceTexture The input texture to the post procesess. (default: null)
  20992. * @param postProcesses An array of post processes to be run. (default: null)
  20993. * @returns True if the post processes were able to be run.
  20994. * @hidden
  20995. */
  20996. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20997. /**
  20998. * Manually render a set of post processes to a texture.
  20999. * @param postProcesses An array of post processes to be run.
  21000. * @param targetTexture The target texture to render to.
  21001. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21002. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21003. * @param lodLevel defines which lod of the texture to render to
  21004. */
  21005. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21006. /**
  21007. * Finalize the result of the output of the postprocesses.
  21008. * @param doNotPresent If true the result will not be displayed to the screen.
  21009. * @param targetTexture The target texture to render to.
  21010. * @param faceIndex The index of the face to bind the target texture to.
  21011. * @param postProcesses The array of post processes to render.
  21012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21013. * @hidden
  21014. */
  21015. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21016. /**
  21017. * Disposes of the post process manager.
  21018. */
  21019. dispose(): void;
  21020. }
  21021. }
  21022. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21023. import { Observable } from "babylonjs/Misc/observable";
  21024. import { SmartArray } from "babylonjs/Misc/smartArray";
  21025. import { Nullable, Immutable } from "babylonjs/types";
  21026. import { Camera } from "babylonjs/Cameras/camera";
  21027. import { Scene } from "babylonjs/scene";
  21028. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21029. import { Color4 } from "babylonjs/Maths/math.color";
  21030. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21034. import { Texture } from "babylonjs/Materials/Textures/texture";
  21035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21036. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21037. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21038. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21039. import { Engine } from "babylonjs/Engines/engine";
  21040. /**
  21041. * This Helps creating a texture that will be created from a camera in your scene.
  21042. * It is basically a dynamic texture that could be used to create special effects for instance.
  21043. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21044. */
  21045. export class RenderTargetTexture extends Texture {
  21046. isCube: boolean;
  21047. /**
  21048. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21049. */
  21050. static readonly REFRESHRATE_RENDER_ONCE: number;
  21051. /**
  21052. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21053. */
  21054. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21055. /**
  21056. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21057. * the central point of your effect and can save a lot of performances.
  21058. */
  21059. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21060. /**
  21061. * Use this predicate to dynamically define the list of mesh you want to render.
  21062. * If set, the renderList property will be overwritten.
  21063. */
  21064. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21065. private _renderList;
  21066. /**
  21067. * Use this list to define the list of mesh you want to render.
  21068. */
  21069. get renderList(): Nullable<Array<AbstractMesh>>;
  21070. set renderList(value: Nullable<Array<AbstractMesh>>);
  21071. /**
  21072. * Use this function to overload the renderList array at rendering time.
  21073. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21074. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21075. * the cube (if the RTT is a cube, else layerOrFace=0).
  21076. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21077. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21078. * hold dummy elements!
  21079. */
  21080. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21081. private _hookArray;
  21082. /**
  21083. * Define if particles should be rendered in your texture.
  21084. */
  21085. renderParticles: boolean;
  21086. /**
  21087. * Define if sprites should be rendered in your texture.
  21088. */
  21089. renderSprites: boolean;
  21090. /**
  21091. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21092. */
  21093. coordinatesMode: number;
  21094. /**
  21095. * Define the camera used to render the texture.
  21096. */
  21097. activeCamera: Nullable<Camera>;
  21098. /**
  21099. * Override the render function of the texture with your own one.
  21100. */
  21101. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21102. /**
  21103. * Define if camera post processes should be use while rendering the texture.
  21104. */
  21105. useCameraPostProcesses: boolean;
  21106. /**
  21107. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21108. */
  21109. ignoreCameraViewport: boolean;
  21110. private _postProcessManager;
  21111. private _postProcesses;
  21112. private _resizeObserver;
  21113. /**
  21114. * An event triggered when the texture is unbind.
  21115. */
  21116. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21117. /**
  21118. * An event triggered when the texture is unbind.
  21119. */
  21120. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21121. private _onAfterUnbindObserver;
  21122. /**
  21123. * Set a after unbind callback in the texture.
  21124. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21125. */
  21126. set onAfterUnbind(callback: () => void);
  21127. /**
  21128. * An event triggered before rendering the texture
  21129. */
  21130. onBeforeRenderObservable: Observable<number>;
  21131. private _onBeforeRenderObserver;
  21132. /**
  21133. * Set a before render callback in the texture.
  21134. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21135. */
  21136. set onBeforeRender(callback: (faceIndex: number) => void);
  21137. /**
  21138. * An event triggered after rendering the texture
  21139. */
  21140. onAfterRenderObservable: Observable<number>;
  21141. private _onAfterRenderObserver;
  21142. /**
  21143. * Set a after render callback in the texture.
  21144. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21145. */
  21146. set onAfterRender(callback: (faceIndex: number) => void);
  21147. /**
  21148. * An event triggered after the texture clear
  21149. */
  21150. onClearObservable: Observable<Engine>;
  21151. private _onClearObserver;
  21152. /**
  21153. * Set a clear callback in the texture.
  21154. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21155. */
  21156. set onClear(callback: (Engine: Engine) => void);
  21157. /**
  21158. * An event triggered when the texture is resized.
  21159. */
  21160. onResizeObservable: Observable<RenderTargetTexture>;
  21161. /**
  21162. * Define the clear color of the Render Target if it should be different from the scene.
  21163. */
  21164. clearColor: Color4;
  21165. protected _size: number | {
  21166. width: number;
  21167. height: number;
  21168. layers?: number;
  21169. };
  21170. protected _initialSizeParameter: number | {
  21171. width: number;
  21172. height: number;
  21173. } | {
  21174. ratio: number;
  21175. };
  21176. protected _sizeRatio: Nullable<number>;
  21177. /** @hidden */
  21178. _generateMipMaps: boolean;
  21179. protected _renderingManager: RenderingManager;
  21180. /** @hidden */
  21181. _waitingRenderList: string[];
  21182. protected _doNotChangeAspectRatio: boolean;
  21183. protected _currentRefreshId: number;
  21184. protected _refreshRate: number;
  21185. protected _textureMatrix: Matrix;
  21186. protected _samples: number;
  21187. protected _renderTargetOptions: RenderTargetCreationOptions;
  21188. /**
  21189. * Gets render target creation options that were used.
  21190. */
  21191. get renderTargetOptions(): RenderTargetCreationOptions;
  21192. protected _engine: Engine;
  21193. protected _onRatioRescale(): void;
  21194. /**
  21195. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21196. * It must define where the camera used to render the texture is set
  21197. */
  21198. boundingBoxPosition: Vector3;
  21199. private _boundingBoxSize;
  21200. /**
  21201. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21202. * When defined, the cubemap will switch to local mode
  21203. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21204. * @example https://www.babylonjs-playground.com/#RNASML
  21205. */
  21206. set boundingBoxSize(value: Vector3);
  21207. get boundingBoxSize(): Vector3;
  21208. /**
  21209. * In case the RTT has been created with a depth texture, get the associated
  21210. * depth texture.
  21211. * Otherwise, return null.
  21212. */
  21213. get depthStencilTexture(): Nullable<InternalTexture>;
  21214. /**
  21215. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21216. * or used a shadow, depth texture...
  21217. * @param name The friendly name of the texture
  21218. * @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)
  21219. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21220. * @param generateMipMaps True if mip maps need to be generated after render.
  21221. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21222. * @param type The type of the buffer in the RTT (int, half float, float...)
  21223. * @param isCube True if a cube texture needs to be created
  21224. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21225. * @param generateDepthBuffer True to generate a depth buffer
  21226. * @param generateStencilBuffer True to generate a stencil buffer
  21227. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21228. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21229. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21230. */
  21231. constructor(name: string, size: number | {
  21232. width: number;
  21233. height: number;
  21234. layers?: number;
  21235. } | {
  21236. ratio: number;
  21237. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21238. /**
  21239. * Creates a depth stencil texture.
  21240. * This is only available in WebGL 2 or with the depth texture extension available.
  21241. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21242. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21243. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21244. */
  21245. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21246. private _processSizeParameter;
  21247. /**
  21248. * Define the number of samples to use in case of MSAA.
  21249. * It defaults to one meaning no MSAA has been enabled.
  21250. */
  21251. get samples(): number;
  21252. set samples(value: number);
  21253. /**
  21254. * Resets the refresh counter of the texture and start bak from scratch.
  21255. * Could be useful to regenerate the texture if it is setup to render only once.
  21256. */
  21257. resetRefreshCounter(): void;
  21258. /**
  21259. * Define the refresh rate of the texture or the rendering frequency.
  21260. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21261. */
  21262. get refreshRate(): number;
  21263. set refreshRate(value: number);
  21264. /**
  21265. * Adds a post process to the render target rendering passes.
  21266. * @param postProcess define the post process to add
  21267. */
  21268. addPostProcess(postProcess: PostProcess): void;
  21269. /**
  21270. * Clear all the post processes attached to the render target
  21271. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21272. */
  21273. clearPostProcesses(dispose?: boolean): void;
  21274. /**
  21275. * Remove one of the post process from the list of attached post processes to the texture
  21276. * @param postProcess define the post process to remove from the list
  21277. */
  21278. removePostProcess(postProcess: PostProcess): void;
  21279. /** @hidden */
  21280. _shouldRender(): boolean;
  21281. /**
  21282. * Gets the actual render size of the texture.
  21283. * @returns the width of the render size
  21284. */
  21285. getRenderSize(): number;
  21286. /**
  21287. * Gets the actual render width of the texture.
  21288. * @returns the width of the render size
  21289. */
  21290. getRenderWidth(): number;
  21291. /**
  21292. * Gets the actual render height of the texture.
  21293. * @returns the height of the render size
  21294. */
  21295. getRenderHeight(): number;
  21296. /**
  21297. * Gets the actual number of layers of the texture.
  21298. * @returns the number of layers
  21299. */
  21300. getRenderLayers(): number;
  21301. /**
  21302. * Get if the texture can be rescaled or not.
  21303. */
  21304. get canRescale(): boolean;
  21305. /**
  21306. * Resize the texture using a ratio.
  21307. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21308. */
  21309. scale(ratio: number): void;
  21310. /**
  21311. * Get the texture reflection matrix used to rotate/transform the reflection.
  21312. * @returns the reflection matrix
  21313. */
  21314. getReflectionTextureMatrix(): Matrix;
  21315. /**
  21316. * Resize the texture to a new desired size.
  21317. * Be carrefull as it will recreate all the data in the new texture.
  21318. * @param size Define the new size. It can be:
  21319. * - a number for squared texture,
  21320. * - an object containing { width: number, height: number }
  21321. * - or an object containing a ratio { ratio: number }
  21322. */
  21323. resize(size: number | {
  21324. width: number;
  21325. height: number;
  21326. } | {
  21327. ratio: number;
  21328. }): void;
  21329. private _defaultRenderListPrepared;
  21330. /**
  21331. * Renders all the objects from the render list into the texture.
  21332. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21333. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21334. */
  21335. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21336. private _bestReflectionRenderTargetDimension;
  21337. private _prepareRenderingManager;
  21338. /**
  21339. * @hidden
  21340. * @param faceIndex face index to bind to if this is a cubetexture
  21341. * @param layer defines the index of the texture to bind in the array
  21342. */
  21343. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21344. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21345. private renderToTarget;
  21346. /**
  21347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21348. * This allowed control for front to back rendering or reversly depending of the special needs.
  21349. *
  21350. * @param renderingGroupId The rendering group id corresponding to its index
  21351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21354. */
  21355. 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;
  21356. /**
  21357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21358. *
  21359. * @param renderingGroupId The rendering group id corresponding to its index
  21360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21361. */
  21362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21363. /**
  21364. * Clones the texture.
  21365. * @returns the cloned texture
  21366. */
  21367. clone(): RenderTargetTexture;
  21368. /**
  21369. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21370. * @returns The JSON representation of the texture
  21371. */
  21372. serialize(): any;
  21373. /**
  21374. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21375. */
  21376. disposeFramebufferObjects(): void;
  21377. /**
  21378. * Dispose the texture and release its associated resources.
  21379. */
  21380. dispose(): void;
  21381. /** @hidden */
  21382. _rebuild(): void;
  21383. /**
  21384. * Clear the info related to rendering groups preventing retention point in material dispose.
  21385. */
  21386. freeRenderingGroups(): void;
  21387. /**
  21388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21389. * @returns the view count
  21390. */
  21391. getViewCount(): number;
  21392. }
  21393. }
  21394. declare module "babylonjs/Materials/material" {
  21395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21396. import { SmartArray } from "babylonjs/Misc/smartArray";
  21397. import { Observable } from "babylonjs/Misc/observable";
  21398. import { Nullable } from "babylonjs/types";
  21399. import { Scene } from "babylonjs/scene";
  21400. import { Matrix } from "babylonjs/Maths/math.vector";
  21401. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21404. import { Effect } from "babylonjs/Materials/effect";
  21405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21407. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21408. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21409. import { Mesh } from "babylonjs/Meshes/mesh";
  21410. import { Animation } from "babylonjs/Animations/animation";
  21411. /**
  21412. * Options for compiling materials.
  21413. */
  21414. export interface IMaterialCompilationOptions {
  21415. /**
  21416. * Defines whether clip planes are enabled.
  21417. */
  21418. clipPlane: boolean;
  21419. /**
  21420. * Defines whether instances are enabled.
  21421. */
  21422. useInstances: boolean;
  21423. }
  21424. /**
  21425. * Base class for the main features of a material in Babylon.js
  21426. */
  21427. export class Material implements IAnimatable {
  21428. /**
  21429. * Returns the triangle fill mode
  21430. */
  21431. static readonly TriangleFillMode: number;
  21432. /**
  21433. * Returns the wireframe mode
  21434. */
  21435. static readonly WireFrameFillMode: number;
  21436. /**
  21437. * Returns the point fill mode
  21438. */
  21439. static readonly PointFillMode: number;
  21440. /**
  21441. * Returns the point list draw mode
  21442. */
  21443. static readonly PointListDrawMode: number;
  21444. /**
  21445. * Returns the line list draw mode
  21446. */
  21447. static readonly LineListDrawMode: number;
  21448. /**
  21449. * Returns the line loop draw mode
  21450. */
  21451. static readonly LineLoopDrawMode: number;
  21452. /**
  21453. * Returns the line strip draw mode
  21454. */
  21455. static readonly LineStripDrawMode: number;
  21456. /**
  21457. * Returns the triangle strip draw mode
  21458. */
  21459. static readonly TriangleStripDrawMode: number;
  21460. /**
  21461. * Returns the triangle fan draw mode
  21462. */
  21463. static readonly TriangleFanDrawMode: number;
  21464. /**
  21465. * Stores the clock-wise side orientation
  21466. */
  21467. static readonly ClockWiseSideOrientation: number;
  21468. /**
  21469. * Stores the counter clock-wise side orientation
  21470. */
  21471. static readonly CounterClockWiseSideOrientation: number;
  21472. /**
  21473. * The dirty texture flag value
  21474. */
  21475. static readonly TextureDirtyFlag: number;
  21476. /**
  21477. * The dirty light flag value
  21478. */
  21479. static readonly LightDirtyFlag: number;
  21480. /**
  21481. * The dirty fresnel flag value
  21482. */
  21483. static readonly FresnelDirtyFlag: number;
  21484. /**
  21485. * The dirty attribute flag value
  21486. */
  21487. static readonly AttributesDirtyFlag: number;
  21488. /**
  21489. * The dirty misc flag value
  21490. */
  21491. static readonly MiscDirtyFlag: number;
  21492. /**
  21493. * The all dirty flag value
  21494. */
  21495. static readonly AllDirtyFlag: number;
  21496. /**
  21497. * The ID of the material
  21498. */
  21499. id: string;
  21500. /**
  21501. * Gets or sets the unique id of the material
  21502. */
  21503. uniqueId: number;
  21504. /**
  21505. * The name of the material
  21506. */
  21507. name: string;
  21508. /**
  21509. * Gets or sets user defined metadata
  21510. */
  21511. metadata: any;
  21512. /**
  21513. * For internal use only. Please do not use.
  21514. */
  21515. reservedDataStore: any;
  21516. /**
  21517. * Specifies if the ready state should be checked on each call
  21518. */
  21519. checkReadyOnEveryCall: boolean;
  21520. /**
  21521. * Specifies if the ready state should be checked once
  21522. */
  21523. checkReadyOnlyOnce: boolean;
  21524. /**
  21525. * The state of the material
  21526. */
  21527. state: string;
  21528. /**
  21529. * The alpha value of the material
  21530. */
  21531. protected _alpha: number;
  21532. /**
  21533. * List of inspectable custom properties (used by the Inspector)
  21534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21535. */
  21536. inspectableCustomProperties: IInspectable[];
  21537. /**
  21538. * Sets the alpha value of the material
  21539. */
  21540. set alpha(value: number);
  21541. /**
  21542. * Gets the alpha value of the material
  21543. */
  21544. get alpha(): number;
  21545. /**
  21546. * Specifies if back face culling is enabled
  21547. */
  21548. protected _backFaceCulling: boolean;
  21549. /**
  21550. * Sets the back-face culling state
  21551. */
  21552. set backFaceCulling(value: boolean);
  21553. /**
  21554. * Gets the back-face culling state
  21555. */
  21556. get backFaceCulling(): boolean;
  21557. /**
  21558. * Stores the value for side orientation
  21559. */
  21560. sideOrientation: number;
  21561. /**
  21562. * Callback triggered when the material is compiled
  21563. */
  21564. onCompiled: Nullable<(effect: Effect) => void>;
  21565. /**
  21566. * Callback triggered when an error occurs
  21567. */
  21568. onError: Nullable<(effect: Effect, errors: string) => void>;
  21569. /**
  21570. * Callback triggered to get the render target textures
  21571. */
  21572. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21573. /**
  21574. * Gets a boolean indicating that current material needs to register RTT
  21575. */
  21576. get hasRenderTargetTextures(): boolean;
  21577. /**
  21578. * Specifies if the material should be serialized
  21579. */
  21580. doNotSerialize: boolean;
  21581. /**
  21582. * @hidden
  21583. */
  21584. _storeEffectOnSubMeshes: boolean;
  21585. /**
  21586. * Stores the animations for the material
  21587. */
  21588. animations: Nullable<Array<Animation>>;
  21589. /**
  21590. * An event triggered when the material is disposed
  21591. */
  21592. onDisposeObservable: Observable<Material>;
  21593. /**
  21594. * An observer which watches for dispose events
  21595. */
  21596. private _onDisposeObserver;
  21597. private _onUnBindObservable;
  21598. /**
  21599. * Called during a dispose event
  21600. */
  21601. set onDispose(callback: () => void);
  21602. private _onBindObservable;
  21603. /**
  21604. * An event triggered when the material is bound
  21605. */
  21606. get onBindObservable(): Observable<AbstractMesh>;
  21607. /**
  21608. * An observer which watches for bind events
  21609. */
  21610. private _onBindObserver;
  21611. /**
  21612. * Called during a bind event
  21613. */
  21614. set onBind(callback: (Mesh: AbstractMesh) => void);
  21615. /**
  21616. * An event triggered when the material is unbound
  21617. */
  21618. get onUnBindObservable(): Observable<Material>;
  21619. /**
  21620. * Stores the value of the alpha mode
  21621. */
  21622. private _alphaMode;
  21623. /**
  21624. * Sets the value of the alpha mode.
  21625. *
  21626. * | Value | Type | Description |
  21627. * | --- | --- | --- |
  21628. * | 0 | ALPHA_DISABLE | |
  21629. * | 1 | ALPHA_ADD | |
  21630. * | 2 | ALPHA_COMBINE | |
  21631. * | 3 | ALPHA_SUBTRACT | |
  21632. * | 4 | ALPHA_MULTIPLY | |
  21633. * | 5 | ALPHA_MAXIMIZED | |
  21634. * | 6 | ALPHA_ONEONE | |
  21635. * | 7 | ALPHA_PREMULTIPLIED | |
  21636. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21637. * | 9 | ALPHA_INTERPOLATE | |
  21638. * | 10 | ALPHA_SCREENMODE | |
  21639. *
  21640. */
  21641. set alphaMode(value: number);
  21642. /**
  21643. * Gets the value of the alpha mode
  21644. */
  21645. get alphaMode(): number;
  21646. /**
  21647. * Stores the state of the need depth pre-pass value
  21648. */
  21649. private _needDepthPrePass;
  21650. /**
  21651. * Sets the need depth pre-pass value
  21652. */
  21653. set needDepthPrePass(value: boolean);
  21654. /**
  21655. * Gets the depth pre-pass value
  21656. */
  21657. get needDepthPrePass(): boolean;
  21658. /**
  21659. * Specifies if depth writing should be disabled
  21660. */
  21661. disableDepthWrite: boolean;
  21662. /**
  21663. * Specifies if depth writing should be forced
  21664. */
  21665. forceDepthWrite: boolean;
  21666. /**
  21667. * Specifies the depth function that should be used. 0 means the default engine function
  21668. */
  21669. depthFunction: number;
  21670. /**
  21671. * Specifies if there should be a separate pass for culling
  21672. */
  21673. separateCullingPass: boolean;
  21674. /**
  21675. * Stores the state specifing if fog should be enabled
  21676. */
  21677. private _fogEnabled;
  21678. /**
  21679. * Sets the state for enabling fog
  21680. */
  21681. set fogEnabled(value: boolean);
  21682. /**
  21683. * Gets the value of the fog enabled state
  21684. */
  21685. get fogEnabled(): boolean;
  21686. /**
  21687. * Stores the size of points
  21688. */
  21689. pointSize: number;
  21690. /**
  21691. * Stores the z offset value
  21692. */
  21693. zOffset: number;
  21694. /**
  21695. * Gets a value specifying if wireframe mode is enabled
  21696. */
  21697. get wireframe(): boolean;
  21698. /**
  21699. * Sets the state of wireframe mode
  21700. */
  21701. set wireframe(value: boolean);
  21702. /**
  21703. * Gets the value specifying if point clouds are enabled
  21704. */
  21705. get pointsCloud(): boolean;
  21706. /**
  21707. * Sets the state of point cloud mode
  21708. */
  21709. set pointsCloud(value: boolean);
  21710. /**
  21711. * Gets the material fill mode
  21712. */
  21713. get fillMode(): number;
  21714. /**
  21715. * Sets the material fill mode
  21716. */
  21717. set fillMode(value: number);
  21718. /**
  21719. * @hidden
  21720. * Stores the effects for the material
  21721. */
  21722. _effect: Nullable<Effect>;
  21723. /**
  21724. * Specifies if uniform buffers should be used
  21725. */
  21726. private _useUBO;
  21727. /**
  21728. * Stores a reference to the scene
  21729. */
  21730. private _scene;
  21731. /**
  21732. * Stores the fill mode state
  21733. */
  21734. private _fillMode;
  21735. /**
  21736. * Specifies if the depth write state should be cached
  21737. */
  21738. private _cachedDepthWriteState;
  21739. /**
  21740. * Specifies if the depth function state should be cached
  21741. */
  21742. private _cachedDepthFunctionState;
  21743. /**
  21744. * Stores the uniform buffer
  21745. */
  21746. protected _uniformBuffer: UniformBuffer;
  21747. /** @hidden */
  21748. _indexInSceneMaterialArray: number;
  21749. /** @hidden */
  21750. meshMap: Nullable<{
  21751. [id: string]: AbstractMesh | undefined;
  21752. }>;
  21753. /**
  21754. * Creates a material instance
  21755. * @param name defines the name of the material
  21756. * @param scene defines the scene to reference
  21757. * @param doNotAdd specifies if the material should be added to the scene
  21758. */
  21759. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21760. /**
  21761. * Returns a string representation of the current material
  21762. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21763. * @returns a string with material information
  21764. */
  21765. toString(fullDetails?: boolean): string;
  21766. /**
  21767. * Gets the class name of the material
  21768. * @returns a string with the class name of the material
  21769. */
  21770. getClassName(): string;
  21771. /**
  21772. * Specifies if updates for the material been locked
  21773. */
  21774. get isFrozen(): boolean;
  21775. /**
  21776. * Locks updates for the material
  21777. */
  21778. freeze(): void;
  21779. /**
  21780. * Unlocks updates for the material
  21781. */
  21782. unfreeze(): void;
  21783. /**
  21784. * Specifies if the material is ready to be used
  21785. * @param mesh defines the mesh to check
  21786. * @param useInstances specifies if instances should be used
  21787. * @returns a boolean indicating if the material is ready to be used
  21788. */
  21789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21790. /**
  21791. * Specifies that the submesh is ready to be used
  21792. * @param mesh defines the mesh to check
  21793. * @param subMesh defines which submesh to check
  21794. * @param useInstances specifies that instances should be used
  21795. * @returns a boolean indicating that the submesh is ready or not
  21796. */
  21797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21798. /**
  21799. * Returns the material effect
  21800. * @returns the effect associated with the material
  21801. */
  21802. getEffect(): Nullable<Effect>;
  21803. /**
  21804. * Returns the current scene
  21805. * @returns a Scene
  21806. */
  21807. getScene(): Scene;
  21808. /**
  21809. * Specifies if the material will require alpha blending
  21810. * @returns a boolean specifying if alpha blending is needed
  21811. */
  21812. needAlphaBlending(): boolean;
  21813. /**
  21814. * Specifies if the mesh will require alpha blending
  21815. * @param mesh defines the mesh to check
  21816. * @returns a boolean specifying if alpha blending is needed for the mesh
  21817. */
  21818. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21819. /**
  21820. * Specifies if this material should be rendered in alpha test mode
  21821. * @returns a boolean specifying if an alpha test is needed.
  21822. */
  21823. needAlphaTesting(): boolean;
  21824. /**
  21825. * Gets the texture used for the alpha test
  21826. * @returns the texture to use for alpha testing
  21827. */
  21828. getAlphaTestTexture(): Nullable<BaseTexture>;
  21829. /**
  21830. * Marks the material to indicate that it needs to be re-calculated
  21831. */
  21832. markDirty(): void;
  21833. /** @hidden */
  21834. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21835. /**
  21836. * Binds the material to the mesh
  21837. * @param world defines the world transformation matrix
  21838. * @param mesh defines the mesh to bind the material to
  21839. */
  21840. bind(world: Matrix, mesh?: Mesh): void;
  21841. /**
  21842. * Binds the submesh to the material
  21843. * @param world defines the world transformation matrix
  21844. * @param mesh defines the mesh containing the submesh
  21845. * @param subMesh defines the submesh to bind the material to
  21846. */
  21847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21848. /**
  21849. * Binds the world matrix to the material
  21850. * @param world defines the world transformation matrix
  21851. */
  21852. bindOnlyWorldMatrix(world: Matrix): void;
  21853. /**
  21854. * Binds the scene's uniform buffer to the effect.
  21855. * @param effect defines the effect to bind to the scene uniform buffer
  21856. * @param sceneUbo defines the uniform buffer storing scene data
  21857. */
  21858. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21859. /**
  21860. * Binds the view matrix to the effect
  21861. * @param effect defines the effect to bind the view matrix to
  21862. */
  21863. bindView(effect: Effect): void;
  21864. /**
  21865. * Binds the view projection matrix to the effect
  21866. * @param effect defines the effect to bind the view projection matrix to
  21867. */
  21868. bindViewProjection(effect: Effect): void;
  21869. /**
  21870. * Specifies if material alpha testing should be turned on for the mesh
  21871. * @param mesh defines the mesh to check
  21872. */
  21873. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21874. /**
  21875. * Processes to execute after binding the material to a mesh
  21876. * @param mesh defines the rendered mesh
  21877. */
  21878. protected _afterBind(mesh?: Mesh): void;
  21879. /**
  21880. * Unbinds the material from the mesh
  21881. */
  21882. unbind(): void;
  21883. /**
  21884. * Gets the active textures from the material
  21885. * @returns an array of textures
  21886. */
  21887. getActiveTextures(): BaseTexture[];
  21888. /**
  21889. * Specifies if the material uses a texture
  21890. * @param texture defines the texture to check against the material
  21891. * @returns a boolean specifying if the material uses the texture
  21892. */
  21893. hasTexture(texture: BaseTexture): boolean;
  21894. /**
  21895. * Makes a duplicate of the material, and gives it a new name
  21896. * @param name defines the new name for the duplicated material
  21897. * @returns the cloned material
  21898. */
  21899. clone(name: string): Nullable<Material>;
  21900. /**
  21901. * Gets the meshes bound to the material
  21902. * @returns an array of meshes bound to the material
  21903. */
  21904. getBindedMeshes(): AbstractMesh[];
  21905. /**
  21906. * Force shader compilation
  21907. * @param mesh defines the mesh associated with this material
  21908. * @param onCompiled defines a function to execute once the material is compiled
  21909. * @param options defines the options to configure the compilation
  21910. * @param onError defines a function to execute if the material fails compiling
  21911. */
  21912. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21913. /**
  21914. * Force shader compilation
  21915. * @param mesh defines the mesh that will use this material
  21916. * @param options defines additional options for compiling the shaders
  21917. * @returns a promise that resolves when the compilation completes
  21918. */
  21919. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21920. private static readonly _AllDirtyCallBack;
  21921. private static readonly _ImageProcessingDirtyCallBack;
  21922. private static readonly _TextureDirtyCallBack;
  21923. private static readonly _FresnelDirtyCallBack;
  21924. private static readonly _MiscDirtyCallBack;
  21925. private static readonly _LightsDirtyCallBack;
  21926. private static readonly _AttributeDirtyCallBack;
  21927. private static _FresnelAndMiscDirtyCallBack;
  21928. private static _TextureAndMiscDirtyCallBack;
  21929. private static readonly _DirtyCallbackArray;
  21930. private static readonly _RunDirtyCallBacks;
  21931. /**
  21932. * Marks a define in the material to indicate that it needs to be re-computed
  21933. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21934. */
  21935. markAsDirty(flag: number): void;
  21936. /**
  21937. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21938. * @param func defines a function which checks material defines against the submeshes
  21939. */
  21940. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21941. /**
  21942. * Indicates that we need to re-calculated for all submeshes
  21943. */
  21944. protected _markAllSubMeshesAsAllDirty(): void;
  21945. /**
  21946. * Indicates that image processing needs to be re-calculated for all submeshes
  21947. */
  21948. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21949. /**
  21950. * Indicates that textures need to be re-calculated for all submeshes
  21951. */
  21952. protected _markAllSubMeshesAsTexturesDirty(): void;
  21953. /**
  21954. * Indicates that fresnel needs to be re-calculated for all submeshes
  21955. */
  21956. protected _markAllSubMeshesAsFresnelDirty(): void;
  21957. /**
  21958. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21959. */
  21960. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21961. /**
  21962. * Indicates that lights need to be re-calculated for all submeshes
  21963. */
  21964. protected _markAllSubMeshesAsLightsDirty(): void;
  21965. /**
  21966. * Indicates that attributes need to be re-calculated for all submeshes
  21967. */
  21968. protected _markAllSubMeshesAsAttributesDirty(): void;
  21969. /**
  21970. * Indicates that misc needs to be re-calculated for all submeshes
  21971. */
  21972. protected _markAllSubMeshesAsMiscDirty(): void;
  21973. /**
  21974. * Indicates that textures and misc need to be re-calculated for all submeshes
  21975. */
  21976. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21977. /**
  21978. * Disposes the material
  21979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21981. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21982. */
  21983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21984. /** @hidden */
  21985. private releaseVertexArrayObject;
  21986. /**
  21987. * Serializes this material
  21988. * @returns the serialized material object
  21989. */
  21990. serialize(): any;
  21991. /**
  21992. * Creates a material from parsed material data
  21993. * @param parsedMaterial defines parsed material data
  21994. * @param scene defines the hosting scene
  21995. * @param rootUrl defines the root URL to use to load textures
  21996. * @returns a new material
  21997. */
  21998. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/multiMaterial" {
  22002. import { Nullable } from "babylonjs/types";
  22003. import { Scene } from "babylonjs/scene";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22007. import { Material } from "babylonjs/Materials/material";
  22008. /**
  22009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22010. * separate meshes. This can be use to improve performances.
  22011. * @see http://doc.babylonjs.com/how_to/multi_materials
  22012. */
  22013. export class MultiMaterial extends Material {
  22014. private _subMaterials;
  22015. /**
  22016. * Gets or Sets the list of Materials used within the multi material.
  22017. * They need to be ordered according to the submeshes order in the associated mesh
  22018. */
  22019. get subMaterials(): Nullable<Material>[];
  22020. set subMaterials(value: Nullable<Material>[]);
  22021. /**
  22022. * Function used to align with Node.getChildren()
  22023. * @returns the list of Materials used within the multi material
  22024. */
  22025. getChildren(): Nullable<Material>[];
  22026. /**
  22027. * Instantiates a new Multi Material
  22028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22029. * separate meshes. This can be use to improve performances.
  22030. * @see http://doc.babylonjs.com/how_to/multi_materials
  22031. * @param name Define the name in the scene
  22032. * @param scene Define the scene the material belongs to
  22033. */
  22034. constructor(name: string, scene: Scene);
  22035. private _hookArray;
  22036. /**
  22037. * Get one of the submaterial by its index in the submaterials array
  22038. * @param index The index to look the sub material at
  22039. * @returns The Material if the index has been defined
  22040. */
  22041. getSubMaterial(index: number): Nullable<Material>;
  22042. /**
  22043. * Get the list of active textures for the whole sub materials list.
  22044. * @returns All the textures that will be used during the rendering
  22045. */
  22046. getActiveTextures(): BaseTexture[];
  22047. /**
  22048. * Gets the current class name of the material e.g. "MultiMaterial"
  22049. * Mainly use in serialization.
  22050. * @returns the class name
  22051. */
  22052. getClassName(): string;
  22053. /**
  22054. * Checks if the material is ready to render the requested sub mesh
  22055. * @param mesh Define the mesh the submesh belongs to
  22056. * @param subMesh Define the sub mesh to look readyness for
  22057. * @param useInstances Define whether or not the material is used with instances
  22058. * @returns true if ready, otherwise false
  22059. */
  22060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22061. /**
  22062. * Clones the current material and its related sub materials
  22063. * @param name Define the name of the newly cloned material
  22064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22065. * @returns the cloned material
  22066. */
  22067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22068. /**
  22069. * Serializes the materials into a JSON representation.
  22070. * @returns the JSON representation
  22071. */
  22072. serialize(): any;
  22073. /**
  22074. * Dispose the material and release its associated resources
  22075. * @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)
  22076. * @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)
  22077. * @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)
  22078. */
  22079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22080. /**
  22081. * Creates a MultiMaterial from parsed MultiMaterial data.
  22082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22083. * @param scene defines the hosting scene
  22084. * @returns a new MultiMaterial
  22085. */
  22086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22087. }
  22088. }
  22089. declare module "babylonjs/Meshes/subMesh" {
  22090. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22092. import { Engine } from "babylonjs/Engines/engine";
  22093. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22094. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22095. import { Effect } from "babylonjs/Materials/effect";
  22096. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22097. import { Plane } from "babylonjs/Maths/math.plane";
  22098. import { Collider } from "babylonjs/Collisions/collider";
  22099. import { Material } from "babylonjs/Materials/material";
  22100. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22102. import { Mesh } from "babylonjs/Meshes/mesh";
  22103. import { Ray } from "babylonjs/Culling/ray";
  22104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22105. /**
  22106. * Base class for submeshes
  22107. */
  22108. export class BaseSubMesh {
  22109. /** @hidden */
  22110. _materialDefines: Nullable<MaterialDefines>;
  22111. /** @hidden */
  22112. _materialEffect: Nullable<Effect>;
  22113. /**
  22114. * Gets material defines used by the effect associated to the sub mesh
  22115. */
  22116. get materialDefines(): Nullable<MaterialDefines>;
  22117. /**
  22118. * Sets material defines used by the effect associated to the sub mesh
  22119. */
  22120. set materialDefines(defines: Nullable<MaterialDefines>);
  22121. /**
  22122. * Gets associated effect
  22123. */
  22124. get effect(): Nullable<Effect>;
  22125. /**
  22126. * Sets associated effect (effect used to render this submesh)
  22127. * @param effect defines the effect to associate with
  22128. * @param defines defines the set of defines used to compile this effect
  22129. */
  22130. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22131. }
  22132. /**
  22133. * Defines a subdivision inside a mesh
  22134. */
  22135. export class SubMesh extends BaseSubMesh implements ICullable {
  22136. /** the material index to use */
  22137. materialIndex: number;
  22138. /** vertex index start */
  22139. verticesStart: number;
  22140. /** vertices count */
  22141. verticesCount: number;
  22142. /** index start */
  22143. indexStart: number;
  22144. /** indices count */
  22145. indexCount: number;
  22146. /** @hidden */
  22147. _linesIndexCount: number;
  22148. private _mesh;
  22149. private _renderingMesh;
  22150. private _boundingInfo;
  22151. private _linesIndexBuffer;
  22152. /** @hidden */
  22153. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22154. /** @hidden */
  22155. _trianglePlanes: Plane[];
  22156. /** @hidden */
  22157. _lastColliderTransformMatrix: Nullable<Matrix>;
  22158. /** @hidden */
  22159. _renderId: number;
  22160. /** @hidden */
  22161. _alphaIndex: number;
  22162. /** @hidden */
  22163. _distanceToCamera: number;
  22164. /** @hidden */
  22165. _id: number;
  22166. private _currentMaterial;
  22167. /**
  22168. * Add a new submesh to a mesh
  22169. * @param materialIndex defines the material index to use
  22170. * @param verticesStart defines vertex index start
  22171. * @param verticesCount defines vertices count
  22172. * @param indexStart defines index start
  22173. * @param indexCount defines indices count
  22174. * @param mesh defines the parent mesh
  22175. * @param renderingMesh defines an optional rendering mesh
  22176. * @param createBoundingBox defines if bounding box should be created for this submesh
  22177. * @returns the new submesh
  22178. */
  22179. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22180. /**
  22181. * Creates a new submesh
  22182. * @param materialIndex defines the material index to use
  22183. * @param verticesStart defines vertex index start
  22184. * @param verticesCount defines vertices count
  22185. * @param indexStart defines index start
  22186. * @param indexCount defines indices count
  22187. * @param mesh defines the parent mesh
  22188. * @param renderingMesh defines an optional rendering mesh
  22189. * @param createBoundingBox defines if bounding box should be created for this submesh
  22190. */
  22191. constructor(
  22192. /** the material index to use */
  22193. materialIndex: number,
  22194. /** vertex index start */
  22195. verticesStart: number,
  22196. /** vertices count */
  22197. verticesCount: number,
  22198. /** index start */
  22199. indexStart: number,
  22200. /** indices count */
  22201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22202. /**
  22203. * Returns true if this submesh covers the entire parent mesh
  22204. * @ignorenaming
  22205. */
  22206. get IsGlobal(): boolean;
  22207. /**
  22208. * Returns the submesh BoudingInfo object
  22209. * @returns current bounding info (or mesh's one if the submesh is global)
  22210. */
  22211. getBoundingInfo(): BoundingInfo;
  22212. /**
  22213. * Sets the submesh BoundingInfo
  22214. * @param boundingInfo defines the new bounding info to use
  22215. * @returns the SubMesh
  22216. */
  22217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22218. /**
  22219. * Returns the mesh of the current submesh
  22220. * @return the parent mesh
  22221. */
  22222. getMesh(): AbstractMesh;
  22223. /**
  22224. * Returns the rendering mesh of the submesh
  22225. * @returns the rendering mesh (could be different from parent mesh)
  22226. */
  22227. getRenderingMesh(): Mesh;
  22228. /**
  22229. * Returns the submesh material
  22230. * @returns null or the current material
  22231. */
  22232. getMaterial(): Nullable<Material>;
  22233. /**
  22234. * Sets a new updated BoundingInfo object to the submesh
  22235. * @param data defines an optional position array to use to determine the bounding info
  22236. * @returns the SubMesh
  22237. */
  22238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22239. /** @hidden */
  22240. _checkCollision(collider: Collider): boolean;
  22241. /**
  22242. * Updates the submesh BoundingInfo
  22243. * @param world defines the world matrix to use to update the bounding info
  22244. * @returns the submesh
  22245. */
  22246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22247. /**
  22248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22249. * @param frustumPlanes defines the frustum planes
  22250. * @returns true if the submesh is intersecting with the frustum
  22251. */
  22252. isInFrustum(frustumPlanes: Plane[]): boolean;
  22253. /**
  22254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22255. * @param frustumPlanes defines the frustum planes
  22256. * @returns true if the submesh is inside the frustum
  22257. */
  22258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22259. /**
  22260. * Renders the submesh
  22261. * @param enableAlphaMode defines if alpha needs to be used
  22262. * @returns the submesh
  22263. */
  22264. render(enableAlphaMode: boolean): SubMesh;
  22265. /**
  22266. * @hidden
  22267. */
  22268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22269. /**
  22270. * Checks if the submesh intersects with a ray
  22271. * @param ray defines the ray to test
  22272. * @returns true is the passed ray intersects the submesh bounding box
  22273. */
  22274. canIntersects(ray: Ray): boolean;
  22275. /**
  22276. * Intersects current submesh with a ray
  22277. * @param ray defines the ray to test
  22278. * @param positions defines mesh's positions array
  22279. * @param indices defines mesh's indices array
  22280. * @param fastCheck defines if only bounding info should be used
  22281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22282. * @returns intersection info or null if no intersection
  22283. */
  22284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22285. /** @hidden */
  22286. private _intersectLines;
  22287. /** @hidden */
  22288. private _intersectUnIndexedLines;
  22289. /** @hidden */
  22290. private _intersectTriangles;
  22291. /** @hidden */
  22292. private _intersectUnIndexedTriangles;
  22293. /** @hidden */
  22294. _rebuild(): void;
  22295. /**
  22296. * Creates a new submesh from the passed mesh
  22297. * @param newMesh defines the new hosting mesh
  22298. * @param newRenderingMesh defines an optional rendering mesh
  22299. * @returns the new submesh
  22300. */
  22301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22302. /**
  22303. * Release associated resources
  22304. */
  22305. dispose(): void;
  22306. /**
  22307. * Gets the class name
  22308. * @returns the string "SubMesh".
  22309. */
  22310. getClassName(): string;
  22311. /**
  22312. * Creates a new submesh from indices data
  22313. * @param materialIndex the index of the main mesh material
  22314. * @param startIndex the index where to start the copy in the mesh indices array
  22315. * @param indexCount the number of indices to copy then from the startIndex
  22316. * @param mesh the main mesh to create the submesh from
  22317. * @param renderingMesh the optional rendering mesh
  22318. * @returns a new submesh
  22319. */
  22320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22321. }
  22322. }
  22323. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22324. /**
  22325. * Class used to represent data loading progression
  22326. */
  22327. export class SceneLoaderFlags {
  22328. private static _ForceFullSceneLoadingForIncremental;
  22329. private static _ShowLoadingScreen;
  22330. private static _CleanBoneMatrixWeights;
  22331. private static _loggingLevel;
  22332. /**
  22333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22334. */
  22335. static get ForceFullSceneLoadingForIncremental(): boolean;
  22336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22337. /**
  22338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22339. */
  22340. static get ShowLoadingScreen(): boolean;
  22341. static set ShowLoadingScreen(value: boolean);
  22342. /**
  22343. * Defines the current logging level (while loading the scene)
  22344. * @ignorenaming
  22345. */
  22346. static get loggingLevel(): number;
  22347. static set loggingLevel(value: number);
  22348. /**
  22349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22350. */
  22351. static get CleanBoneMatrixWeights(): boolean;
  22352. static set CleanBoneMatrixWeights(value: boolean);
  22353. }
  22354. }
  22355. declare module "babylonjs/Meshes/geometry" {
  22356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22357. import { Scene } from "babylonjs/scene";
  22358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22359. import { Engine } from "babylonjs/Engines/engine";
  22360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22362. import { Effect } from "babylonjs/Materials/effect";
  22363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22365. import { Mesh } from "babylonjs/Meshes/mesh";
  22366. /**
  22367. * Class used to store geometry data (vertex buffers + index buffer)
  22368. */
  22369. export class Geometry implements IGetSetVerticesData {
  22370. /**
  22371. * Gets or sets the ID of the geometry
  22372. */
  22373. id: string;
  22374. /**
  22375. * Gets or sets the unique ID of the geometry
  22376. */
  22377. uniqueId: number;
  22378. /**
  22379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22380. */
  22381. delayLoadState: number;
  22382. /**
  22383. * Gets the file containing the data to load when running in delay load state
  22384. */
  22385. delayLoadingFile: Nullable<string>;
  22386. /**
  22387. * Callback called when the geometry is updated
  22388. */
  22389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22390. private _scene;
  22391. private _engine;
  22392. private _meshes;
  22393. private _totalVertices;
  22394. /** @hidden */
  22395. _indices: IndicesArray;
  22396. /** @hidden */
  22397. _vertexBuffers: {
  22398. [key: string]: VertexBuffer;
  22399. };
  22400. private _isDisposed;
  22401. private _extend;
  22402. private _boundingBias;
  22403. /** @hidden */
  22404. _delayInfo: Array<string>;
  22405. private _indexBuffer;
  22406. private _indexBufferIsUpdatable;
  22407. /** @hidden */
  22408. _boundingInfo: Nullable<BoundingInfo>;
  22409. /** @hidden */
  22410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22411. /** @hidden */
  22412. _softwareSkinningFrameId: number;
  22413. private _vertexArrayObjects;
  22414. private _updatable;
  22415. /** @hidden */
  22416. _positions: Nullable<Vector3[]>;
  22417. /**
  22418. * 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
  22419. */
  22420. get boundingBias(): Vector2;
  22421. /**
  22422. * 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
  22423. */
  22424. set boundingBias(value: Vector2);
  22425. /**
  22426. * Static function used to attach a new empty geometry to a mesh
  22427. * @param mesh defines the mesh to attach the geometry to
  22428. * @returns the new Geometry
  22429. */
  22430. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22431. /**
  22432. * Creates a new geometry
  22433. * @param id defines the unique ID
  22434. * @param scene defines the hosting scene
  22435. * @param vertexData defines the VertexData used to get geometry data
  22436. * @param updatable defines if geometry must be updatable (false by default)
  22437. * @param mesh defines the mesh that will be associated with the geometry
  22438. */
  22439. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22440. /**
  22441. * Gets the current extend of the geometry
  22442. */
  22443. get extend(): {
  22444. minimum: Vector3;
  22445. maximum: Vector3;
  22446. };
  22447. /**
  22448. * Gets the hosting scene
  22449. * @returns the hosting Scene
  22450. */
  22451. getScene(): Scene;
  22452. /**
  22453. * Gets the hosting engine
  22454. * @returns the hosting Engine
  22455. */
  22456. getEngine(): Engine;
  22457. /**
  22458. * Defines if the geometry is ready to use
  22459. * @returns true if the geometry is ready to be used
  22460. */
  22461. isReady(): boolean;
  22462. /**
  22463. * Gets a value indicating that the geometry should not be serialized
  22464. */
  22465. get doNotSerialize(): boolean;
  22466. /** @hidden */
  22467. _rebuild(): void;
  22468. /**
  22469. * Affects all geometry data in one call
  22470. * @param vertexData defines the geometry data
  22471. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22472. */
  22473. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22474. /**
  22475. * Set specific vertex data
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param data defines the vertex data to use
  22478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22480. */
  22481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22482. /**
  22483. * Removes a specific vertex data
  22484. * @param kind defines the data kind (Position, normal, etc...)
  22485. */
  22486. removeVerticesData(kind: string): void;
  22487. /**
  22488. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22489. * @param buffer defines the vertex buffer to use
  22490. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22491. */
  22492. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22493. /**
  22494. * Update a specific vertex buffer
  22495. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22496. * It will do nothing if the buffer is not updatable
  22497. * @param kind defines the data kind (Position, normal, etc...)
  22498. * @param data defines the data to use
  22499. * @param offset defines the offset in the target buffer where to store the data
  22500. * @param useBytes set to true if the offset is in bytes
  22501. */
  22502. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22503. /**
  22504. * Update a specific vertex buffer
  22505. * This function will create a new buffer if the current one is not updatable
  22506. * @param kind defines the data kind (Position, normal, etc...)
  22507. * @param data defines the data to use
  22508. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22509. */
  22510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22511. private _updateBoundingInfo;
  22512. /** @hidden */
  22513. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22514. /**
  22515. * Gets total number of vertices
  22516. * @returns the total number of vertices
  22517. */
  22518. getTotalVertices(): number;
  22519. /**
  22520. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22521. * @param kind defines the data kind (Position, normal, etc...)
  22522. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22524. * @returns a float array containing vertex data
  22525. */
  22526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22527. /**
  22528. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22529. * @param kind defines the data kind (Position, normal, etc...)
  22530. * @returns true if the vertex buffer with the specified kind is updatable
  22531. */
  22532. isVertexBufferUpdatable(kind: string): boolean;
  22533. /**
  22534. * Gets a specific vertex buffer
  22535. * @param kind defines the data kind (Position, normal, etc...)
  22536. * @returns a VertexBuffer
  22537. */
  22538. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22539. /**
  22540. * Returns all vertex buffers
  22541. * @return an object holding all vertex buffers indexed by kind
  22542. */
  22543. getVertexBuffers(): Nullable<{
  22544. [key: string]: VertexBuffer;
  22545. }>;
  22546. /**
  22547. * Gets a boolean indicating if specific vertex buffer is present
  22548. * @param kind defines the data kind (Position, normal, etc...)
  22549. * @returns true if data is present
  22550. */
  22551. isVerticesDataPresent(kind: string): boolean;
  22552. /**
  22553. * Gets a list of all attached data kinds (Position, normal, etc...)
  22554. * @returns a list of string containing all kinds
  22555. */
  22556. getVerticesDataKinds(): string[];
  22557. /**
  22558. * Update index buffer
  22559. * @param indices defines the indices to store in the index buffer
  22560. * @param offset defines the offset in the target buffer where to store the data
  22561. * @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)
  22562. */
  22563. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22564. /**
  22565. * Creates a new index buffer
  22566. * @param indices defines the indices to store in the index buffer
  22567. * @param totalVertices defines the total number of vertices (could be null)
  22568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22569. */
  22570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22571. /**
  22572. * Return the total number of indices
  22573. * @returns the total number of indices
  22574. */
  22575. getTotalIndices(): number;
  22576. /**
  22577. * Gets the index buffer array
  22578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22580. * @returns the index buffer array
  22581. */
  22582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22583. /**
  22584. * Gets the index buffer
  22585. * @return the index buffer
  22586. */
  22587. getIndexBuffer(): Nullable<DataBuffer>;
  22588. /** @hidden */
  22589. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22590. /**
  22591. * Release the associated resources for a specific mesh
  22592. * @param mesh defines the source mesh
  22593. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22594. */
  22595. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22596. /**
  22597. * Apply current geometry to a given mesh
  22598. * @param mesh defines the mesh to apply geometry to
  22599. */
  22600. applyToMesh(mesh: Mesh): void;
  22601. private _updateExtend;
  22602. private _applyToMesh;
  22603. private notifyUpdate;
  22604. /**
  22605. * Load the geometry if it was flagged as delay loaded
  22606. * @param scene defines the hosting scene
  22607. * @param onLoaded defines a callback called when the geometry is loaded
  22608. */
  22609. load(scene: Scene, onLoaded?: () => void): void;
  22610. private _queueLoad;
  22611. /**
  22612. * Invert the geometry to move from a right handed system to a left handed one.
  22613. */
  22614. toLeftHanded(): void;
  22615. /** @hidden */
  22616. _resetPointsArrayCache(): void;
  22617. /** @hidden */
  22618. _generatePointsArray(): boolean;
  22619. /**
  22620. * Gets a value indicating if the geometry is disposed
  22621. * @returns true if the geometry was disposed
  22622. */
  22623. isDisposed(): boolean;
  22624. private _disposeVertexArrayObjects;
  22625. /**
  22626. * Free all associated resources
  22627. */
  22628. dispose(): void;
  22629. /**
  22630. * Clone the current geometry into a new geometry
  22631. * @param id defines the unique ID of the new geometry
  22632. * @returns a new geometry object
  22633. */
  22634. copy(id: string): Geometry;
  22635. /**
  22636. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22637. * @return a JSON representation of the current geometry data (without the vertices data)
  22638. */
  22639. serialize(): any;
  22640. private toNumberArray;
  22641. /**
  22642. * Serialize all vertices data into a JSON oject
  22643. * @returns a JSON representation of the current geometry data
  22644. */
  22645. serializeVerticeData(): any;
  22646. /**
  22647. * Extracts a clone of a mesh geometry
  22648. * @param mesh defines the source mesh
  22649. * @param id defines the unique ID of the new geometry object
  22650. * @returns the new geometry object
  22651. */
  22652. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22653. /**
  22654. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22656. * Be aware Math.random() could cause collisions, but:
  22657. * "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"
  22658. * @returns a string containing a new GUID
  22659. */
  22660. static RandomId(): string;
  22661. /** @hidden */
  22662. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22663. private static _CleanMatricesWeights;
  22664. /**
  22665. * Create a new geometry from persisted data (Using .babylon file format)
  22666. * @param parsedVertexData defines the persisted data
  22667. * @param scene defines the hosting scene
  22668. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22669. * @returns the new geometry object
  22670. */
  22671. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22672. }
  22673. }
  22674. declare module "babylonjs/Meshes/mesh.vertexData" {
  22675. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22676. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22677. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22678. import { Geometry } from "babylonjs/Meshes/geometry";
  22679. import { Mesh } from "babylonjs/Meshes/mesh";
  22680. /**
  22681. * Define an interface for all classes that will get and set the data on vertices
  22682. */
  22683. export interface IGetSetVerticesData {
  22684. /**
  22685. * Gets a boolean indicating if specific vertex data is present
  22686. * @param kind defines the vertex data kind to use
  22687. * @returns true is data kind is present
  22688. */
  22689. isVerticesDataPresent(kind: string): boolean;
  22690. /**
  22691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22692. * @param kind defines the data kind (Position, normal, etc...)
  22693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22695. * @returns a float array containing vertex data
  22696. */
  22697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22698. /**
  22699. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22700. * @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.
  22701. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22702. * @returns the indices array or an empty array if the mesh has no geometry
  22703. */
  22704. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22705. /**
  22706. * Set specific vertex data
  22707. * @param kind defines the data kind (Position, normal, etc...)
  22708. * @param data defines the vertex data to use
  22709. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22710. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22711. */
  22712. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22713. /**
  22714. * Update a specific associated vertex buffer
  22715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22716. * - VertexBuffer.PositionKind
  22717. * - VertexBuffer.UVKind
  22718. * - VertexBuffer.UV2Kind
  22719. * - VertexBuffer.UV3Kind
  22720. * - VertexBuffer.UV4Kind
  22721. * - VertexBuffer.UV5Kind
  22722. * - VertexBuffer.UV6Kind
  22723. * - VertexBuffer.ColorKind
  22724. * - VertexBuffer.MatricesIndicesKind
  22725. * - VertexBuffer.MatricesIndicesExtraKind
  22726. * - VertexBuffer.MatricesWeightsKind
  22727. * - VertexBuffer.MatricesWeightsExtraKind
  22728. * @param data defines the data source
  22729. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22730. * @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)
  22731. */
  22732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22733. /**
  22734. * Creates a new index buffer
  22735. * @param indices defines the indices to store in the index buffer
  22736. * @param totalVertices defines the total number of vertices (could be null)
  22737. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22738. */
  22739. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22740. }
  22741. /**
  22742. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22743. */
  22744. export class VertexData {
  22745. /**
  22746. * Mesh side orientation : usually the external or front surface
  22747. */
  22748. static readonly FRONTSIDE: number;
  22749. /**
  22750. * Mesh side orientation : usually the internal or back surface
  22751. */
  22752. static readonly BACKSIDE: number;
  22753. /**
  22754. * Mesh side orientation : both internal and external or front and back surfaces
  22755. */
  22756. static readonly DOUBLESIDE: number;
  22757. /**
  22758. * Mesh side orientation : by default, `FRONTSIDE`
  22759. */
  22760. static readonly DEFAULTSIDE: number;
  22761. /**
  22762. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22763. */
  22764. positions: Nullable<FloatArray>;
  22765. /**
  22766. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22767. */
  22768. normals: Nullable<FloatArray>;
  22769. /**
  22770. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22771. */
  22772. tangents: Nullable<FloatArray>;
  22773. /**
  22774. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22775. */
  22776. uvs: Nullable<FloatArray>;
  22777. /**
  22778. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22779. */
  22780. uvs2: Nullable<FloatArray>;
  22781. /**
  22782. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22783. */
  22784. uvs3: Nullable<FloatArray>;
  22785. /**
  22786. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22787. */
  22788. uvs4: Nullable<FloatArray>;
  22789. /**
  22790. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22791. */
  22792. uvs5: Nullable<FloatArray>;
  22793. /**
  22794. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22795. */
  22796. uvs6: Nullable<FloatArray>;
  22797. /**
  22798. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22799. */
  22800. colors: Nullable<FloatArray>;
  22801. /**
  22802. * 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).
  22803. */
  22804. matricesIndices: Nullable<FloatArray>;
  22805. /**
  22806. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22807. */
  22808. matricesWeights: Nullable<FloatArray>;
  22809. /**
  22810. * An array extending the number of possible indices
  22811. */
  22812. matricesIndicesExtra: Nullable<FloatArray>;
  22813. /**
  22814. * An array extending the number of possible weights when the number of indices is extended
  22815. */
  22816. matricesWeightsExtra: Nullable<FloatArray>;
  22817. /**
  22818. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22819. */
  22820. indices: Nullable<IndicesArray>;
  22821. /**
  22822. * Uses the passed data array to set the set the values for the specified kind of data
  22823. * @param data a linear array of floating numbers
  22824. * @param kind the type of data that is being set, eg positions, colors etc
  22825. */
  22826. set(data: FloatArray, kind: string): void;
  22827. /**
  22828. * Associates the vertexData to the passed Mesh.
  22829. * Sets it as updatable or not (default `false`)
  22830. * @param mesh the mesh the vertexData is applied to
  22831. * @param updatable when used and having the value true allows new data to update the vertexData
  22832. * @returns the VertexData
  22833. */
  22834. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22835. /**
  22836. * Associates the vertexData to the passed Geometry.
  22837. * Sets it as updatable or not (default `false`)
  22838. * @param geometry the geometry the vertexData is applied to
  22839. * @param updatable when used and having the value true allows new data to update the vertexData
  22840. * @returns VertexData
  22841. */
  22842. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22843. /**
  22844. * Updates the associated mesh
  22845. * @param mesh the mesh to be updated
  22846. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22847. * @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
  22848. * @returns VertexData
  22849. */
  22850. updateMesh(mesh: Mesh): VertexData;
  22851. /**
  22852. * Updates the associated geometry
  22853. * @param geometry the geometry to be updated
  22854. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22855. * @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
  22856. * @returns VertexData.
  22857. */
  22858. updateGeometry(geometry: Geometry): VertexData;
  22859. private _applyTo;
  22860. private _update;
  22861. /**
  22862. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22863. * @param matrix the transforming matrix
  22864. * @returns the VertexData
  22865. */
  22866. transform(matrix: Matrix): VertexData;
  22867. /**
  22868. * Merges the passed VertexData into the current one
  22869. * @param other the VertexData to be merged into the current one
  22870. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22871. * @returns the modified VertexData
  22872. */
  22873. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22874. private _mergeElement;
  22875. private _validate;
  22876. /**
  22877. * Serializes the VertexData
  22878. * @returns a serialized object
  22879. */
  22880. serialize(): any;
  22881. /**
  22882. * Extracts the vertexData from a mesh
  22883. * @param mesh the mesh from which to extract the VertexData
  22884. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22885. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22886. * @returns the object VertexData associated to the passed mesh
  22887. */
  22888. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22889. /**
  22890. * Extracts the vertexData from the geometry
  22891. * @param geometry the geometry from which to extract the VertexData
  22892. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22893. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22894. * @returns the object VertexData associated to the passed mesh
  22895. */
  22896. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22897. private static _ExtractFrom;
  22898. /**
  22899. * Creates the VertexData for a Ribbon
  22900. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22901. * * pathArray array of paths, each of which an array of successive Vector3
  22902. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22903. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22904. * * 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
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22909. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22910. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22911. * @returns the VertexData of the ribbon
  22912. */
  22913. static CreateRibbon(options: {
  22914. pathArray: Vector3[][];
  22915. closeArray?: boolean;
  22916. closePath?: boolean;
  22917. offset?: number;
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. invertUV?: boolean;
  22922. uvs?: Vector2[];
  22923. colors?: Color4[];
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22929. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22930. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22931. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22932. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22933. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the box
  22938. */
  22939. static CreateBox(options: {
  22940. size?: number;
  22941. width?: number;
  22942. height?: number;
  22943. depth?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for a tiled box
  22952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22953. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22954. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22955. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22957. * @returns the VertexData of the box
  22958. */
  22959. static CreateTiledBox(options: {
  22960. pattern?: number;
  22961. width?: number;
  22962. height?: number;
  22963. depth?: number;
  22964. tileSize?: number;
  22965. tileWidth?: number;
  22966. tileHeight?: number;
  22967. alignHorizontal?: number;
  22968. alignVertical?: number;
  22969. faceUV?: Vector4[];
  22970. faceColors?: Color4[];
  22971. sideOrientation?: number;
  22972. }): VertexData;
  22973. /**
  22974. * Creates the VertexData for a tiled plane
  22975. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22976. * * pattern a limited pattern arrangement depending on the number
  22977. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22978. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22979. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22981. * * 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)
  22982. * * 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)
  22983. * @returns the VertexData of the tiled plane
  22984. */
  22985. static CreateTiledPlane(options: {
  22986. pattern?: number;
  22987. tileSize?: number;
  22988. tileWidth?: number;
  22989. tileHeight?: number;
  22990. size?: number;
  22991. width?: number;
  22992. height?: number;
  22993. alignHorizontal?: number;
  22994. alignVertical?: number;
  22995. sideOrientation?: number;
  22996. frontUVs?: Vector4;
  22997. backUVs?: Vector4;
  22998. }): VertexData;
  22999. /**
  23000. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23002. * * segments sets the number of horizontal strips optional, default 32
  23003. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23004. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23005. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23006. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23007. * * 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
  23008. * * 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
  23009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23010. * * 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)
  23011. * * 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)
  23012. * @returns the VertexData of the ellipsoid
  23013. */
  23014. static CreateSphere(options: {
  23015. segments?: number;
  23016. diameter?: number;
  23017. diameterX?: number;
  23018. diameterY?: number;
  23019. diameterZ?: number;
  23020. arc?: number;
  23021. slice?: number;
  23022. sideOrientation?: number;
  23023. frontUVs?: Vector4;
  23024. backUVs?: Vector4;
  23025. }): VertexData;
  23026. /**
  23027. * Creates the VertexData for a cylinder, cone or prism
  23028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23029. * * height sets the height (y direction) of the cylinder, optional, default 2
  23030. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23031. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23032. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23033. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23034. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23035. * * 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
  23036. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23037. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23038. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23039. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23041. * * 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)
  23042. * * 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)
  23043. * @returns the VertexData of the cylinder, cone or prism
  23044. */
  23045. static CreateCylinder(options: {
  23046. height?: number;
  23047. diameterTop?: number;
  23048. diameterBottom?: number;
  23049. diameter?: number;
  23050. tessellation?: number;
  23051. subdivisions?: number;
  23052. arc?: number;
  23053. faceColors?: Color4[];
  23054. faceUV?: Vector4[];
  23055. hasRings?: boolean;
  23056. enclose?: boolean;
  23057. sideOrientation?: number;
  23058. frontUVs?: Vector4;
  23059. backUVs?: Vector4;
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData for a torus
  23063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23064. * * diameter the diameter of the torus, optional default 1
  23065. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23066. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23068. * * 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)
  23069. * * 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)
  23070. * @returns the VertexData of the torus
  23071. */
  23072. static CreateTorus(options: {
  23073. diameter?: number;
  23074. thickness?: number;
  23075. tessellation?: number;
  23076. sideOrientation?: number;
  23077. frontUVs?: Vector4;
  23078. backUVs?: Vector4;
  23079. }): VertexData;
  23080. /**
  23081. * Creates the VertexData of the LineSystem
  23082. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23083. * - lines an array of lines, each line being an array of successive Vector3
  23084. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23085. * @returns the VertexData of the LineSystem
  23086. */
  23087. static CreateLineSystem(options: {
  23088. lines: Vector3[][];
  23089. colors?: Nullable<Color4[][]>;
  23090. }): VertexData;
  23091. /**
  23092. * Create the VertexData for a DashedLines
  23093. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23094. * - points an array successive Vector3
  23095. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23096. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23097. * - dashNb the intended total number of dashes, optional, default 200
  23098. * @returns the VertexData for the DashedLines
  23099. */
  23100. static CreateDashedLines(options: {
  23101. points: Vector3[];
  23102. dashSize?: number;
  23103. gapSize?: number;
  23104. dashNb?: number;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for a Ground
  23108. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23109. * - width the width (x direction) of the ground, optional, default 1
  23110. * - height the height (z direction) of the ground, optional, default 1
  23111. * - subdivisions the number of subdivisions per side, optional, default 1
  23112. * @returns the VertexData of the Ground
  23113. */
  23114. static CreateGround(options: {
  23115. width?: number;
  23116. height?: number;
  23117. subdivisions?: number;
  23118. subdivisionsX?: number;
  23119. subdivisionsY?: number;
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23123. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23124. * * xmin the ground minimum X coordinate, optional, default -1
  23125. * * zmin the ground minimum Z coordinate, optional, default -1
  23126. * * xmax the ground maximum X coordinate, optional, default 1
  23127. * * zmax the ground maximum Z coordinate, optional, default 1
  23128. * * 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}
  23129. * * 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}
  23130. * @returns the VertexData of the TiledGround
  23131. */
  23132. static CreateTiledGround(options: {
  23133. xmin: number;
  23134. zmin: number;
  23135. xmax: number;
  23136. zmax: number;
  23137. subdivisions?: {
  23138. w: number;
  23139. h: number;
  23140. };
  23141. precision?: {
  23142. w: number;
  23143. h: number;
  23144. };
  23145. }): VertexData;
  23146. /**
  23147. * Creates the VertexData of the Ground designed from a heightmap
  23148. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23149. * * width the width (x direction) of the ground
  23150. * * height the height (z direction) of the ground
  23151. * * subdivisions the number of subdivisions per side
  23152. * * minHeight the minimum altitude on the ground, optional, default 0
  23153. * * maxHeight the maximum altitude on the ground, optional default 1
  23154. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23155. * * buffer the array holding the image color data
  23156. * * bufferWidth the width of image
  23157. * * bufferHeight the height of image
  23158. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23159. * @returns the VertexData of the Ground designed from a heightmap
  23160. */
  23161. static CreateGroundFromHeightMap(options: {
  23162. width: number;
  23163. height: number;
  23164. subdivisions: number;
  23165. minHeight: number;
  23166. maxHeight: number;
  23167. colorFilter: Color3;
  23168. buffer: Uint8Array;
  23169. bufferWidth: number;
  23170. bufferHeight: number;
  23171. alphaFilter: number;
  23172. }): VertexData;
  23173. /**
  23174. * Creates the VertexData for a Plane
  23175. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23176. * * size sets the width and height of the plane to the value of size, optional default 1
  23177. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23178. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23180. * * 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)
  23181. * * 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)
  23182. * @returns the VertexData of the box
  23183. */
  23184. static CreatePlane(options: {
  23185. size?: number;
  23186. width?: number;
  23187. height?: number;
  23188. sideOrientation?: number;
  23189. frontUVs?: Vector4;
  23190. backUVs?: Vector4;
  23191. }): VertexData;
  23192. /**
  23193. * Creates the VertexData of the Disc or regular Polygon
  23194. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23195. * * radius the radius of the disc, optional default 0.5
  23196. * * tessellation the number of polygon sides, optional, default 64
  23197. * * 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
  23198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23199. * * 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)
  23200. * * 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)
  23201. * @returns the VertexData of the box
  23202. */
  23203. static CreateDisc(options: {
  23204. radius?: number;
  23205. tessellation?: number;
  23206. arc?: number;
  23207. sideOrientation?: number;
  23208. frontUVs?: Vector4;
  23209. backUVs?: Vector4;
  23210. }): VertexData;
  23211. /**
  23212. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23213. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23214. * @param polygon a mesh built from polygonTriangulation.build()
  23215. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23216. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23217. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23218. * @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)
  23219. * @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)
  23220. * @returns the VertexData of the Polygon
  23221. */
  23222. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23223. /**
  23224. * Creates the VertexData of the IcoSphere
  23225. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23226. * * radius the radius of the IcoSphere, optional default 1
  23227. * * radiusX allows stretching in the x direction, optional, default radius
  23228. * * radiusY allows stretching in the y direction, optional, default radius
  23229. * * radiusZ allows stretching in the z direction, optional, default radius
  23230. * * flat when true creates a flat shaded mesh, optional, default true
  23231. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23233. * * 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)
  23234. * * 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)
  23235. * @returns the VertexData of the IcoSphere
  23236. */
  23237. static CreateIcoSphere(options: {
  23238. radius?: number;
  23239. radiusX?: number;
  23240. radiusY?: number;
  23241. radiusZ?: number;
  23242. flat?: boolean;
  23243. subdivisions?: number;
  23244. sideOrientation?: number;
  23245. frontUVs?: Vector4;
  23246. backUVs?: Vector4;
  23247. }): VertexData;
  23248. /**
  23249. * Creates the VertexData for a Polyhedron
  23250. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23251. * * type provided types are:
  23252. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23253. * * 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)
  23254. * * size the size of the IcoSphere, optional default 1
  23255. * * sizeX allows stretching in the x direction, optional, default size
  23256. * * sizeY allows stretching in the y direction, optional, default size
  23257. * * sizeZ allows stretching in the z direction, optional, default size
  23258. * * 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
  23259. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23260. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23261. * * flat when true creates a flat shaded mesh, optional, default true
  23262. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23264. * * 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)
  23265. * * 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)
  23266. * @returns the VertexData of the Polyhedron
  23267. */
  23268. static CreatePolyhedron(options: {
  23269. type?: number;
  23270. size?: number;
  23271. sizeX?: number;
  23272. sizeY?: number;
  23273. sizeZ?: number;
  23274. custom?: any;
  23275. faceUV?: Vector4[];
  23276. faceColors?: Color4[];
  23277. flat?: boolean;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Creates the VertexData for a TorusKnot
  23284. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23285. * * radius the radius of the torus knot, optional, default 2
  23286. * * tube the thickness of the tube, optional, default 0.5
  23287. * * radialSegments the number of sides on each tube segments, optional, default 32
  23288. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23289. * * p the number of windings around the z axis, optional, default 2
  23290. * * q the number of windings around the x axis, optional, default 3
  23291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23292. * * 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)
  23293. * * 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)
  23294. * @returns the VertexData of the Torus Knot
  23295. */
  23296. static CreateTorusKnot(options: {
  23297. radius?: number;
  23298. tube?: number;
  23299. radialSegments?: number;
  23300. tubularSegments?: number;
  23301. p?: number;
  23302. q?: number;
  23303. sideOrientation?: number;
  23304. frontUVs?: Vector4;
  23305. backUVs?: Vector4;
  23306. }): VertexData;
  23307. /**
  23308. * Compute normals for given positions and indices
  23309. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23310. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23311. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23312. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23313. * * facetNormals : optional array of facet normals (vector3)
  23314. * * facetPositions : optional array of facet positions (vector3)
  23315. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23316. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23317. * * bInfo : optional bounding info, required for facetPartitioning computation
  23318. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23319. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23320. * * useRightHandedSystem: optional boolean to for right handed system computation
  23321. * * depthSort : optional boolean to enable the facet depth sort computation
  23322. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23323. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23324. */
  23325. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23326. facetNormals?: any;
  23327. facetPositions?: any;
  23328. facetPartitioning?: any;
  23329. ratio?: number;
  23330. bInfo?: any;
  23331. bbSize?: Vector3;
  23332. subDiv?: any;
  23333. useRightHandedSystem?: boolean;
  23334. depthSort?: boolean;
  23335. distanceTo?: Vector3;
  23336. depthSortedFacets?: any;
  23337. }): void;
  23338. /** @hidden */
  23339. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23340. /**
  23341. * Applies VertexData created from the imported parameters to the geometry
  23342. * @param parsedVertexData the parsed data from an imported file
  23343. * @param geometry the geometry to apply the VertexData to
  23344. */
  23345. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23346. }
  23347. }
  23348. declare module "babylonjs/Morph/morphTarget" {
  23349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23350. import { Observable } from "babylonjs/Misc/observable";
  23351. import { Nullable, FloatArray } from "babylonjs/types";
  23352. import { Scene } from "babylonjs/scene";
  23353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23354. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23355. /**
  23356. * Defines a target to use with MorphTargetManager
  23357. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23358. */
  23359. export class MorphTarget implements IAnimatable {
  23360. /** defines the name of the target */
  23361. name: string;
  23362. /**
  23363. * Gets or sets the list of animations
  23364. */
  23365. animations: import("babylonjs/Animations/animation").Animation[];
  23366. private _scene;
  23367. private _positions;
  23368. private _normals;
  23369. private _tangents;
  23370. private _uvs;
  23371. private _influence;
  23372. private _uniqueId;
  23373. /**
  23374. * Observable raised when the influence changes
  23375. */
  23376. onInfluenceChanged: Observable<boolean>;
  23377. /** @hidden */
  23378. _onDataLayoutChanged: Observable<void>;
  23379. /**
  23380. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23381. */
  23382. get influence(): number;
  23383. set influence(influence: number);
  23384. /**
  23385. * Gets or sets the id of the morph Target
  23386. */
  23387. id: string;
  23388. private _animationPropertiesOverride;
  23389. /**
  23390. * Gets or sets the animation properties override
  23391. */
  23392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23393. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23394. /**
  23395. * Creates a new MorphTarget
  23396. * @param name defines the name of the target
  23397. * @param influence defines the influence to use
  23398. * @param scene defines the scene the morphtarget belongs to
  23399. */
  23400. constructor(
  23401. /** defines the name of the target */
  23402. name: string, influence?: number, scene?: Nullable<Scene>);
  23403. /**
  23404. * Gets the unique ID of this manager
  23405. */
  23406. get uniqueId(): number;
  23407. /**
  23408. * Gets a boolean defining if the target contains position data
  23409. */
  23410. get hasPositions(): boolean;
  23411. /**
  23412. * Gets a boolean defining if the target contains normal data
  23413. */
  23414. get hasNormals(): boolean;
  23415. /**
  23416. * Gets a boolean defining if the target contains tangent data
  23417. */
  23418. get hasTangents(): boolean;
  23419. /**
  23420. * Gets a boolean defining if the target contains texture coordinates data
  23421. */
  23422. get hasUVs(): boolean;
  23423. /**
  23424. * Affects position data to this target
  23425. * @param data defines the position data to use
  23426. */
  23427. setPositions(data: Nullable<FloatArray>): void;
  23428. /**
  23429. * Gets the position data stored in this target
  23430. * @returns a FloatArray containing the position data (or null if not present)
  23431. */
  23432. getPositions(): Nullable<FloatArray>;
  23433. /**
  23434. * Affects normal data to this target
  23435. * @param data defines the normal data to use
  23436. */
  23437. setNormals(data: Nullable<FloatArray>): void;
  23438. /**
  23439. * Gets the normal data stored in this target
  23440. * @returns a FloatArray containing the normal data (or null if not present)
  23441. */
  23442. getNormals(): Nullable<FloatArray>;
  23443. /**
  23444. * Affects tangent data to this target
  23445. * @param data defines the tangent data to use
  23446. */
  23447. setTangents(data: Nullable<FloatArray>): void;
  23448. /**
  23449. * Gets the tangent data stored in this target
  23450. * @returns a FloatArray containing the tangent data (or null if not present)
  23451. */
  23452. getTangents(): Nullable<FloatArray>;
  23453. /**
  23454. * Affects texture coordinates data to this target
  23455. * @param data defines the texture coordinates data to use
  23456. */
  23457. setUVs(data: Nullable<FloatArray>): void;
  23458. /**
  23459. * Gets the texture coordinates data stored in this target
  23460. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23461. */
  23462. getUVs(): Nullable<FloatArray>;
  23463. /**
  23464. * Clone the current target
  23465. * @returns a new MorphTarget
  23466. */
  23467. clone(): MorphTarget;
  23468. /**
  23469. * Serializes the current target into a Serialization object
  23470. * @returns the serialized object
  23471. */
  23472. serialize(): any;
  23473. /**
  23474. * Returns the string "MorphTarget"
  23475. * @returns "MorphTarget"
  23476. */
  23477. getClassName(): string;
  23478. /**
  23479. * Creates a new target from serialized data
  23480. * @param serializationObject defines the serialized data to use
  23481. * @returns a new MorphTarget
  23482. */
  23483. static Parse(serializationObject: any): MorphTarget;
  23484. /**
  23485. * Creates a MorphTarget from mesh data
  23486. * @param mesh defines the source mesh
  23487. * @param name defines the name to use for the new target
  23488. * @param influence defines the influence to attach to the target
  23489. * @returns a new MorphTarget
  23490. */
  23491. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23492. }
  23493. }
  23494. declare module "babylonjs/Morph/morphTargetManager" {
  23495. import { Nullable } from "babylonjs/types";
  23496. import { Scene } from "babylonjs/scene";
  23497. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23498. /**
  23499. * This class is used to deform meshes using morphing between different targets
  23500. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23501. */
  23502. export class MorphTargetManager {
  23503. private _targets;
  23504. private _targetInfluenceChangedObservers;
  23505. private _targetDataLayoutChangedObservers;
  23506. private _activeTargets;
  23507. private _scene;
  23508. private _influences;
  23509. private _supportsNormals;
  23510. private _supportsTangents;
  23511. private _supportsUVs;
  23512. private _vertexCount;
  23513. private _uniqueId;
  23514. private _tempInfluences;
  23515. /**
  23516. * Gets or sets a boolean indicating if normals must be morphed
  23517. */
  23518. enableNormalMorphing: boolean;
  23519. /**
  23520. * Gets or sets a boolean indicating if tangents must be morphed
  23521. */
  23522. enableTangentMorphing: boolean;
  23523. /**
  23524. * Gets or sets a boolean indicating if UV must be morphed
  23525. */
  23526. enableUVMorphing: boolean;
  23527. /**
  23528. * Creates a new MorphTargetManager
  23529. * @param scene defines the current scene
  23530. */
  23531. constructor(scene?: Nullable<Scene>);
  23532. /**
  23533. * Gets the unique ID of this manager
  23534. */
  23535. get uniqueId(): number;
  23536. /**
  23537. * Gets the number of vertices handled by this manager
  23538. */
  23539. get vertexCount(): number;
  23540. /**
  23541. * Gets a boolean indicating if this manager supports morphing of normals
  23542. */
  23543. get supportsNormals(): boolean;
  23544. /**
  23545. * Gets a boolean indicating if this manager supports morphing of tangents
  23546. */
  23547. get supportsTangents(): boolean;
  23548. /**
  23549. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23550. */
  23551. get supportsUVs(): boolean;
  23552. /**
  23553. * Gets the number of targets stored in this manager
  23554. */
  23555. get numTargets(): number;
  23556. /**
  23557. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23558. */
  23559. get numInfluencers(): number;
  23560. /**
  23561. * Gets the list of influences (one per target)
  23562. */
  23563. get influences(): Float32Array;
  23564. /**
  23565. * Gets the active target at specified index. An active target is a target with an influence > 0
  23566. * @param index defines the index to check
  23567. * @returns the requested target
  23568. */
  23569. getActiveTarget(index: number): MorphTarget;
  23570. /**
  23571. * Gets the target at specified index
  23572. * @param index defines the index to check
  23573. * @returns the requested target
  23574. */
  23575. getTarget(index: number): MorphTarget;
  23576. /**
  23577. * Add a new target to this manager
  23578. * @param target defines the target to add
  23579. */
  23580. addTarget(target: MorphTarget): void;
  23581. /**
  23582. * Removes a target from the manager
  23583. * @param target defines the target to remove
  23584. */
  23585. removeTarget(target: MorphTarget): void;
  23586. /**
  23587. * Clone the current manager
  23588. * @returns a new MorphTargetManager
  23589. */
  23590. clone(): MorphTargetManager;
  23591. /**
  23592. * Serializes the current manager into a Serialization object
  23593. * @returns the serialized object
  23594. */
  23595. serialize(): any;
  23596. private _syncActiveTargets;
  23597. /**
  23598. * Syncrhonize the targets with all the meshes using this morph target manager
  23599. */
  23600. synchronize(): void;
  23601. /**
  23602. * Creates a new MorphTargetManager from serialized data
  23603. * @param serializationObject defines the serialized data
  23604. * @param scene defines the hosting scene
  23605. * @returns the new MorphTargetManager
  23606. */
  23607. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23608. }
  23609. }
  23610. declare module "babylonjs/Meshes/meshLODLevel" {
  23611. import { Mesh } from "babylonjs/Meshes/mesh";
  23612. import { Nullable } from "babylonjs/types";
  23613. /**
  23614. * Class used to represent a specific level of detail of a mesh
  23615. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23616. */
  23617. export class MeshLODLevel {
  23618. /** Defines the distance where this level should start being displayed */
  23619. distance: number;
  23620. /** Defines the mesh to use to render this level */
  23621. mesh: Nullable<Mesh>;
  23622. /**
  23623. * Creates a new LOD level
  23624. * @param distance defines the distance where this level should star being displayed
  23625. * @param mesh defines the mesh to use to render this level
  23626. */
  23627. constructor(
  23628. /** Defines the distance where this level should start being displayed */
  23629. distance: number,
  23630. /** Defines the mesh to use to render this level */
  23631. mesh: Nullable<Mesh>);
  23632. }
  23633. }
  23634. declare module "babylonjs/Meshes/groundMesh" {
  23635. import { Scene } from "babylonjs/scene";
  23636. import { Vector3 } from "babylonjs/Maths/math.vector";
  23637. import { Mesh } from "babylonjs/Meshes/mesh";
  23638. /**
  23639. * Mesh representing the gorund
  23640. */
  23641. export class GroundMesh extends Mesh {
  23642. /** If octree should be generated */
  23643. generateOctree: boolean;
  23644. private _heightQuads;
  23645. /** @hidden */
  23646. _subdivisionsX: number;
  23647. /** @hidden */
  23648. _subdivisionsY: number;
  23649. /** @hidden */
  23650. _width: number;
  23651. /** @hidden */
  23652. _height: number;
  23653. /** @hidden */
  23654. _minX: number;
  23655. /** @hidden */
  23656. _maxX: number;
  23657. /** @hidden */
  23658. _minZ: number;
  23659. /** @hidden */
  23660. _maxZ: number;
  23661. constructor(name: string, scene: Scene);
  23662. /**
  23663. * "GroundMesh"
  23664. * @returns "GroundMesh"
  23665. */
  23666. getClassName(): string;
  23667. /**
  23668. * The minimum of x and y subdivisions
  23669. */
  23670. get subdivisions(): number;
  23671. /**
  23672. * X subdivisions
  23673. */
  23674. get subdivisionsX(): number;
  23675. /**
  23676. * Y subdivisions
  23677. */
  23678. get subdivisionsY(): number;
  23679. /**
  23680. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23681. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23682. * @param chunksCount the number of subdivisions for x and y
  23683. * @param octreeBlocksSize (Default: 32)
  23684. */
  23685. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23686. /**
  23687. * Returns a height (y) value in the Worl system :
  23688. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23689. * @param x x coordinate
  23690. * @param z z coordinate
  23691. * @returns the ground y position if (x, z) are outside the ground surface.
  23692. */
  23693. getHeightAtCoordinates(x: number, z: number): number;
  23694. /**
  23695. * Returns a normalized vector (Vector3) orthogonal to the ground
  23696. * at the ground coordinates (x, z) expressed in the World system.
  23697. * @param x x coordinate
  23698. * @param z z coordinate
  23699. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23700. */
  23701. getNormalAtCoordinates(x: number, z: number): Vector3;
  23702. /**
  23703. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23704. * at the ground coordinates (x, z) expressed in the World system.
  23705. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23706. * @param x x coordinate
  23707. * @param z z coordinate
  23708. * @param ref vector to store the result
  23709. * @returns the GroundMesh.
  23710. */
  23711. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23712. /**
  23713. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23714. * if the ground has been updated.
  23715. * This can be used in the render loop.
  23716. * @returns the GroundMesh.
  23717. */
  23718. updateCoordinateHeights(): GroundMesh;
  23719. private _getFacetAt;
  23720. private _initHeightQuads;
  23721. private _computeHeightQuads;
  23722. /**
  23723. * Serializes this ground mesh
  23724. * @param serializationObject object to write serialization to
  23725. */
  23726. serialize(serializationObject: any): void;
  23727. /**
  23728. * Parses a serialized ground mesh
  23729. * @param parsedMesh the serialized mesh
  23730. * @param scene the scene to create the ground mesh in
  23731. * @returns the created ground mesh
  23732. */
  23733. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23734. }
  23735. }
  23736. declare module "babylonjs/Physics/physicsJoint" {
  23737. import { Vector3 } from "babylonjs/Maths/math.vector";
  23738. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23739. /**
  23740. * Interface for Physics-Joint data
  23741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23742. */
  23743. export interface PhysicsJointData {
  23744. /**
  23745. * The main pivot of the joint
  23746. */
  23747. mainPivot?: Vector3;
  23748. /**
  23749. * The connected pivot of the joint
  23750. */
  23751. connectedPivot?: Vector3;
  23752. /**
  23753. * The main axis of the joint
  23754. */
  23755. mainAxis?: Vector3;
  23756. /**
  23757. * The connected axis of the joint
  23758. */
  23759. connectedAxis?: Vector3;
  23760. /**
  23761. * The collision of the joint
  23762. */
  23763. collision?: boolean;
  23764. /**
  23765. * Native Oimo/Cannon/Energy data
  23766. */
  23767. nativeParams?: any;
  23768. }
  23769. /**
  23770. * This is a holder class for the physics joint created by the physics plugin
  23771. * It holds a set of functions to control the underlying joint
  23772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23773. */
  23774. export class PhysicsJoint {
  23775. /**
  23776. * The type of the physics joint
  23777. */
  23778. type: number;
  23779. /**
  23780. * The data for the physics joint
  23781. */
  23782. jointData: PhysicsJointData;
  23783. private _physicsJoint;
  23784. protected _physicsPlugin: IPhysicsEnginePlugin;
  23785. /**
  23786. * Initializes the physics joint
  23787. * @param type The type of the physics joint
  23788. * @param jointData The data for the physics joint
  23789. */
  23790. constructor(
  23791. /**
  23792. * The type of the physics joint
  23793. */
  23794. type: number,
  23795. /**
  23796. * The data for the physics joint
  23797. */
  23798. jointData: PhysicsJointData);
  23799. /**
  23800. * Gets the physics joint
  23801. */
  23802. get physicsJoint(): any;
  23803. /**
  23804. * Sets the physics joint
  23805. */
  23806. set physicsJoint(newJoint: any);
  23807. /**
  23808. * Sets the physics plugin
  23809. */
  23810. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23811. /**
  23812. * Execute a function that is physics-plugin specific.
  23813. * @param {Function} func the function that will be executed.
  23814. * It accepts two parameters: the physics world and the physics joint
  23815. */
  23816. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23817. /**
  23818. * Distance-Joint type
  23819. */
  23820. static DistanceJoint: number;
  23821. /**
  23822. * Hinge-Joint type
  23823. */
  23824. static HingeJoint: number;
  23825. /**
  23826. * Ball-and-Socket joint type
  23827. */
  23828. static BallAndSocketJoint: number;
  23829. /**
  23830. * Wheel-Joint type
  23831. */
  23832. static WheelJoint: number;
  23833. /**
  23834. * Slider-Joint type
  23835. */
  23836. static SliderJoint: number;
  23837. /**
  23838. * Prismatic-Joint type
  23839. */
  23840. static PrismaticJoint: number;
  23841. /**
  23842. * Universal-Joint type
  23843. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23844. */
  23845. static UniversalJoint: number;
  23846. /**
  23847. * Hinge-Joint 2 type
  23848. */
  23849. static Hinge2Joint: number;
  23850. /**
  23851. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23852. */
  23853. static PointToPointJoint: number;
  23854. /**
  23855. * Spring-Joint type
  23856. */
  23857. static SpringJoint: number;
  23858. /**
  23859. * Lock-Joint type
  23860. */
  23861. static LockJoint: number;
  23862. }
  23863. /**
  23864. * A class representing a physics distance joint
  23865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export class DistanceJoint extends PhysicsJoint {
  23868. /**
  23869. *
  23870. * @param jointData The data for the Distance-Joint
  23871. */
  23872. constructor(jointData: DistanceJointData);
  23873. /**
  23874. * Update the predefined distance.
  23875. * @param maxDistance The maximum preferred distance
  23876. * @param minDistance The minimum preferred distance
  23877. */
  23878. updateDistance(maxDistance: number, minDistance?: number): void;
  23879. }
  23880. /**
  23881. * Represents a Motor-Enabled Joint
  23882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23883. */
  23884. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23885. /**
  23886. * Initializes the Motor-Enabled Joint
  23887. * @param type The type of the joint
  23888. * @param jointData The physica joint data for the joint
  23889. */
  23890. constructor(type: number, jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param force the force to apply
  23895. * @param maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a single physics Hinge-Joint
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class HingeJoint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge-Joint
  23913. * @param jointData The joint data for the Hinge-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} force the force to apply
  23920. * @param {number} maxForce max force for this motor.
  23921. */
  23922. setMotor(force?: number, maxForce?: number): void;
  23923. /**
  23924. * Set the motor's limits.
  23925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23926. * @param upperLimit The upper limit of the motor
  23927. * @param lowerLimit The lower limit of the motor
  23928. */
  23929. setLimit(upperLimit: number, lowerLimit?: number): void;
  23930. }
  23931. /**
  23932. * This class represents a dual hinge physics joint (same as wheel joint)
  23933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23934. */
  23935. export class Hinge2Joint extends MotorEnabledJoint {
  23936. /**
  23937. * Initializes the Hinge2-Joint
  23938. * @param jointData The joint data for the Hinge2-Joint
  23939. */
  23940. constructor(jointData: PhysicsJointData);
  23941. /**
  23942. * Set the motor values.
  23943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23944. * @param {number} targetSpeed the speed the motor is to reach
  23945. * @param {number} maxForce max force for this motor.
  23946. * @param {motorIndex} the motor's index, 0 or 1.
  23947. */
  23948. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Set the motor limits.
  23951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23952. * @param {number} upperLimit the upper limit
  23953. * @param {number} lowerLimit lower limit
  23954. * @param {motorIndex} the motor's index, 0 or 1.
  23955. */
  23956. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23957. }
  23958. /**
  23959. * Interface for a motor enabled joint
  23960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23961. */
  23962. export interface IMotorEnabledJoint {
  23963. /**
  23964. * Physics joint
  23965. */
  23966. physicsJoint: any;
  23967. /**
  23968. * Sets the motor of the motor-enabled joint
  23969. * @param force The force of the motor
  23970. * @param maxForce The maximum force of the motor
  23971. * @param motorIndex The index of the motor
  23972. */
  23973. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23974. /**
  23975. * Sets the limit of the motor
  23976. * @param upperLimit The upper limit of the motor
  23977. * @param lowerLimit The lower limit of the motor
  23978. * @param motorIndex The index of the motor
  23979. */
  23980. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23981. }
  23982. /**
  23983. * Joint data for a Distance-Joint
  23984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23985. */
  23986. export interface DistanceJointData extends PhysicsJointData {
  23987. /**
  23988. * Max distance the 2 joint objects can be apart
  23989. */
  23990. maxDistance: number;
  23991. }
  23992. /**
  23993. * Joint data from a spring joint
  23994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23995. */
  23996. export interface SpringJointData extends PhysicsJointData {
  23997. /**
  23998. * Length of the spring
  23999. */
  24000. length: number;
  24001. /**
  24002. * Stiffness of the spring
  24003. */
  24004. stiffness: number;
  24005. /**
  24006. * Damping of the spring
  24007. */
  24008. damping: number;
  24009. /** this callback will be called when applying the force to the impostors. */
  24010. forceApplicationCallback: () => void;
  24011. }
  24012. }
  24013. declare module "babylonjs/Physics/physicsRaycastResult" {
  24014. import { Vector3 } from "babylonjs/Maths/math.vector";
  24015. /**
  24016. * Holds the data for the raycast result
  24017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24018. */
  24019. export class PhysicsRaycastResult {
  24020. private _hasHit;
  24021. private _hitDistance;
  24022. private _hitNormalWorld;
  24023. private _hitPointWorld;
  24024. private _rayFromWorld;
  24025. private _rayToWorld;
  24026. /**
  24027. * Gets if there was a hit
  24028. */
  24029. get hasHit(): boolean;
  24030. /**
  24031. * Gets the distance from the hit
  24032. */
  24033. get hitDistance(): number;
  24034. /**
  24035. * Gets the hit normal/direction in the world
  24036. */
  24037. get hitNormalWorld(): Vector3;
  24038. /**
  24039. * Gets the hit point in the world
  24040. */
  24041. get hitPointWorld(): Vector3;
  24042. /**
  24043. * Gets the ray "start point" of the ray in the world
  24044. */
  24045. get rayFromWorld(): Vector3;
  24046. /**
  24047. * Gets the ray "end point" of the ray in the world
  24048. */
  24049. get rayToWorld(): Vector3;
  24050. /**
  24051. * Sets the hit data (normal & point in world space)
  24052. * @param hitNormalWorld defines the normal in world space
  24053. * @param hitPointWorld defines the point in world space
  24054. */
  24055. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24056. /**
  24057. * Sets the distance from the start point to the hit point
  24058. * @param distance
  24059. */
  24060. setHitDistance(distance: number): void;
  24061. /**
  24062. * Calculates the distance manually
  24063. */
  24064. calculateHitDistance(): void;
  24065. /**
  24066. * Resets all the values to default
  24067. * @param from The from point on world space
  24068. * @param to The to point on world space
  24069. */
  24070. reset(from?: Vector3, to?: Vector3): void;
  24071. }
  24072. /**
  24073. * Interface for the size containing width and height
  24074. */
  24075. interface IXYZ {
  24076. /**
  24077. * X
  24078. */
  24079. x: number;
  24080. /**
  24081. * Y
  24082. */
  24083. y: number;
  24084. /**
  24085. * Z
  24086. */
  24087. z: number;
  24088. }
  24089. }
  24090. declare module "babylonjs/Physics/IPhysicsEngine" {
  24091. import { Nullable } from "babylonjs/types";
  24092. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24094. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24095. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24096. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24097. /**
  24098. * Interface used to describe a physics joint
  24099. */
  24100. export interface PhysicsImpostorJoint {
  24101. /** Defines the main impostor to which the joint is linked */
  24102. mainImpostor: PhysicsImpostor;
  24103. /** Defines the impostor that is connected to the main impostor using this joint */
  24104. connectedImpostor: PhysicsImpostor;
  24105. /** Defines the joint itself */
  24106. joint: PhysicsJoint;
  24107. }
  24108. /** @hidden */
  24109. export interface IPhysicsEnginePlugin {
  24110. world: any;
  24111. name: string;
  24112. setGravity(gravity: Vector3): void;
  24113. setTimeStep(timeStep: number): void;
  24114. getTimeStep(): number;
  24115. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24116. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24118. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24119. removePhysicsBody(impostor: PhysicsImpostor): void;
  24120. generateJoint(joint: PhysicsImpostorJoint): void;
  24121. removeJoint(joint: PhysicsImpostorJoint): void;
  24122. isSupported(): boolean;
  24123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24130. getBodyMass(impostor: PhysicsImpostor): number;
  24131. getBodyFriction(impostor: PhysicsImpostor): number;
  24132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24133. getBodyRestitution(impostor: PhysicsImpostor): number;
  24134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24135. getBodyPressure?(impostor: PhysicsImpostor): number;
  24136. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24137. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24138. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24139. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24140. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24141. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24142. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24143. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24144. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24145. sleepBody(impostor: PhysicsImpostor): void;
  24146. wakeUpBody(impostor: PhysicsImpostor): void;
  24147. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24148. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24149. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24150. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24151. getRadius(impostor: PhysicsImpostor): number;
  24152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24154. dispose(): void;
  24155. }
  24156. /**
  24157. * Interface used to define a physics engine
  24158. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24159. */
  24160. export interface IPhysicsEngine {
  24161. /**
  24162. * Gets the gravity vector used by the simulation
  24163. */
  24164. gravity: Vector3;
  24165. /**
  24166. * Sets the gravity vector used by the simulation
  24167. * @param gravity defines the gravity vector to use
  24168. */
  24169. setGravity(gravity: Vector3): void;
  24170. /**
  24171. * Set the time step of the physics engine.
  24172. * Default is 1/60.
  24173. * To slow it down, enter 1/600 for example.
  24174. * To speed it up, 1/30
  24175. * @param newTimeStep the new timestep to apply to this world.
  24176. */
  24177. setTimeStep(newTimeStep: number): void;
  24178. /**
  24179. * Get the time step of the physics engine.
  24180. * @returns the current time step
  24181. */
  24182. getTimeStep(): number;
  24183. /**
  24184. * Set the sub time step of the physics engine.
  24185. * Default is 0 meaning there is no sub steps
  24186. * To increase physics resolution precision, set a small value (like 1 ms)
  24187. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24188. */
  24189. setSubTimeStep(subTimeStep: number): void;
  24190. /**
  24191. * Get the sub time step of the physics engine.
  24192. * @returns the current sub time step
  24193. */
  24194. getSubTimeStep(): number;
  24195. /**
  24196. * Release all resources
  24197. */
  24198. dispose(): void;
  24199. /**
  24200. * Gets the name of the current physics plugin
  24201. * @returns the name of the plugin
  24202. */
  24203. getPhysicsPluginName(): string;
  24204. /**
  24205. * Adding a new impostor for the impostor tracking.
  24206. * This will be done by the impostor itself.
  24207. * @param impostor the impostor to add
  24208. */
  24209. addImpostor(impostor: PhysicsImpostor): void;
  24210. /**
  24211. * Remove an impostor from the engine.
  24212. * This impostor and its mesh will not longer be updated by the physics engine.
  24213. * @param impostor the impostor to remove
  24214. */
  24215. removeImpostor(impostor: PhysicsImpostor): void;
  24216. /**
  24217. * Add a joint to the physics engine
  24218. * @param mainImpostor defines the main impostor to which the joint is added.
  24219. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24220. * @param joint defines the joint that will connect both impostors.
  24221. */
  24222. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24223. /**
  24224. * Removes a joint from the simulation
  24225. * @param mainImpostor defines the impostor used with the joint
  24226. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24227. * @param joint defines the joint to remove
  24228. */
  24229. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24230. /**
  24231. * Gets the current plugin used to run the simulation
  24232. * @returns current plugin
  24233. */
  24234. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24235. /**
  24236. * Gets the list of physic impostors
  24237. * @returns an array of PhysicsImpostor
  24238. */
  24239. getImpostors(): Array<PhysicsImpostor>;
  24240. /**
  24241. * Gets the impostor for a physics enabled object
  24242. * @param object defines the object impersonated by the impostor
  24243. * @returns the PhysicsImpostor or null if not found
  24244. */
  24245. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24246. /**
  24247. * Gets the impostor for a physics body object
  24248. * @param body defines physics body used by the impostor
  24249. * @returns the PhysicsImpostor or null if not found
  24250. */
  24251. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24252. /**
  24253. * Does a raycast in the physics world
  24254. * @param from when should the ray start?
  24255. * @param to when should the ray end?
  24256. * @returns PhysicsRaycastResult
  24257. */
  24258. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24259. /**
  24260. * Called by the scene. No need to call it.
  24261. * @param delta defines the timespam between frames
  24262. */
  24263. _step(delta: number): void;
  24264. }
  24265. }
  24266. declare module "babylonjs/Physics/physicsImpostor" {
  24267. import { Nullable, IndicesArray } from "babylonjs/types";
  24268. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24271. import { Scene } from "babylonjs/scene";
  24272. import { Bone } from "babylonjs/Bones/bone";
  24273. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24274. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24275. import { Space } from "babylonjs/Maths/math.axis";
  24276. /**
  24277. * The interface for the physics imposter parameters
  24278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24279. */
  24280. export interface PhysicsImpostorParameters {
  24281. /**
  24282. * The mass of the physics imposter
  24283. */
  24284. mass: number;
  24285. /**
  24286. * The friction of the physics imposter
  24287. */
  24288. friction?: number;
  24289. /**
  24290. * The coefficient of restitution of the physics imposter
  24291. */
  24292. restitution?: number;
  24293. /**
  24294. * The native options of the physics imposter
  24295. */
  24296. nativeOptions?: any;
  24297. /**
  24298. * Specifies if the parent should be ignored
  24299. */
  24300. ignoreParent?: boolean;
  24301. /**
  24302. * Specifies if bi-directional transformations should be disabled
  24303. */
  24304. disableBidirectionalTransformation?: boolean;
  24305. /**
  24306. * The pressure inside the physics imposter, soft object only
  24307. */
  24308. pressure?: number;
  24309. /**
  24310. * The stiffness the physics imposter, soft object only
  24311. */
  24312. stiffness?: number;
  24313. /**
  24314. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24315. */
  24316. velocityIterations?: number;
  24317. /**
  24318. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24319. */
  24320. positionIterations?: number;
  24321. /**
  24322. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24323. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24324. * Add to fix multiple points
  24325. */
  24326. fixedPoints?: number;
  24327. /**
  24328. * The collision margin around a soft object
  24329. */
  24330. margin?: number;
  24331. /**
  24332. * The collision margin around a soft object
  24333. */
  24334. damping?: number;
  24335. /**
  24336. * The path for a rope based on an extrusion
  24337. */
  24338. path?: any;
  24339. /**
  24340. * The shape of an extrusion used for a rope based on an extrusion
  24341. */
  24342. shape?: any;
  24343. }
  24344. /**
  24345. * Interface for a physics-enabled object
  24346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24347. */
  24348. export interface IPhysicsEnabledObject {
  24349. /**
  24350. * The position of the physics-enabled object
  24351. */
  24352. position: Vector3;
  24353. /**
  24354. * The rotation of the physics-enabled object
  24355. */
  24356. rotationQuaternion: Nullable<Quaternion>;
  24357. /**
  24358. * The scale of the physics-enabled object
  24359. */
  24360. scaling: Vector3;
  24361. /**
  24362. * The rotation of the physics-enabled object
  24363. */
  24364. rotation?: Vector3;
  24365. /**
  24366. * The parent of the physics-enabled object
  24367. */
  24368. parent?: any;
  24369. /**
  24370. * The bounding info of the physics-enabled object
  24371. * @returns The bounding info of the physics-enabled object
  24372. */
  24373. getBoundingInfo(): BoundingInfo;
  24374. /**
  24375. * Computes the world matrix
  24376. * @param force Specifies if the world matrix should be computed by force
  24377. * @returns A world matrix
  24378. */
  24379. computeWorldMatrix(force: boolean): Matrix;
  24380. /**
  24381. * Gets the world matrix
  24382. * @returns A world matrix
  24383. */
  24384. getWorldMatrix?(): Matrix;
  24385. /**
  24386. * Gets the child meshes
  24387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24388. * @returns An array of abstract meshes
  24389. */
  24390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24391. /**
  24392. * Gets the vertex data
  24393. * @param kind The type of vertex data
  24394. * @returns A nullable array of numbers, or a float32 array
  24395. */
  24396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24397. /**
  24398. * Gets the indices from the mesh
  24399. * @returns A nullable array of index arrays
  24400. */
  24401. getIndices?(): Nullable<IndicesArray>;
  24402. /**
  24403. * Gets the scene from the mesh
  24404. * @returns the indices array or null
  24405. */
  24406. getScene?(): Scene;
  24407. /**
  24408. * Gets the absolute position from the mesh
  24409. * @returns the absolute position
  24410. */
  24411. getAbsolutePosition(): Vector3;
  24412. /**
  24413. * Gets the absolute pivot point from the mesh
  24414. * @returns the absolute pivot point
  24415. */
  24416. getAbsolutePivotPoint(): Vector3;
  24417. /**
  24418. * Rotates the mesh
  24419. * @param axis The axis of rotation
  24420. * @param amount The amount of rotation
  24421. * @param space The space of the rotation
  24422. * @returns The rotation transform node
  24423. */
  24424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24425. /**
  24426. * Translates the mesh
  24427. * @param axis The axis of translation
  24428. * @param distance The distance of translation
  24429. * @param space The space of the translation
  24430. * @returns The transform node
  24431. */
  24432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24433. /**
  24434. * Sets the absolute position of the mesh
  24435. * @param absolutePosition The absolute position of the mesh
  24436. * @returns The transform node
  24437. */
  24438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24439. /**
  24440. * Gets the class name of the mesh
  24441. * @returns The class name
  24442. */
  24443. getClassName(): string;
  24444. }
  24445. /**
  24446. * Represents a physics imposter
  24447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24448. */
  24449. export class PhysicsImpostor {
  24450. /**
  24451. * The physics-enabled object used as the physics imposter
  24452. */
  24453. object: IPhysicsEnabledObject;
  24454. /**
  24455. * The type of the physics imposter
  24456. */
  24457. type: number;
  24458. private _options;
  24459. private _scene?;
  24460. /**
  24461. * The default object size of the imposter
  24462. */
  24463. static DEFAULT_OBJECT_SIZE: Vector3;
  24464. /**
  24465. * The identity quaternion of the imposter
  24466. */
  24467. static IDENTITY_QUATERNION: Quaternion;
  24468. /** @hidden */
  24469. _pluginData: any;
  24470. private _physicsEngine;
  24471. private _physicsBody;
  24472. private _bodyUpdateRequired;
  24473. private _onBeforePhysicsStepCallbacks;
  24474. private _onAfterPhysicsStepCallbacks;
  24475. /** @hidden */
  24476. _onPhysicsCollideCallbacks: Array<{
  24477. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24478. otherImpostors: Array<PhysicsImpostor>;
  24479. }>;
  24480. private _deltaPosition;
  24481. private _deltaRotation;
  24482. private _deltaRotationConjugated;
  24483. /** @hidden */
  24484. _isFromLine: boolean;
  24485. private _parent;
  24486. private _isDisposed;
  24487. private static _tmpVecs;
  24488. private static _tmpQuat;
  24489. /**
  24490. * Specifies if the physics imposter is disposed
  24491. */
  24492. get isDisposed(): boolean;
  24493. /**
  24494. * Gets the mass of the physics imposter
  24495. */
  24496. get mass(): number;
  24497. set mass(value: number);
  24498. /**
  24499. * Gets the coefficient of friction
  24500. */
  24501. get friction(): number;
  24502. /**
  24503. * Sets the coefficient of friction
  24504. */
  24505. set friction(value: number);
  24506. /**
  24507. * Gets the coefficient of restitution
  24508. */
  24509. get restitution(): number;
  24510. /**
  24511. * Sets the coefficient of restitution
  24512. */
  24513. set restitution(value: number);
  24514. /**
  24515. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24516. */
  24517. get pressure(): number;
  24518. /**
  24519. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24520. */
  24521. set pressure(value: number);
  24522. /**
  24523. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24524. */
  24525. get stiffness(): number;
  24526. /**
  24527. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24528. */
  24529. set stiffness(value: number);
  24530. /**
  24531. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24532. */
  24533. get velocityIterations(): number;
  24534. /**
  24535. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24536. */
  24537. set velocityIterations(value: number);
  24538. /**
  24539. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24540. */
  24541. get positionIterations(): number;
  24542. /**
  24543. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24544. */
  24545. set positionIterations(value: number);
  24546. /**
  24547. * The unique id of the physics imposter
  24548. * set by the physics engine when adding this impostor to the array
  24549. */
  24550. uniqueId: number;
  24551. /**
  24552. * @hidden
  24553. */
  24554. soft: boolean;
  24555. /**
  24556. * @hidden
  24557. */
  24558. segments: number;
  24559. private _joints;
  24560. /**
  24561. * Initializes the physics imposter
  24562. * @param object The physics-enabled object used as the physics imposter
  24563. * @param type The type of the physics imposter
  24564. * @param _options The options for the physics imposter
  24565. * @param _scene The Babylon scene
  24566. */
  24567. constructor(
  24568. /**
  24569. * The physics-enabled object used as the physics imposter
  24570. */
  24571. object: IPhysicsEnabledObject,
  24572. /**
  24573. * The type of the physics imposter
  24574. */
  24575. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24576. /**
  24577. * This function will completly initialize this impostor.
  24578. * It will create a new body - but only if this mesh has no parent.
  24579. * If it has, this impostor will not be used other than to define the impostor
  24580. * of the child mesh.
  24581. * @hidden
  24582. */
  24583. _init(): void;
  24584. private _getPhysicsParent;
  24585. /**
  24586. * Should a new body be generated.
  24587. * @returns boolean specifying if body initialization is required
  24588. */
  24589. isBodyInitRequired(): boolean;
  24590. /**
  24591. * Sets the updated scaling
  24592. * @param updated Specifies if the scaling is updated
  24593. */
  24594. setScalingUpdated(): void;
  24595. /**
  24596. * Force a regeneration of this or the parent's impostor's body.
  24597. * Use under cautious - This will remove all joints already implemented.
  24598. */
  24599. forceUpdate(): void;
  24600. /**
  24601. * Gets the body that holds this impostor. Either its own, or its parent.
  24602. */
  24603. get physicsBody(): any;
  24604. /**
  24605. * Get the parent of the physics imposter
  24606. * @returns Physics imposter or null
  24607. */
  24608. get parent(): Nullable<PhysicsImpostor>;
  24609. /**
  24610. * Sets the parent of the physics imposter
  24611. */
  24612. set parent(value: Nullable<PhysicsImpostor>);
  24613. /**
  24614. * Set the physics body. Used mainly by the physics engine/plugin
  24615. */
  24616. set physicsBody(physicsBody: any);
  24617. /**
  24618. * Resets the update flags
  24619. */
  24620. resetUpdateFlags(): void;
  24621. /**
  24622. * Gets the object extend size
  24623. * @returns the object extend size
  24624. */
  24625. getObjectExtendSize(): Vector3;
  24626. /**
  24627. * Gets the object center
  24628. * @returns The object center
  24629. */
  24630. getObjectCenter(): Vector3;
  24631. /**
  24632. * Get a specific parameter from the options parameters
  24633. * @param paramName The object parameter name
  24634. * @returns The object parameter
  24635. */
  24636. getParam(paramName: string): any;
  24637. /**
  24638. * Sets a specific parameter in the options given to the physics plugin
  24639. * @param paramName The parameter name
  24640. * @param value The value of the parameter
  24641. */
  24642. setParam(paramName: string, value: number): void;
  24643. /**
  24644. * Specifically change the body's mass option. Won't recreate the physics body object
  24645. * @param mass The mass of the physics imposter
  24646. */
  24647. setMass(mass: number): void;
  24648. /**
  24649. * Gets the linear velocity
  24650. * @returns linear velocity or null
  24651. */
  24652. getLinearVelocity(): Nullable<Vector3>;
  24653. /**
  24654. * Sets the linear velocity
  24655. * @param velocity linear velocity or null
  24656. */
  24657. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24658. /**
  24659. * Gets the angular velocity
  24660. * @returns angular velocity or null
  24661. */
  24662. getAngularVelocity(): Nullable<Vector3>;
  24663. /**
  24664. * Sets the angular velocity
  24665. * @param velocity The velocity or null
  24666. */
  24667. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24668. /**
  24669. * Execute a function with the physics plugin native code
  24670. * Provide a function the will have two variables - the world object and the physics body object
  24671. * @param func The function to execute with the physics plugin native code
  24672. */
  24673. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24674. /**
  24675. * Register a function that will be executed before the physics world is stepping forward
  24676. * @param func The function to execute before the physics world is stepped forward
  24677. */
  24678. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24679. /**
  24680. * Unregister a function that will be executed before the physics world is stepping forward
  24681. * @param func The function to execute before the physics world is stepped forward
  24682. */
  24683. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24684. /**
  24685. * Register a function that will be executed after the physics step
  24686. * @param func The function to execute after physics step
  24687. */
  24688. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24689. /**
  24690. * Unregisters a function that will be executed after the physics step
  24691. * @param func The function to execute after physics step
  24692. */
  24693. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24694. /**
  24695. * register a function that will be executed when this impostor collides against a different body
  24696. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24697. * @param func Callback that is executed on collision
  24698. */
  24699. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24700. /**
  24701. * Unregisters the physics imposter on contact
  24702. * @param collideAgainst The physics object to collide against
  24703. * @param func Callback to execute on collision
  24704. */
  24705. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24706. private _tmpQuat;
  24707. private _tmpQuat2;
  24708. /**
  24709. * Get the parent rotation
  24710. * @returns The parent rotation
  24711. */
  24712. getParentsRotation(): Quaternion;
  24713. /**
  24714. * this function is executed by the physics engine.
  24715. */
  24716. beforeStep: () => void;
  24717. /**
  24718. * this function is executed by the physics engine
  24719. */
  24720. afterStep: () => void;
  24721. /**
  24722. * Legacy collision detection event support
  24723. */
  24724. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24725. /**
  24726. * event and body object due to cannon's event-based architecture.
  24727. */
  24728. onCollide: (e: {
  24729. body: any;
  24730. }) => void;
  24731. /**
  24732. * Apply a force
  24733. * @param force The force to apply
  24734. * @param contactPoint The contact point for the force
  24735. * @returns The physics imposter
  24736. */
  24737. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24738. /**
  24739. * Apply an impulse
  24740. * @param force The impulse force
  24741. * @param contactPoint The contact point for the impulse force
  24742. * @returns The physics imposter
  24743. */
  24744. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24745. /**
  24746. * A help function to create a joint
  24747. * @param otherImpostor A physics imposter used to create a joint
  24748. * @param jointType The type of joint
  24749. * @param jointData The data for the joint
  24750. * @returns The physics imposter
  24751. */
  24752. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24753. /**
  24754. * Add a joint to this impostor with a different impostor
  24755. * @param otherImpostor A physics imposter used to add a joint
  24756. * @param joint The joint to add
  24757. * @returns The physics imposter
  24758. */
  24759. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24760. /**
  24761. * Add an anchor to a cloth impostor
  24762. * @param otherImpostor rigid impostor to anchor to
  24763. * @param width ratio across width from 0 to 1
  24764. * @param height ratio up height from 0 to 1
  24765. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24766. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24767. * @returns impostor the soft imposter
  24768. */
  24769. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24770. /**
  24771. * Add a hook to a rope impostor
  24772. * @param otherImpostor rigid impostor to anchor to
  24773. * @param length ratio across rope from 0 to 1
  24774. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24775. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24776. * @returns impostor the rope imposter
  24777. */
  24778. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24779. /**
  24780. * Will keep this body still, in a sleep mode.
  24781. * @returns the physics imposter
  24782. */
  24783. sleep(): PhysicsImpostor;
  24784. /**
  24785. * Wake the body up.
  24786. * @returns The physics imposter
  24787. */
  24788. wakeUp(): PhysicsImpostor;
  24789. /**
  24790. * Clones the physics imposter
  24791. * @param newObject The physics imposter clones to this physics-enabled object
  24792. * @returns A nullable physics imposter
  24793. */
  24794. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24795. /**
  24796. * Disposes the physics imposter
  24797. */
  24798. dispose(): void;
  24799. /**
  24800. * Sets the delta position
  24801. * @param position The delta position amount
  24802. */
  24803. setDeltaPosition(position: Vector3): void;
  24804. /**
  24805. * Sets the delta rotation
  24806. * @param rotation The delta rotation amount
  24807. */
  24808. setDeltaRotation(rotation: Quaternion): void;
  24809. /**
  24810. * Gets the box size of the physics imposter and stores the result in the input parameter
  24811. * @param result Stores the box size
  24812. * @returns The physics imposter
  24813. */
  24814. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24815. /**
  24816. * Gets the radius of the physics imposter
  24817. * @returns Radius of the physics imposter
  24818. */
  24819. getRadius(): number;
  24820. /**
  24821. * Sync a bone with this impostor
  24822. * @param bone The bone to sync to the impostor.
  24823. * @param boneMesh The mesh that the bone is influencing.
  24824. * @param jointPivot The pivot of the joint / bone in local space.
  24825. * @param distToJoint Optional distance from the impostor to the joint.
  24826. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24827. */
  24828. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24829. /**
  24830. * Sync impostor to a bone
  24831. * @param bone The bone that the impostor will be synced to.
  24832. * @param boneMesh The mesh that the bone is influencing.
  24833. * @param jointPivot The pivot of the joint / bone in local space.
  24834. * @param distToJoint Optional distance from the impostor to the joint.
  24835. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24836. * @param boneAxis Optional vector3 axis the bone is aligned with
  24837. */
  24838. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24839. /**
  24840. * No-Imposter type
  24841. */
  24842. static NoImpostor: number;
  24843. /**
  24844. * Sphere-Imposter type
  24845. */
  24846. static SphereImpostor: number;
  24847. /**
  24848. * Box-Imposter type
  24849. */
  24850. static BoxImpostor: number;
  24851. /**
  24852. * Plane-Imposter type
  24853. */
  24854. static PlaneImpostor: number;
  24855. /**
  24856. * Mesh-imposter type
  24857. */
  24858. static MeshImpostor: number;
  24859. /**
  24860. * Capsule-Impostor type (Ammo.js plugin only)
  24861. */
  24862. static CapsuleImpostor: number;
  24863. /**
  24864. * Cylinder-Imposter type
  24865. */
  24866. static CylinderImpostor: number;
  24867. /**
  24868. * Particle-Imposter type
  24869. */
  24870. static ParticleImpostor: number;
  24871. /**
  24872. * Heightmap-Imposter type
  24873. */
  24874. static HeightmapImpostor: number;
  24875. /**
  24876. * ConvexHull-Impostor type (Ammo.js plugin only)
  24877. */
  24878. static ConvexHullImpostor: number;
  24879. /**
  24880. * Custom-Imposter type (Ammo.js plugin only)
  24881. */
  24882. static CustomImpostor: number;
  24883. /**
  24884. * Rope-Imposter type
  24885. */
  24886. static RopeImpostor: number;
  24887. /**
  24888. * Cloth-Imposter type
  24889. */
  24890. static ClothImpostor: number;
  24891. /**
  24892. * Softbody-Imposter type
  24893. */
  24894. static SoftbodyImpostor: number;
  24895. }
  24896. }
  24897. declare module "babylonjs/Meshes/mesh" {
  24898. import { Observable } from "babylonjs/Misc/observable";
  24899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24900. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24901. import { Camera } from "babylonjs/Cameras/camera";
  24902. import { Scene } from "babylonjs/scene";
  24903. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24904. import { Color4 } from "babylonjs/Maths/math.color";
  24905. import { Engine } from "babylonjs/Engines/engine";
  24906. import { Node } from "babylonjs/node";
  24907. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24908. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24909. import { Buffer } from "babylonjs/Meshes/buffer";
  24910. import { Geometry } from "babylonjs/Meshes/geometry";
  24911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24912. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24913. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24914. import { Effect } from "babylonjs/Materials/effect";
  24915. import { Material } from "babylonjs/Materials/material";
  24916. import { Skeleton } from "babylonjs/Bones/skeleton";
  24917. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24918. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24919. import { Path3D } from "babylonjs/Maths/math.path";
  24920. import { Plane } from "babylonjs/Maths/math.plane";
  24921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24922. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24923. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24924. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24925. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24926. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24927. /**
  24928. * @hidden
  24929. **/
  24930. export class _CreationDataStorage {
  24931. closePath?: boolean;
  24932. closeArray?: boolean;
  24933. idx: number[];
  24934. dashSize: number;
  24935. gapSize: number;
  24936. path3D: Path3D;
  24937. pathArray: Vector3[][];
  24938. arc: number;
  24939. radius: number;
  24940. cap: number;
  24941. tessellation: number;
  24942. }
  24943. /**
  24944. * @hidden
  24945. **/
  24946. class _InstanceDataStorage {
  24947. visibleInstances: any;
  24948. batchCache: _InstancesBatch;
  24949. instancesBufferSize: number;
  24950. instancesBuffer: Nullable<Buffer>;
  24951. instancesData: Float32Array;
  24952. overridenInstanceCount: number;
  24953. isFrozen: boolean;
  24954. previousBatch: Nullable<_InstancesBatch>;
  24955. hardwareInstancedRendering: boolean;
  24956. sideOrientation: number;
  24957. manualUpdate: boolean;
  24958. }
  24959. /**
  24960. * @hidden
  24961. **/
  24962. export class _InstancesBatch {
  24963. mustReturn: boolean;
  24964. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24965. renderSelf: boolean[];
  24966. hardwareInstancedRendering: boolean[];
  24967. }
  24968. /**
  24969. * Class used to represent renderable models
  24970. */
  24971. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24972. /**
  24973. * Mesh side orientation : usually the external or front surface
  24974. */
  24975. static readonly FRONTSIDE: number;
  24976. /**
  24977. * Mesh side orientation : usually the internal or back surface
  24978. */
  24979. static readonly BACKSIDE: number;
  24980. /**
  24981. * Mesh side orientation : both internal and external or front and back surfaces
  24982. */
  24983. static readonly DOUBLESIDE: number;
  24984. /**
  24985. * Mesh side orientation : by default, `FRONTSIDE`
  24986. */
  24987. static readonly DEFAULTSIDE: number;
  24988. /**
  24989. * Mesh cap setting : no cap
  24990. */
  24991. static readonly NO_CAP: number;
  24992. /**
  24993. * Mesh cap setting : one cap at the beginning of the mesh
  24994. */
  24995. static readonly CAP_START: number;
  24996. /**
  24997. * Mesh cap setting : one cap at the end of the mesh
  24998. */
  24999. static readonly CAP_END: number;
  25000. /**
  25001. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25002. */
  25003. static readonly CAP_ALL: number;
  25004. /**
  25005. * Mesh pattern setting : no flip or rotate
  25006. */
  25007. static readonly NO_FLIP: number;
  25008. /**
  25009. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25010. */
  25011. static readonly FLIP_TILE: number;
  25012. /**
  25013. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25014. */
  25015. static readonly ROTATE_TILE: number;
  25016. /**
  25017. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25018. */
  25019. static readonly FLIP_ROW: number;
  25020. /**
  25021. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25022. */
  25023. static readonly ROTATE_ROW: number;
  25024. /**
  25025. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25026. */
  25027. static readonly FLIP_N_ROTATE_TILE: number;
  25028. /**
  25029. * Mesh pattern setting : rotate pattern and rotate
  25030. */
  25031. static readonly FLIP_N_ROTATE_ROW: number;
  25032. /**
  25033. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25034. */
  25035. static readonly CENTER: number;
  25036. /**
  25037. * Mesh tile positioning : part tiles on left
  25038. */
  25039. static readonly LEFT: number;
  25040. /**
  25041. * Mesh tile positioning : part tiles on right
  25042. */
  25043. static readonly RIGHT: number;
  25044. /**
  25045. * Mesh tile positioning : part tiles on top
  25046. */
  25047. static readonly TOP: number;
  25048. /**
  25049. * Mesh tile positioning : part tiles on bottom
  25050. */
  25051. static readonly BOTTOM: number;
  25052. /**
  25053. * Gets the default side orientation.
  25054. * @param orientation the orientation to value to attempt to get
  25055. * @returns the default orientation
  25056. * @hidden
  25057. */
  25058. static _GetDefaultSideOrientation(orientation?: number): number;
  25059. private _internalMeshDataInfo;
  25060. /**
  25061. * An event triggered before rendering the mesh
  25062. */
  25063. get onBeforeRenderObservable(): Observable<Mesh>;
  25064. /**
  25065. * An event triggered before binding the mesh
  25066. */
  25067. get onBeforeBindObservable(): Observable<Mesh>;
  25068. /**
  25069. * An event triggered after rendering the mesh
  25070. */
  25071. get onAfterRenderObservable(): Observable<Mesh>;
  25072. /**
  25073. * An event triggered before drawing the mesh
  25074. */
  25075. get onBeforeDrawObservable(): Observable<Mesh>;
  25076. private _onBeforeDrawObserver;
  25077. /**
  25078. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25079. */
  25080. set onBeforeDraw(callback: () => void);
  25081. get hasInstances(): boolean;
  25082. /**
  25083. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25084. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25085. */
  25086. delayLoadState: number;
  25087. /**
  25088. * Gets the list of instances created from this mesh
  25089. * it is not supposed to be modified manually.
  25090. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25092. */
  25093. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25094. /**
  25095. * Gets the file containing delay loading data for this mesh
  25096. */
  25097. delayLoadingFile: string;
  25098. /** @hidden */
  25099. _binaryInfo: any;
  25100. /**
  25101. * User defined function used to change how LOD level selection is done
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25103. */
  25104. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25105. /**
  25106. * Gets or sets the morph target manager
  25107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25108. */
  25109. get morphTargetManager(): Nullable<MorphTargetManager>;
  25110. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25111. /** @hidden */
  25112. _creationDataStorage: Nullable<_CreationDataStorage>;
  25113. /** @hidden */
  25114. _geometry: Nullable<Geometry>;
  25115. /** @hidden */
  25116. _delayInfo: Array<string>;
  25117. /** @hidden */
  25118. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25119. /** @hidden */
  25120. _instanceDataStorage: _InstanceDataStorage;
  25121. private _effectiveMaterial;
  25122. /** @hidden */
  25123. _shouldGenerateFlatShading: boolean;
  25124. /** @hidden */
  25125. _originalBuilderSideOrientation: number;
  25126. /**
  25127. * Use this property to change the original side orientation defined at construction time
  25128. */
  25129. overrideMaterialSideOrientation: Nullable<number>;
  25130. /**
  25131. * Gets the source mesh (the one used to clone this one from)
  25132. */
  25133. get source(): Nullable<Mesh>;
  25134. /**
  25135. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25136. */
  25137. get isUnIndexed(): boolean;
  25138. set isUnIndexed(value: boolean);
  25139. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25140. get worldMatrixInstancedBuffer(): Float32Array;
  25141. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25142. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25143. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25144. /**
  25145. * @constructor
  25146. * @param name The value used by scene.getMeshByName() to do a lookup.
  25147. * @param scene The scene to add this mesh to.
  25148. * @param parent The parent of this mesh, if it has one
  25149. * @param source An optional Mesh from which geometry is shared, cloned.
  25150. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25151. * When false, achieved by calling a clone(), also passing False.
  25152. * This will make creation of children, recursive.
  25153. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25154. */
  25155. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25156. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25157. doNotInstantiate: boolean;
  25158. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25159. /**
  25160. * Gets the class name
  25161. * @returns the string "Mesh".
  25162. */
  25163. getClassName(): string;
  25164. /** @hidden */
  25165. get _isMesh(): boolean;
  25166. /**
  25167. * Returns a description of this mesh
  25168. * @param fullDetails define if full details about this mesh must be used
  25169. * @returns a descriptive string representing this mesh
  25170. */
  25171. toString(fullDetails?: boolean): string;
  25172. /** @hidden */
  25173. _unBindEffect(): void;
  25174. /**
  25175. * Gets a boolean indicating if this mesh has LOD
  25176. */
  25177. get hasLODLevels(): boolean;
  25178. /**
  25179. * Gets the list of MeshLODLevel associated with the current mesh
  25180. * @returns an array of MeshLODLevel
  25181. */
  25182. getLODLevels(): MeshLODLevel[];
  25183. private _sortLODLevels;
  25184. /**
  25185. * Add a mesh as LOD level triggered at the given distance.
  25186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25187. * @param distance The distance from the center of the object to show this level
  25188. * @param mesh The mesh to be added as LOD level (can be null)
  25189. * @return This mesh (for chaining)
  25190. */
  25191. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25192. /**
  25193. * Returns the LOD level mesh at the passed distance or null if not found.
  25194. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25195. * @param distance The distance from the center of the object to show this level
  25196. * @returns a Mesh or `null`
  25197. */
  25198. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25199. /**
  25200. * Remove a mesh from the LOD array
  25201. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25202. * @param mesh defines the mesh to be removed
  25203. * @return This mesh (for chaining)
  25204. */
  25205. removeLODLevel(mesh: Mesh): Mesh;
  25206. /**
  25207. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25209. * @param camera defines the camera to use to compute distance
  25210. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25211. * @return This mesh (for chaining)
  25212. */
  25213. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25214. /**
  25215. * Gets the mesh internal Geometry object
  25216. */
  25217. get geometry(): Nullable<Geometry>;
  25218. /**
  25219. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25220. * @returns the total number of vertices
  25221. */
  25222. getTotalVertices(): number;
  25223. /**
  25224. * Returns the content of an associated vertex buffer
  25225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25226. * - VertexBuffer.PositionKind
  25227. * - VertexBuffer.UVKind
  25228. * - VertexBuffer.UV2Kind
  25229. * - VertexBuffer.UV3Kind
  25230. * - VertexBuffer.UV4Kind
  25231. * - VertexBuffer.UV5Kind
  25232. * - VertexBuffer.UV6Kind
  25233. * - VertexBuffer.ColorKind
  25234. * - VertexBuffer.MatricesIndicesKind
  25235. * - VertexBuffer.MatricesIndicesExtraKind
  25236. * - VertexBuffer.MatricesWeightsKind
  25237. * - VertexBuffer.MatricesWeightsExtraKind
  25238. * @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
  25239. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25240. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25241. */
  25242. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25243. /**
  25244. * Returns the mesh VertexBuffer object from the requested `kind`
  25245. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25246. * - VertexBuffer.PositionKind
  25247. * - VertexBuffer.NormalKind
  25248. * - VertexBuffer.UVKind
  25249. * - VertexBuffer.UV2Kind
  25250. * - VertexBuffer.UV3Kind
  25251. * - VertexBuffer.UV4Kind
  25252. * - VertexBuffer.UV5Kind
  25253. * - VertexBuffer.UV6Kind
  25254. * - VertexBuffer.ColorKind
  25255. * - VertexBuffer.MatricesIndicesKind
  25256. * - VertexBuffer.MatricesIndicesExtraKind
  25257. * - VertexBuffer.MatricesWeightsKind
  25258. * - VertexBuffer.MatricesWeightsExtraKind
  25259. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25260. */
  25261. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25262. /**
  25263. * Tests if a specific vertex buffer is associated with this mesh
  25264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25265. * - VertexBuffer.PositionKind
  25266. * - VertexBuffer.NormalKind
  25267. * - VertexBuffer.UVKind
  25268. * - VertexBuffer.UV2Kind
  25269. * - VertexBuffer.UV3Kind
  25270. * - VertexBuffer.UV4Kind
  25271. * - VertexBuffer.UV5Kind
  25272. * - VertexBuffer.UV6Kind
  25273. * - VertexBuffer.ColorKind
  25274. * - VertexBuffer.MatricesIndicesKind
  25275. * - VertexBuffer.MatricesIndicesExtraKind
  25276. * - VertexBuffer.MatricesWeightsKind
  25277. * - VertexBuffer.MatricesWeightsExtraKind
  25278. * @returns a boolean
  25279. */
  25280. isVerticesDataPresent(kind: string): boolean;
  25281. /**
  25282. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25283. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25284. * - VertexBuffer.PositionKind
  25285. * - VertexBuffer.UVKind
  25286. * - VertexBuffer.UV2Kind
  25287. * - VertexBuffer.UV3Kind
  25288. * - VertexBuffer.UV4Kind
  25289. * - VertexBuffer.UV5Kind
  25290. * - VertexBuffer.UV6Kind
  25291. * - VertexBuffer.ColorKind
  25292. * - VertexBuffer.MatricesIndicesKind
  25293. * - VertexBuffer.MatricesIndicesExtraKind
  25294. * - VertexBuffer.MatricesWeightsKind
  25295. * - VertexBuffer.MatricesWeightsExtraKind
  25296. * @returns a boolean
  25297. */
  25298. isVertexBufferUpdatable(kind: string): boolean;
  25299. /**
  25300. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25301. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25302. * - VertexBuffer.PositionKind
  25303. * - VertexBuffer.NormalKind
  25304. * - VertexBuffer.UVKind
  25305. * - VertexBuffer.UV2Kind
  25306. * - VertexBuffer.UV3Kind
  25307. * - VertexBuffer.UV4Kind
  25308. * - VertexBuffer.UV5Kind
  25309. * - VertexBuffer.UV6Kind
  25310. * - VertexBuffer.ColorKind
  25311. * - VertexBuffer.MatricesIndicesKind
  25312. * - VertexBuffer.MatricesIndicesExtraKind
  25313. * - VertexBuffer.MatricesWeightsKind
  25314. * - VertexBuffer.MatricesWeightsExtraKind
  25315. * @returns an array of strings
  25316. */
  25317. getVerticesDataKinds(): string[];
  25318. /**
  25319. * Returns a positive integer : the total number of indices in this mesh geometry.
  25320. * @returns the numner of indices or zero if the mesh has no geometry.
  25321. */
  25322. getTotalIndices(): number;
  25323. /**
  25324. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25325. * @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.
  25326. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25327. * @returns the indices array or an empty array if the mesh has no geometry
  25328. */
  25329. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25330. get isBlocked(): boolean;
  25331. /**
  25332. * Determine if the current mesh is ready to be rendered
  25333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25334. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25335. * @returns true if all associated assets are ready (material, textures, shaders)
  25336. */
  25337. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25338. /**
  25339. * 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.
  25340. */
  25341. get areNormalsFrozen(): boolean;
  25342. /**
  25343. * 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.
  25344. * @returns the current mesh
  25345. */
  25346. freezeNormals(): Mesh;
  25347. /**
  25348. * 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
  25349. * @returns the current mesh
  25350. */
  25351. unfreezeNormals(): Mesh;
  25352. /**
  25353. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25354. */
  25355. set overridenInstanceCount(count: number);
  25356. /** @hidden */
  25357. _preActivate(): Mesh;
  25358. /** @hidden */
  25359. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25360. /** @hidden */
  25361. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25362. /**
  25363. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25364. * This means the mesh underlying bounding box and sphere are recomputed.
  25365. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25366. * @returns the current mesh
  25367. */
  25368. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25369. /** @hidden */
  25370. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25371. /**
  25372. * This function will subdivide the mesh into multiple submeshes
  25373. * @param count defines the expected number of submeshes
  25374. */
  25375. subdivide(count: number): void;
  25376. /**
  25377. * Copy a FloatArray into a specific associated vertex buffer
  25378. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25379. * - VertexBuffer.PositionKind
  25380. * - VertexBuffer.UVKind
  25381. * - VertexBuffer.UV2Kind
  25382. * - VertexBuffer.UV3Kind
  25383. * - VertexBuffer.UV4Kind
  25384. * - VertexBuffer.UV5Kind
  25385. * - VertexBuffer.UV6Kind
  25386. * - VertexBuffer.ColorKind
  25387. * - VertexBuffer.MatricesIndicesKind
  25388. * - VertexBuffer.MatricesIndicesExtraKind
  25389. * - VertexBuffer.MatricesWeightsKind
  25390. * - VertexBuffer.MatricesWeightsExtraKind
  25391. * @param data defines the data source
  25392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25393. * @param stride defines the data stride size (can be null)
  25394. * @returns the current mesh
  25395. */
  25396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25397. /**
  25398. * Delete a vertex buffer associated with this mesh
  25399. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.UVKind
  25402. * - VertexBuffer.UV2Kind
  25403. * - VertexBuffer.UV3Kind
  25404. * - VertexBuffer.UV4Kind
  25405. * - VertexBuffer.UV5Kind
  25406. * - VertexBuffer.UV6Kind
  25407. * - VertexBuffer.ColorKind
  25408. * - VertexBuffer.MatricesIndicesKind
  25409. * - VertexBuffer.MatricesIndicesExtraKind
  25410. * - VertexBuffer.MatricesWeightsKind
  25411. * - VertexBuffer.MatricesWeightsExtraKind
  25412. */
  25413. removeVerticesData(kind: string): void;
  25414. /**
  25415. * Flags an associated vertex buffer as updatable
  25416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25417. * - VertexBuffer.PositionKind
  25418. * - VertexBuffer.UVKind
  25419. * - VertexBuffer.UV2Kind
  25420. * - VertexBuffer.UV3Kind
  25421. * - VertexBuffer.UV4Kind
  25422. * - VertexBuffer.UV5Kind
  25423. * - VertexBuffer.UV6Kind
  25424. * - VertexBuffer.ColorKind
  25425. * - VertexBuffer.MatricesIndicesKind
  25426. * - VertexBuffer.MatricesIndicesExtraKind
  25427. * - VertexBuffer.MatricesWeightsKind
  25428. * - VertexBuffer.MatricesWeightsExtraKind
  25429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25430. */
  25431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25432. /**
  25433. * Sets the mesh global Vertex Buffer
  25434. * @param buffer defines the buffer to use
  25435. * @returns the current mesh
  25436. */
  25437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25438. /**
  25439. * Update a specific associated vertex buffer
  25440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25441. * - VertexBuffer.PositionKind
  25442. * - VertexBuffer.UVKind
  25443. * - VertexBuffer.UV2Kind
  25444. * - VertexBuffer.UV3Kind
  25445. * - VertexBuffer.UV4Kind
  25446. * - VertexBuffer.UV5Kind
  25447. * - VertexBuffer.UV6Kind
  25448. * - VertexBuffer.ColorKind
  25449. * - VertexBuffer.MatricesIndicesKind
  25450. * - VertexBuffer.MatricesIndicesExtraKind
  25451. * - VertexBuffer.MatricesWeightsKind
  25452. * - VertexBuffer.MatricesWeightsExtraKind
  25453. * @param data defines the data source
  25454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25455. * @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)
  25456. * @returns the current mesh
  25457. */
  25458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25459. /**
  25460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25464. * @returns the current mesh
  25465. */
  25466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25467. /**
  25468. * Creates a un-shared specific occurence of the geometry for the mesh.
  25469. * @returns the current mesh
  25470. */
  25471. makeGeometryUnique(): Mesh;
  25472. /**
  25473. * Set the index buffer of this mesh
  25474. * @param indices defines the source data
  25475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25477. * @returns the current mesh
  25478. */
  25479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25480. /**
  25481. * Update the current index buffer
  25482. * @param indices defines the source data
  25483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25484. * @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)
  25485. * @returns the current mesh
  25486. */
  25487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25488. /**
  25489. * Invert the geometry to move from a right handed system to a left handed one.
  25490. * @returns the current mesh
  25491. */
  25492. toLeftHanded(): Mesh;
  25493. /** @hidden */
  25494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25495. /** @hidden */
  25496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25497. /**
  25498. * Registers for this mesh a javascript function called just before the rendering process
  25499. * @param func defines the function to call before rendering this mesh
  25500. * @returns the current mesh
  25501. */
  25502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25503. /**
  25504. * Disposes a previously registered javascript function called before the rendering
  25505. * @param func defines the function to remove
  25506. * @returns the current mesh
  25507. */
  25508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25509. /**
  25510. * Registers for this mesh a javascript function called just after the rendering is complete
  25511. * @param func defines the function to call after rendering this mesh
  25512. * @returns the current mesh
  25513. */
  25514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25515. /**
  25516. * Disposes a previously registered javascript function called after the rendering.
  25517. * @param func defines the function to remove
  25518. * @returns the current mesh
  25519. */
  25520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25521. /** @hidden */
  25522. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25523. /** @hidden */
  25524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25525. /** @hidden */
  25526. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25527. /** @hidden */
  25528. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25529. /** @hidden */
  25530. _rebuild(): void;
  25531. /** @hidden */
  25532. _freeze(): void;
  25533. /** @hidden */
  25534. _unFreeze(): void;
  25535. /**
  25536. * 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
  25537. * @param subMesh defines the subMesh to render
  25538. * @param enableAlphaMode defines if alpha mode can be changed
  25539. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25540. * @returns the current mesh
  25541. */
  25542. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25543. private _onBeforeDraw;
  25544. /**
  25545. * Renormalize the mesh and patch it up if there are no weights
  25546. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25547. * However in the case of zero weights then we set just a single influence to 1.
  25548. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25549. */
  25550. cleanMatrixWeights(): void;
  25551. private normalizeSkinFourWeights;
  25552. private normalizeSkinWeightsAndExtra;
  25553. /**
  25554. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25555. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25556. * the user know there was an issue with importing the mesh
  25557. * @returns a validation object with skinned, valid and report string
  25558. */
  25559. validateSkinning(): {
  25560. skinned: boolean;
  25561. valid: boolean;
  25562. report: string;
  25563. };
  25564. /** @hidden */
  25565. _checkDelayState(): Mesh;
  25566. private _queueLoad;
  25567. /**
  25568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25569. * A mesh is in the frustum if its bounding box intersects the frustum
  25570. * @param frustumPlanes defines the frustum to test
  25571. * @returns true if the mesh is in the frustum planes
  25572. */
  25573. isInFrustum(frustumPlanes: Plane[]): boolean;
  25574. /**
  25575. * Sets the mesh material by the material or multiMaterial `id` property
  25576. * @param id is a string identifying the material or the multiMaterial
  25577. * @returns the current mesh
  25578. */
  25579. setMaterialByID(id: string): Mesh;
  25580. /**
  25581. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25582. * @returns an array of IAnimatable
  25583. */
  25584. getAnimatables(): IAnimatable[];
  25585. /**
  25586. * Modifies the mesh geometry according to the passed transformation matrix.
  25587. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25588. * The mesh normals are modified using the same transformation.
  25589. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25590. * @param transform defines the transform matrix to use
  25591. * @see http://doc.babylonjs.com/resources/baking_transformations
  25592. * @returns the current mesh
  25593. */
  25594. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25595. /**
  25596. * Modifies the mesh geometry according to its own current World Matrix.
  25597. * The mesh World Matrix is then reset.
  25598. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25599. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25600. * @see http://doc.babylonjs.com/resources/baking_transformations
  25601. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25602. * @returns the current mesh
  25603. */
  25604. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25605. /** @hidden */
  25606. get _positions(): Nullable<Vector3[]>;
  25607. /** @hidden */
  25608. _resetPointsArrayCache(): Mesh;
  25609. /** @hidden */
  25610. _generatePointsArray(): boolean;
  25611. /**
  25612. * Returns a new Mesh object generated from the current mesh properties.
  25613. * This method must not get confused with createInstance()
  25614. * @param name is a string, the name given to the new mesh
  25615. * @param newParent can be any Node object (default `null`)
  25616. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25617. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25618. * @returns a new mesh
  25619. */
  25620. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25621. /**
  25622. * Releases resources associated with this mesh.
  25623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25625. */
  25626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25627. /** @hidden */
  25628. _disposeInstanceSpecificData(): void;
  25629. /**
  25630. * Modifies the mesh geometry according to a displacement map.
  25631. * 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.
  25632. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25633. * @param url is a string, the URL from the image file is to be downloaded.
  25634. * @param minHeight is the lower limit of the displacement.
  25635. * @param maxHeight is the upper limit of the displacement.
  25636. * @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.
  25637. * @param uvOffset is an optional vector2 used to offset UV.
  25638. * @param uvScale is an optional vector2 used to scale UV.
  25639. * @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.
  25640. * @returns the Mesh.
  25641. */
  25642. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25643. /**
  25644. * Modifies the mesh geometry according to a displacementMap buffer.
  25645. * 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.
  25646. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25647. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25648. * @param heightMapWidth is the width of the buffer image.
  25649. * @param heightMapHeight is the height of the buffer image.
  25650. * @param minHeight is the lower limit of the displacement.
  25651. * @param maxHeight is the upper limit of the displacement.
  25652. * @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.
  25653. * @param uvOffset is an optional vector2 used to offset UV.
  25654. * @param uvScale is an optional vector2 used to scale UV.
  25655. * @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.
  25656. * @returns the Mesh.
  25657. */
  25658. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25659. /**
  25660. * Modify the mesh to get a flat shading rendering.
  25661. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25662. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25663. * @returns current mesh
  25664. */
  25665. convertToFlatShadedMesh(): Mesh;
  25666. /**
  25667. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25668. * In other words, more vertices, no more indices and a single bigger VBO.
  25669. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25670. * @returns current mesh
  25671. */
  25672. convertToUnIndexedMesh(): Mesh;
  25673. /**
  25674. * Inverses facet orientations.
  25675. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25676. * @param flipNormals will also inverts the normals
  25677. * @returns current mesh
  25678. */
  25679. flipFaces(flipNormals?: boolean): Mesh;
  25680. /**
  25681. * Increase the number of facets and hence vertices in a mesh
  25682. * Vertex normals are interpolated from existing vertex normals
  25683. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25684. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25685. */
  25686. increaseVertices(numberPerEdge: number): void;
  25687. /**
  25688. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25689. * This will undo any application of covertToFlatShadedMesh
  25690. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25691. */
  25692. forceSharedVertices(): void;
  25693. /** @hidden */
  25694. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25695. /** @hidden */
  25696. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25697. /**
  25698. * Creates a new InstancedMesh object from the mesh model.
  25699. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25700. * @param name defines the name of the new instance
  25701. * @returns a new InstancedMesh
  25702. */
  25703. createInstance(name: string): InstancedMesh;
  25704. /**
  25705. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25706. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25707. * @returns the current mesh
  25708. */
  25709. synchronizeInstances(): Mesh;
  25710. /**
  25711. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25712. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25713. * This should be used together with the simplification to avoid disappearing triangles.
  25714. * @param successCallback an optional success callback to be called after the optimization finished.
  25715. * @returns the current mesh
  25716. */
  25717. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25718. /**
  25719. * Serialize current mesh
  25720. * @param serializationObject defines the object which will receive the serialization data
  25721. */
  25722. serialize(serializationObject: any): void;
  25723. /** @hidden */
  25724. _syncGeometryWithMorphTargetManager(): void;
  25725. /** @hidden */
  25726. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25727. /**
  25728. * Returns a new Mesh object parsed from the source provided.
  25729. * @param parsedMesh is the source
  25730. * @param scene defines the hosting scene
  25731. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25732. * @returns a new Mesh
  25733. */
  25734. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25735. /**
  25736. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25737. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25738. * @param name defines the name of the mesh to create
  25739. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25740. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25741. * @param closePath creates a seam between the first and the last points of each path of the path array
  25742. * @param offset is taken in account only if the `pathArray` is containing a single path
  25743. * @param scene defines the hosting scene
  25744. * @param updatable defines if the mesh must be flagged as updatable
  25745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25746. * @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)
  25747. * @returns a new Mesh
  25748. */
  25749. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25750. /**
  25751. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25752. * @param name defines the name of the mesh to create
  25753. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25754. * @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
  25755. * @param scene defines the hosting scene
  25756. * @param updatable defines if the mesh must be flagged as updatable
  25757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25761. /**
  25762. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25763. * @param name defines the name of the mesh to create
  25764. * @param size sets the size (float) of each box side (default 1)
  25765. * @param scene defines the hosting scene
  25766. * @param updatable defines if the mesh must be flagged as updatable
  25767. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25768. * @returns a new Mesh
  25769. */
  25770. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25771. /**
  25772. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25773. * @param name defines the name of the mesh to create
  25774. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25775. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25776. * @param scene defines the hosting scene
  25777. * @param updatable defines if the mesh must be flagged as updatable
  25778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25779. * @returns a new Mesh
  25780. */
  25781. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25782. /**
  25783. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25784. * @param name defines the name of the mesh to create
  25785. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25786. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25787. * @param scene defines the hosting scene
  25788. * @returns a new Mesh
  25789. */
  25790. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25791. /**
  25792. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25793. * @param name defines the name of the mesh to create
  25794. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25795. * @param diameterTop set the top cap diameter (floats, default 1)
  25796. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25797. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25798. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25799. * @param scene defines the hosting scene
  25800. * @param updatable defines if the mesh must be flagged as updatable
  25801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25802. * @returns a new Mesh
  25803. */
  25804. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25805. /**
  25806. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25807. * @param name defines the name of the mesh to create
  25808. * @param diameter sets the diameter size (float) of the torus (default 1)
  25809. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25810. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25817. /**
  25818. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25821. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25822. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25823. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25824. * @param p the number of windings on X axis (positive integers, default 2)
  25825. * @param q the number of windings on Y axis (positive integers, default 3)
  25826. * @param scene defines the hosting scene
  25827. * @param updatable defines if the mesh must be flagged as updatable
  25828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25829. * @returns a new Mesh
  25830. */
  25831. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25832. /**
  25833. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25834. * @param name defines the name of the mesh to create
  25835. * @param points is an array successive Vector3
  25836. * @param scene defines the hosting scene
  25837. * @param updatable defines if the mesh must be flagged as updatable
  25838. * @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).
  25839. * @returns a new Mesh
  25840. */
  25841. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25842. /**
  25843. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25844. * @param name defines the name of the mesh to create
  25845. * @param points is an array successive Vector3
  25846. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25847. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25848. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25849. * @param scene defines the hosting scene
  25850. * @param updatable defines if the mesh must be flagged as updatable
  25851. * @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)
  25852. * @returns a new Mesh
  25853. */
  25854. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25855. /**
  25856. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25857. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25858. * 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.
  25859. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25860. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25861. * Remember you can only change the shape positions, not their number when updating a polygon.
  25862. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25863. * @param name defines the name of the mesh to create
  25864. * @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
  25865. * @param scene defines the hosting scene
  25866. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25867. * @param updatable defines if the mesh must be flagged as updatable
  25868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25869. * @param earcutInjection can be used to inject your own earcut reference
  25870. * @returns a new Mesh
  25871. */
  25872. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25873. /**
  25874. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25876. * @param name defines the name of the mesh to create
  25877. * @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
  25878. * @param depth defines the height of extrusion
  25879. * @param scene defines the hosting scene
  25880. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25881. * @param updatable defines if the mesh must be flagged as updatable
  25882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25883. * @param earcutInjection can be used to inject your own earcut reference
  25884. * @returns a new Mesh
  25885. */
  25886. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25887. /**
  25888. * Creates an extruded shape mesh.
  25889. * 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
  25890. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25891. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25892. * @param name defines the name of the mesh to create
  25893. * @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
  25894. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25895. * @param scale is the value to scale the shape
  25896. * @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
  25897. * @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
  25898. * @param scene defines the hosting scene
  25899. * @param updatable defines if the mesh must be flagged as updatable
  25900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25901. * @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)
  25902. * @returns a new Mesh
  25903. */
  25904. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25905. /**
  25906. * Creates an custom extruded shape mesh.
  25907. * The custom extrusion is a parametric shape.
  25908. * It has no predefined shape. Its final shape will depend on the input parameters.
  25909. * Please consider using the same method from the MeshBuilder class instead
  25910. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25911. * @param name defines the name of the mesh to create
  25912. * @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
  25913. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25914. * @param scaleFunction is a custom Javascript function called on each path point
  25915. * @param rotationFunction is a custom Javascript function called on each path point
  25916. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25917. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25918. * @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
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @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)
  25923. * @returns a new Mesh
  25924. */
  25925. 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;
  25926. /**
  25927. * Creates lathe mesh.
  25928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25929. * Please consider using the same method from the MeshBuilder class instead
  25930. * @param name defines the name of the mesh to create
  25931. * @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
  25932. * @param radius is the radius value of the lathe
  25933. * @param tessellation is the side number of the lathe.
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25940. /**
  25941. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @param name defines the name of the mesh to create
  25943. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25944. * @param scene defines the hosting scene
  25945. * @param updatable defines if the mesh must be flagged as updatable
  25946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25947. * @returns a new Mesh
  25948. */
  25949. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25950. /**
  25951. * Creates a ground mesh.
  25952. * Please consider using the same method from the MeshBuilder class instead
  25953. * @param name defines the name of the mesh to create
  25954. * @param width set the width of the ground
  25955. * @param height set the height of the ground
  25956. * @param subdivisions sets the number of subdivisions per side
  25957. * @param scene defines the hosting scene
  25958. * @param updatable defines if the mesh must be flagged as updatable
  25959. * @returns a new Mesh
  25960. */
  25961. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25962. /**
  25963. * Creates a tiled ground mesh.
  25964. * Please consider using the same method from the MeshBuilder class instead
  25965. * @param name defines the name of the mesh to create
  25966. * @param xmin set the ground minimum X coordinate
  25967. * @param zmin set the ground minimum Y coordinate
  25968. * @param xmax set the ground maximum X coordinate
  25969. * @param zmax set the ground maximum Z coordinate
  25970. * @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
  25971. * @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
  25972. * @param scene defines the hosting scene
  25973. * @param updatable defines if the mesh must be flagged as updatable
  25974. * @returns a new Mesh
  25975. */
  25976. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25977. w: number;
  25978. h: number;
  25979. }, precision: {
  25980. w: number;
  25981. h: number;
  25982. }, scene: Scene, updatable?: boolean): Mesh;
  25983. /**
  25984. * Creates a ground mesh from a height map.
  25985. * Please consider using the same method from the MeshBuilder class instead
  25986. * @see http://doc.babylonjs.com/babylon101/height_map
  25987. * @param name defines the name of the mesh to create
  25988. * @param url sets the URL of the height map image resource
  25989. * @param width set the ground width size
  25990. * @param height set the ground height size
  25991. * @param subdivisions sets the number of subdivision per side
  25992. * @param minHeight is the minimum altitude on the ground
  25993. * @param maxHeight is the maximum altitude on the ground
  25994. * @param scene defines the hosting scene
  25995. * @param updatable defines if the mesh must be flagged as updatable
  25996. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25997. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25998. * @returns a new Mesh
  25999. */
  26000. 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;
  26001. /**
  26002. * Creates a tube mesh.
  26003. * The tube is a parametric shape.
  26004. * It has no predefined shape. Its final shape will depend on the input parameters.
  26005. * Please consider using the same method from the MeshBuilder class instead
  26006. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26007. * @param name defines the name of the mesh to create
  26008. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26009. * @param radius sets the tube radius size
  26010. * @param tessellation is the number of sides on the tubular surface
  26011. * @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
  26012. * @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
  26013. * @param scene defines the hosting scene
  26014. * @param updatable defines if the mesh must be flagged as updatable
  26015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26016. * @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)
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26020. (i: number, distance: number): number;
  26021. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26022. /**
  26023. * Creates a polyhedron mesh.
  26024. * Please consider using the same method from the MeshBuilder class instead.
  26025. * * 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
  26026. * * The parameter `size` (positive float, default 1) sets the polygon size
  26027. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26028. * * 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`
  26029. * * 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
  26030. * * 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)`)
  26031. * * 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
  26032. * * 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
  26033. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26034. * * If you create a double-sided mesh, you can choose what parts of 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
  26035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26036. * @param name defines the name of the mesh to create
  26037. * @param options defines the options used to create the mesh
  26038. * @param scene defines the hosting scene
  26039. * @returns a new Mesh
  26040. */
  26041. static CreatePolyhedron(name: string, options: {
  26042. type?: number;
  26043. size?: number;
  26044. sizeX?: number;
  26045. sizeY?: number;
  26046. sizeZ?: number;
  26047. custom?: any;
  26048. faceUV?: Vector4[];
  26049. faceColors?: Color4[];
  26050. updatable?: boolean;
  26051. sideOrientation?: number;
  26052. }, scene: Scene): Mesh;
  26053. /**
  26054. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26055. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26056. * * 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`)
  26057. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26058. * * 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
  26059. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26060. * * If you create a double-sided mesh, you can choose what parts of 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
  26061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26062. * @param name defines the name of the mesh
  26063. * @param options defines the options used to create the mesh
  26064. * @param scene defines the hosting scene
  26065. * @returns a new Mesh
  26066. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26067. */
  26068. static CreateIcoSphere(name: string, options: {
  26069. radius?: number;
  26070. flat?: boolean;
  26071. subdivisions?: number;
  26072. sideOrientation?: number;
  26073. updatable?: boolean;
  26074. }, scene: Scene): Mesh;
  26075. /**
  26076. * Creates a decal mesh.
  26077. * Please consider using the same method from the MeshBuilder class instead.
  26078. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26079. * @param name defines the name of the mesh
  26080. * @param sourceMesh defines the mesh receiving the decal
  26081. * @param position sets the position of the decal in world coordinates
  26082. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26083. * @param size sets the decal scaling
  26084. * @param angle sets the angle to rotate the decal
  26085. * @returns a new Mesh
  26086. */
  26087. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26088. /**
  26089. * Prepare internal position array for software CPU skinning
  26090. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26091. */
  26092. setPositionsForCPUSkinning(): Float32Array;
  26093. /**
  26094. * Prepare internal normal array for software CPU skinning
  26095. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26096. */
  26097. setNormalsForCPUSkinning(): Float32Array;
  26098. /**
  26099. * Updates the vertex buffer by applying transformation from the bones
  26100. * @param skeleton defines the skeleton to apply to current mesh
  26101. * @returns the current mesh
  26102. */
  26103. applySkeleton(skeleton: Skeleton): Mesh;
  26104. /**
  26105. * 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
  26106. * @param meshes defines the list of meshes to scan
  26107. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26108. */
  26109. static MinMax(meshes: AbstractMesh[]): {
  26110. min: Vector3;
  26111. max: Vector3;
  26112. };
  26113. /**
  26114. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26115. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26116. * @returns a vector3
  26117. */
  26118. static Center(meshesOrMinMaxVector: {
  26119. min: Vector3;
  26120. max: Vector3;
  26121. } | AbstractMesh[]): Vector3;
  26122. /**
  26123. * Merge the array of meshes into a single mesh for performance reasons.
  26124. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26125. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26126. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26127. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26128. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26129. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26130. * @returns a new mesh
  26131. */
  26132. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26133. /** @hidden */
  26134. addInstance(instance: InstancedMesh): void;
  26135. /** @hidden */
  26136. removeInstance(instance: InstancedMesh): void;
  26137. }
  26138. }
  26139. declare module "babylonjs/Cameras/camera" {
  26140. import { SmartArray } from "babylonjs/Misc/smartArray";
  26141. import { Observable } from "babylonjs/Misc/observable";
  26142. import { Nullable } from "babylonjs/types";
  26143. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26144. import { Scene } from "babylonjs/scene";
  26145. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26146. import { Node } from "babylonjs/node";
  26147. import { Mesh } from "babylonjs/Meshes/mesh";
  26148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26149. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26150. import { Viewport } from "babylonjs/Maths/math.viewport";
  26151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26154. import { Ray } from "babylonjs/Culling/ray";
  26155. /**
  26156. * This is the base class of all the camera used in the application.
  26157. * @see http://doc.babylonjs.com/features/cameras
  26158. */
  26159. export class Camera extends Node {
  26160. /** @hidden */
  26161. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26162. /**
  26163. * This is the default projection mode used by the cameras.
  26164. * It helps recreating a feeling of perspective and better appreciate depth.
  26165. * This is the best way to simulate real life cameras.
  26166. */
  26167. static readonly PERSPECTIVE_CAMERA: number;
  26168. /**
  26169. * This helps creating camera with an orthographic mode.
  26170. * 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.
  26171. */
  26172. static readonly ORTHOGRAPHIC_CAMERA: number;
  26173. /**
  26174. * This is the default FOV mode for perspective cameras.
  26175. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26176. */
  26177. static readonly FOVMODE_VERTICAL_FIXED: number;
  26178. /**
  26179. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26180. */
  26181. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26182. /**
  26183. * This specifies ther is no need for a camera rig.
  26184. * Basically only one eye is rendered corresponding to the camera.
  26185. */
  26186. static readonly RIG_MODE_NONE: number;
  26187. /**
  26188. * Simulates a camera Rig with one blue eye and one red eye.
  26189. * This can be use with 3d blue and red glasses.
  26190. */
  26191. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26192. /**
  26193. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26194. */
  26195. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26196. /**
  26197. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26198. */
  26199. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26200. /**
  26201. * Defines that both eyes of the camera will be rendered over under each other.
  26202. */
  26203. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26204. /**
  26205. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26206. */
  26207. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26208. /**
  26209. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26210. */
  26211. static readonly RIG_MODE_VR: number;
  26212. /**
  26213. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26214. */
  26215. static readonly RIG_MODE_WEBVR: number;
  26216. /**
  26217. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26218. */
  26219. static readonly RIG_MODE_CUSTOM: number;
  26220. /**
  26221. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26222. */
  26223. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26224. /**
  26225. * Define the input manager associated with the camera.
  26226. */
  26227. inputs: CameraInputsManager<Camera>;
  26228. /** @hidden */
  26229. _position: Vector3;
  26230. /**
  26231. * Define the current local position of the camera in the scene
  26232. */
  26233. get position(): Vector3;
  26234. set position(newPosition: Vector3);
  26235. /**
  26236. * The vector the camera should consider as up.
  26237. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26238. */
  26239. upVector: Vector3;
  26240. /**
  26241. * Define the current limit on the left side for an orthographic camera
  26242. * In scene unit
  26243. */
  26244. orthoLeft: Nullable<number>;
  26245. /**
  26246. * Define the current limit on the right side for an orthographic camera
  26247. * In scene unit
  26248. */
  26249. orthoRight: Nullable<number>;
  26250. /**
  26251. * Define the current limit on the bottom side for an orthographic camera
  26252. * In scene unit
  26253. */
  26254. orthoBottom: Nullable<number>;
  26255. /**
  26256. * Define the current limit on the top side for an orthographic camera
  26257. * In scene unit
  26258. */
  26259. orthoTop: Nullable<number>;
  26260. /**
  26261. * Field Of View is set in Radians. (default is 0.8)
  26262. */
  26263. fov: number;
  26264. /**
  26265. * Define the minimum distance the camera can see from.
  26266. * This is important to note that the depth buffer are not infinite and the closer it starts
  26267. * the more your scene might encounter depth fighting issue.
  26268. */
  26269. minZ: number;
  26270. /**
  26271. * Define the maximum distance the camera can see to.
  26272. * This is important to note that the depth buffer are not infinite and the further it end
  26273. * the more your scene might encounter depth fighting issue.
  26274. */
  26275. maxZ: number;
  26276. /**
  26277. * Define the default inertia of the camera.
  26278. * This helps giving a smooth feeling to the camera movement.
  26279. */
  26280. inertia: number;
  26281. /**
  26282. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26283. */
  26284. mode: number;
  26285. /**
  26286. * Define whether the camera is intermediate.
  26287. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26288. */
  26289. isIntermediate: boolean;
  26290. /**
  26291. * Define the viewport of the camera.
  26292. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26293. */
  26294. viewport: Viewport;
  26295. /**
  26296. * Restricts the camera to viewing objects with the same layerMask.
  26297. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26298. */
  26299. layerMask: number;
  26300. /**
  26301. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26302. */
  26303. fovMode: number;
  26304. /**
  26305. * Rig mode of the camera.
  26306. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26307. * This is normally controlled byt the camera themselves as internal use.
  26308. */
  26309. cameraRigMode: number;
  26310. /**
  26311. * Defines the distance between both "eyes" in case of a RIG
  26312. */
  26313. interaxialDistance: number;
  26314. /**
  26315. * Defines if stereoscopic rendering is done side by side or over under.
  26316. */
  26317. isStereoscopicSideBySide: boolean;
  26318. /**
  26319. * 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
  26320. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26321. * else in the scene. (Eg. security camera)
  26322. *
  26323. * 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)
  26324. */
  26325. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26326. /**
  26327. * When set, the camera will render to this render target instead of the default canvas
  26328. *
  26329. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26330. */
  26331. outputRenderTarget: Nullable<RenderTargetTexture>;
  26332. /**
  26333. * Observable triggered when the camera view matrix has changed.
  26334. */
  26335. onViewMatrixChangedObservable: Observable<Camera>;
  26336. /**
  26337. * Observable triggered when the camera Projection matrix has changed.
  26338. */
  26339. onProjectionMatrixChangedObservable: Observable<Camera>;
  26340. /**
  26341. * Observable triggered when the inputs have been processed.
  26342. */
  26343. onAfterCheckInputsObservable: Observable<Camera>;
  26344. /**
  26345. * Observable triggered when reset has been called and applied to the camera.
  26346. */
  26347. onRestoreStateObservable: Observable<Camera>;
  26348. /**
  26349. * Is this camera a part of a rig system?
  26350. */
  26351. isRigCamera: boolean;
  26352. /**
  26353. * If isRigCamera set to true this will be set with the parent camera.
  26354. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26355. */
  26356. rigParent?: Camera;
  26357. /** @hidden */
  26358. _cameraRigParams: any;
  26359. /** @hidden */
  26360. _rigCameras: Camera[];
  26361. /** @hidden */
  26362. _rigPostProcess: Nullable<PostProcess>;
  26363. protected _webvrViewMatrix: Matrix;
  26364. /** @hidden */
  26365. _skipRendering: boolean;
  26366. /** @hidden */
  26367. _projectionMatrix: Matrix;
  26368. /** @hidden */
  26369. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26370. /** @hidden */
  26371. _activeMeshes: SmartArray<AbstractMesh>;
  26372. protected _globalPosition: Vector3;
  26373. /** @hidden */
  26374. _computedViewMatrix: Matrix;
  26375. private _doNotComputeProjectionMatrix;
  26376. private _transformMatrix;
  26377. private _frustumPlanes;
  26378. private _refreshFrustumPlanes;
  26379. private _storedFov;
  26380. private _stateStored;
  26381. /**
  26382. * Instantiates a new camera object.
  26383. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26384. * @see http://doc.babylonjs.com/features/cameras
  26385. * @param name Defines the name of the camera in the scene
  26386. * @param position Defines the position of the camera
  26387. * @param scene Defines the scene the camera belongs too
  26388. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26389. */
  26390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26391. /**
  26392. * Store current camera state (fov, position, etc..)
  26393. * @returns the camera
  26394. */
  26395. storeState(): Camera;
  26396. /**
  26397. * Restores the camera state values if it has been stored. You must call storeState() first
  26398. */
  26399. protected _restoreStateValues(): boolean;
  26400. /**
  26401. * Restored camera state. You must call storeState() first.
  26402. * @returns true if restored and false otherwise
  26403. */
  26404. restoreState(): boolean;
  26405. /**
  26406. * Gets the class name of the camera.
  26407. * @returns the class name
  26408. */
  26409. getClassName(): string;
  26410. /** @hidden */
  26411. readonly _isCamera: boolean;
  26412. /**
  26413. * Gets a string representation of the camera useful for debug purpose.
  26414. * @param fullDetails Defines that a more verboe level of logging is required
  26415. * @returns the string representation
  26416. */
  26417. toString(fullDetails?: boolean): string;
  26418. /**
  26419. * Gets the current world space position of the camera.
  26420. */
  26421. get globalPosition(): Vector3;
  26422. /**
  26423. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26424. * @returns the active meshe list
  26425. */
  26426. getActiveMeshes(): SmartArray<AbstractMesh>;
  26427. /**
  26428. * Check whether a mesh is part of the current active mesh list of the camera
  26429. * @param mesh Defines the mesh to check
  26430. * @returns true if active, false otherwise
  26431. */
  26432. isActiveMesh(mesh: Mesh): boolean;
  26433. /**
  26434. * Is this camera ready to be used/rendered
  26435. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26436. * @return true if the camera is ready
  26437. */
  26438. isReady(completeCheck?: boolean): boolean;
  26439. /** @hidden */
  26440. _initCache(): void;
  26441. /** @hidden */
  26442. _updateCache(ignoreParentClass?: boolean): void;
  26443. /** @hidden */
  26444. _isSynchronized(): boolean;
  26445. /** @hidden */
  26446. _isSynchronizedViewMatrix(): boolean;
  26447. /** @hidden */
  26448. _isSynchronizedProjectionMatrix(): boolean;
  26449. /**
  26450. * Attach the input controls to a specific dom element to get the input from.
  26451. * @param element Defines the element the controls should be listened from
  26452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26453. */
  26454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26455. /**
  26456. * Detach the current controls from the specified dom element.
  26457. * @param element Defines the element to stop listening the inputs from
  26458. */
  26459. detachControl(element: HTMLElement): void;
  26460. /**
  26461. * Update the camera state according to the different inputs gathered during the frame.
  26462. */
  26463. update(): void;
  26464. /** @hidden */
  26465. _checkInputs(): void;
  26466. /** @hidden */
  26467. get rigCameras(): Camera[];
  26468. /**
  26469. * Gets the post process used by the rig cameras
  26470. */
  26471. get rigPostProcess(): Nullable<PostProcess>;
  26472. /**
  26473. * Internal, gets the first post proces.
  26474. * @returns the first post process to be run on this camera.
  26475. */
  26476. _getFirstPostProcess(): Nullable<PostProcess>;
  26477. private _cascadePostProcessesToRigCams;
  26478. /**
  26479. * Attach a post process to the camera.
  26480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26481. * @param postProcess The post process to attach to the camera
  26482. * @param insertAt The position of the post process in case several of them are in use in the scene
  26483. * @returns the position the post process has been inserted at
  26484. */
  26485. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26486. /**
  26487. * Detach a post process to the camera.
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26489. * @param postProcess The post process to detach from the camera
  26490. */
  26491. detachPostProcess(postProcess: PostProcess): void;
  26492. /**
  26493. * Gets the current world matrix of the camera
  26494. */
  26495. getWorldMatrix(): Matrix;
  26496. /** @hidden */
  26497. _getViewMatrix(): Matrix;
  26498. /**
  26499. * Gets the current view matrix of the camera.
  26500. * @param force forces the camera to recompute the matrix without looking at the cached state
  26501. * @returns the view matrix
  26502. */
  26503. getViewMatrix(force?: boolean): Matrix;
  26504. /**
  26505. * Freeze the projection matrix.
  26506. * It will prevent the cache check of the camera projection compute and can speed up perf
  26507. * if no parameter of the camera are meant to change
  26508. * @param projection Defines manually a projection if necessary
  26509. */
  26510. freezeProjectionMatrix(projection?: Matrix): void;
  26511. /**
  26512. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26513. */
  26514. unfreezeProjectionMatrix(): void;
  26515. /**
  26516. * Gets the current projection matrix of the camera.
  26517. * @param force forces the camera to recompute the matrix without looking at the cached state
  26518. * @returns the projection matrix
  26519. */
  26520. getProjectionMatrix(force?: boolean): Matrix;
  26521. /**
  26522. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26523. * @returns a Matrix
  26524. */
  26525. getTransformationMatrix(): Matrix;
  26526. private _updateFrustumPlanes;
  26527. /**
  26528. * Checks if a cullable object (mesh...) is in the camera frustum
  26529. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26530. * @param target The object to check
  26531. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26532. * @returns true if the object is in frustum otherwise false
  26533. */
  26534. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26535. /**
  26536. * Checks if a cullable object (mesh...) is in the camera frustum
  26537. * Unlike isInFrustum this cheks the full bounding box
  26538. * @param target The object to check
  26539. * @returns true if the object is in frustum otherwise false
  26540. */
  26541. isCompletelyInFrustum(target: ICullable): boolean;
  26542. /**
  26543. * Gets a ray in the forward direction from the camera.
  26544. * @param length Defines the length of the ray to create
  26545. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26546. * @param origin Defines the start point of the ray which defaults to the camera position
  26547. * @returns the forward ray
  26548. */
  26549. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26550. /**
  26551. * Releases resources associated with this node.
  26552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26554. */
  26555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26556. /** @hidden */
  26557. _isLeftCamera: boolean;
  26558. /**
  26559. * Gets the left camera of a rig setup in case of Rigged Camera
  26560. */
  26561. get isLeftCamera(): boolean;
  26562. /** @hidden */
  26563. _isRightCamera: boolean;
  26564. /**
  26565. * Gets the right camera of a rig setup in case of Rigged Camera
  26566. */
  26567. get isRightCamera(): boolean;
  26568. /**
  26569. * Gets the left camera of a rig setup in case of Rigged Camera
  26570. */
  26571. get leftCamera(): Nullable<FreeCamera>;
  26572. /**
  26573. * Gets the right camera of a rig setup in case of Rigged Camera
  26574. */
  26575. get rightCamera(): Nullable<FreeCamera>;
  26576. /**
  26577. * Gets the left camera target of a rig setup in case of Rigged Camera
  26578. * @returns the target position
  26579. */
  26580. getLeftTarget(): Nullable<Vector3>;
  26581. /**
  26582. * Gets the right camera target of a rig setup in case of Rigged Camera
  26583. * @returns the target position
  26584. */
  26585. getRightTarget(): Nullable<Vector3>;
  26586. /**
  26587. * @hidden
  26588. */
  26589. setCameraRigMode(mode: number, rigParams: any): void;
  26590. /** @hidden */
  26591. static _setStereoscopicRigMode(camera: Camera): void;
  26592. /** @hidden */
  26593. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26594. /** @hidden */
  26595. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26596. /** @hidden */
  26597. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26598. /** @hidden */
  26599. _getVRProjectionMatrix(): Matrix;
  26600. protected _updateCameraRotationMatrix(): void;
  26601. protected _updateWebVRCameraRotationMatrix(): void;
  26602. /**
  26603. * This function MUST be overwritten by the different WebVR cameras available.
  26604. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26605. * @hidden
  26606. */
  26607. _getWebVRProjectionMatrix(): Matrix;
  26608. /**
  26609. * This function MUST be overwritten by the different WebVR cameras available.
  26610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26611. * @hidden
  26612. */
  26613. _getWebVRViewMatrix(): Matrix;
  26614. /** @hidden */
  26615. setCameraRigParameter(name: string, value: any): void;
  26616. /**
  26617. * needs to be overridden by children so sub has required properties to be copied
  26618. * @hidden
  26619. */
  26620. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26621. /**
  26622. * May need to be overridden by children
  26623. * @hidden
  26624. */
  26625. _updateRigCameras(): void;
  26626. /** @hidden */
  26627. _setupInputs(): void;
  26628. /**
  26629. * Serialiaze the camera setup to a json represention
  26630. * @returns the JSON representation
  26631. */
  26632. serialize(): any;
  26633. /**
  26634. * Clones the current camera.
  26635. * @param name The cloned camera name
  26636. * @returns the cloned camera
  26637. */
  26638. clone(name: string): Camera;
  26639. /**
  26640. * Gets the direction of the camera relative to a given local axis.
  26641. * @param localAxis Defines the reference axis to provide a relative direction.
  26642. * @return the direction
  26643. */
  26644. getDirection(localAxis: Vector3): Vector3;
  26645. /**
  26646. * Returns the current camera absolute rotation
  26647. */
  26648. get absoluteRotation(): Quaternion;
  26649. /**
  26650. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26651. * @param localAxis Defines the reference axis to provide a relative direction.
  26652. * @param result Defines the vector to store the result in
  26653. */
  26654. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26655. /**
  26656. * Gets a camera constructor for a given camera type
  26657. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26658. * @param name The name of the camera the result will be able to instantiate
  26659. * @param scene The scene the result will construct the camera in
  26660. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26661. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26662. * @returns a factory method to construc the camera
  26663. */
  26664. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26665. /**
  26666. * Compute the world matrix of the camera.
  26667. * @returns the camera world matrix
  26668. */
  26669. computeWorldMatrix(): Matrix;
  26670. /**
  26671. * Parse a JSON and creates the camera from the parsed information
  26672. * @param parsedCamera The JSON to parse
  26673. * @param scene The scene to instantiate the camera in
  26674. * @returns the newly constructed camera
  26675. */
  26676. static Parse(parsedCamera: any, scene: Scene): Camera;
  26677. }
  26678. }
  26679. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26680. import { Nullable } from "babylonjs/types";
  26681. import { Scene } from "babylonjs/scene";
  26682. import { Vector4 } from "babylonjs/Maths/math.vector";
  26683. import { Mesh } from "babylonjs/Meshes/mesh";
  26684. /**
  26685. * Class containing static functions to help procedurally build meshes
  26686. */
  26687. export class DiscBuilder {
  26688. /**
  26689. * Creates a plane polygonal mesh. By default, this is a disc
  26690. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26691. * * 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
  26692. * * 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
  26693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26696. * @param name defines the name of the mesh
  26697. * @param options defines the options used to create the mesh
  26698. * @param scene defines the hosting scene
  26699. * @returns the plane polygonal mesh
  26700. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26701. */
  26702. static CreateDisc(name: string, options: {
  26703. radius?: number;
  26704. tessellation?: number;
  26705. arc?: number;
  26706. updatable?: boolean;
  26707. sideOrientation?: number;
  26708. frontUVs?: Vector4;
  26709. backUVs?: Vector4;
  26710. }, scene?: Nullable<Scene>): Mesh;
  26711. }
  26712. }
  26713. declare module "babylonjs/Materials/fresnelParameters" {
  26714. import { Color3 } from "babylonjs/Maths/math.color";
  26715. /**
  26716. * This represents all the required information to add a fresnel effect on a material:
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26718. */
  26719. export class FresnelParameters {
  26720. private _isEnabled;
  26721. /**
  26722. * Define if the fresnel effect is enable or not.
  26723. */
  26724. get isEnabled(): boolean;
  26725. set isEnabled(value: boolean);
  26726. /**
  26727. * Define the color used on edges (grazing angle)
  26728. */
  26729. leftColor: Color3;
  26730. /**
  26731. * Define the color used on center
  26732. */
  26733. rightColor: Color3;
  26734. /**
  26735. * Define bias applied to computed fresnel term
  26736. */
  26737. bias: number;
  26738. /**
  26739. * Defined the power exponent applied to fresnel term
  26740. */
  26741. power: number;
  26742. /**
  26743. * Clones the current fresnel and its valuues
  26744. * @returns a clone fresnel configuration
  26745. */
  26746. clone(): FresnelParameters;
  26747. /**
  26748. * Serializes the current fresnel parameters to a JSON representation.
  26749. * @return the JSON serialization
  26750. */
  26751. serialize(): any;
  26752. /**
  26753. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26754. * @param parsedFresnelParameters Define the JSON representation
  26755. * @returns the parsed parameters
  26756. */
  26757. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26758. }
  26759. }
  26760. declare module "babylonjs/Materials/pushMaterial" {
  26761. import { Nullable } from "babylonjs/types";
  26762. import { Scene } from "babylonjs/scene";
  26763. import { Matrix } from "babylonjs/Maths/math.vector";
  26764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26765. import { Mesh } from "babylonjs/Meshes/mesh";
  26766. import { Material } from "babylonjs/Materials/material";
  26767. import { Effect } from "babylonjs/Materials/effect";
  26768. /**
  26769. * Base class of materials working in push mode in babylon JS
  26770. * @hidden
  26771. */
  26772. export class PushMaterial extends Material {
  26773. protected _activeEffect: Effect;
  26774. protected _normalMatrix: Matrix;
  26775. /**
  26776. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26777. * This means that the material can keep using a previous shader while a new one is being compiled.
  26778. * This is mostly used when shader parallel compilation is supported (true by default)
  26779. */
  26780. allowShaderHotSwapping: boolean;
  26781. constructor(name: string, scene: Scene);
  26782. getEffect(): Effect;
  26783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26784. /**
  26785. * Binds the given world matrix to the active effect
  26786. *
  26787. * @param world the matrix to bind
  26788. */
  26789. bindOnlyWorldMatrix(world: Matrix): void;
  26790. /**
  26791. * Binds the given normal matrix to the active effect
  26792. *
  26793. * @param normalMatrix the matrix to bind
  26794. */
  26795. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26796. bind(world: Matrix, mesh?: Mesh): void;
  26797. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26798. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26799. }
  26800. }
  26801. declare module "babylonjs/Materials/materialFlags" {
  26802. /**
  26803. * This groups all the flags used to control the materials channel.
  26804. */
  26805. export class MaterialFlags {
  26806. private static _DiffuseTextureEnabled;
  26807. /**
  26808. * Are diffuse textures enabled in the application.
  26809. */
  26810. static get DiffuseTextureEnabled(): boolean;
  26811. static set DiffuseTextureEnabled(value: boolean);
  26812. private static _AmbientTextureEnabled;
  26813. /**
  26814. * Are ambient textures enabled in the application.
  26815. */
  26816. static get AmbientTextureEnabled(): boolean;
  26817. static set AmbientTextureEnabled(value: boolean);
  26818. private static _OpacityTextureEnabled;
  26819. /**
  26820. * Are opacity textures enabled in the application.
  26821. */
  26822. static get OpacityTextureEnabled(): boolean;
  26823. static set OpacityTextureEnabled(value: boolean);
  26824. private static _ReflectionTextureEnabled;
  26825. /**
  26826. * Are reflection textures enabled in the application.
  26827. */
  26828. static get ReflectionTextureEnabled(): boolean;
  26829. static set ReflectionTextureEnabled(value: boolean);
  26830. private static _EmissiveTextureEnabled;
  26831. /**
  26832. * Are emissive textures enabled in the application.
  26833. */
  26834. static get EmissiveTextureEnabled(): boolean;
  26835. static set EmissiveTextureEnabled(value: boolean);
  26836. private static _SpecularTextureEnabled;
  26837. /**
  26838. * Are specular textures enabled in the application.
  26839. */
  26840. static get SpecularTextureEnabled(): boolean;
  26841. static set SpecularTextureEnabled(value: boolean);
  26842. private static _BumpTextureEnabled;
  26843. /**
  26844. * Are bump textures enabled in the application.
  26845. */
  26846. static get BumpTextureEnabled(): boolean;
  26847. static set BumpTextureEnabled(value: boolean);
  26848. private static _LightmapTextureEnabled;
  26849. /**
  26850. * Are lightmap textures enabled in the application.
  26851. */
  26852. static get LightmapTextureEnabled(): boolean;
  26853. static set LightmapTextureEnabled(value: boolean);
  26854. private static _RefractionTextureEnabled;
  26855. /**
  26856. * Are refraction textures enabled in the application.
  26857. */
  26858. static get RefractionTextureEnabled(): boolean;
  26859. static set RefractionTextureEnabled(value: boolean);
  26860. private static _ColorGradingTextureEnabled;
  26861. /**
  26862. * Are color grading textures enabled in the application.
  26863. */
  26864. static get ColorGradingTextureEnabled(): boolean;
  26865. static set ColorGradingTextureEnabled(value: boolean);
  26866. private static _FresnelEnabled;
  26867. /**
  26868. * Are fresnels enabled in the application.
  26869. */
  26870. static get FresnelEnabled(): boolean;
  26871. static set FresnelEnabled(value: boolean);
  26872. private static _ClearCoatTextureEnabled;
  26873. /**
  26874. * Are clear coat textures enabled in the application.
  26875. */
  26876. static get ClearCoatTextureEnabled(): boolean;
  26877. static set ClearCoatTextureEnabled(value: boolean);
  26878. private static _ClearCoatBumpTextureEnabled;
  26879. /**
  26880. * Are clear coat bump textures enabled in the application.
  26881. */
  26882. static get ClearCoatBumpTextureEnabled(): boolean;
  26883. static set ClearCoatBumpTextureEnabled(value: boolean);
  26884. private static _ClearCoatTintTextureEnabled;
  26885. /**
  26886. * Are clear coat tint textures enabled in the application.
  26887. */
  26888. static get ClearCoatTintTextureEnabled(): boolean;
  26889. static set ClearCoatTintTextureEnabled(value: boolean);
  26890. private static _SheenTextureEnabled;
  26891. /**
  26892. * Are sheen textures enabled in the application.
  26893. */
  26894. static get SheenTextureEnabled(): boolean;
  26895. static set SheenTextureEnabled(value: boolean);
  26896. private static _AnisotropicTextureEnabled;
  26897. /**
  26898. * Are anisotropic textures enabled in the application.
  26899. */
  26900. static get AnisotropicTextureEnabled(): boolean;
  26901. static set AnisotropicTextureEnabled(value: boolean);
  26902. private static _ThicknessTextureEnabled;
  26903. /**
  26904. * Are thickness textures enabled in the application.
  26905. */
  26906. static get ThicknessTextureEnabled(): boolean;
  26907. static set ThicknessTextureEnabled(value: boolean);
  26908. }
  26909. }
  26910. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26911. /** @hidden */
  26912. export var defaultFragmentDeclaration: {
  26913. name: string;
  26914. shader: string;
  26915. };
  26916. }
  26917. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26918. /** @hidden */
  26919. export var defaultUboDeclaration: {
  26920. name: string;
  26921. shader: string;
  26922. };
  26923. }
  26924. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26925. /** @hidden */
  26926. export var lightFragmentDeclaration: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26932. /** @hidden */
  26933. export var lightUboDeclaration: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26939. /** @hidden */
  26940. export var lightsFragmentFunctions: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26946. /** @hidden */
  26947. export var shadowsFragmentFunctions: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26953. /** @hidden */
  26954. export var fresnelFunction: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26960. /** @hidden */
  26961. export var reflectionFunction: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26967. /** @hidden */
  26968. export var bumpFragmentFunctions: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26974. /** @hidden */
  26975. export var logDepthDeclaration: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26981. /** @hidden */
  26982. export var bumpFragment: {
  26983. name: string;
  26984. shader: string;
  26985. };
  26986. }
  26987. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26988. /** @hidden */
  26989. export var depthPrePass: {
  26990. name: string;
  26991. shader: string;
  26992. };
  26993. }
  26994. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26995. /** @hidden */
  26996. export var lightFragment: {
  26997. name: string;
  26998. shader: string;
  26999. };
  27000. }
  27001. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27002. /** @hidden */
  27003. export var logDepthFragment: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/default.fragment" {
  27009. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27010. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27012. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27013. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27014. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27015. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27016. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27019. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27020. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27022. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27023. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27024. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27025. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27026. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27027. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27030. /** @hidden */
  27031. export var defaultPixelShader: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27037. /** @hidden */
  27038. export var defaultVertexDeclaration: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27044. /** @hidden */
  27045. export var bumpVertexDeclaration: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27051. /** @hidden */
  27052. export var bumpVertex: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27058. /** @hidden */
  27059. export var fogVertex: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27065. /** @hidden */
  27066. export var shadowsVertex: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27072. /** @hidden */
  27073. export var pointCloudVertex: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27079. /** @hidden */
  27080. export var logDepthVertex: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/default.vertex" {
  27086. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27087. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27089. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27091. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27092. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27093. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27094. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27095. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27096. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27098. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27102. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27103. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27104. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27105. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27106. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27108. /** @hidden */
  27109. export var defaultVertexShader: {
  27110. name: string;
  27111. shader: string;
  27112. };
  27113. }
  27114. declare module "babylonjs/Materials/standardMaterial" {
  27115. import { SmartArray } from "babylonjs/Misc/smartArray";
  27116. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27117. import { Nullable } from "babylonjs/types";
  27118. import { Scene } from "babylonjs/scene";
  27119. import { Matrix } from "babylonjs/Maths/math.vector";
  27120. import { Color3 } from "babylonjs/Maths/math.color";
  27121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27123. import { Mesh } from "babylonjs/Meshes/mesh";
  27124. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27126. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27127. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27128. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27131. import "babylonjs/Shaders/default.fragment";
  27132. import "babylonjs/Shaders/default.vertex";
  27133. /** @hidden */
  27134. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27135. MAINUV1: boolean;
  27136. MAINUV2: boolean;
  27137. DIFFUSE: boolean;
  27138. DIFFUSEDIRECTUV: number;
  27139. AMBIENT: boolean;
  27140. AMBIENTDIRECTUV: number;
  27141. OPACITY: boolean;
  27142. OPACITYDIRECTUV: number;
  27143. OPACITYRGB: boolean;
  27144. REFLECTION: boolean;
  27145. EMISSIVE: boolean;
  27146. EMISSIVEDIRECTUV: number;
  27147. SPECULAR: boolean;
  27148. SPECULARDIRECTUV: number;
  27149. BUMP: boolean;
  27150. BUMPDIRECTUV: number;
  27151. PARALLAX: boolean;
  27152. PARALLAXOCCLUSION: boolean;
  27153. SPECULAROVERALPHA: boolean;
  27154. CLIPPLANE: boolean;
  27155. CLIPPLANE2: boolean;
  27156. CLIPPLANE3: boolean;
  27157. CLIPPLANE4: boolean;
  27158. CLIPPLANE5: boolean;
  27159. CLIPPLANE6: boolean;
  27160. ALPHATEST: boolean;
  27161. DEPTHPREPASS: boolean;
  27162. ALPHAFROMDIFFUSE: boolean;
  27163. POINTSIZE: boolean;
  27164. FOG: boolean;
  27165. SPECULARTERM: boolean;
  27166. DIFFUSEFRESNEL: boolean;
  27167. OPACITYFRESNEL: boolean;
  27168. REFLECTIONFRESNEL: boolean;
  27169. REFRACTIONFRESNEL: boolean;
  27170. EMISSIVEFRESNEL: boolean;
  27171. FRESNEL: boolean;
  27172. NORMAL: boolean;
  27173. UV1: boolean;
  27174. UV2: boolean;
  27175. VERTEXCOLOR: boolean;
  27176. VERTEXALPHA: boolean;
  27177. NUM_BONE_INFLUENCERS: number;
  27178. BonesPerMesh: number;
  27179. BONETEXTURE: boolean;
  27180. INSTANCES: boolean;
  27181. GLOSSINESS: boolean;
  27182. ROUGHNESS: boolean;
  27183. EMISSIVEASILLUMINATION: boolean;
  27184. LINKEMISSIVEWITHDIFFUSE: boolean;
  27185. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27186. LIGHTMAP: boolean;
  27187. LIGHTMAPDIRECTUV: number;
  27188. OBJECTSPACE_NORMALMAP: boolean;
  27189. USELIGHTMAPASSHADOWMAP: boolean;
  27190. REFLECTIONMAP_3D: boolean;
  27191. REFLECTIONMAP_SPHERICAL: boolean;
  27192. REFLECTIONMAP_PLANAR: boolean;
  27193. REFLECTIONMAP_CUBIC: boolean;
  27194. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27195. REFLECTIONMAP_PROJECTION: boolean;
  27196. REFLECTIONMAP_SKYBOX: boolean;
  27197. REFLECTIONMAP_EXPLICIT: boolean;
  27198. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27199. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27200. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27201. INVERTCUBICMAP: boolean;
  27202. LOGARITHMICDEPTH: boolean;
  27203. REFRACTION: boolean;
  27204. REFRACTIONMAP_3D: boolean;
  27205. REFLECTIONOVERALPHA: boolean;
  27206. TWOSIDEDLIGHTING: boolean;
  27207. SHADOWFLOAT: boolean;
  27208. MORPHTARGETS: boolean;
  27209. MORPHTARGETS_NORMAL: boolean;
  27210. MORPHTARGETS_TANGENT: boolean;
  27211. MORPHTARGETS_UV: boolean;
  27212. NUM_MORPH_INFLUENCERS: number;
  27213. NONUNIFORMSCALING: boolean;
  27214. PREMULTIPLYALPHA: boolean;
  27215. IMAGEPROCESSING: boolean;
  27216. VIGNETTE: boolean;
  27217. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27218. VIGNETTEBLENDMODEOPAQUE: boolean;
  27219. TONEMAPPING: boolean;
  27220. TONEMAPPING_ACES: boolean;
  27221. CONTRAST: boolean;
  27222. COLORCURVES: boolean;
  27223. COLORGRADING: boolean;
  27224. COLORGRADING3D: boolean;
  27225. SAMPLER3DGREENDEPTH: boolean;
  27226. SAMPLER3DBGRMAP: boolean;
  27227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27228. MULTIVIEW: boolean;
  27229. /**
  27230. * If the reflection texture on this material is in linear color space
  27231. * @hidden
  27232. */
  27233. IS_REFLECTION_LINEAR: boolean;
  27234. /**
  27235. * If the refraction texture on this material is in linear color space
  27236. * @hidden
  27237. */
  27238. IS_REFRACTION_LINEAR: boolean;
  27239. EXPOSURE: boolean;
  27240. constructor();
  27241. setReflectionMode(modeToEnable: string): void;
  27242. }
  27243. /**
  27244. * This is the default material used in Babylon. It is the best trade off between quality
  27245. * and performances.
  27246. * @see http://doc.babylonjs.com/babylon101/materials
  27247. */
  27248. export class StandardMaterial extends PushMaterial {
  27249. private _diffuseTexture;
  27250. /**
  27251. * The basic texture of the material as viewed under a light.
  27252. */
  27253. diffuseTexture: Nullable<BaseTexture>;
  27254. private _ambientTexture;
  27255. /**
  27256. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27257. */
  27258. ambientTexture: Nullable<BaseTexture>;
  27259. private _opacityTexture;
  27260. /**
  27261. * Define the transparency of the material from a texture.
  27262. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27263. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27264. */
  27265. opacityTexture: Nullable<BaseTexture>;
  27266. private _reflectionTexture;
  27267. /**
  27268. * Define the texture used to display the reflection.
  27269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27270. */
  27271. reflectionTexture: Nullable<BaseTexture>;
  27272. private _emissiveTexture;
  27273. /**
  27274. * Define texture of the material as if self lit.
  27275. * This will be mixed in the final result even in the absence of light.
  27276. */
  27277. emissiveTexture: Nullable<BaseTexture>;
  27278. private _specularTexture;
  27279. /**
  27280. * Define how the color and intensity of the highlight given by the light in the material.
  27281. */
  27282. specularTexture: Nullable<BaseTexture>;
  27283. private _bumpTexture;
  27284. /**
  27285. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27286. * 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.
  27287. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27288. */
  27289. bumpTexture: Nullable<BaseTexture>;
  27290. private _lightmapTexture;
  27291. /**
  27292. * Complex lighting can be computationally expensive to compute at runtime.
  27293. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27294. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27295. */
  27296. lightmapTexture: Nullable<BaseTexture>;
  27297. private _refractionTexture;
  27298. /**
  27299. * Define the texture used to display the refraction.
  27300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27301. */
  27302. refractionTexture: Nullable<BaseTexture>;
  27303. /**
  27304. * The color of the material lit by the environmental background lighting.
  27305. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27306. */
  27307. ambientColor: Color3;
  27308. /**
  27309. * The basic color of the material as viewed under a light.
  27310. */
  27311. diffuseColor: Color3;
  27312. /**
  27313. * Define how the color and intensity of the highlight given by the light in the material.
  27314. */
  27315. specularColor: Color3;
  27316. /**
  27317. * Define the color of the material as if self lit.
  27318. * This will be mixed in the final result even in the absence of light.
  27319. */
  27320. emissiveColor: Color3;
  27321. /**
  27322. * Defines how sharp are the highlights in the material.
  27323. * The bigger the value the sharper giving a more glossy feeling to the result.
  27324. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27325. */
  27326. specularPower: number;
  27327. private _useAlphaFromDiffuseTexture;
  27328. /**
  27329. * Does the transparency come from the diffuse texture alpha channel.
  27330. */
  27331. useAlphaFromDiffuseTexture: boolean;
  27332. private _useEmissiveAsIllumination;
  27333. /**
  27334. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27335. */
  27336. useEmissiveAsIllumination: boolean;
  27337. private _linkEmissiveWithDiffuse;
  27338. /**
  27339. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27340. * the emissive level when the final color is close to one.
  27341. */
  27342. linkEmissiveWithDiffuse: boolean;
  27343. private _useSpecularOverAlpha;
  27344. /**
  27345. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27346. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27347. */
  27348. useSpecularOverAlpha: boolean;
  27349. private _useReflectionOverAlpha;
  27350. /**
  27351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27353. */
  27354. useReflectionOverAlpha: boolean;
  27355. private _disableLighting;
  27356. /**
  27357. * Does lights from the scene impacts this material.
  27358. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27359. */
  27360. disableLighting: boolean;
  27361. private _useObjectSpaceNormalMap;
  27362. /**
  27363. * Allows using an object space normal map (instead of tangent space).
  27364. */
  27365. useObjectSpaceNormalMap: boolean;
  27366. private _useParallax;
  27367. /**
  27368. * Is parallax enabled or not.
  27369. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27370. */
  27371. useParallax: boolean;
  27372. private _useParallaxOcclusion;
  27373. /**
  27374. * Is parallax occlusion enabled or not.
  27375. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27376. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27377. */
  27378. useParallaxOcclusion: boolean;
  27379. /**
  27380. * 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.
  27381. */
  27382. parallaxScaleBias: number;
  27383. private _roughness;
  27384. /**
  27385. * Helps to define how blurry the reflections should appears in the material.
  27386. */
  27387. roughness: number;
  27388. /**
  27389. * In case of refraction, define the value of the index of refraction.
  27390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27391. */
  27392. indexOfRefraction: number;
  27393. /**
  27394. * Invert the refraction texture alongside the y axis.
  27395. * It can be useful with procedural textures or probe for instance.
  27396. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27397. */
  27398. invertRefractionY: boolean;
  27399. /**
  27400. * Defines the alpha limits in alpha test mode.
  27401. */
  27402. alphaCutOff: number;
  27403. private _useLightmapAsShadowmap;
  27404. /**
  27405. * In case of light mapping, define whether the map contains light or shadow informations.
  27406. */
  27407. useLightmapAsShadowmap: boolean;
  27408. private _diffuseFresnelParameters;
  27409. /**
  27410. * Define the diffuse fresnel parameters of the material.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. diffuseFresnelParameters: FresnelParameters;
  27414. private _opacityFresnelParameters;
  27415. /**
  27416. * Define the opacity fresnel parameters of the material.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. opacityFresnelParameters: FresnelParameters;
  27420. private _reflectionFresnelParameters;
  27421. /**
  27422. * Define the reflection fresnel parameters of the material.
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27424. */
  27425. reflectionFresnelParameters: FresnelParameters;
  27426. private _refractionFresnelParameters;
  27427. /**
  27428. * Define the refraction fresnel parameters of the material.
  27429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27430. */
  27431. refractionFresnelParameters: FresnelParameters;
  27432. private _emissiveFresnelParameters;
  27433. /**
  27434. * Define the emissive fresnel parameters of the material.
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27436. */
  27437. emissiveFresnelParameters: FresnelParameters;
  27438. private _useReflectionFresnelFromSpecular;
  27439. /**
  27440. * If true automatically deducts the fresnels values from the material specularity.
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27442. */
  27443. useReflectionFresnelFromSpecular: boolean;
  27444. private _useGlossinessFromSpecularMapAlpha;
  27445. /**
  27446. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27447. */
  27448. useGlossinessFromSpecularMapAlpha: boolean;
  27449. private _maxSimultaneousLights;
  27450. /**
  27451. * Defines the maximum number of lights that can be used in the material
  27452. */
  27453. maxSimultaneousLights: number;
  27454. private _invertNormalMapX;
  27455. /**
  27456. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27457. */
  27458. invertNormalMapX: boolean;
  27459. private _invertNormalMapY;
  27460. /**
  27461. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27462. */
  27463. invertNormalMapY: boolean;
  27464. private _twoSidedLighting;
  27465. /**
  27466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27467. */
  27468. twoSidedLighting: boolean;
  27469. /**
  27470. * Default configuration related to image processing available in the standard Material.
  27471. */
  27472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27473. /**
  27474. * Gets the image processing configuration used either in this material.
  27475. */
  27476. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27477. /**
  27478. * Sets the Default image processing configuration used either in the this material.
  27479. *
  27480. * If sets to null, the scene one is in use.
  27481. */
  27482. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27483. /**
  27484. * Keep track of the image processing observer to allow dispose and replace.
  27485. */
  27486. private _imageProcessingObserver;
  27487. /**
  27488. * Attaches a new image processing configuration to the Standard Material.
  27489. * @param configuration
  27490. */
  27491. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27492. /**
  27493. * Gets wether the color curves effect is enabled.
  27494. */
  27495. get cameraColorCurvesEnabled(): boolean;
  27496. /**
  27497. * Sets wether the color curves effect is enabled.
  27498. */
  27499. set cameraColorCurvesEnabled(value: boolean);
  27500. /**
  27501. * Gets wether the color grading effect is enabled.
  27502. */
  27503. get cameraColorGradingEnabled(): boolean;
  27504. /**
  27505. * Gets wether the color grading effect is enabled.
  27506. */
  27507. set cameraColorGradingEnabled(value: boolean);
  27508. /**
  27509. * Gets wether tonemapping is enabled or not.
  27510. */
  27511. get cameraToneMappingEnabled(): boolean;
  27512. /**
  27513. * Sets wether tonemapping is enabled or not
  27514. */
  27515. set cameraToneMappingEnabled(value: boolean);
  27516. /**
  27517. * The camera exposure used on this material.
  27518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27519. * This corresponds to a photographic exposure.
  27520. */
  27521. get cameraExposure(): number;
  27522. /**
  27523. * The camera exposure used on this material.
  27524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27525. * This corresponds to a photographic exposure.
  27526. */
  27527. set cameraExposure(value: number);
  27528. /**
  27529. * Gets The camera contrast used on this material.
  27530. */
  27531. get cameraContrast(): number;
  27532. /**
  27533. * Sets The camera contrast used on this material.
  27534. */
  27535. set cameraContrast(value: number);
  27536. /**
  27537. * Gets the Color Grading 2D Lookup Texture.
  27538. */
  27539. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27540. /**
  27541. * Sets the Color Grading 2D Lookup Texture.
  27542. */
  27543. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27544. /**
  27545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27547. * 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;
  27548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27549. */
  27550. get cameraColorCurves(): Nullable<ColorCurves>;
  27551. /**
  27552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27554. * 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;
  27555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27556. */
  27557. set cameraColorCurves(value: Nullable<ColorCurves>);
  27558. /**
  27559. * Custom callback helping to override the default shader used in the material.
  27560. */
  27561. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27562. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27563. protected _worldViewProjectionMatrix: Matrix;
  27564. protected _globalAmbientColor: Color3;
  27565. protected _useLogarithmicDepth: boolean;
  27566. protected _rebuildInParallel: boolean;
  27567. /**
  27568. * Instantiates a new standard material.
  27569. * This is the default material used in Babylon. It is the best trade off between quality
  27570. * and performances.
  27571. * @see http://doc.babylonjs.com/babylon101/materials
  27572. * @param name Define the name of the material in the scene
  27573. * @param scene Define the scene the material belong to
  27574. */
  27575. constructor(name: string, scene: Scene);
  27576. /**
  27577. * Gets a boolean indicating that current material needs to register RTT
  27578. */
  27579. get hasRenderTargetTextures(): boolean;
  27580. /**
  27581. * Gets the current class name of the material e.g. "StandardMaterial"
  27582. * Mainly use in serialization.
  27583. * @returns the class name
  27584. */
  27585. getClassName(): string;
  27586. /**
  27587. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27588. * You can try switching to logarithmic depth.
  27589. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27590. */
  27591. get useLogarithmicDepth(): boolean;
  27592. set useLogarithmicDepth(value: boolean);
  27593. /**
  27594. * Specifies if the material will require alpha blending
  27595. * @returns a boolean specifying if alpha blending is needed
  27596. */
  27597. needAlphaBlending(): boolean;
  27598. /**
  27599. * Specifies if this material should be rendered in alpha test mode
  27600. * @returns a boolean specifying if an alpha test is needed.
  27601. */
  27602. needAlphaTesting(): boolean;
  27603. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27604. /**
  27605. * Get the texture used for alpha test purpose.
  27606. * @returns the diffuse texture in case of the standard material.
  27607. */
  27608. getAlphaTestTexture(): Nullable<BaseTexture>;
  27609. /**
  27610. * Get if the submesh is ready to be used and all its information available.
  27611. * Child classes can use it to update shaders
  27612. * @param mesh defines the mesh to check
  27613. * @param subMesh defines which submesh to check
  27614. * @param useInstances specifies that instances should be used
  27615. * @returns a boolean indicating that the submesh is ready or not
  27616. */
  27617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27618. /**
  27619. * Builds the material UBO layouts.
  27620. * Used internally during the effect preparation.
  27621. */
  27622. buildUniformLayout(): void;
  27623. /**
  27624. * Unbinds the material from the mesh
  27625. */
  27626. unbind(): void;
  27627. /**
  27628. * Binds the submesh to this material by preparing the effect and shader to draw
  27629. * @param world defines the world transformation matrix
  27630. * @param mesh defines the mesh containing the submesh
  27631. * @param subMesh defines the submesh to bind the material to
  27632. */
  27633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27634. /**
  27635. * Get the list of animatables in the material.
  27636. * @returns the list of animatables object used in the material
  27637. */
  27638. getAnimatables(): IAnimatable[];
  27639. /**
  27640. * Gets the active textures from the material
  27641. * @returns an array of textures
  27642. */
  27643. getActiveTextures(): BaseTexture[];
  27644. /**
  27645. * Specifies if the material uses a texture
  27646. * @param texture defines the texture to check against the material
  27647. * @returns a boolean specifying if the material uses the texture
  27648. */
  27649. hasTexture(texture: BaseTexture): boolean;
  27650. /**
  27651. * Disposes the material
  27652. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27653. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27654. */
  27655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27656. /**
  27657. * Makes a duplicate of the material, and gives it a new name
  27658. * @param name defines the new name for the duplicated material
  27659. * @returns the cloned material
  27660. */
  27661. clone(name: string): StandardMaterial;
  27662. /**
  27663. * Serializes this material in a JSON representation
  27664. * @returns the serialized material object
  27665. */
  27666. serialize(): any;
  27667. /**
  27668. * Creates a standard material from parsed material data
  27669. * @param source defines the JSON representation of the material
  27670. * @param scene defines the hosting scene
  27671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27672. * @returns a new standard material
  27673. */
  27674. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27675. /**
  27676. * Are diffuse textures enabled in the application.
  27677. */
  27678. static get DiffuseTextureEnabled(): boolean;
  27679. static set DiffuseTextureEnabled(value: boolean);
  27680. /**
  27681. * Are ambient textures enabled in the application.
  27682. */
  27683. static get AmbientTextureEnabled(): boolean;
  27684. static set AmbientTextureEnabled(value: boolean);
  27685. /**
  27686. * Are opacity textures enabled in the application.
  27687. */
  27688. static get OpacityTextureEnabled(): boolean;
  27689. static set OpacityTextureEnabled(value: boolean);
  27690. /**
  27691. * Are reflection textures enabled in the application.
  27692. */
  27693. static get ReflectionTextureEnabled(): boolean;
  27694. static set ReflectionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are emissive textures enabled in the application.
  27697. */
  27698. static get EmissiveTextureEnabled(): boolean;
  27699. static set EmissiveTextureEnabled(value: boolean);
  27700. /**
  27701. * Are specular textures enabled in the application.
  27702. */
  27703. static get SpecularTextureEnabled(): boolean;
  27704. static set SpecularTextureEnabled(value: boolean);
  27705. /**
  27706. * Are bump textures enabled in the application.
  27707. */
  27708. static get BumpTextureEnabled(): boolean;
  27709. static set BumpTextureEnabled(value: boolean);
  27710. /**
  27711. * Are lightmap textures enabled in the application.
  27712. */
  27713. static get LightmapTextureEnabled(): boolean;
  27714. static set LightmapTextureEnabled(value: boolean);
  27715. /**
  27716. * Are refraction textures enabled in the application.
  27717. */
  27718. static get RefractionTextureEnabled(): boolean;
  27719. static set RefractionTextureEnabled(value: boolean);
  27720. /**
  27721. * Are color grading textures enabled in the application.
  27722. */
  27723. static get ColorGradingTextureEnabled(): boolean;
  27724. static set ColorGradingTextureEnabled(value: boolean);
  27725. /**
  27726. * Are fresnels enabled in the application.
  27727. */
  27728. static get FresnelEnabled(): boolean;
  27729. static set FresnelEnabled(value: boolean);
  27730. }
  27731. }
  27732. declare module "babylonjs/Particles/solidParticleSystem" {
  27733. import { Nullable } from "babylonjs/types";
  27734. import { Vector3 } from "babylonjs/Maths/math.vector";
  27735. import { Mesh } from "babylonjs/Meshes/mesh";
  27736. import { Scene, IDisposable } from "babylonjs/scene";
  27737. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27738. import { Material } from "babylonjs/Materials/material";
  27739. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27740. /**
  27741. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27742. *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.
  27743. * The SPS is also a particle system. It provides some methods to manage the particles.
  27744. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27745. *
  27746. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27747. */
  27748. export class SolidParticleSystem implements IDisposable {
  27749. /**
  27750. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27751. * Example : var p = SPS.particles[i];
  27752. */
  27753. particles: SolidParticle[];
  27754. /**
  27755. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27756. */
  27757. nbParticles: number;
  27758. /**
  27759. * If the particles must ever face the camera (default false). Useful for planar particles.
  27760. */
  27761. billboard: boolean;
  27762. /**
  27763. * Recompute normals when adding a shape
  27764. */
  27765. recomputeNormals: boolean;
  27766. /**
  27767. * This a counter ofr your own usage. It's not set by any SPS functions.
  27768. */
  27769. counter: number;
  27770. /**
  27771. * The SPS name. This name is also given to the underlying mesh.
  27772. */
  27773. name: string;
  27774. /**
  27775. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27776. */
  27777. mesh: Mesh;
  27778. /**
  27779. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27780. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27781. */
  27782. vars: any;
  27783. /**
  27784. * This array is populated when the SPS is set as 'pickable'.
  27785. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27786. * Each element of this array is an object `{idx: int, faceId: int}`.
  27787. * `idx` is the picked particle index in the `SPS.particles` array
  27788. * `faceId` is the picked face index counted within this particle.
  27789. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27790. */
  27791. pickedParticles: {
  27792. idx: number;
  27793. faceId: number;
  27794. }[];
  27795. /**
  27796. * This array is populated when `enableDepthSort` is set to true.
  27797. * Each element of this array is an instance of the class DepthSortedParticle.
  27798. */
  27799. depthSortedParticles: DepthSortedParticle[];
  27800. /**
  27801. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27802. * @hidden
  27803. */
  27804. _bSphereOnly: boolean;
  27805. /**
  27806. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27807. * @hidden
  27808. */
  27809. _bSphereRadiusFactor: number;
  27810. private _scene;
  27811. private _positions;
  27812. private _indices;
  27813. private _normals;
  27814. private _colors;
  27815. private _uvs;
  27816. private _indices32;
  27817. private _positions32;
  27818. private _normals32;
  27819. private _fixedNormal32;
  27820. private _colors32;
  27821. private _uvs32;
  27822. private _index;
  27823. private _updatable;
  27824. private _pickable;
  27825. private _isVisibilityBoxLocked;
  27826. private _alwaysVisible;
  27827. private _depthSort;
  27828. private _expandable;
  27829. private _shapeCounter;
  27830. private _copy;
  27831. private _color;
  27832. private _computeParticleColor;
  27833. private _computeParticleTexture;
  27834. private _computeParticleRotation;
  27835. private _computeParticleVertex;
  27836. private _computeBoundingBox;
  27837. private _depthSortParticles;
  27838. private _camera;
  27839. private _mustUnrotateFixedNormals;
  27840. private _particlesIntersect;
  27841. private _needs32Bits;
  27842. private _isNotBuilt;
  27843. private _lastParticleId;
  27844. private _idxOfId;
  27845. private _multimaterialEnabled;
  27846. private _useModelMaterial;
  27847. private _indicesByMaterial;
  27848. private _materialIndexes;
  27849. private _depthSortFunction;
  27850. private _materialSortFunction;
  27851. private _materials;
  27852. private _multimaterial;
  27853. private _materialIndexesById;
  27854. private _defaultMaterial;
  27855. private _autoUpdateSubMeshes;
  27856. /**
  27857. * Creates a SPS (Solid Particle System) object.
  27858. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27859. * @param scene (Scene) is the scene in which the SPS is added.
  27860. * @param options defines the options of the sps e.g.
  27861. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27862. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27863. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27864. * * 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.
  27865. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27866. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27867. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27868. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27869. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27870. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27871. */
  27872. constructor(name: string, scene: Scene, options?: {
  27873. updatable?: boolean;
  27874. isPickable?: boolean;
  27875. enableDepthSort?: boolean;
  27876. particleIntersection?: boolean;
  27877. boundingSphereOnly?: boolean;
  27878. bSphereRadiusFactor?: number;
  27879. expandable?: boolean;
  27880. useModelMaterial?: boolean;
  27881. enableMultiMaterial?: boolean;
  27882. });
  27883. /**
  27884. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27885. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27886. * @returns the created mesh
  27887. */
  27888. buildMesh(): Mesh;
  27889. /**
  27890. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27891. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27892. * Thus the particles generated from `digest()` have their property `position` set yet.
  27893. * @param mesh ( Mesh ) is the mesh to be digested
  27894. * @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
  27895. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27896. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27897. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27898. * @returns the current SPS
  27899. */
  27900. digest(mesh: Mesh, options?: {
  27901. facetNb?: number;
  27902. number?: number;
  27903. delta?: number;
  27904. storage?: [];
  27905. }): SolidParticleSystem;
  27906. /**
  27907. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27908. * @hidden
  27909. */
  27910. private _unrotateFixedNormals;
  27911. /**
  27912. * Resets the temporary working copy particle
  27913. * @hidden
  27914. */
  27915. private _resetCopy;
  27916. /**
  27917. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27918. * @param p the current index in the positions array to be updated
  27919. * @param ind the current index in the indices array
  27920. * @param shape a Vector3 array, the shape geometry
  27921. * @param positions the positions array to be updated
  27922. * @param meshInd the shape indices array
  27923. * @param indices the indices array to be updated
  27924. * @param meshUV the shape uv array
  27925. * @param uvs the uv array to be updated
  27926. * @param meshCol the shape color array
  27927. * @param colors the color array to be updated
  27928. * @param meshNor the shape normals array
  27929. * @param normals the normals array to be updated
  27930. * @param idx the particle index
  27931. * @param idxInShape the particle index in its shape
  27932. * @param options the addShape() method passed options
  27933. * @model the particle model
  27934. * @hidden
  27935. */
  27936. private _meshBuilder;
  27937. /**
  27938. * Returns a shape Vector3 array from positions float array
  27939. * @param positions float array
  27940. * @returns a vector3 array
  27941. * @hidden
  27942. */
  27943. private _posToShape;
  27944. /**
  27945. * Returns a shapeUV array from a float uvs (array deep copy)
  27946. * @param uvs as a float array
  27947. * @returns a shapeUV array
  27948. * @hidden
  27949. */
  27950. private _uvsToShapeUV;
  27951. /**
  27952. * Adds a new particle object in the particles array
  27953. * @param idx particle index in particles array
  27954. * @param id particle id
  27955. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27956. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27957. * @param model particle ModelShape object
  27958. * @param shapeId model shape identifier
  27959. * @param idxInShape index of the particle in the current model
  27960. * @param bInfo model bounding info object
  27961. * @param storage target storage array, if any
  27962. * @hidden
  27963. */
  27964. private _addParticle;
  27965. /**
  27966. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27967. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27968. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27969. * @param nb (positive integer) the number of particles to be created from this model
  27970. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27971. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27972. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27973. * @returns the number of shapes in the system
  27974. */
  27975. addShape(mesh: Mesh, nb: number, options?: {
  27976. positionFunction?: any;
  27977. vertexFunction?: any;
  27978. storage?: [];
  27979. }): number;
  27980. /**
  27981. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27982. * @hidden
  27983. */
  27984. private _rebuildParticle;
  27985. /**
  27986. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27987. * @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.
  27988. * @returns the SPS.
  27989. */
  27990. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27991. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27992. * Returns an array with the removed particles.
  27993. * 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.
  27994. * The SPS can't be empty so at least one particle needs to remain in place.
  27995. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27996. * @param start index of the first particle to remove
  27997. * @param end index of the last particle to remove (included)
  27998. * @returns an array populated with the removed particles
  27999. */
  28000. removeParticles(start: number, end: number): SolidParticle[];
  28001. /**
  28002. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28003. * @param solidParticleArray an array populated with Solid Particles objects
  28004. * @returns the SPS
  28005. */
  28006. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28007. /**
  28008. * Creates a new particle and modifies the SPS mesh geometry :
  28009. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28010. * - calls _addParticle() to populate the particle array
  28011. * factorized code from addShape() and insertParticlesFromArray()
  28012. * @param idx particle index in the particles array
  28013. * @param i particle index in its shape
  28014. * @param modelShape particle ModelShape object
  28015. * @param shape shape vertex array
  28016. * @param meshInd shape indices array
  28017. * @param meshUV shape uv array
  28018. * @param meshCol shape color array
  28019. * @param meshNor shape normals array
  28020. * @param bbInfo shape bounding info
  28021. * @param storage target particle storage
  28022. * @options addShape() passed options
  28023. * @hidden
  28024. */
  28025. private _insertNewParticle;
  28026. /**
  28027. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28028. * This method calls `updateParticle()` for each particle of the SPS.
  28029. * For an animated SPS, it is usually called within the render loop.
  28030. * 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.
  28031. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28032. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28033. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28034. * @returns the SPS.
  28035. */
  28036. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28037. /**
  28038. * Disposes the SPS.
  28039. */
  28040. dispose(): void;
  28041. /**
  28042. * Returns a SolidParticle object from its identifier : particle.id
  28043. * @param id (integer) the particle Id
  28044. * @returns the searched particle or null if not found in the SPS.
  28045. */
  28046. getParticleById(id: number): Nullable<SolidParticle>;
  28047. /**
  28048. * Returns a new array populated with the particles having the passed shapeId.
  28049. * @param shapeId (integer) the shape identifier
  28050. * @returns a new solid particle array
  28051. */
  28052. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28053. /**
  28054. * Populates the passed array "ref" with the particles having the passed shapeId.
  28055. * @param shapeId the shape identifier
  28056. * @returns the SPS
  28057. * @param ref
  28058. */
  28059. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28060. /**
  28061. * Computes the required SubMeshes according the materials assigned to the particles.
  28062. * @returns the solid particle system.
  28063. * Does nothing if called before the SPS mesh is built.
  28064. */
  28065. computeSubMeshes(): SolidParticleSystem;
  28066. /**
  28067. * Sorts the solid particles by material when MultiMaterial is enabled.
  28068. * Updates the indices32 array.
  28069. * Updates the indicesByMaterial array.
  28070. * Updates the mesh indices array.
  28071. * @returns the SPS
  28072. * @hidden
  28073. */
  28074. private _sortParticlesByMaterial;
  28075. /**
  28076. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28077. * @hidden
  28078. */
  28079. private _setMaterialIndexesById;
  28080. /**
  28081. * Returns an array with unique values of Materials from the passed array
  28082. * @param array the material array to be checked and filtered
  28083. * @hidden
  28084. */
  28085. private _filterUniqueMaterialId;
  28086. /**
  28087. * Sets a new Standard Material as _defaultMaterial if not already set.
  28088. * @hidden
  28089. */
  28090. private _setDefaultMaterial;
  28091. /**
  28092. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28094. * @returns the SPS.
  28095. */
  28096. refreshVisibleSize(): SolidParticleSystem;
  28097. /**
  28098. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28099. * @param size the size (float) of the visibility box
  28100. * note : this doesn't lock the SPS mesh bounding box.
  28101. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28102. */
  28103. setVisibilityBox(size: number): void;
  28104. /**
  28105. * Gets whether the SPS as always visible or not
  28106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28107. */
  28108. get isAlwaysVisible(): boolean;
  28109. /**
  28110. * Sets the SPS as always visible or not
  28111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28112. */
  28113. set isAlwaysVisible(val: boolean);
  28114. /**
  28115. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28116. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28117. */
  28118. set isVisibilityBoxLocked(val: boolean);
  28119. /**
  28120. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28122. */
  28123. get isVisibilityBoxLocked(): boolean;
  28124. /**
  28125. * Tells to `setParticles()` to compute the particle rotations or not.
  28126. * Default value : true. The SPS is faster when it's set to false.
  28127. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28128. */
  28129. set computeParticleRotation(val: boolean);
  28130. /**
  28131. * Tells to `setParticles()` to compute the particle colors or not.
  28132. * Default value : true. The SPS is faster when it's set to false.
  28133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28134. */
  28135. set computeParticleColor(val: boolean);
  28136. set computeParticleTexture(val: boolean);
  28137. /**
  28138. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28139. * Default value : false. The SPS is faster when it's set to false.
  28140. * Note : the particle custom vertex positions aren't stored values.
  28141. */
  28142. set computeParticleVertex(val: boolean);
  28143. /**
  28144. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28145. */
  28146. set computeBoundingBox(val: boolean);
  28147. /**
  28148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28150. * Default : `true`
  28151. */
  28152. set depthSortParticles(val: boolean);
  28153. /**
  28154. * Gets if `setParticles()` computes the particle rotations or not.
  28155. * Default value : true. The SPS is faster when it's set to false.
  28156. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28157. */
  28158. get computeParticleRotation(): boolean;
  28159. /**
  28160. * Gets if `setParticles()` computes the particle colors or not.
  28161. * Default value : true. The SPS is faster when it's set to false.
  28162. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28163. */
  28164. get computeParticleColor(): boolean;
  28165. /**
  28166. * Gets if `setParticles()` computes the particle textures or not.
  28167. * Default value : true. The SPS is faster when it's set to false.
  28168. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28169. */
  28170. get computeParticleTexture(): boolean;
  28171. /**
  28172. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28173. * Default value : false. The SPS is faster when it's set to false.
  28174. * Note : the particle custom vertex positions aren't stored values.
  28175. */
  28176. get computeParticleVertex(): boolean;
  28177. /**
  28178. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28179. */
  28180. get computeBoundingBox(): boolean;
  28181. /**
  28182. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28183. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28184. * Default : `true`
  28185. */
  28186. get depthSortParticles(): boolean;
  28187. /**
  28188. * Gets if the SPS is created as expandable at construction time.
  28189. * Default : `false`
  28190. */
  28191. get expandable(): boolean;
  28192. /**
  28193. * Gets if the SPS supports the Multi Materials
  28194. */
  28195. get multimaterialEnabled(): boolean;
  28196. /**
  28197. * Gets if the SPS uses the model materials for its own multimaterial.
  28198. */
  28199. get useModelMaterial(): boolean;
  28200. /**
  28201. * The SPS used material array.
  28202. */
  28203. get materials(): Material[];
  28204. /**
  28205. * Sets the SPS MultiMaterial from the passed materials.
  28206. * Note : the passed array is internally copied and not used then by reference.
  28207. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28208. */
  28209. setMultiMaterial(materials: Material[]): void;
  28210. /**
  28211. * The SPS computed multimaterial object
  28212. */
  28213. get multimaterial(): MultiMaterial;
  28214. set multimaterial(mm: MultiMaterial);
  28215. /**
  28216. * If the subMeshes must be updated on the next call to setParticles()
  28217. */
  28218. get autoUpdateSubMeshes(): boolean;
  28219. set autoUpdateSubMeshes(val: boolean);
  28220. /**
  28221. * This function does nothing. It may be overwritten to set all the particle first values.
  28222. * The SPS doesn't call this function, you may have to call it by your own.
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28224. */
  28225. initParticles(): void;
  28226. /**
  28227. * This function does nothing. It may be overwritten to recycle a particle.
  28228. * The SPS doesn't call this function, you may have to call it by your own.
  28229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28230. * @param particle The particle to recycle
  28231. * @returns the recycled particle
  28232. */
  28233. recycleParticle(particle: SolidParticle): SolidParticle;
  28234. /**
  28235. * Updates a particle : this function should be overwritten by the user.
  28236. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28237. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28238. * @example : just set a particle position or velocity and recycle conditions
  28239. * @param particle The particle to update
  28240. * @returns the updated particle
  28241. */
  28242. updateParticle(particle: SolidParticle): SolidParticle;
  28243. /**
  28244. * Updates a vertex of a particle : it can be overwritten by the user.
  28245. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28246. * @param particle the current particle
  28247. * @param vertex the current index of the current particle
  28248. * @param pt the index of the current vertex in the particle shape
  28249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28250. * @example : just set a vertex particle position
  28251. * @returns the updated vertex
  28252. */
  28253. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28254. /**
  28255. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28256. * This does nothing and may be overwritten by the user.
  28257. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28258. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28259. * @param update the boolean update value actually passed to setParticles()
  28260. */
  28261. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28262. /**
  28263. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28264. * This will be passed three parameters.
  28265. * This does nothing and may be overwritten by the user.
  28266. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28268. * @param update the boolean update value actually passed to setParticles()
  28269. */
  28270. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28271. }
  28272. }
  28273. declare module "babylonjs/Particles/solidParticle" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28276. import { Color4 } from "babylonjs/Maths/math.color";
  28277. import { Mesh } from "babylonjs/Meshes/mesh";
  28278. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28279. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28280. import { Plane } from "babylonjs/Maths/math.plane";
  28281. import { Material } from "babylonjs/Materials/material";
  28282. /**
  28283. * Represents one particle of a solid particle system.
  28284. */
  28285. export class SolidParticle {
  28286. /**
  28287. * particle global index
  28288. */
  28289. idx: number;
  28290. /**
  28291. * particle identifier
  28292. */
  28293. id: number;
  28294. /**
  28295. * The color of the particle
  28296. */
  28297. color: Nullable<Color4>;
  28298. /**
  28299. * The world space position of the particle.
  28300. */
  28301. position: Vector3;
  28302. /**
  28303. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28304. */
  28305. rotation: Vector3;
  28306. /**
  28307. * The world space rotation quaternion of the particle.
  28308. */
  28309. rotationQuaternion: Nullable<Quaternion>;
  28310. /**
  28311. * The scaling of the particle.
  28312. */
  28313. scaling: Vector3;
  28314. /**
  28315. * The uvs of the particle.
  28316. */
  28317. uvs: Vector4;
  28318. /**
  28319. * The current speed of the particle.
  28320. */
  28321. velocity: Vector3;
  28322. /**
  28323. * The pivot point in the particle local space.
  28324. */
  28325. pivot: Vector3;
  28326. /**
  28327. * Must the particle be translated from its pivot point in its local space ?
  28328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28329. * Default : false
  28330. */
  28331. translateFromPivot: boolean;
  28332. /**
  28333. * Is the particle active or not ?
  28334. */
  28335. alive: boolean;
  28336. /**
  28337. * Is the particle visible or not ?
  28338. */
  28339. isVisible: boolean;
  28340. /**
  28341. * Index of this particle in the global "positions" array (Internal use)
  28342. * @hidden
  28343. */
  28344. _pos: number;
  28345. /**
  28346. * @hidden Index of this particle in the global "indices" array (Internal use)
  28347. */
  28348. _ind: number;
  28349. /**
  28350. * @hidden ModelShape of this particle (Internal use)
  28351. */
  28352. _model: ModelShape;
  28353. /**
  28354. * ModelShape id of this particle
  28355. */
  28356. shapeId: number;
  28357. /**
  28358. * Index of the particle in its shape id
  28359. */
  28360. idxInShape: number;
  28361. /**
  28362. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28363. */
  28364. _modelBoundingInfo: BoundingInfo;
  28365. /**
  28366. * @hidden Particle BoundingInfo object (Internal use)
  28367. */
  28368. _boundingInfo: BoundingInfo;
  28369. /**
  28370. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28371. */
  28372. _sps: SolidParticleSystem;
  28373. /**
  28374. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28375. */
  28376. _stillInvisible: boolean;
  28377. /**
  28378. * @hidden Last computed particle rotation matrix
  28379. */
  28380. _rotationMatrix: number[];
  28381. /**
  28382. * Parent particle Id, if any.
  28383. * Default null.
  28384. */
  28385. parentId: Nullable<number>;
  28386. /**
  28387. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28388. */
  28389. materialIndex: Nullable<number>;
  28390. /**
  28391. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28392. * The possible values are :
  28393. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28394. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28395. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28396. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28397. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28398. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28399. * */
  28400. cullingStrategy: number;
  28401. /**
  28402. * @hidden Internal global position in the SPS.
  28403. */
  28404. _globalPosition: Vector3;
  28405. /**
  28406. * Creates a Solid Particle object.
  28407. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28408. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28409. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28410. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28411. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28412. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28413. * @param shapeId (integer) is the model shape identifier in the SPS.
  28414. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28415. * @param sps defines the sps it is associated to
  28416. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28417. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28418. */
  28419. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28420. /**
  28421. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28422. * @param target the particle target
  28423. * @returns the current particle
  28424. */
  28425. copyToRef(target: SolidParticle): SolidParticle;
  28426. /**
  28427. * Legacy support, changed scale to scaling
  28428. */
  28429. get scale(): Vector3;
  28430. /**
  28431. * Legacy support, changed scale to scaling
  28432. */
  28433. set scale(scale: Vector3);
  28434. /**
  28435. * Legacy support, changed quaternion to rotationQuaternion
  28436. */
  28437. get quaternion(): Nullable<Quaternion>;
  28438. /**
  28439. * Legacy support, changed quaternion to rotationQuaternion
  28440. */
  28441. set quaternion(q: Nullable<Quaternion>);
  28442. /**
  28443. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28444. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28445. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28446. * @returns true if it intersects
  28447. */
  28448. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28449. /**
  28450. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28451. * A particle is in the frustum if its bounding box intersects the frustum
  28452. * @param frustumPlanes defines the frustum to test
  28453. * @returns true if the particle is in the frustum planes
  28454. */
  28455. isInFrustum(frustumPlanes: Plane[]): boolean;
  28456. /**
  28457. * get the rotation matrix of the particle
  28458. * @hidden
  28459. */
  28460. getRotationMatrix(m: Matrix): void;
  28461. }
  28462. /**
  28463. * Represents the shape of the model used by one particle of a solid particle system.
  28464. * SPS internal tool, don't use it manually.
  28465. */
  28466. export class ModelShape {
  28467. /**
  28468. * The shape id
  28469. * @hidden
  28470. */
  28471. shapeID: number;
  28472. /**
  28473. * flat array of model positions (internal use)
  28474. * @hidden
  28475. */
  28476. _shape: Vector3[];
  28477. /**
  28478. * flat array of model UVs (internal use)
  28479. * @hidden
  28480. */
  28481. _shapeUV: number[];
  28482. /**
  28483. * color array of the model
  28484. * @hidden
  28485. */
  28486. _shapeColors: number[];
  28487. /**
  28488. * indices array of the model
  28489. * @hidden
  28490. */
  28491. _indices: number[];
  28492. /**
  28493. * normals array of the model
  28494. * @hidden
  28495. */
  28496. _normals: number[];
  28497. /**
  28498. * length of the shape in the model indices array (internal use)
  28499. * @hidden
  28500. */
  28501. _indicesLength: number;
  28502. /**
  28503. * Custom position function (internal use)
  28504. * @hidden
  28505. */
  28506. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28507. /**
  28508. * Custom vertex function (internal use)
  28509. * @hidden
  28510. */
  28511. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28512. /**
  28513. * Model material (internal use)
  28514. * @hidden
  28515. */
  28516. _material: Nullable<Material>;
  28517. /**
  28518. * 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.
  28519. * SPS internal tool, don't use it manually.
  28520. * @hidden
  28521. */
  28522. 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>);
  28523. }
  28524. /**
  28525. * Represents a Depth Sorted Particle in the solid particle system.
  28526. * @hidden
  28527. */
  28528. export class DepthSortedParticle {
  28529. /**
  28530. * Index of the particle in the "indices" array
  28531. */
  28532. ind: number;
  28533. /**
  28534. * Length of the particle shape in the "indices" array
  28535. */
  28536. indicesLength: number;
  28537. /**
  28538. * Squared distance from the particle to the camera
  28539. */
  28540. sqDistance: number;
  28541. /**
  28542. * Material index when used with MultiMaterials
  28543. */
  28544. materialIndex: number;
  28545. /**
  28546. * Creates a new sorted particle
  28547. * @param materialIndex
  28548. */
  28549. constructor(ind: number, indLength: number, materialIndex: number);
  28550. }
  28551. }
  28552. declare module "babylonjs/Collisions/meshCollisionData" {
  28553. import { Collider } from "babylonjs/Collisions/collider";
  28554. import { Vector3 } from "babylonjs/Maths/math.vector";
  28555. import { Nullable } from "babylonjs/types";
  28556. import { Observer } from "babylonjs/Misc/observable";
  28557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28558. /**
  28559. * @hidden
  28560. */
  28561. export class _MeshCollisionData {
  28562. _checkCollisions: boolean;
  28563. _collisionMask: number;
  28564. _collisionGroup: number;
  28565. _collider: Nullable<Collider>;
  28566. _oldPositionForCollisions: Vector3;
  28567. _diffPositionForCollisions: Vector3;
  28568. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28569. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28570. }
  28571. }
  28572. declare module "babylonjs/Meshes/abstractMesh" {
  28573. import { Observable } from "babylonjs/Misc/observable";
  28574. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28575. import { Camera } from "babylonjs/Cameras/camera";
  28576. import { Scene, IDisposable } from "babylonjs/scene";
  28577. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28578. import { Node } from "babylonjs/node";
  28579. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28582. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28583. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28584. import { Material } from "babylonjs/Materials/material";
  28585. import { Light } from "babylonjs/Lights/light";
  28586. import { Skeleton } from "babylonjs/Bones/skeleton";
  28587. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28588. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28589. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28590. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28591. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28592. import { Plane } from "babylonjs/Maths/math.plane";
  28593. import { Ray } from "babylonjs/Culling/ray";
  28594. import { Collider } from "babylonjs/Collisions/collider";
  28595. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28596. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28597. /** @hidden */
  28598. class _FacetDataStorage {
  28599. facetPositions: Vector3[];
  28600. facetNormals: Vector3[];
  28601. facetPartitioning: number[][];
  28602. facetNb: number;
  28603. partitioningSubdivisions: number;
  28604. partitioningBBoxRatio: number;
  28605. facetDataEnabled: boolean;
  28606. facetParameters: any;
  28607. bbSize: Vector3;
  28608. subDiv: {
  28609. max: number;
  28610. X: number;
  28611. Y: number;
  28612. Z: number;
  28613. };
  28614. facetDepthSort: boolean;
  28615. facetDepthSortEnabled: boolean;
  28616. depthSortedIndices: IndicesArray;
  28617. depthSortedFacets: {
  28618. ind: number;
  28619. sqDistance: number;
  28620. }[];
  28621. facetDepthSortFunction: (f1: {
  28622. ind: number;
  28623. sqDistance: number;
  28624. }, f2: {
  28625. ind: number;
  28626. sqDistance: number;
  28627. }) => number;
  28628. facetDepthSortFrom: Vector3;
  28629. facetDepthSortOrigin: Vector3;
  28630. invertedMatrix: Matrix;
  28631. }
  28632. /**
  28633. * @hidden
  28634. **/
  28635. class _InternalAbstractMeshDataInfo {
  28636. _hasVertexAlpha: boolean;
  28637. _useVertexColors: boolean;
  28638. _numBoneInfluencers: number;
  28639. _applyFog: boolean;
  28640. _receiveShadows: boolean;
  28641. _facetData: _FacetDataStorage;
  28642. _visibility: number;
  28643. _skeleton: Nullable<Skeleton>;
  28644. _layerMask: number;
  28645. _computeBonesUsingShaders: boolean;
  28646. _isActive: boolean;
  28647. _onlyForInstances: boolean;
  28648. _isActiveIntermediate: boolean;
  28649. _onlyForInstancesIntermediate: boolean;
  28650. _actAsRegularMesh: boolean;
  28651. }
  28652. /**
  28653. * Class used to store all common mesh properties
  28654. */
  28655. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28656. /** No occlusion */
  28657. static OCCLUSION_TYPE_NONE: number;
  28658. /** Occlusion set to optimisitic */
  28659. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28660. /** Occlusion set to strict */
  28661. static OCCLUSION_TYPE_STRICT: number;
  28662. /** Use an accurante occlusion algorithm */
  28663. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28664. /** Use a conservative occlusion algorithm */
  28665. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28666. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28667. * Test order :
  28668. * Is the bounding sphere outside the frustum ?
  28669. * If not, are the bounding box vertices outside the frustum ?
  28670. * It not, then the cullable object is in the frustum.
  28671. */
  28672. static readonly CULLINGSTRATEGY_STANDARD: number;
  28673. /** Culling strategy : Bounding Sphere Only.
  28674. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28675. * It's also less accurate than the standard because some not visible objects can still be selected.
  28676. * Test : is the bounding sphere outside the frustum ?
  28677. * If not, then the cullable object is in the frustum.
  28678. */
  28679. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28680. /** Culling strategy : Optimistic Inclusion.
  28681. * This in an inclusion test first, then the standard exclusion test.
  28682. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28683. * 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.
  28684. * Anyway, it's as accurate as the standard strategy.
  28685. * Test :
  28686. * Is the cullable object bounding sphere center in the frustum ?
  28687. * If not, apply the default culling strategy.
  28688. */
  28689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28690. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28691. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28692. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28693. * 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.
  28694. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28695. * Test :
  28696. * Is the cullable object bounding sphere center in the frustum ?
  28697. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28698. */
  28699. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28700. /**
  28701. * No billboard
  28702. */
  28703. static get BILLBOARDMODE_NONE(): number;
  28704. /** Billboard on X axis */
  28705. static get BILLBOARDMODE_X(): number;
  28706. /** Billboard on Y axis */
  28707. static get BILLBOARDMODE_Y(): number;
  28708. /** Billboard on Z axis */
  28709. static get BILLBOARDMODE_Z(): number;
  28710. /** Billboard on all axes */
  28711. static get BILLBOARDMODE_ALL(): number;
  28712. /** Billboard on using position instead of orientation */
  28713. static get BILLBOARDMODE_USE_POSITION(): number;
  28714. /** @hidden */
  28715. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28716. /**
  28717. * The culling strategy to use to check whether the mesh must be rendered or not.
  28718. * This value can be changed at any time and will be used on the next render mesh selection.
  28719. * The possible values are :
  28720. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28721. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28722. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28724. * Please read each static variable documentation to get details about the culling process.
  28725. * */
  28726. cullingStrategy: number;
  28727. /**
  28728. * Gets the number of facets in the mesh
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28730. */
  28731. get facetNb(): number;
  28732. /**
  28733. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28735. */
  28736. get partitioningSubdivisions(): number;
  28737. set partitioningSubdivisions(nb: number);
  28738. /**
  28739. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28740. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28742. */
  28743. get partitioningBBoxRatio(): number;
  28744. set partitioningBBoxRatio(ratio: number);
  28745. /**
  28746. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28747. * Works only for updatable meshes.
  28748. * Doesn't work with multi-materials
  28749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28750. */
  28751. get mustDepthSortFacets(): boolean;
  28752. set mustDepthSortFacets(sort: boolean);
  28753. /**
  28754. * The location (Vector3) where the facet depth sort must be computed from.
  28755. * By default, the active camera position.
  28756. * Used only when facet depth sort is enabled
  28757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28758. */
  28759. get facetDepthSortFrom(): Vector3;
  28760. set facetDepthSortFrom(location: Vector3);
  28761. /**
  28762. * gets a boolean indicating if facetData is enabled
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28764. */
  28765. get isFacetDataEnabled(): boolean;
  28766. /** @hidden */
  28767. _updateNonUniformScalingState(value: boolean): boolean;
  28768. /**
  28769. * An event triggered when this mesh collides with another one
  28770. */
  28771. onCollideObservable: Observable<AbstractMesh>;
  28772. /** Set a function to call when this mesh collides with another one */
  28773. set onCollide(callback: () => void);
  28774. /**
  28775. * An event triggered when the collision's position changes
  28776. */
  28777. onCollisionPositionChangeObservable: Observable<Vector3>;
  28778. /** Set a function to call when the collision's position changes */
  28779. set onCollisionPositionChange(callback: () => void);
  28780. /**
  28781. * An event triggered when material is changed
  28782. */
  28783. onMaterialChangedObservable: Observable<AbstractMesh>;
  28784. /**
  28785. * Gets or sets the orientation for POV movement & rotation
  28786. */
  28787. definedFacingForward: boolean;
  28788. /** @hidden */
  28789. _occlusionQuery: Nullable<WebGLQuery>;
  28790. /** @hidden */
  28791. _renderingGroup: Nullable<RenderingGroup>;
  28792. /**
  28793. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28794. */
  28795. get visibility(): number;
  28796. /**
  28797. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28798. */
  28799. set visibility(value: number);
  28800. /** Gets or sets the alpha index used to sort transparent meshes
  28801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28802. */
  28803. alphaIndex: number;
  28804. /**
  28805. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28806. */
  28807. isVisible: boolean;
  28808. /**
  28809. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28810. */
  28811. isPickable: boolean;
  28812. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28813. showSubMeshesBoundingBox: boolean;
  28814. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28815. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28816. */
  28817. isBlocker: boolean;
  28818. /**
  28819. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28820. */
  28821. enablePointerMoveEvents: boolean;
  28822. /**
  28823. * Specifies the rendering group id for this mesh (0 by default)
  28824. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28825. */
  28826. renderingGroupId: number;
  28827. private _material;
  28828. /** Gets or sets current material */
  28829. get material(): Nullable<Material>;
  28830. set material(value: Nullable<Material>);
  28831. /**
  28832. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28833. * @see http://doc.babylonjs.com/babylon101/shadows
  28834. */
  28835. get receiveShadows(): boolean;
  28836. set receiveShadows(value: boolean);
  28837. /** Defines color to use when rendering outline */
  28838. outlineColor: Color3;
  28839. /** Define width to use when rendering outline */
  28840. outlineWidth: number;
  28841. /** Defines color to use when rendering overlay */
  28842. overlayColor: Color3;
  28843. /** Defines alpha to use when rendering overlay */
  28844. overlayAlpha: number;
  28845. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28846. get hasVertexAlpha(): boolean;
  28847. set hasVertexAlpha(value: boolean);
  28848. /** 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) */
  28849. get useVertexColors(): boolean;
  28850. set useVertexColors(value: boolean);
  28851. /**
  28852. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28853. */
  28854. get computeBonesUsingShaders(): boolean;
  28855. set computeBonesUsingShaders(value: boolean);
  28856. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28857. get numBoneInfluencers(): number;
  28858. set numBoneInfluencers(value: number);
  28859. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28860. get applyFog(): boolean;
  28861. set applyFog(value: boolean);
  28862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28863. useOctreeForRenderingSelection: boolean;
  28864. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28865. useOctreeForPicking: boolean;
  28866. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28867. useOctreeForCollisions: boolean;
  28868. /**
  28869. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28870. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28871. */
  28872. get layerMask(): number;
  28873. set layerMask(value: number);
  28874. /**
  28875. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28876. */
  28877. alwaysSelectAsActiveMesh: boolean;
  28878. /**
  28879. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28880. */
  28881. doNotSyncBoundingInfo: boolean;
  28882. /**
  28883. * Gets or sets the current action manager
  28884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28885. */
  28886. actionManager: Nullable<AbstractActionManager>;
  28887. private _meshCollisionData;
  28888. /**
  28889. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28891. */
  28892. ellipsoid: Vector3;
  28893. /**
  28894. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28895. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28896. */
  28897. ellipsoidOffset: Vector3;
  28898. /**
  28899. * Gets or sets a collision mask used to mask collisions (default is -1).
  28900. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28901. */
  28902. get collisionMask(): number;
  28903. set collisionMask(mask: number);
  28904. /**
  28905. * Gets or sets the current collision group mask (-1 by default).
  28906. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28907. */
  28908. get collisionGroup(): number;
  28909. set collisionGroup(mask: number);
  28910. /**
  28911. * Defines edge width used when edgesRenderer is enabled
  28912. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28913. */
  28914. edgesWidth: number;
  28915. /**
  28916. * Defines edge color used when edgesRenderer is enabled
  28917. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28918. */
  28919. edgesColor: Color4;
  28920. /** @hidden */
  28921. _edgesRenderer: Nullable<IEdgesRenderer>;
  28922. /** @hidden */
  28923. _masterMesh: Nullable<AbstractMesh>;
  28924. /** @hidden */
  28925. _boundingInfo: Nullable<BoundingInfo>;
  28926. /** @hidden */
  28927. _renderId: number;
  28928. /**
  28929. * Gets or sets the list of subMeshes
  28930. * @see http://doc.babylonjs.com/how_to/multi_materials
  28931. */
  28932. subMeshes: SubMesh[];
  28933. /** @hidden */
  28934. _intersectionsInProgress: AbstractMesh[];
  28935. /** @hidden */
  28936. _unIndexed: boolean;
  28937. /** @hidden */
  28938. _lightSources: Light[];
  28939. /** Gets the list of lights affecting that mesh */
  28940. get lightSources(): Light[];
  28941. /** @hidden */
  28942. get _positions(): Nullable<Vector3[]>;
  28943. /** @hidden */
  28944. _waitingData: {
  28945. lods: Nullable<any>;
  28946. actions: Nullable<any>;
  28947. freezeWorldMatrix: Nullable<boolean>;
  28948. };
  28949. /** @hidden */
  28950. _bonesTransformMatrices: Nullable<Float32Array>;
  28951. /** @hidden */
  28952. _transformMatrixTexture: Nullable<RawTexture>;
  28953. /**
  28954. * Gets or sets a skeleton to apply skining transformations
  28955. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28956. */
  28957. set skeleton(value: Nullable<Skeleton>);
  28958. get skeleton(): Nullable<Skeleton>;
  28959. /**
  28960. * An event triggered when the mesh is rebuilt.
  28961. */
  28962. onRebuildObservable: Observable<AbstractMesh>;
  28963. /**
  28964. * Creates a new AbstractMesh
  28965. * @param name defines the name of the mesh
  28966. * @param scene defines the hosting scene
  28967. */
  28968. constructor(name: string, scene?: Nullable<Scene>);
  28969. /**
  28970. * Returns the string "AbstractMesh"
  28971. * @returns "AbstractMesh"
  28972. */
  28973. getClassName(): string;
  28974. /**
  28975. * Gets a string representation of the current mesh
  28976. * @param fullDetails defines a boolean indicating if full details must be included
  28977. * @returns a string representation of the current mesh
  28978. */
  28979. toString(fullDetails?: boolean): string;
  28980. /**
  28981. * @hidden
  28982. */
  28983. protected _getEffectiveParent(): Nullable<Node>;
  28984. /** @hidden */
  28985. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28986. /** @hidden */
  28987. _rebuild(): void;
  28988. /** @hidden */
  28989. _resyncLightSources(): void;
  28990. /** @hidden */
  28991. _resyncLightSource(light: Light): void;
  28992. /** @hidden */
  28993. _unBindEffect(): void;
  28994. /** @hidden */
  28995. _removeLightSource(light: Light, dispose: boolean): void;
  28996. private _markSubMeshesAsDirty;
  28997. /** @hidden */
  28998. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28999. /** @hidden */
  29000. _markSubMeshesAsAttributesDirty(): void;
  29001. /** @hidden */
  29002. _markSubMeshesAsMiscDirty(): void;
  29003. /**
  29004. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29005. */
  29006. get scaling(): Vector3;
  29007. set scaling(newScaling: Vector3);
  29008. /**
  29009. * Returns true if the mesh is blocked. Implemented by child classes
  29010. */
  29011. get isBlocked(): boolean;
  29012. /**
  29013. * Returns the mesh itself by default. Implemented by child classes
  29014. * @param camera defines the camera to use to pick the right LOD level
  29015. * @returns the currentAbstractMesh
  29016. */
  29017. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29018. /**
  29019. * Returns 0 by default. Implemented by child classes
  29020. * @returns an integer
  29021. */
  29022. getTotalVertices(): number;
  29023. /**
  29024. * Returns a positive integer : the total number of indices in this mesh geometry.
  29025. * @returns the numner of indices or zero if the mesh has no geometry.
  29026. */
  29027. getTotalIndices(): number;
  29028. /**
  29029. * Returns null by default. Implemented by child classes
  29030. * @returns null
  29031. */
  29032. getIndices(): Nullable<IndicesArray>;
  29033. /**
  29034. * Returns the array of the requested vertex data kind. Implemented by child classes
  29035. * @param kind defines the vertex data kind to use
  29036. * @returns null
  29037. */
  29038. getVerticesData(kind: string): Nullable<FloatArray>;
  29039. /**
  29040. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29041. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29042. * Note that a new underlying VertexBuffer object is created each call.
  29043. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29044. * @param kind defines vertex data kind:
  29045. * * VertexBuffer.PositionKind
  29046. * * VertexBuffer.UVKind
  29047. * * VertexBuffer.UV2Kind
  29048. * * VertexBuffer.UV3Kind
  29049. * * VertexBuffer.UV4Kind
  29050. * * VertexBuffer.UV5Kind
  29051. * * VertexBuffer.UV6Kind
  29052. * * VertexBuffer.ColorKind
  29053. * * VertexBuffer.MatricesIndicesKind
  29054. * * VertexBuffer.MatricesIndicesExtraKind
  29055. * * VertexBuffer.MatricesWeightsKind
  29056. * * VertexBuffer.MatricesWeightsExtraKind
  29057. * @param data defines the data source
  29058. * @param updatable defines if the data must be flagged as updatable (or static)
  29059. * @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
  29060. * @returns the current mesh
  29061. */
  29062. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29063. /**
  29064. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29065. * If the mesh has no geometry, it is simply returned as it is.
  29066. * @param kind defines vertex data kind:
  29067. * * VertexBuffer.PositionKind
  29068. * * VertexBuffer.UVKind
  29069. * * VertexBuffer.UV2Kind
  29070. * * VertexBuffer.UV3Kind
  29071. * * VertexBuffer.UV4Kind
  29072. * * VertexBuffer.UV5Kind
  29073. * * VertexBuffer.UV6Kind
  29074. * * VertexBuffer.ColorKind
  29075. * * VertexBuffer.MatricesIndicesKind
  29076. * * VertexBuffer.MatricesIndicesExtraKind
  29077. * * VertexBuffer.MatricesWeightsKind
  29078. * * VertexBuffer.MatricesWeightsExtraKind
  29079. * @param data defines the data source
  29080. * @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
  29081. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29082. * @returns the current mesh
  29083. */
  29084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29085. /**
  29086. * Sets the mesh indices,
  29087. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29088. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29089. * @param totalVertices Defines the total number of vertices
  29090. * @returns the current mesh
  29091. */
  29092. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29093. /**
  29094. * Gets a boolean indicating if specific vertex data is present
  29095. * @param kind defines the vertex data kind to use
  29096. * @returns true is data kind is present
  29097. */
  29098. isVerticesDataPresent(kind: string): boolean;
  29099. /**
  29100. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29101. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29102. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29103. * @returns a BoundingInfo
  29104. */
  29105. getBoundingInfo(): BoundingInfo;
  29106. /**
  29107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29111. * @returns the current mesh
  29112. */
  29113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29114. /**
  29115. * Overwrite the current bounding info
  29116. * @param boundingInfo defines the new bounding info
  29117. * @returns the current mesh
  29118. */
  29119. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29120. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29121. get useBones(): boolean;
  29122. /** @hidden */
  29123. _preActivate(): void;
  29124. /** @hidden */
  29125. _preActivateForIntermediateRendering(renderId: number): void;
  29126. /** @hidden */
  29127. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29128. /** @hidden */
  29129. _postActivate(): void;
  29130. /** @hidden */
  29131. _freeze(): void;
  29132. /** @hidden */
  29133. _unFreeze(): void;
  29134. /**
  29135. * Gets the current world matrix
  29136. * @returns a Matrix
  29137. */
  29138. getWorldMatrix(): Matrix;
  29139. /** @hidden */
  29140. _getWorldMatrixDeterminant(): number;
  29141. /**
  29142. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29143. */
  29144. get isAnInstance(): boolean;
  29145. /**
  29146. * Gets a boolean indicating if this mesh has instances
  29147. */
  29148. get hasInstances(): boolean;
  29149. /**
  29150. * Perform relative position change from the point of view of behind the front of the mesh.
  29151. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29152. * Supports definition of mesh facing forward or backward
  29153. * @param amountRight defines the distance on the right axis
  29154. * @param amountUp defines the distance on the up axis
  29155. * @param amountForward defines the distance on the forward axis
  29156. * @returns the current mesh
  29157. */
  29158. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29159. /**
  29160. * Calculate relative position change from the point of view of behind the front of the mesh.
  29161. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29162. * Supports definition of mesh facing forward or backward
  29163. * @param amountRight defines the distance on the right axis
  29164. * @param amountUp defines the distance on the up axis
  29165. * @param amountForward defines the distance on the forward axis
  29166. * @returns the new displacement vector
  29167. */
  29168. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29169. /**
  29170. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29171. * Supports definition of mesh facing forward or backward
  29172. * @param flipBack defines the flip
  29173. * @param twirlClockwise defines the twirl
  29174. * @param tiltRight defines the tilt
  29175. * @returns the current mesh
  29176. */
  29177. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29178. /**
  29179. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29180. * Supports definition of mesh facing forward or backward.
  29181. * @param flipBack defines the flip
  29182. * @param twirlClockwise defines the twirl
  29183. * @param tiltRight defines the tilt
  29184. * @returns the new rotation vector
  29185. */
  29186. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29187. /**
  29188. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29189. * This means the mesh underlying bounding box and sphere are recomputed.
  29190. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29191. * @returns the current mesh
  29192. */
  29193. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29194. /** @hidden */
  29195. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29196. /** @hidden */
  29197. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29198. /** @hidden */
  29199. _updateBoundingInfo(): AbstractMesh;
  29200. /** @hidden */
  29201. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29202. /** @hidden */
  29203. protected _afterComputeWorldMatrix(): void;
  29204. /** @hidden */
  29205. get _effectiveMesh(): AbstractMesh;
  29206. /**
  29207. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29208. * A mesh is in the frustum if its bounding box intersects the frustum
  29209. * @param frustumPlanes defines the frustum to test
  29210. * @returns true if the mesh is in the frustum planes
  29211. */
  29212. isInFrustum(frustumPlanes: Plane[]): boolean;
  29213. /**
  29214. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29215. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29216. * @param frustumPlanes defines the frustum to test
  29217. * @returns true if the mesh is completely in the frustum planes
  29218. */
  29219. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29220. /**
  29221. * True if the mesh intersects another mesh or a SolidParticle object
  29222. * @param mesh defines a target mesh or SolidParticle to test
  29223. * @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)
  29224. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29225. * @returns true if there is an intersection
  29226. */
  29227. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29228. /**
  29229. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29230. * @param point defines the point to test
  29231. * @returns true if there is an intersection
  29232. */
  29233. intersectsPoint(point: Vector3): boolean;
  29234. /**
  29235. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29237. */
  29238. get checkCollisions(): boolean;
  29239. set checkCollisions(collisionEnabled: boolean);
  29240. /**
  29241. * Gets Collider object used to compute collisions (not physics)
  29242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29243. */
  29244. get collider(): Nullable<Collider>;
  29245. /**
  29246. * Move the mesh using collision engine
  29247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29248. * @param displacement defines the requested displacement vector
  29249. * @returns the current mesh
  29250. */
  29251. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29252. private _onCollisionPositionChange;
  29253. /** @hidden */
  29254. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29255. /** @hidden */
  29256. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29257. /** @hidden */
  29258. _checkCollision(collider: Collider): AbstractMesh;
  29259. /** @hidden */
  29260. _generatePointsArray(): boolean;
  29261. /**
  29262. * Checks if the passed Ray intersects with the mesh
  29263. * @param ray defines the ray to use
  29264. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29266. * @returns the picking info
  29267. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29268. */
  29269. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29270. /**
  29271. * Clones the current mesh
  29272. * @param name defines the mesh name
  29273. * @param newParent defines the new mesh parent
  29274. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29275. * @returns the new mesh
  29276. */
  29277. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29278. /**
  29279. * Disposes all the submeshes of the current meshnp
  29280. * @returns the current mesh
  29281. */
  29282. releaseSubMeshes(): AbstractMesh;
  29283. /**
  29284. * Releases resources associated with this abstract mesh.
  29285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29287. */
  29288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29289. /**
  29290. * Adds the passed mesh as a child to the current mesh
  29291. * @param mesh defines the child mesh
  29292. * @returns the current mesh
  29293. */
  29294. addChild(mesh: AbstractMesh): AbstractMesh;
  29295. /**
  29296. * Removes the passed mesh from the current mesh children list
  29297. * @param mesh defines the child mesh
  29298. * @returns the current mesh
  29299. */
  29300. removeChild(mesh: AbstractMesh): AbstractMesh;
  29301. /** @hidden */
  29302. private _initFacetData;
  29303. /**
  29304. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29305. * This method can be called within the render loop.
  29306. * 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
  29307. * @returns the current mesh
  29308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29309. */
  29310. updateFacetData(): AbstractMesh;
  29311. /**
  29312. * Returns the facetLocalNormals array.
  29313. * The normals are expressed in the mesh local spac
  29314. * @returns an array of Vector3
  29315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29316. */
  29317. getFacetLocalNormals(): Vector3[];
  29318. /**
  29319. * Returns the facetLocalPositions array.
  29320. * The facet positions are expressed in the mesh local space
  29321. * @returns an array of Vector3
  29322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29323. */
  29324. getFacetLocalPositions(): Vector3[];
  29325. /**
  29326. * Returns the facetLocalPartioning array
  29327. * @returns an array of array of numbers
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetLocalPartitioning(): number[][];
  29331. /**
  29332. * Returns the i-th facet position in the world system.
  29333. * This method allocates a new Vector3 per call
  29334. * @param i defines the facet index
  29335. * @returns a new Vector3
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29337. */
  29338. getFacetPosition(i: number): Vector3;
  29339. /**
  29340. * Sets the reference Vector3 with the i-th facet position in the world system
  29341. * @param i defines the facet index
  29342. * @param ref defines the target vector
  29343. * @returns the current mesh
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29347. /**
  29348. * Returns the i-th facet normal in the world system.
  29349. * This method allocates a new Vector3 per call
  29350. * @param i defines the facet index
  29351. * @returns a new Vector3
  29352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29353. */
  29354. getFacetNormal(i: number): Vector3;
  29355. /**
  29356. * Sets the reference Vector3 with the i-th facet normal in the world system
  29357. * @param i defines the facet index
  29358. * @param ref defines the target vector
  29359. * @returns the current mesh
  29360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29361. */
  29362. getFacetNormalToRef(i: number, ref: Vector3): this;
  29363. /**
  29364. * 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)
  29365. * @param x defines x coordinate
  29366. * @param y defines y coordinate
  29367. * @param z defines z coordinate
  29368. * @returns the array of facet indexes
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29372. /**
  29373. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29374. * @param projected sets as the (x,y,z) world projection on the facet
  29375. * @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
  29376. * @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
  29377. * @param x defines x coordinate
  29378. * @param y defines y coordinate
  29379. * @param z defines z coordinate
  29380. * @returns the face index if found (or null instead)
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29382. */
  29383. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29384. /**
  29385. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29386. * @param projected sets as the (x,y,z) local projection on the facet
  29387. * @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
  29388. * @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
  29389. * @param x defines x coordinate
  29390. * @param y defines y coordinate
  29391. * @param z defines z coordinate
  29392. * @returns the face index if found (or null instead)
  29393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29394. */
  29395. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29396. /**
  29397. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29398. * @returns the parameters
  29399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29400. */
  29401. getFacetDataParameters(): any;
  29402. /**
  29403. * Disables the feature FacetData and frees the related memory
  29404. * @returns the current mesh
  29405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29406. */
  29407. disableFacetData(): AbstractMesh;
  29408. /**
  29409. * Updates the AbstractMesh indices array
  29410. * @param indices defines the data source
  29411. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29412. * @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)
  29413. * @returns the current mesh
  29414. */
  29415. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29416. /**
  29417. * Creates new normals data for the mesh
  29418. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29419. * @returns the current mesh
  29420. */
  29421. createNormals(updatable: boolean): AbstractMesh;
  29422. /**
  29423. * Align the mesh with a normal
  29424. * @param normal defines the normal to use
  29425. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29426. * @returns the current mesh
  29427. */
  29428. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29429. /** @hidden */
  29430. _checkOcclusionQuery(): boolean;
  29431. /**
  29432. * Disables the mesh edge rendering mode
  29433. * @returns the currentAbstractMesh
  29434. */
  29435. disableEdgesRendering(): AbstractMesh;
  29436. /**
  29437. * Enables the edge rendering mode on the mesh.
  29438. * This mode makes the mesh edges visible
  29439. * @param epsilon defines the maximal distance between two angles to detect a face
  29440. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29441. * @returns the currentAbstractMesh
  29442. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29443. */
  29444. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29445. }
  29446. }
  29447. declare module "babylonjs/Actions/actionEvent" {
  29448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29449. import { Nullable } from "babylonjs/types";
  29450. import { Sprite } from "babylonjs/Sprites/sprite";
  29451. import { Scene } from "babylonjs/scene";
  29452. import { Vector2 } from "babylonjs/Maths/math.vector";
  29453. /**
  29454. * Interface used to define ActionEvent
  29455. */
  29456. export interface IActionEvent {
  29457. /** The mesh or sprite that triggered the action */
  29458. source: any;
  29459. /** The X mouse cursor position at the time of the event */
  29460. pointerX: number;
  29461. /** The Y mouse cursor position at the time of the event */
  29462. pointerY: number;
  29463. /** The mesh that is currently pointed at (can be null) */
  29464. meshUnderPointer: Nullable<AbstractMesh>;
  29465. /** the original (browser) event that triggered the ActionEvent */
  29466. sourceEvent?: any;
  29467. /** additional data for the event */
  29468. additionalData?: any;
  29469. }
  29470. /**
  29471. * ActionEvent is the event being sent when an action is triggered.
  29472. */
  29473. export class ActionEvent implements IActionEvent {
  29474. /** The mesh or sprite that triggered the action */
  29475. source: any;
  29476. /** The X mouse cursor position at the time of the event */
  29477. pointerX: number;
  29478. /** The Y mouse cursor position at the time of the event */
  29479. pointerY: number;
  29480. /** The mesh that is currently pointed at (can be null) */
  29481. meshUnderPointer: Nullable<AbstractMesh>;
  29482. /** the original (browser) event that triggered the ActionEvent */
  29483. sourceEvent?: any;
  29484. /** additional data for the event */
  29485. additionalData?: any;
  29486. /**
  29487. * Creates a new ActionEvent
  29488. * @param source The mesh or sprite that triggered the action
  29489. * @param pointerX The X mouse cursor position at the time of the event
  29490. * @param pointerY The Y mouse cursor position at the time of the event
  29491. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29492. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29493. * @param additionalData additional data for the event
  29494. */
  29495. constructor(
  29496. /** The mesh or sprite that triggered the action */
  29497. source: any,
  29498. /** The X mouse cursor position at the time of the event */
  29499. pointerX: number,
  29500. /** The Y mouse cursor position at the time of the event */
  29501. pointerY: number,
  29502. /** The mesh that is currently pointed at (can be null) */
  29503. meshUnderPointer: Nullable<AbstractMesh>,
  29504. /** the original (browser) event that triggered the ActionEvent */
  29505. sourceEvent?: any,
  29506. /** additional data for the event */
  29507. additionalData?: any);
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a source mesh.
  29510. * @param source The source mesh that triggered the event
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29516. /**
  29517. * Helper function to auto-create an ActionEvent from a source sprite
  29518. * @param source The source sprite that triggered the event
  29519. * @param scene Scene associated with the sprite
  29520. * @param evt The original (browser) event
  29521. * @param additionalData additional data for the event
  29522. * @returns the new ActionEvent
  29523. */
  29524. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29525. /**
  29526. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29527. * @param scene the scene where the event occurred
  29528. * @param evt The original (browser) event
  29529. * @returns the new ActionEvent
  29530. */
  29531. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29532. /**
  29533. * Helper function to auto-create an ActionEvent from a primitive
  29534. * @param prim defines the target primitive
  29535. * @param pointerPos defines the pointer position
  29536. * @param evt The original (browser) event
  29537. * @param additionalData additional data for the event
  29538. * @returns the new ActionEvent
  29539. */
  29540. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29541. }
  29542. }
  29543. declare module "babylonjs/Actions/abstractActionManager" {
  29544. import { IDisposable } from "babylonjs/scene";
  29545. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29546. import { IAction } from "babylonjs/Actions/action";
  29547. import { Nullable } from "babylonjs/types";
  29548. /**
  29549. * Abstract class used to decouple action Manager from scene and meshes.
  29550. * Do not instantiate.
  29551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29552. */
  29553. export abstract class AbstractActionManager implements IDisposable {
  29554. /** Gets the list of active triggers */
  29555. static Triggers: {
  29556. [key: string]: number;
  29557. };
  29558. /** Gets the cursor to use when hovering items */
  29559. hoverCursor: string;
  29560. /** Gets the list of actions */
  29561. actions: IAction[];
  29562. /**
  29563. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29564. */
  29565. isRecursive: boolean;
  29566. /**
  29567. * Releases all associated resources
  29568. */
  29569. abstract dispose(): void;
  29570. /**
  29571. * Does this action manager has pointer triggers
  29572. */
  29573. abstract get hasPointerTriggers(): boolean;
  29574. /**
  29575. * Does this action manager has pick triggers
  29576. */
  29577. abstract get hasPickTriggers(): boolean;
  29578. /**
  29579. * Process a specific trigger
  29580. * @param trigger defines the trigger to process
  29581. * @param evt defines the event details to be processed
  29582. */
  29583. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29584. /**
  29585. * Does this action manager handles actions of any of the given triggers
  29586. * @param triggers defines the triggers to be tested
  29587. * @return a boolean indicating whether one (or more) of the triggers is handled
  29588. */
  29589. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29590. /**
  29591. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29592. * speed.
  29593. * @param triggerA defines the trigger to be tested
  29594. * @param triggerB defines the trigger to be tested
  29595. * @return a boolean indicating whether one (or more) of the triggers is handled
  29596. */
  29597. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29598. /**
  29599. * Does this action manager handles actions of a given trigger
  29600. * @param trigger defines the trigger to be tested
  29601. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29602. * @return whether the trigger is handled
  29603. */
  29604. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29605. /**
  29606. * Serialize this manager to a JSON object
  29607. * @param name defines the property name to store this manager
  29608. * @returns a JSON representation of this manager
  29609. */
  29610. abstract serialize(name: string): any;
  29611. /**
  29612. * Registers an action to this action manager
  29613. * @param action defines the action to be registered
  29614. * @return the action amended (prepared) after registration
  29615. */
  29616. abstract registerAction(action: IAction): Nullable<IAction>;
  29617. /**
  29618. * Unregisters an action to this action manager
  29619. * @param action defines the action to be unregistered
  29620. * @return a boolean indicating whether the action has been unregistered
  29621. */
  29622. abstract unregisterAction(action: IAction): Boolean;
  29623. /**
  29624. * Does exist one action manager with at least one trigger
  29625. **/
  29626. static get HasTriggers(): boolean;
  29627. /**
  29628. * Does exist one action manager with at least one pick trigger
  29629. **/
  29630. static get HasPickTriggers(): boolean;
  29631. /**
  29632. * Does exist one action manager that handles actions of a given trigger
  29633. * @param trigger defines the trigger to be tested
  29634. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29635. **/
  29636. static HasSpecificTrigger(trigger: number): boolean;
  29637. }
  29638. }
  29639. declare module "babylonjs/node" {
  29640. import { Scene } from "babylonjs/scene";
  29641. import { Nullable } from "babylonjs/types";
  29642. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29643. import { Engine } from "babylonjs/Engines/engine";
  29644. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29645. import { Observable } from "babylonjs/Misc/observable";
  29646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29647. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29648. import { Animatable } from "babylonjs/Animations/animatable";
  29649. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29650. import { Animation } from "babylonjs/Animations/animation";
  29651. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29653. /**
  29654. * Defines how a node can be built from a string name.
  29655. */
  29656. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29657. /**
  29658. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29659. */
  29660. export class Node implements IBehaviorAware<Node> {
  29661. /** @hidden */
  29662. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29663. private static _NodeConstructors;
  29664. /**
  29665. * Add a new node constructor
  29666. * @param type defines the type name of the node to construct
  29667. * @param constructorFunc defines the constructor function
  29668. */
  29669. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29670. /**
  29671. * Returns a node constructor based on type name
  29672. * @param type defines the type name
  29673. * @param name defines the new node name
  29674. * @param scene defines the hosting scene
  29675. * @param options defines optional options to transmit to constructors
  29676. * @returns the new constructor or null
  29677. */
  29678. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29679. /**
  29680. * Gets or sets the name of the node
  29681. */
  29682. name: string;
  29683. /**
  29684. * Gets or sets the id of the node
  29685. */
  29686. id: string;
  29687. /**
  29688. * Gets or sets the unique id of the node
  29689. */
  29690. uniqueId: number;
  29691. /**
  29692. * Gets or sets a string used to store user defined state for the node
  29693. */
  29694. state: string;
  29695. /**
  29696. * Gets or sets an object used to store user defined information for the node
  29697. */
  29698. metadata: any;
  29699. /**
  29700. * For internal use only. Please do not use.
  29701. */
  29702. reservedDataStore: any;
  29703. /**
  29704. * List of inspectable custom properties (used by the Inspector)
  29705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29706. */
  29707. inspectableCustomProperties: IInspectable[];
  29708. private _doNotSerialize;
  29709. /**
  29710. * Gets or sets a boolean used to define if the node must be serialized
  29711. */
  29712. get doNotSerialize(): boolean;
  29713. set doNotSerialize(value: boolean);
  29714. /** @hidden */
  29715. _isDisposed: boolean;
  29716. /**
  29717. * Gets a list of Animations associated with the node
  29718. */
  29719. animations: import("babylonjs/Animations/animation").Animation[];
  29720. protected _ranges: {
  29721. [name: string]: Nullable<AnimationRange>;
  29722. };
  29723. /**
  29724. * Callback raised when the node is ready to be used
  29725. */
  29726. onReady: Nullable<(node: Node) => void>;
  29727. private _isEnabled;
  29728. private _isParentEnabled;
  29729. private _isReady;
  29730. /** @hidden */
  29731. _currentRenderId: number;
  29732. private _parentUpdateId;
  29733. /** @hidden */
  29734. _childUpdateId: number;
  29735. /** @hidden */
  29736. _waitingParentId: Nullable<string>;
  29737. /** @hidden */
  29738. _scene: Scene;
  29739. /** @hidden */
  29740. _cache: any;
  29741. private _parentNode;
  29742. private _children;
  29743. /** @hidden */
  29744. _worldMatrix: Matrix;
  29745. /** @hidden */
  29746. _worldMatrixDeterminant: number;
  29747. /** @hidden */
  29748. _worldMatrixDeterminantIsDirty: boolean;
  29749. /** @hidden */
  29750. private _sceneRootNodesIndex;
  29751. /**
  29752. * Gets a boolean indicating if the node has been disposed
  29753. * @returns true if the node was disposed
  29754. */
  29755. isDisposed(): boolean;
  29756. /**
  29757. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29758. * @see https://doc.babylonjs.com/how_to/parenting
  29759. */
  29760. set parent(parent: Nullable<Node>);
  29761. get parent(): Nullable<Node>;
  29762. /** @hidden */
  29763. _addToSceneRootNodes(): void;
  29764. /** @hidden */
  29765. _removeFromSceneRootNodes(): void;
  29766. private _animationPropertiesOverride;
  29767. /**
  29768. * Gets or sets the animation properties override
  29769. */
  29770. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29771. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29772. /**
  29773. * Gets a string idenfifying the name of the class
  29774. * @returns "Node" string
  29775. */
  29776. getClassName(): string;
  29777. /** @hidden */
  29778. readonly _isNode: boolean;
  29779. /**
  29780. * An event triggered when the mesh is disposed
  29781. */
  29782. onDisposeObservable: Observable<Node>;
  29783. private _onDisposeObserver;
  29784. /**
  29785. * Sets a callback that will be raised when the node will be disposed
  29786. */
  29787. set onDispose(callback: () => void);
  29788. /**
  29789. * Creates a new Node
  29790. * @param name the name and id to be given to this node
  29791. * @param scene the scene this node will be added to
  29792. */
  29793. constructor(name: string, scene?: Nullable<Scene>);
  29794. /**
  29795. * Gets the scene of the node
  29796. * @returns a scene
  29797. */
  29798. getScene(): Scene;
  29799. /**
  29800. * Gets the engine of the node
  29801. * @returns a Engine
  29802. */
  29803. getEngine(): Engine;
  29804. private _behaviors;
  29805. /**
  29806. * Attach a behavior to the node
  29807. * @see http://doc.babylonjs.com/features/behaviour
  29808. * @param behavior defines the behavior to attach
  29809. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29810. * @returns the current Node
  29811. */
  29812. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29813. /**
  29814. * Remove an attached behavior
  29815. * @see http://doc.babylonjs.com/features/behaviour
  29816. * @param behavior defines the behavior to attach
  29817. * @returns the current Node
  29818. */
  29819. removeBehavior(behavior: Behavior<Node>): Node;
  29820. /**
  29821. * Gets the list of attached behaviors
  29822. * @see http://doc.babylonjs.com/features/behaviour
  29823. */
  29824. get behaviors(): Behavior<Node>[];
  29825. /**
  29826. * Gets an attached behavior by name
  29827. * @param name defines the name of the behavior to look for
  29828. * @see http://doc.babylonjs.com/features/behaviour
  29829. * @returns null if behavior was not found else the requested behavior
  29830. */
  29831. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29832. /**
  29833. * Returns the latest update of the World matrix
  29834. * @returns a Matrix
  29835. */
  29836. getWorldMatrix(): Matrix;
  29837. /** @hidden */
  29838. _getWorldMatrixDeterminant(): number;
  29839. /**
  29840. * Returns directly the latest state of the mesh World matrix.
  29841. * A Matrix is returned.
  29842. */
  29843. get worldMatrixFromCache(): Matrix;
  29844. /** @hidden */
  29845. _initCache(): void;
  29846. /** @hidden */
  29847. updateCache(force?: boolean): void;
  29848. /** @hidden */
  29849. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29850. /** @hidden */
  29851. _updateCache(ignoreParentClass?: boolean): void;
  29852. /** @hidden */
  29853. _isSynchronized(): boolean;
  29854. /** @hidden */
  29855. _markSyncedWithParent(): void;
  29856. /** @hidden */
  29857. isSynchronizedWithParent(): boolean;
  29858. /** @hidden */
  29859. isSynchronized(): boolean;
  29860. /**
  29861. * Is this node ready to be used/rendered
  29862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29863. * @return true if the node is ready
  29864. */
  29865. isReady(completeCheck?: boolean): boolean;
  29866. /**
  29867. * Is this node enabled?
  29868. * 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
  29869. * @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
  29870. * @return whether this node (and its parent) is enabled
  29871. */
  29872. isEnabled(checkAncestors?: boolean): boolean;
  29873. /** @hidden */
  29874. protected _syncParentEnabledState(): void;
  29875. /**
  29876. * Set the enabled state of this node
  29877. * @param value defines the new enabled state
  29878. */
  29879. setEnabled(value: boolean): void;
  29880. /**
  29881. * Is this node a descendant of the given node?
  29882. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29883. * @param ancestor defines the parent node to inspect
  29884. * @returns a boolean indicating if this node is a descendant of the given node
  29885. */
  29886. isDescendantOf(ancestor: Node): boolean;
  29887. /** @hidden */
  29888. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29889. /**
  29890. * Will return all nodes that have this node as ascendant
  29891. * @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
  29892. * @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
  29893. * @return all children nodes of all types
  29894. */
  29895. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29896. /**
  29897. * Get all child-meshes of this node
  29898. * @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)
  29899. * @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
  29900. * @returns an array of AbstractMesh
  29901. */
  29902. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29903. /**
  29904. * Get all direct children of this node
  29905. * @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
  29906. * @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)
  29907. * @returns an array of Node
  29908. */
  29909. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29910. /** @hidden */
  29911. _setReady(state: boolean): void;
  29912. /**
  29913. * Get an animation by name
  29914. * @param name defines the name of the animation to look for
  29915. * @returns null if not found else the requested animation
  29916. */
  29917. getAnimationByName(name: string): Nullable<Animation>;
  29918. /**
  29919. * Creates an animation range for this node
  29920. * @param name defines the name of the range
  29921. * @param from defines the starting key
  29922. * @param to defines the end key
  29923. */
  29924. createAnimationRange(name: string, from: number, to: number): void;
  29925. /**
  29926. * Delete a specific animation range
  29927. * @param name defines the name of the range to delete
  29928. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29929. */
  29930. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29931. /**
  29932. * Get an animation range by name
  29933. * @param name defines the name of the animation range to look for
  29934. * @returns null if not found else the requested animation range
  29935. */
  29936. getAnimationRange(name: string): Nullable<AnimationRange>;
  29937. /**
  29938. * Gets the list of all animation ranges defined on this node
  29939. * @returns an array
  29940. */
  29941. getAnimationRanges(): Nullable<AnimationRange>[];
  29942. /**
  29943. * Will start the animation sequence
  29944. * @param name defines the range frames for animation sequence
  29945. * @param loop defines if the animation should loop (false by default)
  29946. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29947. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29948. * @returns the object created for this animation. If range does not exist, it will return null
  29949. */
  29950. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29951. /**
  29952. * Serialize animation ranges into a JSON compatible object
  29953. * @returns serialization object
  29954. */
  29955. serializeAnimationRanges(): any;
  29956. /**
  29957. * Computes the world matrix of the node
  29958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29959. * @returns the world matrix
  29960. */
  29961. computeWorldMatrix(force?: boolean): Matrix;
  29962. /**
  29963. * Releases resources associated with this node.
  29964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29966. */
  29967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29968. /**
  29969. * Parse animation range data from a serialization object and store them into a given node
  29970. * @param node defines where to store the animation ranges
  29971. * @param parsedNode defines the serialization object to read data from
  29972. * @param scene defines the hosting scene
  29973. */
  29974. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29975. /**
  29976. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29977. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29978. * @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
  29979. * @returns the new bounding vectors
  29980. */
  29981. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29982. min: Vector3;
  29983. max: Vector3;
  29984. };
  29985. }
  29986. }
  29987. declare module "babylonjs/Animations/animation" {
  29988. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29989. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29990. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29991. import { Nullable } from "babylonjs/types";
  29992. import { Scene } from "babylonjs/scene";
  29993. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29994. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29995. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29996. import { Node } from "babylonjs/node";
  29997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29998. import { Size } from "babylonjs/Maths/math.size";
  29999. import { Animatable } from "babylonjs/Animations/animatable";
  30000. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30001. /**
  30002. * @hidden
  30003. */
  30004. export class _IAnimationState {
  30005. key: number;
  30006. repeatCount: number;
  30007. workValue?: any;
  30008. loopMode?: number;
  30009. offsetValue?: any;
  30010. highLimitValue?: any;
  30011. }
  30012. /**
  30013. * Class used to store any kind of animation
  30014. */
  30015. export class Animation {
  30016. /**Name of the animation */
  30017. name: string;
  30018. /**Property to animate */
  30019. targetProperty: string;
  30020. /**The frames per second of the animation */
  30021. framePerSecond: number;
  30022. /**The data type of the animation */
  30023. dataType: number;
  30024. /**The loop mode of the animation */
  30025. loopMode?: number | undefined;
  30026. /**Specifies if blending should be enabled */
  30027. enableBlending?: boolean | undefined;
  30028. /**
  30029. * Use matrix interpolation instead of using direct key value when animating matrices
  30030. */
  30031. static AllowMatricesInterpolation: boolean;
  30032. /**
  30033. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30034. */
  30035. static AllowMatrixDecomposeForInterpolation: boolean;
  30036. /**
  30037. * Stores the key frames of the animation
  30038. */
  30039. private _keys;
  30040. /**
  30041. * Stores the easing function of the animation
  30042. */
  30043. private _easingFunction;
  30044. /**
  30045. * @hidden Internal use only
  30046. */
  30047. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30048. /**
  30049. * The set of event that will be linked to this animation
  30050. */
  30051. private _events;
  30052. /**
  30053. * Stores an array of target property paths
  30054. */
  30055. targetPropertyPath: string[];
  30056. /**
  30057. * Stores the blending speed of the animation
  30058. */
  30059. blendingSpeed: number;
  30060. /**
  30061. * Stores the animation ranges for the animation
  30062. */
  30063. private _ranges;
  30064. /**
  30065. * @hidden Internal use
  30066. */
  30067. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30068. /**
  30069. * Sets up an animation
  30070. * @param property The property to animate
  30071. * @param animationType The animation type to apply
  30072. * @param framePerSecond The frames per second of the animation
  30073. * @param easingFunction The easing function used in the animation
  30074. * @returns The created animation
  30075. */
  30076. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30077. /**
  30078. * Create and start an animation on a node
  30079. * @param name defines the name of the global animation that will be run on all nodes
  30080. * @param node defines the root node where the animation will take place
  30081. * @param targetProperty defines property to animate
  30082. * @param framePerSecond defines the number of frame per second yo use
  30083. * @param totalFrame defines the number of frames in total
  30084. * @param from defines the initial value
  30085. * @param to defines the final value
  30086. * @param loopMode defines which loop mode you want to use (off by default)
  30087. * @param easingFunction defines the easing function to use (linear by default)
  30088. * @param onAnimationEnd defines the callback to call when animation end
  30089. * @returns the animatable created for this animation
  30090. */
  30091. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30092. /**
  30093. * Create and start an animation on a node and its descendants
  30094. * @param name defines the name of the global animation that will be run on all nodes
  30095. * @param node defines the root node where the animation will take place
  30096. * @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
  30097. * @param targetProperty defines property to animate
  30098. * @param framePerSecond defines the number of frame per second to use
  30099. * @param totalFrame defines the number of frames in total
  30100. * @param from defines the initial value
  30101. * @param to defines the final value
  30102. * @param loopMode defines which loop mode you want to use (off by default)
  30103. * @param easingFunction defines the easing function to use (linear by default)
  30104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30105. * @returns the list of animatables created for all nodes
  30106. * @example https://www.babylonjs-playground.com/#MH0VLI
  30107. */
  30108. 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[]>;
  30109. /**
  30110. * Creates a new animation, merges it with the existing animations and starts it
  30111. * @param name Name of the animation
  30112. * @param node Node which contains the scene that begins the animations
  30113. * @param targetProperty Specifies which property to animate
  30114. * @param framePerSecond The frames per second of the animation
  30115. * @param totalFrame The total number of frames
  30116. * @param from The frame at the beginning of the animation
  30117. * @param to The frame at the end of the animation
  30118. * @param loopMode Specifies the loop mode of the animation
  30119. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30120. * @param onAnimationEnd Callback to run once the animation is complete
  30121. * @returns Nullable animation
  30122. */
  30123. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30124. /**
  30125. * Transition property of an host to the target Value
  30126. * @param property The property to transition
  30127. * @param targetValue The target Value of the property
  30128. * @param host The object where the property to animate belongs
  30129. * @param scene Scene used to run the animation
  30130. * @param frameRate Framerate (in frame/s) to use
  30131. * @param transition The transition type we want to use
  30132. * @param duration The duration of the animation, in milliseconds
  30133. * @param onAnimationEnd Callback trigger at the end of the animation
  30134. * @returns Nullable animation
  30135. */
  30136. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30137. /**
  30138. * Return the array of runtime animations currently using this animation
  30139. */
  30140. get runtimeAnimations(): RuntimeAnimation[];
  30141. /**
  30142. * Specifies if any of the runtime animations are currently running
  30143. */
  30144. get hasRunningRuntimeAnimations(): boolean;
  30145. /**
  30146. * Initializes the animation
  30147. * @param name Name of the animation
  30148. * @param targetProperty Property to animate
  30149. * @param framePerSecond The frames per second of the animation
  30150. * @param dataType The data type of the animation
  30151. * @param loopMode The loop mode of the animation
  30152. * @param enableBlending Specifies if blending should be enabled
  30153. */
  30154. constructor(
  30155. /**Name of the animation */
  30156. name: string,
  30157. /**Property to animate */
  30158. targetProperty: string,
  30159. /**The frames per second of the animation */
  30160. framePerSecond: number,
  30161. /**The data type of the animation */
  30162. dataType: number,
  30163. /**The loop mode of the animation */
  30164. loopMode?: number | undefined,
  30165. /**Specifies if blending should be enabled */
  30166. enableBlending?: boolean | undefined);
  30167. /**
  30168. * Converts the animation to a string
  30169. * @param fullDetails support for multiple levels of logging within scene loading
  30170. * @returns String form of the animation
  30171. */
  30172. toString(fullDetails?: boolean): string;
  30173. /**
  30174. * Add an event to this animation
  30175. * @param event Event to add
  30176. */
  30177. addEvent(event: AnimationEvent): void;
  30178. /**
  30179. * Remove all events found at the given frame
  30180. * @param frame The frame to remove events from
  30181. */
  30182. removeEvents(frame: number): void;
  30183. /**
  30184. * Retrieves all the events from the animation
  30185. * @returns Events from the animation
  30186. */
  30187. getEvents(): AnimationEvent[];
  30188. /**
  30189. * Creates an animation range
  30190. * @param name Name of the animation range
  30191. * @param from Starting frame of the animation range
  30192. * @param to Ending frame of the animation
  30193. */
  30194. createRange(name: string, from: number, to: number): void;
  30195. /**
  30196. * Deletes an animation range by name
  30197. * @param name Name of the animation range to delete
  30198. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30199. */
  30200. deleteRange(name: string, deleteFrames?: boolean): void;
  30201. /**
  30202. * Gets the animation range by name, or null if not defined
  30203. * @param name Name of the animation range
  30204. * @returns Nullable animation range
  30205. */
  30206. getRange(name: string): Nullable<AnimationRange>;
  30207. /**
  30208. * Gets the key frames from the animation
  30209. * @returns The key frames of the animation
  30210. */
  30211. getKeys(): Array<IAnimationKey>;
  30212. /**
  30213. * Gets the highest frame rate of the animation
  30214. * @returns Highest frame rate of the animation
  30215. */
  30216. getHighestFrame(): number;
  30217. /**
  30218. * Gets the easing function of the animation
  30219. * @returns Easing function of the animation
  30220. */
  30221. getEasingFunction(): IEasingFunction;
  30222. /**
  30223. * Sets the easing function of the animation
  30224. * @param easingFunction A custom mathematical formula for animation
  30225. */
  30226. setEasingFunction(easingFunction: EasingFunction): void;
  30227. /**
  30228. * Interpolates a scalar linearly
  30229. * @param startValue Start value of the animation curve
  30230. * @param endValue End value of the animation curve
  30231. * @param gradient Scalar amount to interpolate
  30232. * @returns Interpolated scalar value
  30233. */
  30234. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30235. /**
  30236. * Interpolates a scalar cubically
  30237. * @param startValue Start value of the animation curve
  30238. * @param outTangent End tangent of the animation
  30239. * @param endValue End value of the animation curve
  30240. * @param inTangent Start tangent of the animation curve
  30241. * @param gradient Scalar amount to interpolate
  30242. * @returns Interpolated scalar value
  30243. */
  30244. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30245. /**
  30246. * Interpolates a quaternion using a spherical linear interpolation
  30247. * @param startValue Start value of the animation curve
  30248. * @param endValue End value of the animation curve
  30249. * @param gradient Scalar amount to interpolate
  30250. * @returns Interpolated quaternion value
  30251. */
  30252. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30253. /**
  30254. * Interpolates a quaternion cubically
  30255. * @param startValue Start value of the animation curve
  30256. * @param outTangent End tangent of the animation curve
  30257. * @param endValue End value of the animation curve
  30258. * @param inTangent Start tangent of the animation curve
  30259. * @param gradient Scalar amount to interpolate
  30260. * @returns Interpolated quaternion value
  30261. */
  30262. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30263. /**
  30264. * Interpolates a Vector3 linearl
  30265. * @param startValue Start value of the animation curve
  30266. * @param endValue End value of the animation curve
  30267. * @param gradient Scalar amount to interpolate
  30268. * @returns Interpolated scalar value
  30269. */
  30270. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30271. /**
  30272. * Interpolates a Vector3 cubically
  30273. * @param startValue Start value of the animation curve
  30274. * @param outTangent End tangent of the animation
  30275. * @param endValue End value of the animation curve
  30276. * @param inTangent Start tangent of the animation curve
  30277. * @param gradient Scalar amount to interpolate
  30278. * @returns InterpolatedVector3 value
  30279. */
  30280. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30281. /**
  30282. * Interpolates a Vector2 linearly
  30283. * @param startValue Start value of the animation curve
  30284. * @param endValue End value of the animation curve
  30285. * @param gradient Scalar amount to interpolate
  30286. * @returns Interpolated Vector2 value
  30287. */
  30288. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30289. /**
  30290. * Interpolates a Vector2 cubically
  30291. * @param startValue Start value of the animation curve
  30292. * @param outTangent End tangent of the animation
  30293. * @param endValue End value of the animation curve
  30294. * @param inTangent Start tangent of the animation curve
  30295. * @param gradient Scalar amount to interpolate
  30296. * @returns Interpolated Vector2 value
  30297. */
  30298. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30299. /**
  30300. * Interpolates a size linearly
  30301. * @param startValue Start value of the animation curve
  30302. * @param endValue End value of the animation curve
  30303. * @param gradient Scalar amount to interpolate
  30304. * @returns Interpolated Size value
  30305. */
  30306. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30307. /**
  30308. * Interpolates a Color3 linearly
  30309. * @param startValue Start value of the animation curve
  30310. * @param endValue End value of the animation curve
  30311. * @param gradient Scalar amount to interpolate
  30312. * @returns Interpolated Color3 value
  30313. */
  30314. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30315. /**
  30316. * Interpolates a Color4 linearly
  30317. * @param startValue Start value of the animation curve
  30318. * @param endValue End value of the animation curve
  30319. * @param gradient Scalar amount to interpolate
  30320. * @returns Interpolated Color3 value
  30321. */
  30322. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30323. /**
  30324. * @hidden Internal use only
  30325. */
  30326. _getKeyValue(value: any): any;
  30327. /**
  30328. * @hidden Internal use only
  30329. */
  30330. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30331. /**
  30332. * Defines the function to use to interpolate matrices
  30333. * @param startValue defines the start matrix
  30334. * @param endValue defines the end matrix
  30335. * @param gradient defines the gradient between both matrices
  30336. * @param result defines an optional target matrix where to store the interpolation
  30337. * @returns the interpolated matrix
  30338. */
  30339. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30340. /**
  30341. * Makes a copy of the animation
  30342. * @returns Cloned animation
  30343. */
  30344. clone(): Animation;
  30345. /**
  30346. * Sets the key frames of the animation
  30347. * @param values The animation key frames to set
  30348. */
  30349. setKeys(values: Array<IAnimationKey>): void;
  30350. /**
  30351. * Serializes the animation to an object
  30352. * @returns Serialized object
  30353. */
  30354. serialize(): any;
  30355. /**
  30356. * Float animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_FLOAT: number;
  30359. /**
  30360. * Vector3 animation type
  30361. */
  30362. static readonly ANIMATIONTYPE_VECTOR3: number;
  30363. /**
  30364. * Quaternion animation type
  30365. */
  30366. static readonly ANIMATIONTYPE_QUATERNION: number;
  30367. /**
  30368. * Matrix animation type
  30369. */
  30370. static readonly ANIMATIONTYPE_MATRIX: number;
  30371. /**
  30372. * Color3 animation type
  30373. */
  30374. static readonly ANIMATIONTYPE_COLOR3: number;
  30375. /**
  30376. * Color3 animation type
  30377. */
  30378. static readonly ANIMATIONTYPE_COLOR4: number;
  30379. /**
  30380. * Vector2 animation type
  30381. */
  30382. static readonly ANIMATIONTYPE_VECTOR2: number;
  30383. /**
  30384. * Size animation type
  30385. */
  30386. static readonly ANIMATIONTYPE_SIZE: number;
  30387. /**
  30388. * Relative Loop Mode
  30389. */
  30390. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30391. /**
  30392. * Cycle Loop Mode
  30393. */
  30394. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30395. /**
  30396. * Constant Loop Mode
  30397. */
  30398. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30399. /** @hidden */
  30400. static _UniversalLerp(left: any, right: any, amount: number): any;
  30401. /**
  30402. * Parses an animation object and creates an animation
  30403. * @param parsedAnimation Parsed animation object
  30404. * @returns Animation object
  30405. */
  30406. static Parse(parsedAnimation: any): Animation;
  30407. /**
  30408. * Appends the serialized animations from the source animations
  30409. * @param source Source containing the animations
  30410. * @param destination Target to store the animations
  30411. */
  30412. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30413. }
  30414. }
  30415. declare module "babylonjs/Animations/animatable.interface" {
  30416. import { Nullable } from "babylonjs/types";
  30417. import { Animation } from "babylonjs/Animations/animation";
  30418. /**
  30419. * Interface containing an array of animations
  30420. */
  30421. export interface IAnimatable {
  30422. /**
  30423. * Array of animations
  30424. */
  30425. animations: Nullable<Array<Animation>>;
  30426. }
  30427. }
  30428. declare module "babylonjs/Misc/decorators" {
  30429. import { Nullable } from "babylonjs/types";
  30430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30431. import { Scene } from "babylonjs/scene";
  30432. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30433. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30434. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30435. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30436. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. /**
  30446. * Decorator used to define property that can be serialized as reference to a camera
  30447. * @param sourceName defines the name of the property to decorate
  30448. */
  30449. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30450. /**
  30451. * Class used to help serialization objects
  30452. */
  30453. export class SerializationHelper {
  30454. /** @hidden */
  30455. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30456. /** @hidden */
  30457. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30458. /** @hidden */
  30459. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30460. /** @hidden */
  30461. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30462. /**
  30463. * Appends the serialized animations from the source animations
  30464. * @param source Source containing the animations
  30465. * @param destination Target to store the animations
  30466. */
  30467. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30468. /**
  30469. * Static function used to serialized a specific entity
  30470. * @param entity defines the entity to serialize
  30471. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30472. * @returns a JSON compatible object representing the serialization of the entity
  30473. */
  30474. static Serialize<T>(entity: T, serializationObject?: any): any;
  30475. /**
  30476. * Creates a new entity from a serialization data object
  30477. * @param creationFunction defines a function used to instanciated the new entity
  30478. * @param source defines the source serialization data
  30479. * @param scene defines the hosting scene
  30480. * @param rootUrl defines the root url for resources
  30481. * @returns a new entity
  30482. */
  30483. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30484. /**
  30485. * Clones an object
  30486. * @param creationFunction defines the function used to instanciate the new object
  30487. * @param source defines the source object
  30488. * @returns the cloned object
  30489. */
  30490. static Clone<T>(creationFunction: () => T, source: T): T;
  30491. /**
  30492. * Instanciates a new object based on a source one (some data will be shared between both object)
  30493. * @param creationFunction defines the function used to instanciate the new object
  30494. * @param source defines the source object
  30495. * @returns the new object
  30496. */
  30497. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30498. }
  30499. }
  30500. declare module "babylonjs/Misc/guid" {
  30501. /**
  30502. * Class used to manipulate GUIDs
  30503. */
  30504. export class GUID {
  30505. /**
  30506. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30507. * Be aware Math.random() could cause collisions, but:
  30508. * "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"
  30509. * @returns a pseudo random id
  30510. */
  30511. static RandomId(): string;
  30512. }
  30513. }
  30514. declare module "babylonjs/Materials/Textures/baseTexture" {
  30515. import { Observable } from "babylonjs/Misc/observable";
  30516. import { Nullable } from "babylonjs/types";
  30517. import { Scene } from "babylonjs/scene";
  30518. import { Matrix } from "babylonjs/Maths/math.vector";
  30519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30521. import { ISize } from "babylonjs/Maths/math.size";
  30522. import "babylonjs/Misc/fileTools";
  30523. /**
  30524. * Base class of all the textures in babylon.
  30525. * It groups all the common properties the materials, post process, lights... might need
  30526. * in order to make a correct use of the texture.
  30527. */
  30528. export class BaseTexture implements IAnimatable {
  30529. /**
  30530. * Default anisotropic filtering level for the application.
  30531. * It is set to 4 as a good tradeoff between perf and quality.
  30532. */
  30533. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30534. /**
  30535. * Gets or sets the unique id of the texture
  30536. */
  30537. uniqueId: number;
  30538. /**
  30539. * Define the name of the texture.
  30540. */
  30541. name: string;
  30542. /**
  30543. * Gets or sets an object used to store user defined information.
  30544. */
  30545. metadata: any;
  30546. /**
  30547. * For internal use only. Please do not use.
  30548. */
  30549. reservedDataStore: any;
  30550. private _hasAlpha;
  30551. /**
  30552. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30553. */
  30554. set hasAlpha(value: boolean);
  30555. get hasAlpha(): boolean;
  30556. /**
  30557. * Defines if the alpha value should be determined via the rgb values.
  30558. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30559. */
  30560. getAlphaFromRGB: boolean;
  30561. /**
  30562. * Intensity or strength of the texture.
  30563. * It is commonly used by materials to fine tune the intensity of the texture
  30564. */
  30565. level: number;
  30566. /**
  30567. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30568. * This is part of the texture as textures usually maps to one uv set.
  30569. */
  30570. coordinatesIndex: number;
  30571. private _coordinatesMode;
  30572. /**
  30573. * How a texture is mapped.
  30574. *
  30575. * | Value | Type | Description |
  30576. * | ----- | ----------------------------------- | ----------- |
  30577. * | 0 | EXPLICIT_MODE | |
  30578. * | 1 | SPHERICAL_MODE | |
  30579. * | 2 | PLANAR_MODE | |
  30580. * | 3 | CUBIC_MODE | |
  30581. * | 4 | PROJECTION_MODE | |
  30582. * | 5 | SKYBOX_MODE | |
  30583. * | 6 | INVCUBIC_MODE | |
  30584. * | 7 | EQUIRECTANGULAR_MODE | |
  30585. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30586. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30587. */
  30588. set coordinatesMode(value: number);
  30589. get coordinatesMode(): number;
  30590. /**
  30591. * | Value | Type | Description |
  30592. * | ----- | ------------------ | ----------- |
  30593. * | 0 | CLAMP_ADDRESSMODE | |
  30594. * | 1 | WRAP_ADDRESSMODE | |
  30595. * | 2 | MIRROR_ADDRESSMODE | |
  30596. */
  30597. wrapU: number;
  30598. /**
  30599. * | Value | Type | Description |
  30600. * | ----- | ------------------ | ----------- |
  30601. * | 0 | CLAMP_ADDRESSMODE | |
  30602. * | 1 | WRAP_ADDRESSMODE | |
  30603. * | 2 | MIRROR_ADDRESSMODE | |
  30604. */
  30605. wrapV: number;
  30606. /**
  30607. * | Value | Type | Description |
  30608. * | ----- | ------------------ | ----------- |
  30609. * | 0 | CLAMP_ADDRESSMODE | |
  30610. * | 1 | WRAP_ADDRESSMODE | |
  30611. * | 2 | MIRROR_ADDRESSMODE | |
  30612. */
  30613. wrapR: number;
  30614. /**
  30615. * With compliant hardware and browser (supporting anisotropic filtering)
  30616. * this defines the level of anisotropic filtering in the texture.
  30617. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30618. */
  30619. anisotropicFilteringLevel: number;
  30620. /**
  30621. * Define if the texture is a cube texture or if false a 2d texture.
  30622. */
  30623. get isCube(): boolean;
  30624. set isCube(value: boolean);
  30625. /**
  30626. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30627. */
  30628. get is3D(): boolean;
  30629. set is3D(value: boolean);
  30630. /**
  30631. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30632. */
  30633. get is2DArray(): boolean;
  30634. set is2DArray(value: boolean);
  30635. /**
  30636. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30637. * HDR texture are usually stored in linear space.
  30638. * This only impacts the PBR and Background materials
  30639. */
  30640. gammaSpace: boolean;
  30641. /**
  30642. * Gets or sets whether or not the texture contains RGBD data.
  30643. */
  30644. get isRGBD(): boolean;
  30645. set isRGBD(value: boolean);
  30646. /**
  30647. * Is Z inverted in the texture (useful in a cube texture).
  30648. */
  30649. invertZ: boolean;
  30650. /**
  30651. * Are mip maps generated for this texture or not.
  30652. */
  30653. get noMipmap(): boolean;
  30654. /**
  30655. * @hidden
  30656. */
  30657. lodLevelInAlpha: boolean;
  30658. /**
  30659. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30660. */
  30661. get lodGenerationOffset(): number;
  30662. set lodGenerationOffset(value: number);
  30663. /**
  30664. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30665. */
  30666. get lodGenerationScale(): number;
  30667. set lodGenerationScale(value: number);
  30668. /**
  30669. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30670. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30671. * average roughness values.
  30672. */
  30673. get linearSpecularLOD(): boolean;
  30674. set linearSpecularLOD(value: boolean);
  30675. /**
  30676. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30677. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30678. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30679. */
  30680. get irradianceTexture(): Nullable<BaseTexture>;
  30681. set irradianceTexture(value: Nullable<BaseTexture>);
  30682. /**
  30683. * Define if the texture is a render target.
  30684. */
  30685. isRenderTarget: boolean;
  30686. /**
  30687. * Define the unique id of the texture in the scene.
  30688. */
  30689. get uid(): string;
  30690. /**
  30691. * Return a string representation of the texture.
  30692. * @returns the texture as a string
  30693. */
  30694. toString(): string;
  30695. /**
  30696. * Get the class name of the texture.
  30697. * @returns "BaseTexture"
  30698. */
  30699. getClassName(): string;
  30700. /**
  30701. * Define the list of animation attached to the texture.
  30702. */
  30703. animations: import("babylonjs/Animations/animation").Animation[];
  30704. /**
  30705. * An event triggered when the texture is disposed.
  30706. */
  30707. onDisposeObservable: Observable<BaseTexture>;
  30708. private _onDisposeObserver;
  30709. /**
  30710. * Callback triggered when the texture has been disposed.
  30711. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30712. */
  30713. set onDispose(callback: () => void);
  30714. /**
  30715. * Define the current state of the loading sequence when in delayed load mode.
  30716. */
  30717. delayLoadState: number;
  30718. private _scene;
  30719. /** @hidden */
  30720. _texture: Nullable<InternalTexture>;
  30721. private _uid;
  30722. /**
  30723. * Define if the texture is preventinga material to render or not.
  30724. * If not and the texture is not ready, the engine will use a default black texture instead.
  30725. */
  30726. get isBlocking(): boolean;
  30727. /**
  30728. * Instantiates a new BaseTexture.
  30729. * Base class of all the textures in babylon.
  30730. * It groups all the common properties the materials, post process, lights... might need
  30731. * in order to make a correct use of the texture.
  30732. * @param scene Define the scene the texture blongs to
  30733. */
  30734. constructor(scene: Nullable<Scene>);
  30735. /**
  30736. * Get the scene the texture belongs to.
  30737. * @returns the scene or null if undefined
  30738. */
  30739. getScene(): Nullable<Scene>;
  30740. /**
  30741. * Get the texture transform matrix used to offset tile the texture for istance.
  30742. * @returns the transformation matrix
  30743. */
  30744. getTextureMatrix(): Matrix;
  30745. /**
  30746. * Get the texture reflection matrix used to rotate/transform the reflection.
  30747. * @returns the reflection matrix
  30748. */
  30749. getReflectionTextureMatrix(): Matrix;
  30750. /**
  30751. * Get the underlying lower level texture from Babylon.
  30752. * @returns the insternal texture
  30753. */
  30754. getInternalTexture(): Nullable<InternalTexture>;
  30755. /**
  30756. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30757. * @returns true if ready or not blocking
  30758. */
  30759. isReadyOrNotBlocking(): boolean;
  30760. /**
  30761. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30762. * @returns true if fully ready
  30763. */
  30764. isReady(): boolean;
  30765. private _cachedSize;
  30766. /**
  30767. * Get the size of the texture.
  30768. * @returns the texture size.
  30769. */
  30770. getSize(): ISize;
  30771. /**
  30772. * Get the base size of the texture.
  30773. * It can be different from the size if the texture has been resized for POT for instance
  30774. * @returns the base size
  30775. */
  30776. getBaseSize(): ISize;
  30777. /**
  30778. * Update the sampling mode of the texture.
  30779. * Default is Trilinear mode.
  30780. *
  30781. * | Value | Type | Description |
  30782. * | ----- | ------------------ | ----------- |
  30783. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30784. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30785. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30786. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30787. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30788. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30789. * | 7 | NEAREST_LINEAR | |
  30790. * | 8 | NEAREST_NEAREST | |
  30791. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30792. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30793. * | 11 | LINEAR_LINEAR | |
  30794. * | 12 | LINEAR_NEAREST | |
  30795. *
  30796. * > _mag_: magnification filter (close to the viewer)
  30797. * > _min_: minification filter (far from the viewer)
  30798. * > _mip_: filter used between mip map levels
  30799. *@param samplingMode Define the new sampling mode of the texture
  30800. */
  30801. updateSamplingMode(samplingMode: number): void;
  30802. /**
  30803. * Scales the texture if is `canRescale()`
  30804. * @param ratio the resize factor we want to use to rescale
  30805. */
  30806. scale(ratio: number): void;
  30807. /**
  30808. * Get if the texture can rescale.
  30809. */
  30810. get canRescale(): boolean;
  30811. /** @hidden */
  30812. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30813. /** @hidden */
  30814. _rebuild(): void;
  30815. /**
  30816. * Triggers the load sequence in delayed load mode.
  30817. */
  30818. delayLoad(): void;
  30819. /**
  30820. * Clones the texture.
  30821. * @returns the cloned texture
  30822. */
  30823. clone(): Nullable<BaseTexture>;
  30824. /**
  30825. * Get the texture underlying type (INT, FLOAT...)
  30826. */
  30827. get textureType(): number;
  30828. /**
  30829. * Get the texture underlying format (RGB, RGBA...)
  30830. */
  30831. get textureFormat(): number;
  30832. /**
  30833. * Indicates that textures need to be re-calculated for all materials
  30834. */
  30835. protected _markAllSubMeshesAsTexturesDirty(): void;
  30836. /**
  30837. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30838. * This will returns an RGBA array buffer containing either in values (0-255) or
  30839. * float values (0-1) depending of the underlying buffer type.
  30840. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30841. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30842. * @param buffer defines a user defined buffer to fill with data (can be null)
  30843. * @returns The Array buffer containing the pixels data.
  30844. */
  30845. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30846. /**
  30847. * Release and destroy the underlying lower level texture aka internalTexture.
  30848. */
  30849. releaseInternalTexture(): void;
  30850. /** @hidden */
  30851. get _lodTextureHigh(): Nullable<BaseTexture>;
  30852. /** @hidden */
  30853. get _lodTextureMid(): Nullable<BaseTexture>;
  30854. /** @hidden */
  30855. get _lodTextureLow(): Nullable<BaseTexture>;
  30856. /**
  30857. * Dispose the texture and release its associated resources.
  30858. */
  30859. dispose(): void;
  30860. /**
  30861. * Serialize the texture into a JSON representation that can be parsed later on.
  30862. * @returns the JSON representation of the texture
  30863. */
  30864. serialize(): any;
  30865. /**
  30866. * Helper function to be called back once a list of texture contains only ready textures.
  30867. * @param textures Define the list of textures to wait for
  30868. * @param callback Define the callback triggered once the entire list will be ready
  30869. */
  30870. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30871. }
  30872. }
  30873. declare module "babylonjs/Materials/effect" {
  30874. import { Observable } from "babylonjs/Misc/observable";
  30875. import { Nullable } from "babylonjs/types";
  30876. import { IDisposable } from "babylonjs/scene";
  30877. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30879. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30881. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30882. import { Engine } from "babylonjs/Engines/engine";
  30883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30887. /**
  30888. * Options to be used when creating an effect.
  30889. */
  30890. export interface IEffectCreationOptions {
  30891. /**
  30892. * Atrributes that will be used in the shader.
  30893. */
  30894. attributes: string[];
  30895. /**
  30896. * Uniform varible names that will be set in the shader.
  30897. */
  30898. uniformsNames: string[];
  30899. /**
  30900. * Uniform buffer variable names that will be set in the shader.
  30901. */
  30902. uniformBuffersNames: string[];
  30903. /**
  30904. * Sampler texture variable names that will be set in the shader.
  30905. */
  30906. samplers: string[];
  30907. /**
  30908. * Define statements that will be set in the shader.
  30909. */
  30910. defines: any;
  30911. /**
  30912. * Possible fallbacks for this effect to improve performance when needed.
  30913. */
  30914. fallbacks: Nullable<IEffectFallbacks>;
  30915. /**
  30916. * Callback that will be called when the shader is compiled.
  30917. */
  30918. onCompiled: Nullable<(effect: Effect) => void>;
  30919. /**
  30920. * Callback that will be called if an error occurs during shader compilation.
  30921. */
  30922. onError: Nullable<(effect: Effect, errors: string) => void>;
  30923. /**
  30924. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30925. */
  30926. indexParameters?: any;
  30927. /**
  30928. * Max number of lights that can be used in the shader.
  30929. */
  30930. maxSimultaneousLights?: number;
  30931. /**
  30932. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30933. */
  30934. transformFeedbackVaryings?: Nullable<string[]>;
  30935. }
  30936. /**
  30937. * Effect containing vertex and fragment shader that can be executed on an object.
  30938. */
  30939. export class Effect implements IDisposable {
  30940. /**
  30941. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30942. */
  30943. static ShadersRepository: string;
  30944. /**
  30945. * Name of the effect.
  30946. */
  30947. name: any;
  30948. /**
  30949. * String container all the define statements that should be set on the shader.
  30950. */
  30951. defines: string;
  30952. /**
  30953. * Callback that will be called when the shader is compiled.
  30954. */
  30955. onCompiled: Nullable<(effect: Effect) => void>;
  30956. /**
  30957. * Callback that will be called if an error occurs during shader compilation.
  30958. */
  30959. onError: Nullable<(effect: Effect, errors: string) => void>;
  30960. /**
  30961. * Callback that will be called when effect is bound.
  30962. */
  30963. onBind: Nullable<(effect: Effect) => void>;
  30964. /**
  30965. * Unique ID of the effect.
  30966. */
  30967. uniqueId: number;
  30968. /**
  30969. * Observable that will be called when the shader is compiled.
  30970. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30971. */
  30972. onCompileObservable: Observable<Effect>;
  30973. /**
  30974. * Observable that will be called if an error occurs during shader compilation.
  30975. */
  30976. onErrorObservable: Observable<Effect>;
  30977. /** @hidden */
  30978. _onBindObservable: Nullable<Observable<Effect>>;
  30979. /**
  30980. * @hidden
  30981. * Specifies if the effect was previously ready
  30982. */
  30983. _wasPreviouslyReady: boolean;
  30984. /**
  30985. * Observable that will be called when effect is bound.
  30986. */
  30987. get onBindObservable(): Observable<Effect>;
  30988. /** @hidden */
  30989. _bonesComputationForcedToCPU: boolean;
  30990. private static _uniqueIdSeed;
  30991. private _engine;
  30992. private _uniformBuffersNames;
  30993. private _uniformsNames;
  30994. private _samplerList;
  30995. private _samplers;
  30996. private _isReady;
  30997. private _compilationError;
  30998. private _allFallbacksProcessed;
  30999. private _attributesNames;
  31000. private _attributes;
  31001. private _attributeLocationByName;
  31002. private _uniforms;
  31003. /**
  31004. * Key for the effect.
  31005. * @hidden
  31006. */
  31007. _key: string;
  31008. private _indexParameters;
  31009. private _fallbacks;
  31010. private _vertexSourceCode;
  31011. private _fragmentSourceCode;
  31012. private _vertexSourceCodeOverride;
  31013. private _fragmentSourceCodeOverride;
  31014. private _transformFeedbackVaryings;
  31015. /**
  31016. * Compiled shader to webGL program.
  31017. * @hidden
  31018. */
  31019. _pipelineContext: Nullable<IPipelineContext>;
  31020. private _valueCache;
  31021. private static _baseCache;
  31022. /**
  31023. * Instantiates an effect.
  31024. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31025. * @param baseName Name of the effect.
  31026. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31027. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31028. * @param samplers List of sampler variables that will be passed to the shader.
  31029. * @param engine Engine to be used to render the effect
  31030. * @param defines Define statements to be added to the shader.
  31031. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31032. * @param onCompiled Callback that will be called when the shader is compiled.
  31033. * @param onError Callback that will be called if an error occurs during shader compilation.
  31034. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31035. */
  31036. 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);
  31037. private _useFinalCode;
  31038. /**
  31039. * Unique key for this effect
  31040. */
  31041. get key(): string;
  31042. /**
  31043. * If the effect has been compiled and prepared.
  31044. * @returns if the effect is compiled and prepared.
  31045. */
  31046. isReady(): boolean;
  31047. private _isReadyInternal;
  31048. /**
  31049. * The engine the effect was initialized with.
  31050. * @returns the engine.
  31051. */
  31052. getEngine(): Engine;
  31053. /**
  31054. * The pipeline context for this effect
  31055. * @returns the associated pipeline context
  31056. */
  31057. getPipelineContext(): Nullable<IPipelineContext>;
  31058. /**
  31059. * The set of names of attribute variables for the shader.
  31060. * @returns An array of attribute names.
  31061. */
  31062. getAttributesNames(): string[];
  31063. /**
  31064. * Returns the attribute at the given index.
  31065. * @param index The index of the attribute.
  31066. * @returns The location of the attribute.
  31067. */
  31068. getAttributeLocation(index: number): number;
  31069. /**
  31070. * Returns the attribute based on the name of the variable.
  31071. * @param name of the attribute to look up.
  31072. * @returns the attribute location.
  31073. */
  31074. getAttributeLocationByName(name: string): number;
  31075. /**
  31076. * The number of attributes.
  31077. * @returns the numnber of attributes.
  31078. */
  31079. getAttributesCount(): number;
  31080. /**
  31081. * Gets the index of a uniform variable.
  31082. * @param uniformName of the uniform to look up.
  31083. * @returns the index.
  31084. */
  31085. getUniformIndex(uniformName: string): number;
  31086. /**
  31087. * Returns the attribute based on the name of the variable.
  31088. * @param uniformName of the uniform to look up.
  31089. * @returns the location of the uniform.
  31090. */
  31091. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31092. /**
  31093. * Returns an array of sampler variable names
  31094. * @returns The array of sampler variable neames.
  31095. */
  31096. getSamplers(): string[];
  31097. /**
  31098. * The error from the last compilation.
  31099. * @returns the error string.
  31100. */
  31101. getCompilationError(): string;
  31102. /**
  31103. * Gets a boolean indicating that all fallbacks were used during compilation
  31104. * @returns true if all fallbacks were used
  31105. */
  31106. allFallbacksProcessed(): boolean;
  31107. /**
  31108. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31109. * @param func The callback to be used.
  31110. */
  31111. executeWhenCompiled(func: (effect: Effect) => void): void;
  31112. private _checkIsReady;
  31113. private _loadShader;
  31114. /**
  31115. * Recompiles the webGL program
  31116. * @param vertexSourceCode The source code for the vertex shader.
  31117. * @param fragmentSourceCode The source code for the fragment shader.
  31118. * @param onCompiled Callback called when completed.
  31119. * @param onError Callback called on error.
  31120. * @hidden
  31121. */
  31122. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31123. /**
  31124. * Prepares the effect
  31125. * @hidden
  31126. */
  31127. _prepareEffect(): void;
  31128. private _processCompilationErrors;
  31129. /**
  31130. * Checks if the effect is supported. (Must be called after compilation)
  31131. */
  31132. get isSupported(): boolean;
  31133. /**
  31134. * Binds a texture to the engine to be used as output of the shader.
  31135. * @param channel Name of the output variable.
  31136. * @param texture Texture to bind.
  31137. * @hidden
  31138. */
  31139. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31140. /**
  31141. * Sets a texture on the engine to be used in the shader.
  31142. * @param channel Name of the sampler variable.
  31143. * @param texture Texture to set.
  31144. */
  31145. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31146. /**
  31147. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31148. * @param channel Name of the sampler variable.
  31149. * @param texture Texture to set.
  31150. */
  31151. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31152. /**
  31153. * Sets an array of textures on the engine to be used in the shader.
  31154. * @param channel Name of the variable.
  31155. * @param textures Textures to set.
  31156. */
  31157. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31158. /**
  31159. * 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)
  31160. * @param channel Name of the sampler variable.
  31161. * @param postProcess Post process to get the input texture from.
  31162. */
  31163. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31164. /**
  31165. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31166. * 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)
  31167. * @param channel Name of the sampler variable.
  31168. * @param postProcess Post process to get the output texture from.
  31169. */
  31170. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31171. /** @hidden */
  31172. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31173. /** @hidden */
  31174. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31175. /** @hidden */
  31176. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31177. /** @hidden */
  31178. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31179. /**
  31180. * Binds a buffer to a uniform.
  31181. * @param buffer Buffer to bind.
  31182. * @param name Name of the uniform variable to bind to.
  31183. */
  31184. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31185. /**
  31186. * Binds block to a uniform.
  31187. * @param blockName Name of the block to bind.
  31188. * @param index Index to bind.
  31189. */
  31190. bindUniformBlock(blockName: string, index: number): void;
  31191. /**
  31192. * Sets an interger value on a uniform variable.
  31193. * @param uniformName Name of the variable.
  31194. * @param value Value to be set.
  31195. * @returns this effect.
  31196. */
  31197. setInt(uniformName: string, value: number): Effect;
  31198. /**
  31199. * Sets an int array on a uniform variable.
  31200. * @param uniformName Name of the variable.
  31201. * @param array array to be set.
  31202. * @returns this effect.
  31203. */
  31204. setIntArray(uniformName: string, array: Int32Array): Effect;
  31205. /**
  31206. * 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)
  31207. * @param uniformName Name of the variable.
  31208. * @param array array to be set.
  31209. * @returns this effect.
  31210. */
  31211. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31212. /**
  31213. * 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)
  31214. * @param uniformName Name of the variable.
  31215. * @param array array to be set.
  31216. * @returns this effect.
  31217. */
  31218. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31219. /**
  31220. * 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)
  31221. * @param uniformName Name of the variable.
  31222. * @param array array to be set.
  31223. * @returns this effect.
  31224. */
  31225. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31226. /**
  31227. * Sets an float array on a uniform variable.
  31228. * @param uniformName Name of the variable.
  31229. * @param array array to be set.
  31230. * @returns this effect.
  31231. */
  31232. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31233. /**
  31234. * 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)
  31235. * @param uniformName Name of the variable.
  31236. * @param array array to be set.
  31237. * @returns this effect.
  31238. */
  31239. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31240. /**
  31241. * 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)
  31242. * @param uniformName Name of the variable.
  31243. * @param array array to be set.
  31244. * @returns this effect.
  31245. */
  31246. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31247. /**
  31248. * 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)
  31249. * @param uniformName Name of the variable.
  31250. * @param array array to be set.
  31251. * @returns this effect.
  31252. */
  31253. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31254. /**
  31255. * Sets an array on a uniform variable.
  31256. * @param uniformName Name of the variable.
  31257. * @param array array to be set.
  31258. * @returns this effect.
  31259. */
  31260. setArray(uniformName: string, array: number[]): Effect;
  31261. /**
  31262. * 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)
  31263. * @param uniformName Name of the variable.
  31264. * @param array array to be set.
  31265. * @returns this effect.
  31266. */
  31267. setArray2(uniformName: string, array: number[]): Effect;
  31268. /**
  31269. * 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)
  31270. * @param uniformName Name of the variable.
  31271. * @param array array to be set.
  31272. * @returns this effect.
  31273. */
  31274. setArray3(uniformName: string, array: number[]): Effect;
  31275. /**
  31276. * 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)
  31277. * @param uniformName Name of the variable.
  31278. * @param array array to be set.
  31279. * @returns this effect.
  31280. */
  31281. setArray4(uniformName: string, array: number[]): Effect;
  31282. /**
  31283. * Sets matrices on a uniform variable.
  31284. * @param uniformName Name of the variable.
  31285. * @param matrices matrices to be set.
  31286. * @returns this effect.
  31287. */
  31288. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31289. /**
  31290. * Sets matrix on a uniform variable.
  31291. * @param uniformName Name of the variable.
  31292. * @param matrix matrix to be set.
  31293. * @returns this effect.
  31294. */
  31295. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31296. /**
  31297. * 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)
  31298. * @param uniformName Name of the variable.
  31299. * @param matrix matrix to be set.
  31300. * @returns this effect.
  31301. */
  31302. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31303. /**
  31304. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31305. * @param uniformName Name of the variable.
  31306. * @param matrix matrix to be set.
  31307. * @returns this effect.
  31308. */
  31309. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31310. /**
  31311. * Sets a float on a uniform variable.
  31312. * @param uniformName Name of the variable.
  31313. * @param value value to be set.
  31314. * @returns this effect.
  31315. */
  31316. setFloat(uniformName: string, value: number): Effect;
  31317. /**
  31318. * Sets a boolean on a uniform variable.
  31319. * @param uniformName Name of the variable.
  31320. * @param bool value to be set.
  31321. * @returns this effect.
  31322. */
  31323. setBool(uniformName: string, bool: boolean): Effect;
  31324. /**
  31325. * Sets a Vector2 on a uniform variable.
  31326. * @param uniformName Name of the variable.
  31327. * @param vector2 vector2 to be set.
  31328. * @returns this effect.
  31329. */
  31330. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31331. /**
  31332. * Sets a float2 on a uniform variable.
  31333. * @param uniformName Name of the variable.
  31334. * @param x First float in float2.
  31335. * @param y Second float in float2.
  31336. * @returns this effect.
  31337. */
  31338. setFloat2(uniformName: string, x: number, y: number): Effect;
  31339. /**
  31340. * Sets a Vector3 on a uniform variable.
  31341. * @param uniformName Name of the variable.
  31342. * @param vector3 Value to be set.
  31343. * @returns this effect.
  31344. */
  31345. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31346. /**
  31347. * Sets a float3 on a uniform variable.
  31348. * @param uniformName Name of the variable.
  31349. * @param x First float in float3.
  31350. * @param y Second float in float3.
  31351. * @param z Third float in float3.
  31352. * @returns this effect.
  31353. */
  31354. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31355. /**
  31356. * Sets a Vector4 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param vector4 Value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31362. /**
  31363. * Sets a float4 on a uniform variable.
  31364. * @param uniformName Name of the variable.
  31365. * @param x First float in float4.
  31366. * @param y Second float in float4.
  31367. * @param z Third float in float4.
  31368. * @param w Fourth float in float4.
  31369. * @returns this effect.
  31370. */
  31371. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31372. /**
  31373. * Sets a Color3 on a uniform variable.
  31374. * @param uniformName Name of the variable.
  31375. * @param color3 Value to be set.
  31376. * @returns this effect.
  31377. */
  31378. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31379. /**
  31380. * Sets a Color4 on a uniform variable.
  31381. * @param uniformName Name of the variable.
  31382. * @param color3 Value to be set.
  31383. * @param alpha Alpha value to be set.
  31384. * @returns this effect.
  31385. */
  31386. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31387. /**
  31388. * Sets a Color4 on a uniform variable
  31389. * @param uniformName defines the name of the variable
  31390. * @param color4 defines the value to be set
  31391. * @returns this effect.
  31392. */
  31393. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31394. /** Release all associated resources */
  31395. dispose(): void;
  31396. /**
  31397. * This function will add a new shader to the shader store
  31398. * @param name the name of the shader
  31399. * @param pixelShader optional pixel shader content
  31400. * @param vertexShader optional vertex shader content
  31401. */
  31402. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31403. /**
  31404. * Store of each shader (The can be looked up using effect.key)
  31405. */
  31406. static ShadersStore: {
  31407. [key: string]: string;
  31408. };
  31409. /**
  31410. * Store of each included file for a shader (The can be looked up using effect.key)
  31411. */
  31412. static IncludesShadersStore: {
  31413. [key: string]: string;
  31414. };
  31415. /**
  31416. * Resets the cache of effects.
  31417. */
  31418. static ResetCache(): void;
  31419. }
  31420. }
  31421. declare module "babylonjs/Engines/engineCapabilities" {
  31422. /**
  31423. * Interface used to describe the capabilities of the engine relatively to the current browser
  31424. */
  31425. export interface EngineCapabilities {
  31426. /** Maximum textures units per fragment shader */
  31427. maxTexturesImageUnits: number;
  31428. /** Maximum texture units per vertex shader */
  31429. maxVertexTextureImageUnits: number;
  31430. /** Maximum textures units in the entire pipeline */
  31431. maxCombinedTexturesImageUnits: number;
  31432. /** Maximum texture size */
  31433. maxTextureSize: number;
  31434. /** Maximum texture samples */
  31435. maxSamples?: number;
  31436. /** Maximum cube texture size */
  31437. maxCubemapTextureSize: number;
  31438. /** Maximum render texture size */
  31439. maxRenderTextureSize: number;
  31440. /** Maximum number of vertex attributes */
  31441. maxVertexAttribs: number;
  31442. /** Maximum number of varyings */
  31443. maxVaryingVectors: number;
  31444. /** Maximum number of uniforms per vertex shader */
  31445. maxVertexUniformVectors: number;
  31446. /** Maximum number of uniforms per fragment shader */
  31447. maxFragmentUniformVectors: number;
  31448. /** Defines if standard derivates (dx/dy) are supported */
  31449. standardDerivatives: boolean;
  31450. /** Defines if s3tc texture compression is supported */
  31451. s3tc?: WEBGL_compressed_texture_s3tc;
  31452. /** Defines if pvrtc texture compression is supported */
  31453. pvrtc: any;
  31454. /** Defines if etc1 texture compression is supported */
  31455. etc1: any;
  31456. /** Defines if etc2 texture compression is supported */
  31457. etc2: any;
  31458. /** Defines if astc texture compression is supported */
  31459. astc: any;
  31460. /** Defines if float textures are supported */
  31461. textureFloat: boolean;
  31462. /** Defines if vertex array objects are supported */
  31463. vertexArrayObject: boolean;
  31464. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31465. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31466. /** Gets the maximum level of anisotropy supported */
  31467. maxAnisotropy: number;
  31468. /** Defines if instancing is supported */
  31469. instancedArrays: boolean;
  31470. /** Defines if 32 bits indices are supported */
  31471. uintIndices: boolean;
  31472. /** Defines if high precision shaders are supported */
  31473. highPrecisionShaderSupported: boolean;
  31474. /** Defines if depth reading in the fragment shader is supported */
  31475. fragmentDepthSupported: boolean;
  31476. /** Defines if float texture linear filtering is supported*/
  31477. textureFloatLinearFiltering: boolean;
  31478. /** Defines if rendering to float textures is supported */
  31479. textureFloatRender: boolean;
  31480. /** Defines if half float textures are supported*/
  31481. textureHalfFloat: boolean;
  31482. /** Defines if half float texture linear filtering is supported*/
  31483. textureHalfFloatLinearFiltering: boolean;
  31484. /** Defines if rendering to half float textures is supported */
  31485. textureHalfFloatRender: boolean;
  31486. /** Defines if textureLOD shader command is supported */
  31487. textureLOD: boolean;
  31488. /** Defines if draw buffers extension is supported */
  31489. drawBuffersExtension: boolean;
  31490. /** Defines if depth textures are supported */
  31491. depthTextureExtension: boolean;
  31492. /** Defines if float color buffer are supported */
  31493. colorBufferFloat: boolean;
  31494. /** Gets disjoint timer query extension (null if not supported) */
  31495. timerQuery?: EXT_disjoint_timer_query;
  31496. /** Defines if timestamp can be used with timer query */
  31497. canUseTimestampForTimerQuery: boolean;
  31498. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31499. multiview?: any;
  31500. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31501. oculusMultiview?: any;
  31502. /** Function used to let the system compiles shaders in background */
  31503. parallelShaderCompile?: {
  31504. COMPLETION_STATUS_KHR: number;
  31505. };
  31506. /** Max number of texture samples for MSAA */
  31507. maxMSAASamples: number;
  31508. /** Defines if the blend min max extension is supported */
  31509. blendMinMax: boolean;
  31510. }
  31511. }
  31512. declare module "babylonjs/States/depthCullingState" {
  31513. import { Nullable } from "babylonjs/types";
  31514. /**
  31515. * @hidden
  31516. **/
  31517. export class DepthCullingState {
  31518. private _isDepthTestDirty;
  31519. private _isDepthMaskDirty;
  31520. private _isDepthFuncDirty;
  31521. private _isCullFaceDirty;
  31522. private _isCullDirty;
  31523. private _isZOffsetDirty;
  31524. private _isFrontFaceDirty;
  31525. private _depthTest;
  31526. private _depthMask;
  31527. private _depthFunc;
  31528. private _cull;
  31529. private _cullFace;
  31530. private _zOffset;
  31531. private _frontFace;
  31532. /**
  31533. * Initializes the state.
  31534. */
  31535. constructor();
  31536. get isDirty(): boolean;
  31537. get zOffset(): number;
  31538. set zOffset(value: number);
  31539. get cullFace(): Nullable<number>;
  31540. set cullFace(value: Nullable<number>);
  31541. get cull(): Nullable<boolean>;
  31542. set cull(value: Nullable<boolean>);
  31543. get depthFunc(): Nullable<number>;
  31544. set depthFunc(value: Nullable<number>);
  31545. get depthMask(): boolean;
  31546. set depthMask(value: boolean);
  31547. get depthTest(): boolean;
  31548. set depthTest(value: boolean);
  31549. get frontFace(): Nullable<number>;
  31550. set frontFace(value: Nullable<number>);
  31551. reset(): void;
  31552. apply(gl: WebGLRenderingContext): void;
  31553. }
  31554. }
  31555. declare module "babylonjs/States/stencilState" {
  31556. /**
  31557. * @hidden
  31558. **/
  31559. export class StencilState {
  31560. /** 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 */
  31561. static readonly ALWAYS: number;
  31562. /** Passed to stencilOperation to specify that stencil value must be kept */
  31563. static readonly KEEP: number;
  31564. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31565. static readonly REPLACE: number;
  31566. private _isStencilTestDirty;
  31567. private _isStencilMaskDirty;
  31568. private _isStencilFuncDirty;
  31569. private _isStencilOpDirty;
  31570. private _stencilTest;
  31571. private _stencilMask;
  31572. private _stencilFunc;
  31573. private _stencilFuncRef;
  31574. private _stencilFuncMask;
  31575. private _stencilOpStencilFail;
  31576. private _stencilOpDepthFail;
  31577. private _stencilOpStencilDepthPass;
  31578. get isDirty(): boolean;
  31579. get stencilFunc(): number;
  31580. set stencilFunc(value: number);
  31581. get stencilFuncRef(): number;
  31582. set stencilFuncRef(value: number);
  31583. get stencilFuncMask(): number;
  31584. set stencilFuncMask(value: number);
  31585. get stencilOpStencilFail(): number;
  31586. set stencilOpStencilFail(value: number);
  31587. get stencilOpDepthFail(): number;
  31588. set stencilOpDepthFail(value: number);
  31589. get stencilOpStencilDepthPass(): number;
  31590. set stencilOpStencilDepthPass(value: number);
  31591. get stencilMask(): number;
  31592. set stencilMask(value: number);
  31593. get stencilTest(): boolean;
  31594. set stencilTest(value: boolean);
  31595. constructor();
  31596. reset(): void;
  31597. apply(gl: WebGLRenderingContext): void;
  31598. }
  31599. }
  31600. declare module "babylonjs/States/alphaCullingState" {
  31601. /**
  31602. * @hidden
  31603. **/
  31604. export class AlphaState {
  31605. private _isAlphaBlendDirty;
  31606. private _isBlendFunctionParametersDirty;
  31607. private _isBlendEquationParametersDirty;
  31608. private _isBlendConstantsDirty;
  31609. private _alphaBlend;
  31610. private _blendFunctionParameters;
  31611. private _blendEquationParameters;
  31612. private _blendConstants;
  31613. /**
  31614. * Initializes the state.
  31615. */
  31616. constructor();
  31617. get isDirty(): boolean;
  31618. get alphaBlend(): boolean;
  31619. set alphaBlend(value: boolean);
  31620. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31621. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31622. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31623. reset(): void;
  31624. apply(gl: WebGLRenderingContext): void;
  31625. }
  31626. }
  31627. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31628. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31629. /** @hidden */
  31630. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31631. attributeProcessor(attribute: string): string;
  31632. varyingProcessor(varying: string, isFragment: boolean): string;
  31633. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31634. }
  31635. }
  31636. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31637. /**
  31638. * Interface for attribute information associated with buffer instanciation
  31639. */
  31640. export interface InstancingAttributeInfo {
  31641. /**
  31642. * Name of the GLSL attribute
  31643. * if attribute index is not specified, this is used to retrieve the index from the effect
  31644. */
  31645. attributeName: string;
  31646. /**
  31647. * Index/offset of the attribute in the vertex shader
  31648. * if not specified, this will be computes from the name.
  31649. */
  31650. index?: number;
  31651. /**
  31652. * size of the attribute, 1, 2, 3 or 4
  31653. */
  31654. attributeSize: number;
  31655. /**
  31656. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31657. */
  31658. offset: number;
  31659. /**
  31660. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31661. * default to 1
  31662. */
  31663. divisor?: number;
  31664. /**
  31665. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31666. * default is FLOAT
  31667. */
  31668. attributeType?: number;
  31669. /**
  31670. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31671. */
  31672. normalized?: boolean;
  31673. }
  31674. }
  31675. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31677. import { Nullable } from "babylonjs/types";
  31678. module "babylonjs/Engines/thinEngine" {
  31679. interface ThinEngine {
  31680. /**
  31681. * Update a video texture
  31682. * @param texture defines the texture to update
  31683. * @param video defines the video element to use
  31684. * @param invertY defines if data must be stored with Y axis inverted
  31685. */
  31686. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31687. }
  31688. }
  31689. }
  31690. declare module "babylonjs/Materials/Textures/videoTexture" {
  31691. import { Observable } from "babylonjs/Misc/observable";
  31692. import { Nullable } from "babylonjs/types";
  31693. import { Scene } from "babylonjs/scene";
  31694. import { Texture } from "babylonjs/Materials/Textures/texture";
  31695. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31696. /**
  31697. * Settings for finer control over video usage
  31698. */
  31699. export interface VideoTextureSettings {
  31700. /**
  31701. * Applies `autoplay` to video, if specified
  31702. */
  31703. autoPlay?: boolean;
  31704. /**
  31705. * Applies `loop` to video, if specified
  31706. */
  31707. loop?: boolean;
  31708. /**
  31709. * Automatically updates internal texture from video at every frame in the render loop
  31710. */
  31711. autoUpdateTexture: boolean;
  31712. /**
  31713. * Image src displayed during the video loading or until the user interacts with the video.
  31714. */
  31715. poster?: string;
  31716. }
  31717. /**
  31718. * If you want to display a video in your scene, this is the special texture for that.
  31719. * This special texture works similar to other textures, with the exception of a few parameters.
  31720. * @see https://doc.babylonjs.com/how_to/video_texture
  31721. */
  31722. export class VideoTexture extends Texture {
  31723. /**
  31724. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31725. */
  31726. readonly autoUpdateTexture: boolean;
  31727. /**
  31728. * The video instance used by the texture internally
  31729. */
  31730. readonly video: HTMLVideoElement;
  31731. private _onUserActionRequestedObservable;
  31732. /**
  31733. * Event triggerd when a dom action is required by the user to play the video.
  31734. * This happens due to recent changes in browser policies preventing video to auto start.
  31735. */
  31736. get onUserActionRequestedObservable(): Observable<Texture>;
  31737. private _generateMipMaps;
  31738. private _engine;
  31739. private _stillImageCaptured;
  31740. private _displayingPosterTexture;
  31741. private _settings;
  31742. private _createInternalTextureOnEvent;
  31743. private _frameId;
  31744. private _currentSrc;
  31745. /**
  31746. * Creates a video texture.
  31747. * If you want to display a video in your scene, this is the special texture for that.
  31748. * This special texture works similar to other textures, with the exception of a few parameters.
  31749. * @see https://doc.babylonjs.com/how_to/video_texture
  31750. * @param name optional name, will detect from video source, if not defined
  31751. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31752. * @param scene is obviously the current scene.
  31753. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31754. * @param invertY is false by default but can be used to invert video on Y axis
  31755. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31756. * @param settings allows finer control over video usage
  31757. */
  31758. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31759. private _getName;
  31760. private _getVideo;
  31761. private _createInternalTexture;
  31762. private reset;
  31763. /**
  31764. * @hidden Internal method to initiate `update`.
  31765. */
  31766. _rebuild(): void;
  31767. /**
  31768. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31769. */
  31770. update(): void;
  31771. /**
  31772. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31773. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31774. */
  31775. updateTexture(isVisible: boolean): void;
  31776. protected _updateInternalTexture: () => void;
  31777. /**
  31778. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31779. * @param url New url.
  31780. */
  31781. updateURL(url: string): void;
  31782. /**
  31783. * Clones the texture.
  31784. * @returns the cloned texture
  31785. */
  31786. clone(): VideoTexture;
  31787. /**
  31788. * Dispose the texture and release its associated resources.
  31789. */
  31790. dispose(): void;
  31791. /**
  31792. * Creates a video texture straight from a stream.
  31793. * @param scene Define the scene the texture should be created in
  31794. * @param stream Define the stream the texture should be created from
  31795. * @returns The created video texture as a promise
  31796. */
  31797. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31798. /**
  31799. * Creates a video texture straight from your WebCam video feed.
  31800. * @param scene Define the scene the texture should be created in
  31801. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31802. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31803. * @returns The created video texture as a promise
  31804. */
  31805. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31806. minWidth: number;
  31807. maxWidth: number;
  31808. minHeight: number;
  31809. maxHeight: number;
  31810. deviceId: string;
  31811. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31812. /**
  31813. * Creates a video texture straight from your WebCam video feed.
  31814. * @param scene Define the scene the texture should be created in
  31815. * @param onReady Define a callback to triggered once the texture will be ready
  31816. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31817. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31818. */
  31819. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31820. minWidth: number;
  31821. maxWidth: number;
  31822. minHeight: number;
  31823. maxHeight: number;
  31824. deviceId: string;
  31825. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31826. }
  31827. }
  31828. declare module "babylonjs/Engines/thinEngine" {
  31829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31830. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31831. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31833. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31834. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31835. import { Observable } from "babylonjs/Misc/observable";
  31836. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31837. import { StencilState } from "babylonjs/States/stencilState";
  31838. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31840. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31841. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31843. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31844. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31845. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31846. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31848. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31849. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31850. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31851. import { WebRequest } from "babylonjs/Misc/webRequest";
  31852. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31853. /**
  31854. * Defines the interface used by objects working like Scene
  31855. * @hidden
  31856. */
  31857. export interface ISceneLike {
  31858. _addPendingData(data: any): void;
  31859. _removePendingData(data: any): void;
  31860. offlineProvider: IOfflineProvider;
  31861. }
  31862. /** Interface defining initialization parameters for Engine class */
  31863. export interface EngineOptions extends WebGLContextAttributes {
  31864. /**
  31865. * Defines if the engine should no exceed a specified device ratio
  31866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31867. */
  31868. limitDeviceRatio?: number;
  31869. /**
  31870. * Defines if webvr should be enabled automatically
  31871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31872. */
  31873. autoEnableWebVR?: boolean;
  31874. /**
  31875. * Defines if webgl2 should be turned off even if supported
  31876. * @see http://doc.babylonjs.com/features/webgl2
  31877. */
  31878. disableWebGL2Support?: boolean;
  31879. /**
  31880. * Defines if webaudio should be initialized as well
  31881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31882. */
  31883. audioEngine?: boolean;
  31884. /**
  31885. * Defines if animations should run using a deterministic lock step
  31886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31887. */
  31888. deterministicLockstep?: boolean;
  31889. /** Defines the maximum steps to use with deterministic lock step mode */
  31890. lockstepMaxSteps?: number;
  31891. /** Defines the seconds between each deterministic lock step */
  31892. timeStep?: number;
  31893. /**
  31894. * Defines that engine should ignore context lost events
  31895. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31896. */
  31897. doNotHandleContextLost?: boolean;
  31898. /**
  31899. * Defines that engine should ignore modifying touch action attribute and style
  31900. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31901. */
  31902. doNotHandleTouchAction?: boolean;
  31903. /**
  31904. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31905. */
  31906. useHighPrecisionFloats?: boolean;
  31907. }
  31908. /**
  31909. * The base engine class (root of all engines)
  31910. */
  31911. export class ThinEngine {
  31912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31913. static ExceptionList: ({
  31914. key: string;
  31915. capture: string;
  31916. captureConstraint: number;
  31917. targets: string[];
  31918. } | {
  31919. key: string;
  31920. capture: null;
  31921. captureConstraint: null;
  31922. targets: string[];
  31923. })[];
  31924. /** @hidden */
  31925. static _TextureLoaders: IInternalTextureLoader[];
  31926. /**
  31927. * Returns the current npm package of the sdk
  31928. */
  31929. static get NpmPackage(): string;
  31930. /**
  31931. * Returns the current version of the framework
  31932. */
  31933. static get Version(): string;
  31934. /**
  31935. * Returns a string describing the current engine
  31936. */
  31937. get description(): string;
  31938. /**
  31939. * Gets or sets the epsilon value used by collision engine
  31940. */
  31941. static CollisionsEpsilon: number;
  31942. /**
  31943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31944. */
  31945. static get ShadersRepository(): string;
  31946. static set ShadersRepository(value: string);
  31947. /** @hidden */
  31948. _shaderProcessor: IShaderProcessor;
  31949. /**
  31950. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31951. */
  31952. forcePOTTextures: boolean;
  31953. /**
  31954. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31955. */
  31956. isFullscreen: boolean;
  31957. /**
  31958. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31959. */
  31960. cullBackFaces: boolean;
  31961. /**
  31962. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31963. */
  31964. renderEvenInBackground: boolean;
  31965. /**
  31966. * Gets or sets a boolean indicating that cache can be kept between frames
  31967. */
  31968. preventCacheWipeBetweenFrames: boolean;
  31969. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31970. validateShaderPrograms: boolean;
  31971. /**
  31972. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31973. * This can provide greater z depth for distant objects.
  31974. */
  31975. useReverseDepthBuffer: boolean;
  31976. /**
  31977. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31978. */
  31979. disableUniformBuffers: boolean;
  31980. /** @hidden */
  31981. _uniformBuffers: UniformBuffer[];
  31982. /**
  31983. * Gets a boolean indicating that the engine supports uniform buffers
  31984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31985. */
  31986. get supportsUniformBuffers(): boolean;
  31987. /** @hidden */
  31988. _gl: WebGLRenderingContext;
  31989. /** @hidden */
  31990. _webGLVersion: number;
  31991. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31992. protected _windowIsBackground: boolean;
  31993. protected _creationOptions: EngineOptions;
  31994. protected _highPrecisionShadersAllowed: boolean;
  31995. /** @hidden */
  31996. get _shouldUseHighPrecisionShader(): boolean;
  31997. /**
  31998. * Gets a boolean indicating that only power of 2 textures are supported
  31999. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32000. */
  32001. get needPOTTextures(): boolean;
  32002. /** @hidden */
  32003. _badOS: boolean;
  32004. /** @hidden */
  32005. _badDesktopOS: boolean;
  32006. private _hardwareScalingLevel;
  32007. /** @hidden */
  32008. _caps: EngineCapabilities;
  32009. private _isStencilEnable;
  32010. private _glVersion;
  32011. private _glRenderer;
  32012. private _glVendor;
  32013. /** @hidden */
  32014. _videoTextureSupported: boolean;
  32015. protected _renderingQueueLaunched: boolean;
  32016. protected _activeRenderLoops: (() => void)[];
  32017. /**
  32018. * Observable signaled when a context lost event is raised
  32019. */
  32020. onContextLostObservable: Observable<ThinEngine>;
  32021. /**
  32022. * Observable signaled when a context restored event is raised
  32023. */
  32024. onContextRestoredObservable: Observable<ThinEngine>;
  32025. private _onContextLost;
  32026. private _onContextRestored;
  32027. protected _contextWasLost: boolean;
  32028. /** @hidden */
  32029. _doNotHandleContextLost: boolean;
  32030. /**
  32031. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32033. */
  32034. get doNotHandleContextLost(): boolean;
  32035. set doNotHandleContextLost(value: boolean);
  32036. /**
  32037. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32038. */
  32039. disableVertexArrayObjects: boolean;
  32040. /** @hidden */
  32041. protected _colorWrite: boolean;
  32042. /** @hidden */
  32043. protected _colorWriteChanged: boolean;
  32044. /** @hidden */
  32045. protected _depthCullingState: DepthCullingState;
  32046. /** @hidden */
  32047. protected _stencilState: StencilState;
  32048. /** @hidden */
  32049. _alphaState: AlphaState;
  32050. /** @hidden */
  32051. _alphaMode: number;
  32052. /** @hidden */
  32053. _alphaEquation: number;
  32054. /** @hidden */
  32055. _internalTexturesCache: InternalTexture[];
  32056. /** @hidden */
  32057. protected _activeChannel: number;
  32058. private _currentTextureChannel;
  32059. /** @hidden */
  32060. protected _boundTexturesCache: {
  32061. [key: string]: Nullable<InternalTexture>;
  32062. };
  32063. /** @hidden */
  32064. protected _currentEffect: Nullable<Effect>;
  32065. /** @hidden */
  32066. protected _currentProgram: Nullable<WebGLProgram>;
  32067. private _compiledEffects;
  32068. private _vertexAttribArraysEnabled;
  32069. /** @hidden */
  32070. protected _cachedViewport: Nullable<IViewportLike>;
  32071. private _cachedVertexArrayObject;
  32072. /** @hidden */
  32073. protected _cachedVertexBuffers: any;
  32074. /** @hidden */
  32075. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32076. /** @hidden */
  32077. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32078. /** @hidden */
  32079. _currentRenderTarget: Nullable<InternalTexture>;
  32080. private _uintIndicesCurrentlySet;
  32081. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32082. /** @hidden */
  32083. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32084. private _currentBufferPointers;
  32085. private _currentInstanceLocations;
  32086. private _currentInstanceBuffers;
  32087. private _textureUnits;
  32088. /** @hidden */
  32089. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32090. /** @hidden */
  32091. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32092. /** @hidden */
  32093. _boundRenderFunction: any;
  32094. private _vaoRecordInProgress;
  32095. private _mustWipeVertexAttributes;
  32096. private _emptyTexture;
  32097. private _emptyCubeTexture;
  32098. private _emptyTexture3D;
  32099. private _emptyTexture2DArray;
  32100. /** @hidden */
  32101. _frameHandler: number;
  32102. private _nextFreeTextureSlots;
  32103. private _maxSimultaneousTextures;
  32104. private _activeRequests;
  32105. protected _texturesSupported: string[];
  32106. /** @hidden */
  32107. _textureFormatInUse: Nullable<string>;
  32108. protected get _supportsHardwareTextureRescaling(): boolean;
  32109. /**
  32110. * Gets the list of texture formats supported
  32111. */
  32112. get texturesSupported(): Array<string>;
  32113. /**
  32114. * Gets the list of texture formats in use
  32115. */
  32116. get textureFormatInUse(): Nullable<string>;
  32117. /**
  32118. * Gets the current viewport
  32119. */
  32120. get currentViewport(): Nullable<IViewportLike>;
  32121. /**
  32122. * Gets the default empty texture
  32123. */
  32124. get emptyTexture(): InternalTexture;
  32125. /**
  32126. * Gets the default empty 3D texture
  32127. */
  32128. get emptyTexture3D(): InternalTexture;
  32129. /**
  32130. * Gets the default empty 2D array texture
  32131. */
  32132. get emptyTexture2DArray(): InternalTexture;
  32133. /**
  32134. * Gets the default empty cube texture
  32135. */
  32136. get emptyCubeTexture(): InternalTexture;
  32137. /**
  32138. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32139. */
  32140. readonly premultipliedAlpha: boolean;
  32141. /**
  32142. * Observable event triggered before each texture is initialized
  32143. */
  32144. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32145. /**
  32146. * Creates a new engine
  32147. * @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
  32148. * @param antialias defines enable antialiasing (default: false)
  32149. * @param options defines further options to be sent to the getContext() function
  32150. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32151. */
  32152. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32153. private _rebuildInternalTextures;
  32154. private _rebuildEffects;
  32155. /**
  32156. * Gets a boolean indicating if all created effects are ready
  32157. * @returns true if all effects are ready
  32158. */
  32159. areAllEffectsReady(): boolean;
  32160. protected _rebuildBuffers(): void;
  32161. private _initGLContext;
  32162. /**
  32163. * Gets version of the current webGL context
  32164. */
  32165. get webGLVersion(): number;
  32166. /**
  32167. * Gets a string idenfifying the name of the class
  32168. * @returns "Engine" string
  32169. */
  32170. getClassName(): string;
  32171. /**
  32172. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32173. */
  32174. get isStencilEnable(): boolean;
  32175. /** @hidden */
  32176. _prepareWorkingCanvas(): void;
  32177. /**
  32178. * Reset the texture cache to empty state
  32179. */
  32180. resetTextureCache(): void;
  32181. /**
  32182. * Gets an object containing information about the current webGL context
  32183. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32184. */
  32185. getGlInfo(): {
  32186. vendor: string;
  32187. renderer: string;
  32188. version: string;
  32189. };
  32190. /**
  32191. * Defines the hardware scaling level.
  32192. * By default the hardware scaling level is computed from the window device ratio.
  32193. * 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.
  32194. * @param level defines the level to use
  32195. */
  32196. setHardwareScalingLevel(level: number): void;
  32197. /**
  32198. * Gets the current hardware scaling level.
  32199. * By default the hardware scaling level is computed from the window device ratio.
  32200. * 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.
  32201. * @returns a number indicating the current hardware scaling level
  32202. */
  32203. getHardwareScalingLevel(): number;
  32204. /**
  32205. * Gets the list of loaded textures
  32206. * @returns an array containing all loaded textures
  32207. */
  32208. getLoadedTexturesCache(): InternalTexture[];
  32209. /**
  32210. * Gets the object containing all engine capabilities
  32211. * @returns the EngineCapabilities object
  32212. */
  32213. getCaps(): EngineCapabilities;
  32214. /**
  32215. * stop executing a render loop function and remove it from the execution array
  32216. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32217. */
  32218. stopRenderLoop(renderFunction?: () => void): void;
  32219. /** @hidden */
  32220. _renderLoop(): void;
  32221. /**
  32222. * Gets the HTML canvas attached with the current webGL context
  32223. * @returns a HTML canvas
  32224. */
  32225. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32226. /**
  32227. * Gets host window
  32228. * @returns the host window object
  32229. */
  32230. getHostWindow(): Nullable<Window>;
  32231. /**
  32232. * Gets the current render width
  32233. * @param useScreen defines if screen size must be used (or the current render target if any)
  32234. * @returns a number defining the current render width
  32235. */
  32236. getRenderWidth(useScreen?: boolean): number;
  32237. /**
  32238. * Gets the current render height
  32239. * @param useScreen defines if screen size must be used (or the current render target if any)
  32240. * @returns a number defining the current render height
  32241. */
  32242. getRenderHeight(useScreen?: boolean): number;
  32243. /**
  32244. * Can be used to override the current requestAnimationFrame requester.
  32245. * @hidden
  32246. */
  32247. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32248. /**
  32249. * Register and execute a render loop. The engine can have more than one render function
  32250. * @param renderFunction defines the function to continuously execute
  32251. */
  32252. runRenderLoop(renderFunction: () => void): void;
  32253. /**
  32254. * Clear the current render buffer or the current render target (if any is set up)
  32255. * @param color defines the color to use
  32256. * @param backBuffer defines if the back buffer must be cleared
  32257. * @param depth defines if the depth buffer must be cleared
  32258. * @param stencil defines if the stencil buffer must be cleared
  32259. */
  32260. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32261. private _viewportCached;
  32262. /** @hidden */
  32263. _viewport(x: number, y: number, width: number, height: number): void;
  32264. /**
  32265. * Set the WebGL's viewport
  32266. * @param viewport defines the viewport element to be used
  32267. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32268. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32269. */
  32270. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32271. /**
  32272. * Begin a new frame
  32273. */
  32274. beginFrame(): void;
  32275. /**
  32276. * Enf the current frame
  32277. */
  32278. endFrame(): void;
  32279. /**
  32280. * Resize the view according to the canvas' size
  32281. */
  32282. resize(): void;
  32283. /**
  32284. * Force a specific size of the canvas
  32285. * @param width defines the new canvas' width
  32286. * @param height defines the new canvas' height
  32287. */
  32288. setSize(width: number, height: number): void;
  32289. /**
  32290. * Binds the frame buffer to the specified texture.
  32291. * @param texture The texture to render to or null for the default canvas
  32292. * @param faceIndex The face of the texture to render to in case of cube texture
  32293. * @param requiredWidth The width of the target to render to
  32294. * @param requiredHeight The height of the target to render to
  32295. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32296. * @param lodLevel defines the lod level to bind to the frame buffer
  32297. * @param layer defines the 2d array index to bind to frame buffer to
  32298. */
  32299. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32300. /** @hidden */
  32301. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32302. /**
  32303. * Unbind the current render target texture from the webGL context
  32304. * @param texture defines the render target texture to unbind
  32305. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32306. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32307. */
  32308. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32309. /**
  32310. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32311. */
  32312. flushFramebuffer(): void;
  32313. /**
  32314. * Unbind the current render target and bind the default framebuffer
  32315. */
  32316. restoreDefaultFramebuffer(): void;
  32317. /** @hidden */
  32318. protected _resetVertexBufferBinding(): void;
  32319. /**
  32320. * Creates a vertex buffer
  32321. * @param data the data for the vertex buffer
  32322. * @returns the new WebGL static buffer
  32323. */
  32324. createVertexBuffer(data: DataArray): DataBuffer;
  32325. private _createVertexBuffer;
  32326. /**
  32327. * Creates a dynamic vertex buffer
  32328. * @param data the data for the dynamic vertex buffer
  32329. * @returns the new WebGL dynamic buffer
  32330. */
  32331. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32332. protected _resetIndexBufferBinding(): void;
  32333. /**
  32334. * Creates a new index buffer
  32335. * @param indices defines the content of the index buffer
  32336. * @param updatable defines if the index buffer must be updatable
  32337. * @returns a new webGL buffer
  32338. */
  32339. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32340. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32341. /**
  32342. * Bind a webGL buffer to the webGL context
  32343. * @param buffer defines the buffer to bind
  32344. */
  32345. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32346. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32347. private bindBuffer;
  32348. /**
  32349. * update the bound buffer with the given data
  32350. * @param data defines the data to update
  32351. */
  32352. updateArrayBuffer(data: Float32Array): void;
  32353. private _vertexAttribPointer;
  32354. /** @hidden */
  32355. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32356. private _bindVertexBuffersAttributes;
  32357. /**
  32358. * Records a vertex array object
  32359. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32360. * @param vertexBuffers defines the list of vertex buffers to store
  32361. * @param indexBuffer defines the index buffer to store
  32362. * @param effect defines the effect to store
  32363. * @returns the new vertex array object
  32364. */
  32365. recordVertexArrayObject(vertexBuffers: {
  32366. [key: string]: VertexBuffer;
  32367. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32368. /**
  32369. * Bind a specific vertex array object
  32370. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32371. * @param vertexArrayObject defines the vertex array object to bind
  32372. * @param indexBuffer defines the index buffer to bind
  32373. */
  32374. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32375. /**
  32376. * Bind webGl buffers directly to the webGL context
  32377. * @param vertexBuffer defines the vertex buffer to bind
  32378. * @param indexBuffer defines the index buffer to bind
  32379. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32380. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32381. * @param effect defines the effect associated with the vertex buffer
  32382. */
  32383. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32384. private _unbindVertexArrayObject;
  32385. /**
  32386. * Bind a list of vertex buffers to the webGL context
  32387. * @param vertexBuffers defines the list of vertex buffers to bind
  32388. * @param indexBuffer defines the index buffer to bind
  32389. * @param effect defines the effect associated with the vertex buffers
  32390. */
  32391. bindBuffers(vertexBuffers: {
  32392. [key: string]: Nullable<VertexBuffer>;
  32393. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32394. /**
  32395. * Unbind all instance attributes
  32396. */
  32397. unbindInstanceAttributes(): void;
  32398. /**
  32399. * Release and free the memory of a vertex array object
  32400. * @param vao defines the vertex array object to delete
  32401. */
  32402. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32403. /** @hidden */
  32404. _releaseBuffer(buffer: DataBuffer): boolean;
  32405. protected _deleteBuffer(buffer: DataBuffer): void;
  32406. /**
  32407. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32408. * @param instancesBuffer defines the webGL buffer to update and bind
  32409. * @param data defines the data to store in the buffer
  32410. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32411. */
  32412. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32413. /**
  32414. * Bind the content of a webGL buffer used with instantiation
  32415. * @param instancesBuffer defines the webGL buffer to bind
  32416. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32417. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32418. */
  32419. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32420. /**
  32421. * Disable the instance attribute corresponding to the name in parameter
  32422. * @param name defines the name of the attribute to disable
  32423. */
  32424. disableInstanceAttributeByName(name: string): void;
  32425. /**
  32426. * Disable the instance attribute corresponding to the location in parameter
  32427. * @param attributeLocation defines the attribute location of the attribute to disable
  32428. */
  32429. disableInstanceAttribute(attributeLocation: number): void;
  32430. /**
  32431. * Disable the attribute corresponding to the location in parameter
  32432. * @param attributeLocation defines the attribute location of the attribute to disable
  32433. */
  32434. disableAttributeByIndex(attributeLocation: number): void;
  32435. /**
  32436. * Send a draw order
  32437. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32438. * @param indexStart defines the starting index
  32439. * @param indexCount defines the number of index to draw
  32440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32441. */
  32442. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32443. /**
  32444. * Draw a list of points
  32445. * @param verticesStart defines the index of first vertex to draw
  32446. * @param verticesCount defines the count of vertices to draw
  32447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32448. */
  32449. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32450. /**
  32451. * Draw a list of unindexed primitives
  32452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32453. * @param verticesStart defines the index of first vertex to draw
  32454. * @param verticesCount defines the count of vertices to draw
  32455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32456. */
  32457. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32458. /**
  32459. * Draw a list of indexed primitives
  32460. * @param fillMode defines the primitive to use
  32461. * @param indexStart defines the starting index
  32462. * @param indexCount defines the number of index to draw
  32463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32464. */
  32465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32466. /**
  32467. * Draw a list of unindexed primitives
  32468. * @param fillMode defines the primitive to use
  32469. * @param verticesStart defines the index of first vertex to draw
  32470. * @param verticesCount defines the count of vertices to draw
  32471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32472. */
  32473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32474. private _drawMode;
  32475. /** @hidden */
  32476. protected _reportDrawCall(): void;
  32477. /** @hidden */
  32478. _releaseEffect(effect: Effect): void;
  32479. /** @hidden */
  32480. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32481. /**
  32482. * Create a new effect (used to store vertex/fragment shaders)
  32483. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32484. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32485. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32486. * @param samplers defines an array of string used to represent textures
  32487. * @param defines defines the string containing the defines to use to compile the shaders
  32488. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32489. * @param onCompiled defines a function to call when the effect creation is successful
  32490. * @param onError defines a function to call when the effect creation has failed
  32491. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32492. * @returns the new Effect
  32493. */
  32494. 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;
  32495. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32496. private _compileShader;
  32497. private _compileRawShader;
  32498. /**
  32499. * Directly creates a webGL program
  32500. * @param pipelineContext defines the pipeline context to attach to
  32501. * @param vertexCode defines the vertex shader code to use
  32502. * @param fragmentCode defines the fragment shader code to use
  32503. * @param context defines the webGL context to use (if not set, the current one will be used)
  32504. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32505. * @returns the new webGL program
  32506. */
  32507. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32508. /**
  32509. * Creates a webGL program
  32510. * @param pipelineContext defines the pipeline context to attach to
  32511. * @param vertexCode defines the vertex shader code to use
  32512. * @param fragmentCode defines the fragment shader code to use
  32513. * @param defines defines the string containing the defines to use to compile the shaders
  32514. * @param context defines the webGL context to use (if not set, the current one will be used)
  32515. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32516. * @returns the new webGL program
  32517. */
  32518. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32519. /**
  32520. * Creates a new pipeline context
  32521. * @returns the new pipeline
  32522. */
  32523. createPipelineContext(): IPipelineContext;
  32524. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32525. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32526. /** @hidden */
  32527. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32528. /** @hidden */
  32529. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32530. /** @hidden */
  32531. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32532. /**
  32533. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32534. * @param pipelineContext defines the pipeline context to use
  32535. * @param uniformsNames defines the list of uniform names
  32536. * @returns an array of webGL uniform locations
  32537. */
  32538. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32539. /**
  32540. * Gets the lsit of active attributes for a given webGL program
  32541. * @param pipelineContext defines the pipeline context to use
  32542. * @param attributesNames defines the list of attribute names to get
  32543. * @returns an array of indices indicating the offset of each attribute
  32544. */
  32545. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32546. /**
  32547. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32548. * @param effect defines the effect to activate
  32549. */
  32550. enableEffect(effect: Nullable<Effect>): void;
  32551. /**
  32552. * Set the value of an uniform to a number (int)
  32553. * @param uniform defines the webGL uniform location where to store the value
  32554. * @param value defines the int number to store
  32555. */
  32556. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32557. /**
  32558. * Set the value of an uniform to an array of int32
  32559. * @param uniform defines the webGL uniform location where to store the value
  32560. * @param array defines the array of int32 to store
  32561. */
  32562. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32563. /**
  32564. * Set the value of an uniform to an array of int32 (stored as vec2)
  32565. * @param uniform defines the webGL uniform location where to store the value
  32566. * @param array defines the array of int32 to store
  32567. */
  32568. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32569. /**
  32570. * Set the value of an uniform to an array of int32 (stored as vec3)
  32571. * @param uniform defines the webGL uniform location where to store the value
  32572. * @param array defines the array of int32 to store
  32573. */
  32574. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32575. /**
  32576. * Set the value of an uniform to an array of int32 (stored as vec4)
  32577. * @param uniform defines the webGL uniform location where to store the value
  32578. * @param array defines the array of int32 to store
  32579. */
  32580. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32581. /**
  32582. * Set the value of an uniform to an array of number
  32583. * @param uniform defines the webGL uniform location where to store the value
  32584. * @param array defines the array of number to store
  32585. */
  32586. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32587. /**
  32588. * Set the value of an uniform to an array of number (stored as vec2)
  32589. * @param uniform defines the webGL uniform location where to store the value
  32590. * @param array defines the array of number to store
  32591. */
  32592. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32593. /**
  32594. * Set the value of an uniform to an array of number (stored as vec3)
  32595. * @param uniform defines the webGL uniform location where to store the value
  32596. * @param array defines the array of number to store
  32597. */
  32598. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32599. /**
  32600. * Set the value of an uniform to an array of number (stored as vec4)
  32601. * @param uniform defines the webGL uniform location where to store the value
  32602. * @param array defines the array of number to store
  32603. */
  32604. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32605. /**
  32606. * Set the value of an uniform to an array of float32 (stored as matrices)
  32607. * @param uniform defines the webGL uniform location where to store the value
  32608. * @param matrices defines the array of float32 to store
  32609. */
  32610. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32611. /**
  32612. * Set the value of an uniform to a matrix (3x3)
  32613. * @param uniform defines the webGL uniform location where to store the value
  32614. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32615. */
  32616. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32617. /**
  32618. * Set the value of an uniform to a matrix (2x2)
  32619. * @param uniform defines the webGL uniform location where to store the value
  32620. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32621. */
  32622. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32623. /**
  32624. * Set the value of an uniform to a number (float)
  32625. * @param uniform defines the webGL uniform location where to store the value
  32626. * @param value defines the float number to store
  32627. */
  32628. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32629. /**
  32630. * Set the value of an uniform to a vec2
  32631. * @param uniform defines the webGL uniform location where to store the value
  32632. * @param x defines the 1st component of the value
  32633. * @param y defines the 2nd component of the value
  32634. */
  32635. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32636. /**
  32637. * Set the value of an uniform to a vec3
  32638. * @param uniform defines the webGL uniform location where to store the value
  32639. * @param x defines the 1st component of the value
  32640. * @param y defines the 2nd component of the value
  32641. * @param z defines the 3rd component of the value
  32642. */
  32643. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32644. /**
  32645. * Set the value of an uniform to a vec4
  32646. * @param uniform defines the webGL uniform location where to store the value
  32647. * @param x defines the 1st component of the value
  32648. * @param y defines the 2nd component of the value
  32649. * @param z defines the 3rd component of the value
  32650. * @param w defines the 4th component of the value
  32651. */
  32652. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32653. /**
  32654. * Apply all cached states (depth, culling, stencil and alpha)
  32655. */
  32656. applyStates(): void;
  32657. /**
  32658. * Enable or disable color writing
  32659. * @param enable defines the state to set
  32660. */
  32661. setColorWrite(enable: boolean): void;
  32662. /**
  32663. * Gets a boolean indicating if color writing is enabled
  32664. * @returns the current color writing state
  32665. */
  32666. getColorWrite(): boolean;
  32667. /**
  32668. * Gets the depth culling state manager
  32669. */
  32670. get depthCullingState(): DepthCullingState;
  32671. /**
  32672. * Gets the alpha state manager
  32673. */
  32674. get alphaState(): AlphaState;
  32675. /**
  32676. * Gets the stencil state manager
  32677. */
  32678. get stencilState(): StencilState;
  32679. /**
  32680. * Clears the list of texture accessible through engine.
  32681. * This can help preventing texture load conflict due to name collision.
  32682. */
  32683. clearInternalTexturesCache(): void;
  32684. /**
  32685. * Force the entire cache to be cleared
  32686. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32687. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32688. */
  32689. wipeCaches(bruteForce?: boolean): void;
  32690. /** @hidden */
  32691. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32692. min: number;
  32693. mag: number;
  32694. };
  32695. /** @hidden */
  32696. _createTexture(): WebGLTexture;
  32697. /**
  32698. * Usually called from Texture.ts.
  32699. * Passed information to create a WebGLTexture
  32700. * @param urlArg defines a value which contains one of the following:
  32701. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32702. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32703. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32704. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32705. * @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)
  32706. * @param scene needed for loading to the correct scene
  32707. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32708. * @param onLoad optional callback to be called upon successful completion
  32709. * @param onError optional callback to be called upon failure
  32710. * @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
  32711. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32712. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32713. * @param forcedExtension defines the extension to use to pick the right loader
  32714. * @param mimeType defines an optional mime type
  32715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32716. */
  32717. 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;
  32718. /**
  32719. * Loads an image as an HTMLImageElement.
  32720. * @param input url string, ArrayBuffer, or Blob to load
  32721. * @param onLoad callback called when the image successfully loads
  32722. * @param onError callback called when the image fails to load
  32723. * @param offlineProvider offline provider for caching
  32724. * @param mimeType optional mime type
  32725. * @returns the HTMLImageElement of the loaded image
  32726. * @hidden
  32727. */
  32728. 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>;
  32729. /**
  32730. * @hidden
  32731. */
  32732. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32733. /**
  32734. * Creates a raw texture
  32735. * @param data defines the data to store in the texture
  32736. * @param width defines the width of the texture
  32737. * @param height defines the height of the texture
  32738. * @param format defines the format of the data
  32739. * @param generateMipMaps defines if the engine should generate the mip levels
  32740. * @param invertY defines if data must be stored with Y axis inverted
  32741. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32742. * @param compression defines the compression used (null by default)
  32743. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32744. * @returns the raw texture inside an InternalTexture
  32745. */
  32746. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32747. /**
  32748. * Creates a new raw cube texture
  32749. * @param data defines the array of data to use to create each face
  32750. * @param size defines the size of the textures
  32751. * @param format defines the format of the data
  32752. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32753. * @param generateMipMaps defines if the engine should generate the mip levels
  32754. * @param invertY defines if data must be stored with Y axis inverted
  32755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32756. * @param compression defines the compression used (null by default)
  32757. * @returns the cube texture as an InternalTexture
  32758. */
  32759. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32760. /**
  32761. * Creates a new raw 3D texture
  32762. * @param data defines the data used to create the texture
  32763. * @param width defines the width of the texture
  32764. * @param height defines the height of the texture
  32765. * @param depth defines the depth of the texture
  32766. * @param format defines the format of the texture
  32767. * @param generateMipMaps defines if the engine must generate mip levels
  32768. * @param invertY defines if data must be stored with Y axis inverted
  32769. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32770. * @param compression defines the compressed used (can be null)
  32771. * @param textureType defines the compressed used (can be null)
  32772. * @returns a new raw 3D texture (stored in an InternalTexture)
  32773. */
  32774. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32775. /**
  32776. * Creates a new raw 2D array texture
  32777. * @param data defines the data used to create the texture
  32778. * @param width defines the width of the texture
  32779. * @param height defines the height of the texture
  32780. * @param depth defines the number of layers of the texture
  32781. * @param format defines the format of the texture
  32782. * @param generateMipMaps defines if the engine must generate mip levels
  32783. * @param invertY defines if data must be stored with Y axis inverted
  32784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32785. * @param compression defines the compressed used (can be null)
  32786. * @param textureType defines the compressed used (can be null)
  32787. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32788. */
  32789. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32790. private _unpackFlipYCached;
  32791. /**
  32792. * In case you are sharing the context with other applications, it might
  32793. * be interested to not cache the unpack flip y state to ensure a consistent
  32794. * value would be set.
  32795. */
  32796. enableUnpackFlipYCached: boolean;
  32797. /** @hidden */
  32798. _unpackFlipY(value: boolean): void;
  32799. /** @hidden */
  32800. _getUnpackAlignement(): number;
  32801. private _getTextureTarget;
  32802. /**
  32803. * Update the sampling mode of a given texture
  32804. * @param samplingMode defines the required sampling mode
  32805. * @param texture defines the texture to update
  32806. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32807. */
  32808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32809. /**
  32810. * Update the sampling mode of a given texture
  32811. * @param texture defines the texture to update
  32812. * @param wrapU defines the texture wrap mode of the u coordinates
  32813. * @param wrapV defines the texture wrap mode of the v coordinates
  32814. * @param wrapR defines the texture wrap mode of the r coordinates
  32815. */
  32816. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32817. /** @hidden */
  32818. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32819. width: number;
  32820. height: number;
  32821. layers?: number;
  32822. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32823. /** @hidden */
  32824. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32825. /** @hidden */
  32826. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32827. /**
  32828. * Update a portion of an internal texture
  32829. * @param texture defines the texture to update
  32830. * @param imageData defines the data to store into the texture
  32831. * @param xOffset defines the x coordinates of the update rectangle
  32832. * @param yOffset defines the y coordinates of the update rectangle
  32833. * @param width defines the width of the update rectangle
  32834. * @param height defines the height of the update rectangle
  32835. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32836. * @param lod defines the lod level to update (0 by default)
  32837. */
  32838. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32839. /** @hidden */
  32840. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32841. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32842. private _prepareWebGLTexture;
  32843. /** @hidden */
  32844. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32845. private _getDepthStencilBuffer;
  32846. /** @hidden */
  32847. _releaseFramebufferObjects(texture: InternalTexture): void;
  32848. /** @hidden */
  32849. _releaseTexture(texture: InternalTexture): void;
  32850. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32851. protected _setProgram(program: WebGLProgram): void;
  32852. protected _boundUniforms: {
  32853. [key: number]: WebGLUniformLocation;
  32854. };
  32855. /**
  32856. * Binds an effect to the webGL context
  32857. * @param effect defines the effect to bind
  32858. */
  32859. bindSamplers(effect: Effect): void;
  32860. private _activateCurrentTexture;
  32861. /** @hidden */
  32862. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32863. /** @hidden */
  32864. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32865. /**
  32866. * Unbind all textures from the webGL context
  32867. */
  32868. unbindAllTextures(): void;
  32869. /**
  32870. * Sets a texture to the according uniform.
  32871. * @param channel The texture channel
  32872. * @param uniform The uniform to set
  32873. * @param texture The texture to apply
  32874. */
  32875. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32876. private _bindSamplerUniformToChannel;
  32877. private _getTextureWrapMode;
  32878. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32879. /**
  32880. * Sets an array of texture to the webGL context
  32881. * @param channel defines the channel where the texture array must be set
  32882. * @param uniform defines the associated uniform location
  32883. * @param textures defines the array of textures to bind
  32884. */
  32885. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32886. /** @hidden */
  32887. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32888. private _setTextureParameterFloat;
  32889. private _setTextureParameterInteger;
  32890. /**
  32891. * Unbind all vertex attributes from the webGL context
  32892. */
  32893. unbindAllAttributes(): void;
  32894. /**
  32895. * 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
  32896. */
  32897. releaseEffects(): void;
  32898. /**
  32899. * Dispose and release all associated resources
  32900. */
  32901. dispose(): void;
  32902. /**
  32903. * Attach a new callback raised when context lost event is fired
  32904. * @param callback defines the callback to call
  32905. */
  32906. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32907. /**
  32908. * Attach a new callback raised when context restored event is fired
  32909. * @param callback defines the callback to call
  32910. */
  32911. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32912. /**
  32913. * Get the current error code of the webGL context
  32914. * @returns the error code
  32915. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32916. */
  32917. getError(): number;
  32918. private _canRenderToFloatFramebuffer;
  32919. private _canRenderToHalfFloatFramebuffer;
  32920. private _canRenderToFramebuffer;
  32921. /** @hidden */
  32922. _getWebGLTextureType(type: number): number;
  32923. /** @hidden */
  32924. _getInternalFormat(format: number): number;
  32925. /** @hidden */
  32926. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32927. /** @hidden */
  32928. _getRGBAMultiSampleBufferFormat(type: number): number;
  32929. /** @hidden */
  32930. _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;
  32931. /**
  32932. * Loads a file from a url
  32933. * @param url url to load
  32934. * @param onSuccess callback called when the file successfully loads
  32935. * @param onProgress callback called while file is loading (if the server supports this mode)
  32936. * @param offlineProvider defines the offline provider for caching
  32937. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32938. * @param onError callback called when the file fails to load
  32939. * @returns a file request object
  32940. * @hidden
  32941. */
  32942. 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;
  32943. /**
  32944. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32945. * @param x defines the x coordinate of the rectangle where pixels must be read
  32946. * @param y defines the y coordinate of the rectangle where pixels must be read
  32947. * @param width defines the width of the rectangle where pixels must be read
  32948. * @param height defines the height of the rectangle where pixels must be read
  32949. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32950. * @returns a Uint8Array containing RGBA colors
  32951. */
  32952. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32953. private static _isSupported;
  32954. /**
  32955. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32956. * @returns true if the engine can be created
  32957. * @ignorenaming
  32958. */
  32959. static isSupported(): boolean;
  32960. /**
  32961. * Find the next highest power of two.
  32962. * @param x Number to start search from.
  32963. * @return Next highest power of two.
  32964. */
  32965. static CeilingPOT(x: number): number;
  32966. /**
  32967. * Find the next lowest power of two.
  32968. * @param x Number to start search from.
  32969. * @return Next lowest power of two.
  32970. */
  32971. static FloorPOT(x: number): number;
  32972. /**
  32973. * Find the nearest power of two.
  32974. * @param x Number to start search from.
  32975. * @return Next nearest power of two.
  32976. */
  32977. static NearestPOT(x: number): number;
  32978. /**
  32979. * Get the closest exponent of two
  32980. * @param value defines the value to approximate
  32981. * @param max defines the maximum value to return
  32982. * @param mode defines how to define the closest value
  32983. * @returns closest exponent of two of the given value
  32984. */
  32985. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32986. /**
  32987. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32988. * @param func - the function to be called
  32989. * @param requester - the object that will request the next frame. Falls back to window.
  32990. * @returns frame number
  32991. */
  32992. static QueueNewFrame(func: () => void, requester?: any): number;
  32993. /**
  32994. * Gets host document
  32995. * @returns the host document object
  32996. */
  32997. getHostDocument(): Nullable<Document>;
  32998. }
  32999. }
  33000. declare module "babylonjs/Maths/sphericalPolynomial" {
  33001. import { Vector3 } from "babylonjs/Maths/math.vector";
  33002. import { Color3 } from "babylonjs/Maths/math.color";
  33003. /**
  33004. * Class representing spherical harmonics coefficients to the 3rd degree
  33005. */
  33006. export class SphericalHarmonics {
  33007. /**
  33008. * Defines whether or not the harmonics have been prescaled for rendering.
  33009. */
  33010. preScaled: boolean;
  33011. /**
  33012. * The l0,0 coefficients of the spherical harmonics
  33013. */
  33014. l00: Vector3;
  33015. /**
  33016. * The l1,-1 coefficients of the spherical harmonics
  33017. */
  33018. l1_1: Vector3;
  33019. /**
  33020. * The l1,0 coefficients of the spherical harmonics
  33021. */
  33022. l10: Vector3;
  33023. /**
  33024. * The l1,1 coefficients of the spherical harmonics
  33025. */
  33026. l11: Vector3;
  33027. /**
  33028. * The l2,-2 coefficients of the spherical harmonics
  33029. */
  33030. l2_2: Vector3;
  33031. /**
  33032. * The l2,-1 coefficients of the spherical harmonics
  33033. */
  33034. l2_1: Vector3;
  33035. /**
  33036. * The l2,0 coefficients of the spherical harmonics
  33037. */
  33038. l20: Vector3;
  33039. /**
  33040. * The l2,1 coefficients of the spherical harmonics
  33041. */
  33042. l21: Vector3;
  33043. /**
  33044. * The l2,2 coefficients of the spherical harmonics
  33045. */
  33046. l22: Vector3;
  33047. /**
  33048. * Adds a light to the spherical harmonics
  33049. * @param direction the direction of the light
  33050. * @param color the color of the light
  33051. * @param deltaSolidAngle the delta solid angle of the light
  33052. */
  33053. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33054. /**
  33055. * Scales the spherical harmonics by the given amount
  33056. * @param scale the amount to scale
  33057. */
  33058. scaleInPlace(scale: number): void;
  33059. /**
  33060. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33061. *
  33062. * ```
  33063. * E_lm = A_l * L_lm
  33064. * ```
  33065. *
  33066. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33067. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33068. * the scaling factors are given in equation 9.
  33069. */
  33070. convertIncidentRadianceToIrradiance(): void;
  33071. /**
  33072. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33073. *
  33074. * ```
  33075. * L = (1/pi) * E * rho
  33076. * ```
  33077. *
  33078. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33079. */
  33080. convertIrradianceToLambertianRadiance(): void;
  33081. /**
  33082. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33083. * required operations at run time.
  33084. *
  33085. * This is simply done by scaling back the SH with Ylm constants parameter.
  33086. * The trigonometric part being applied by the shader at run time.
  33087. */
  33088. preScaleForRendering(): void;
  33089. /**
  33090. * Constructs a spherical harmonics from an array.
  33091. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33092. * @returns the spherical harmonics
  33093. */
  33094. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33095. /**
  33096. * Gets the spherical harmonics from polynomial
  33097. * @param polynomial the spherical polynomial
  33098. * @returns the spherical harmonics
  33099. */
  33100. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33101. }
  33102. /**
  33103. * Class representing spherical polynomial coefficients to the 3rd degree
  33104. */
  33105. export class SphericalPolynomial {
  33106. private _harmonics;
  33107. /**
  33108. * The spherical harmonics used to create the polynomials.
  33109. */
  33110. get preScaledHarmonics(): SphericalHarmonics;
  33111. /**
  33112. * The x coefficients of the spherical polynomial
  33113. */
  33114. x: Vector3;
  33115. /**
  33116. * The y coefficients of the spherical polynomial
  33117. */
  33118. y: Vector3;
  33119. /**
  33120. * The z coefficients of the spherical polynomial
  33121. */
  33122. z: Vector3;
  33123. /**
  33124. * The xx coefficients of the spherical polynomial
  33125. */
  33126. xx: Vector3;
  33127. /**
  33128. * The yy coefficients of the spherical polynomial
  33129. */
  33130. yy: Vector3;
  33131. /**
  33132. * The zz coefficients of the spherical polynomial
  33133. */
  33134. zz: Vector3;
  33135. /**
  33136. * The xy coefficients of the spherical polynomial
  33137. */
  33138. xy: Vector3;
  33139. /**
  33140. * The yz coefficients of the spherical polynomial
  33141. */
  33142. yz: Vector3;
  33143. /**
  33144. * The zx coefficients of the spherical polynomial
  33145. */
  33146. zx: Vector3;
  33147. /**
  33148. * Adds an ambient color to the spherical polynomial
  33149. * @param color the color to add
  33150. */
  33151. addAmbient(color: Color3): void;
  33152. /**
  33153. * Scales the spherical polynomial by the given amount
  33154. * @param scale the amount to scale
  33155. */
  33156. scaleInPlace(scale: number): void;
  33157. /**
  33158. * Gets the spherical polynomial from harmonics
  33159. * @param harmonics the spherical harmonics
  33160. * @returns the spherical polynomial
  33161. */
  33162. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33163. /**
  33164. * Constructs a spherical polynomial from an array.
  33165. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33166. * @returns the spherical polynomial
  33167. */
  33168. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33169. }
  33170. }
  33171. declare module "babylonjs/Materials/Textures/internalTexture" {
  33172. import { Observable } from "babylonjs/Misc/observable";
  33173. import { Nullable, int } from "babylonjs/types";
  33174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33176. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33177. /**
  33178. * Defines the source of the internal texture
  33179. */
  33180. export enum InternalTextureSource {
  33181. /**
  33182. * The source of the texture data is unknown
  33183. */
  33184. Unknown = 0,
  33185. /**
  33186. * Texture data comes from an URL
  33187. */
  33188. Url = 1,
  33189. /**
  33190. * Texture data is only used for temporary storage
  33191. */
  33192. Temp = 2,
  33193. /**
  33194. * Texture data comes from raw data (ArrayBuffer)
  33195. */
  33196. Raw = 3,
  33197. /**
  33198. * Texture content is dynamic (video or dynamic texture)
  33199. */
  33200. Dynamic = 4,
  33201. /**
  33202. * Texture content is generated by rendering to it
  33203. */
  33204. RenderTarget = 5,
  33205. /**
  33206. * Texture content is part of a multi render target process
  33207. */
  33208. MultiRenderTarget = 6,
  33209. /**
  33210. * Texture data comes from a cube data file
  33211. */
  33212. Cube = 7,
  33213. /**
  33214. * Texture data comes from a raw cube data
  33215. */
  33216. CubeRaw = 8,
  33217. /**
  33218. * Texture data come from a prefiltered cube data file
  33219. */
  33220. CubePrefiltered = 9,
  33221. /**
  33222. * Texture content is raw 3D data
  33223. */
  33224. Raw3D = 10,
  33225. /**
  33226. * Texture content is raw 2D array data
  33227. */
  33228. Raw2DArray = 11,
  33229. /**
  33230. * Texture content is a depth texture
  33231. */
  33232. Depth = 12,
  33233. /**
  33234. * Texture data comes from a raw cube data encoded with RGBD
  33235. */
  33236. CubeRawRGBD = 13
  33237. }
  33238. /**
  33239. * Class used to store data associated with WebGL texture data for the engine
  33240. * This class should not be used directly
  33241. */
  33242. export class InternalTexture {
  33243. /** @hidden */
  33244. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33245. /**
  33246. * Defines if the texture is ready
  33247. */
  33248. isReady: boolean;
  33249. /**
  33250. * Defines if the texture is a cube texture
  33251. */
  33252. isCube: boolean;
  33253. /**
  33254. * Defines if the texture contains 3D data
  33255. */
  33256. is3D: boolean;
  33257. /**
  33258. * Defines if the texture contains 2D array data
  33259. */
  33260. is2DArray: boolean;
  33261. /**
  33262. * Defines if the texture contains multiview data
  33263. */
  33264. isMultiview: boolean;
  33265. /**
  33266. * Gets the URL used to load this texture
  33267. */
  33268. url: string;
  33269. /**
  33270. * Gets the sampling mode of the texture
  33271. */
  33272. samplingMode: number;
  33273. /**
  33274. * Gets a boolean indicating if the texture needs mipmaps generation
  33275. */
  33276. generateMipMaps: boolean;
  33277. /**
  33278. * Gets the number of samples used by the texture (WebGL2+ only)
  33279. */
  33280. samples: number;
  33281. /**
  33282. * Gets the type of the texture (int, float...)
  33283. */
  33284. type: number;
  33285. /**
  33286. * Gets the format of the texture (RGB, RGBA...)
  33287. */
  33288. format: number;
  33289. /**
  33290. * Observable called when the texture is loaded
  33291. */
  33292. onLoadedObservable: Observable<InternalTexture>;
  33293. /**
  33294. * Gets the width of the texture
  33295. */
  33296. width: number;
  33297. /**
  33298. * Gets the height of the texture
  33299. */
  33300. height: number;
  33301. /**
  33302. * Gets the depth of the texture
  33303. */
  33304. depth: number;
  33305. /**
  33306. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33307. */
  33308. baseWidth: number;
  33309. /**
  33310. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33311. */
  33312. baseHeight: number;
  33313. /**
  33314. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33315. */
  33316. baseDepth: number;
  33317. /**
  33318. * Gets a boolean indicating if the texture is inverted on Y axis
  33319. */
  33320. invertY: boolean;
  33321. /** @hidden */
  33322. _invertVScale: boolean;
  33323. /** @hidden */
  33324. _associatedChannel: number;
  33325. /** @hidden */
  33326. _source: InternalTextureSource;
  33327. /** @hidden */
  33328. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33329. /** @hidden */
  33330. _bufferView: Nullable<ArrayBufferView>;
  33331. /** @hidden */
  33332. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33333. /** @hidden */
  33334. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33335. /** @hidden */
  33336. _size: number;
  33337. /** @hidden */
  33338. _extension: string;
  33339. /** @hidden */
  33340. _files: Nullable<string[]>;
  33341. /** @hidden */
  33342. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33343. /** @hidden */
  33344. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33345. /** @hidden */
  33346. _framebuffer: Nullable<WebGLFramebuffer>;
  33347. /** @hidden */
  33348. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33349. /** @hidden */
  33350. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33351. /** @hidden */
  33352. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33353. /** @hidden */
  33354. _attachments: Nullable<number[]>;
  33355. /** @hidden */
  33356. _cachedCoordinatesMode: Nullable<number>;
  33357. /** @hidden */
  33358. _cachedWrapU: Nullable<number>;
  33359. /** @hidden */
  33360. _cachedWrapV: Nullable<number>;
  33361. /** @hidden */
  33362. _cachedWrapR: Nullable<number>;
  33363. /** @hidden */
  33364. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33365. /** @hidden */
  33366. _isDisabled: boolean;
  33367. /** @hidden */
  33368. _compression: Nullable<string>;
  33369. /** @hidden */
  33370. _generateStencilBuffer: boolean;
  33371. /** @hidden */
  33372. _generateDepthBuffer: boolean;
  33373. /** @hidden */
  33374. _comparisonFunction: number;
  33375. /** @hidden */
  33376. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33377. /** @hidden */
  33378. _lodGenerationScale: number;
  33379. /** @hidden */
  33380. _lodGenerationOffset: number;
  33381. /** @hidden */
  33382. _depthStencilTexture: Nullable<InternalTexture>;
  33383. /** @hidden */
  33384. _colorTextureArray: Nullable<WebGLTexture>;
  33385. /** @hidden */
  33386. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33387. /** @hidden */
  33388. _lodTextureHigh: Nullable<BaseTexture>;
  33389. /** @hidden */
  33390. _lodTextureMid: Nullable<BaseTexture>;
  33391. /** @hidden */
  33392. _lodTextureLow: Nullable<BaseTexture>;
  33393. /** @hidden */
  33394. _isRGBD: boolean;
  33395. /** @hidden */
  33396. _linearSpecularLOD: boolean;
  33397. /** @hidden */
  33398. _irradianceTexture: Nullable<BaseTexture>;
  33399. /** @hidden */
  33400. _webGLTexture: Nullable<WebGLTexture>;
  33401. /** @hidden */
  33402. _references: number;
  33403. private _engine;
  33404. /**
  33405. * Gets the Engine the texture belongs to.
  33406. * @returns The babylon engine
  33407. */
  33408. getEngine(): ThinEngine;
  33409. /**
  33410. * Gets the data source type of the texture
  33411. */
  33412. get source(): InternalTextureSource;
  33413. /**
  33414. * Creates a new InternalTexture
  33415. * @param engine defines the engine to use
  33416. * @param source defines the type of data that will be used
  33417. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33418. */
  33419. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33420. /**
  33421. * Increments the number of references (ie. the number of Texture that point to it)
  33422. */
  33423. incrementReferences(): void;
  33424. /**
  33425. * Change the size of the texture (not the size of the content)
  33426. * @param width defines the new width
  33427. * @param height defines the new height
  33428. * @param depth defines the new depth (1 by default)
  33429. */
  33430. updateSize(width: int, height: int, depth?: int): void;
  33431. /** @hidden */
  33432. _rebuild(): void;
  33433. /** @hidden */
  33434. _swapAndDie(target: InternalTexture): void;
  33435. /**
  33436. * Dispose the current allocated resources
  33437. */
  33438. dispose(): void;
  33439. }
  33440. }
  33441. declare module "babylonjs/Audio/analyser" {
  33442. import { Scene } from "babylonjs/scene";
  33443. /**
  33444. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33446. */
  33447. export class Analyser {
  33448. /**
  33449. * Gets or sets the smoothing
  33450. * @ignorenaming
  33451. */
  33452. SMOOTHING: number;
  33453. /**
  33454. * Gets or sets the FFT table size
  33455. * @ignorenaming
  33456. */
  33457. FFT_SIZE: number;
  33458. /**
  33459. * Gets or sets the bar graph amplitude
  33460. * @ignorenaming
  33461. */
  33462. BARGRAPHAMPLITUDE: number;
  33463. /**
  33464. * Gets or sets the position of the debug canvas
  33465. * @ignorenaming
  33466. */
  33467. DEBUGCANVASPOS: {
  33468. x: number;
  33469. y: number;
  33470. };
  33471. /**
  33472. * Gets or sets the debug canvas size
  33473. * @ignorenaming
  33474. */
  33475. DEBUGCANVASSIZE: {
  33476. width: number;
  33477. height: number;
  33478. };
  33479. private _byteFreqs;
  33480. private _byteTime;
  33481. private _floatFreqs;
  33482. private _webAudioAnalyser;
  33483. private _debugCanvas;
  33484. private _debugCanvasContext;
  33485. private _scene;
  33486. private _registerFunc;
  33487. private _audioEngine;
  33488. /**
  33489. * Creates a new analyser
  33490. * @param scene defines hosting scene
  33491. */
  33492. constructor(scene: Scene);
  33493. /**
  33494. * Get the number of data values you will have to play with for the visualization
  33495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33496. * @returns a number
  33497. */
  33498. getFrequencyBinCount(): number;
  33499. /**
  33500. * Gets the current frequency data as a byte array
  33501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33502. * @returns a Uint8Array
  33503. */
  33504. getByteFrequencyData(): Uint8Array;
  33505. /**
  33506. * Gets the current waveform as a byte array
  33507. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33508. * @returns a Uint8Array
  33509. */
  33510. getByteTimeDomainData(): Uint8Array;
  33511. /**
  33512. * Gets the current frequency data as a float array
  33513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33514. * @returns a Float32Array
  33515. */
  33516. getFloatFrequencyData(): Float32Array;
  33517. /**
  33518. * Renders the debug canvas
  33519. */
  33520. drawDebugCanvas(): void;
  33521. /**
  33522. * Stops rendering the debug canvas and removes it
  33523. */
  33524. stopDebugCanvas(): void;
  33525. /**
  33526. * Connects two audio nodes
  33527. * @param inputAudioNode defines first node to connect
  33528. * @param outputAudioNode defines second node to connect
  33529. */
  33530. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33531. /**
  33532. * Releases all associated resources
  33533. */
  33534. dispose(): void;
  33535. }
  33536. }
  33537. declare module "babylonjs/Audio/audioEngine" {
  33538. import { IDisposable } from "babylonjs/scene";
  33539. import { Analyser } from "babylonjs/Audio/analyser";
  33540. import { Nullable } from "babylonjs/types";
  33541. import { Observable } from "babylonjs/Misc/observable";
  33542. /**
  33543. * This represents an audio engine and it is responsible
  33544. * to play, synchronize and analyse sounds throughout the application.
  33545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33546. */
  33547. export interface IAudioEngine extends IDisposable {
  33548. /**
  33549. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33550. */
  33551. readonly canUseWebAudio: boolean;
  33552. /**
  33553. * Gets the current AudioContext if available.
  33554. */
  33555. readonly audioContext: Nullable<AudioContext>;
  33556. /**
  33557. * The master gain node defines the global audio volume of your audio engine.
  33558. */
  33559. readonly masterGain: GainNode;
  33560. /**
  33561. * Gets whether or not mp3 are supported by your browser.
  33562. */
  33563. readonly isMP3supported: boolean;
  33564. /**
  33565. * Gets whether or not ogg are supported by your browser.
  33566. */
  33567. readonly isOGGsupported: boolean;
  33568. /**
  33569. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33570. * @ignoreNaming
  33571. */
  33572. WarnedWebAudioUnsupported: boolean;
  33573. /**
  33574. * Defines if the audio engine relies on a custom unlocked button.
  33575. * In this case, the embedded button will not be displayed.
  33576. */
  33577. useCustomUnlockedButton: boolean;
  33578. /**
  33579. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33580. */
  33581. readonly unlocked: boolean;
  33582. /**
  33583. * Event raised when audio has been unlocked on the browser.
  33584. */
  33585. onAudioUnlockedObservable: Observable<AudioEngine>;
  33586. /**
  33587. * Event raised when audio has been locked on the browser.
  33588. */
  33589. onAudioLockedObservable: Observable<AudioEngine>;
  33590. /**
  33591. * Flags the audio engine in Locked state.
  33592. * This happens due to new browser policies preventing audio to autoplay.
  33593. */
  33594. lock(): void;
  33595. /**
  33596. * Unlocks the audio engine once a user action has been done on the dom.
  33597. * This is helpful to resume play once browser policies have been satisfied.
  33598. */
  33599. unlock(): void;
  33600. }
  33601. /**
  33602. * This represents the default audio engine used in babylon.
  33603. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33605. */
  33606. export class AudioEngine implements IAudioEngine {
  33607. private _audioContext;
  33608. private _audioContextInitialized;
  33609. private _muteButton;
  33610. private _hostElement;
  33611. /**
  33612. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33613. */
  33614. canUseWebAudio: boolean;
  33615. /**
  33616. * The master gain node defines the global audio volume of your audio engine.
  33617. */
  33618. masterGain: GainNode;
  33619. /**
  33620. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33621. * @ignoreNaming
  33622. */
  33623. WarnedWebAudioUnsupported: boolean;
  33624. /**
  33625. * Gets whether or not mp3 are supported by your browser.
  33626. */
  33627. isMP3supported: boolean;
  33628. /**
  33629. * Gets whether or not ogg are supported by your browser.
  33630. */
  33631. isOGGsupported: boolean;
  33632. /**
  33633. * Gets whether audio has been unlocked on the device.
  33634. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33635. * a user interaction has happened.
  33636. */
  33637. unlocked: boolean;
  33638. /**
  33639. * Defines if the audio engine relies on a custom unlocked button.
  33640. * In this case, the embedded button will not be displayed.
  33641. */
  33642. useCustomUnlockedButton: boolean;
  33643. /**
  33644. * Event raised when audio has been unlocked on the browser.
  33645. */
  33646. onAudioUnlockedObservable: Observable<AudioEngine>;
  33647. /**
  33648. * Event raised when audio has been locked on the browser.
  33649. */
  33650. onAudioLockedObservable: Observable<AudioEngine>;
  33651. /**
  33652. * Gets the current AudioContext if available.
  33653. */
  33654. get audioContext(): Nullable<AudioContext>;
  33655. private _connectedAnalyser;
  33656. /**
  33657. * Instantiates a new audio engine.
  33658. *
  33659. * There should be only one per page as some browsers restrict the number
  33660. * of audio contexts you can create.
  33661. * @param hostElement defines the host element where to display the mute icon if necessary
  33662. */
  33663. constructor(hostElement?: Nullable<HTMLElement>);
  33664. /**
  33665. * Flags the audio engine in Locked state.
  33666. * This happens due to new browser policies preventing audio to autoplay.
  33667. */
  33668. lock(): void;
  33669. /**
  33670. * Unlocks the audio engine once a user action has been done on the dom.
  33671. * This is helpful to resume play once browser policies have been satisfied.
  33672. */
  33673. unlock(): void;
  33674. private _resumeAudioContext;
  33675. private _initializeAudioContext;
  33676. private _tryToRun;
  33677. private _triggerRunningState;
  33678. private _triggerSuspendedState;
  33679. private _displayMuteButton;
  33680. private _moveButtonToTopLeft;
  33681. private _onResize;
  33682. private _hideMuteButton;
  33683. /**
  33684. * Destroy and release the resources associated with the audio ccontext.
  33685. */
  33686. dispose(): void;
  33687. /**
  33688. * Gets the global volume sets on the master gain.
  33689. * @returns the global volume if set or -1 otherwise
  33690. */
  33691. getGlobalVolume(): number;
  33692. /**
  33693. * Sets the global volume of your experience (sets on the master gain).
  33694. * @param newVolume Defines the new global volume of the application
  33695. */
  33696. setGlobalVolume(newVolume: number): void;
  33697. /**
  33698. * Connect the audio engine to an audio analyser allowing some amazing
  33699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33701. * @param analyser The analyser to connect to the engine
  33702. */
  33703. connectToAnalyser(analyser: Analyser): void;
  33704. }
  33705. }
  33706. declare module "babylonjs/Loading/loadingScreen" {
  33707. /**
  33708. * Interface used to present a loading screen while loading a scene
  33709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33710. */
  33711. export interface ILoadingScreen {
  33712. /**
  33713. * Function called to display the loading screen
  33714. */
  33715. displayLoadingUI: () => void;
  33716. /**
  33717. * Function called to hide the loading screen
  33718. */
  33719. hideLoadingUI: () => void;
  33720. /**
  33721. * Gets or sets the color to use for the background
  33722. */
  33723. loadingUIBackgroundColor: string;
  33724. /**
  33725. * Gets or sets the text to display while loading
  33726. */
  33727. loadingUIText: string;
  33728. }
  33729. /**
  33730. * Class used for the default loading screen
  33731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33732. */
  33733. export class DefaultLoadingScreen implements ILoadingScreen {
  33734. private _renderingCanvas;
  33735. private _loadingText;
  33736. private _loadingDivBackgroundColor;
  33737. private _loadingDiv;
  33738. private _loadingTextDiv;
  33739. /** Gets or sets the logo url to use for the default loading screen */
  33740. static DefaultLogoUrl: string;
  33741. /** Gets or sets the spinner url to use for the default loading screen */
  33742. static DefaultSpinnerUrl: string;
  33743. /**
  33744. * Creates a new default loading screen
  33745. * @param _renderingCanvas defines the canvas used to render the scene
  33746. * @param _loadingText defines the default text to display
  33747. * @param _loadingDivBackgroundColor defines the default background color
  33748. */
  33749. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33750. /**
  33751. * Function called to display the loading screen
  33752. */
  33753. displayLoadingUI(): void;
  33754. /**
  33755. * Function called to hide the loading screen
  33756. */
  33757. hideLoadingUI(): void;
  33758. /**
  33759. * Gets or sets the text to display while loading
  33760. */
  33761. set loadingUIText(text: string);
  33762. get loadingUIText(): string;
  33763. /**
  33764. * Gets or sets the color to use for the background
  33765. */
  33766. get loadingUIBackgroundColor(): string;
  33767. set loadingUIBackgroundColor(color: string);
  33768. private _resizeLoadingUI;
  33769. }
  33770. }
  33771. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33772. /**
  33773. * Interface for any object that can request an animation frame
  33774. */
  33775. export interface ICustomAnimationFrameRequester {
  33776. /**
  33777. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33778. */
  33779. renderFunction?: Function;
  33780. /**
  33781. * Called to request the next frame to render to
  33782. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33783. */
  33784. requestAnimationFrame: Function;
  33785. /**
  33786. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33787. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33788. */
  33789. requestID?: number;
  33790. }
  33791. }
  33792. declare module "babylonjs/Misc/performanceMonitor" {
  33793. /**
  33794. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33795. */
  33796. export class PerformanceMonitor {
  33797. private _enabled;
  33798. private _rollingFrameTime;
  33799. private _lastFrameTimeMs;
  33800. /**
  33801. * constructor
  33802. * @param frameSampleSize The number of samples required to saturate the sliding window
  33803. */
  33804. constructor(frameSampleSize?: number);
  33805. /**
  33806. * Samples current frame
  33807. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33808. */
  33809. sampleFrame(timeMs?: number): void;
  33810. /**
  33811. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFrameTime(): number;
  33814. /**
  33815. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33816. */
  33817. get averageFrameTimeVariance(): number;
  33818. /**
  33819. * Returns the frame time of the most recent frame
  33820. */
  33821. get instantaneousFrameTime(): number;
  33822. /**
  33823. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33824. */
  33825. get averageFPS(): number;
  33826. /**
  33827. * Returns the average framerate in frames per second using the most recent frame time
  33828. */
  33829. get instantaneousFPS(): number;
  33830. /**
  33831. * Returns true if enough samples have been taken to completely fill the sliding window
  33832. */
  33833. get isSaturated(): boolean;
  33834. /**
  33835. * Enables contributions to the sliding window sample set
  33836. */
  33837. enable(): void;
  33838. /**
  33839. * Disables contributions to the sliding window sample set
  33840. * Samples will not be interpolated over the disabled period
  33841. */
  33842. disable(): void;
  33843. /**
  33844. * Returns true if sampling is enabled
  33845. */
  33846. get isEnabled(): boolean;
  33847. /**
  33848. * Resets performance monitor
  33849. */
  33850. reset(): void;
  33851. }
  33852. /**
  33853. * RollingAverage
  33854. *
  33855. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33856. */
  33857. export class RollingAverage {
  33858. /**
  33859. * Current average
  33860. */
  33861. average: number;
  33862. /**
  33863. * Current variance
  33864. */
  33865. variance: number;
  33866. protected _samples: Array<number>;
  33867. protected _sampleCount: number;
  33868. protected _pos: number;
  33869. protected _m2: number;
  33870. /**
  33871. * constructor
  33872. * @param length The number of samples required to saturate the sliding window
  33873. */
  33874. constructor(length: number);
  33875. /**
  33876. * Adds a sample to the sample set
  33877. * @param v The sample value
  33878. */
  33879. add(v: number): void;
  33880. /**
  33881. * Returns previously added values or null if outside of history or outside the sliding window domain
  33882. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33883. * @return Value previously recorded with add() or null if outside of range
  33884. */
  33885. history(i: number): number;
  33886. /**
  33887. * Returns true if enough samples have been taken to completely fill the sliding window
  33888. * @return true if sample-set saturated
  33889. */
  33890. isSaturated(): boolean;
  33891. /**
  33892. * Resets the rolling average (equivalent to 0 samples taken so far)
  33893. */
  33894. reset(): void;
  33895. /**
  33896. * Wraps a value around the sample range boundaries
  33897. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33898. * @return Wrapped position in sample range
  33899. */
  33900. protected _wrapPosition(i: number): number;
  33901. }
  33902. }
  33903. declare module "babylonjs/Misc/perfCounter" {
  33904. /**
  33905. * This class is used to track a performance counter which is number based.
  33906. * The user has access to many properties which give statistics of different nature.
  33907. *
  33908. * The implementer can track two kinds of Performance Counter: time and count.
  33909. * 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.
  33910. * 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.
  33911. */
  33912. export class PerfCounter {
  33913. /**
  33914. * Gets or sets a global boolean to turn on and off all the counters
  33915. */
  33916. static Enabled: boolean;
  33917. /**
  33918. * Returns the smallest value ever
  33919. */
  33920. get min(): number;
  33921. /**
  33922. * Returns the biggest value ever
  33923. */
  33924. get max(): number;
  33925. /**
  33926. * Returns the average value since the performance counter is running
  33927. */
  33928. get average(): number;
  33929. /**
  33930. * Returns the average value of the last second the counter was monitored
  33931. */
  33932. get lastSecAverage(): number;
  33933. /**
  33934. * Returns the current value
  33935. */
  33936. get current(): number;
  33937. /**
  33938. * Gets the accumulated total
  33939. */
  33940. get total(): number;
  33941. /**
  33942. * Gets the total value count
  33943. */
  33944. get count(): number;
  33945. /**
  33946. * Creates a new counter
  33947. */
  33948. constructor();
  33949. /**
  33950. * Call this method to start monitoring a new frame.
  33951. * 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.
  33952. */
  33953. fetchNewFrame(): void;
  33954. /**
  33955. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33956. * @param newCount the count value to add to the monitored count
  33957. * @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.
  33958. */
  33959. addCount(newCount: number, fetchResult: boolean): void;
  33960. /**
  33961. * Start monitoring this performance counter
  33962. */
  33963. beginMonitoring(): void;
  33964. /**
  33965. * Compute the time lapsed since the previous beginMonitoring() call.
  33966. * @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
  33967. */
  33968. endMonitoring(newFrame?: boolean): void;
  33969. private _fetchResult;
  33970. private _startMonitoringTime;
  33971. private _min;
  33972. private _max;
  33973. private _average;
  33974. private _current;
  33975. private _totalValueCount;
  33976. private _totalAccumulated;
  33977. private _lastSecAverage;
  33978. private _lastSecAccumulated;
  33979. private _lastSecTime;
  33980. private _lastSecValueCount;
  33981. }
  33982. }
  33983. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33984. module "babylonjs/Engines/thinEngine" {
  33985. interface ThinEngine {
  33986. /**
  33987. * Sets alpha constants used by some alpha blending modes
  33988. * @param r defines the red component
  33989. * @param g defines the green component
  33990. * @param b defines the blue component
  33991. * @param a defines the alpha component
  33992. */
  33993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33994. /**
  33995. * Sets the current alpha mode
  33996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33999. */
  34000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34001. /**
  34002. * Gets the current alpha mode
  34003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34004. * @returns the current alpha mode
  34005. */
  34006. getAlphaMode(): number;
  34007. /**
  34008. * Sets the current alpha equation
  34009. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34010. */
  34011. setAlphaEquation(equation: number): void;
  34012. /**
  34013. * Gets the current alpha equation.
  34014. * @returns the current alpha equation
  34015. */
  34016. getAlphaEquation(): number;
  34017. }
  34018. }
  34019. }
  34020. declare module "babylonjs/Engines/engine" {
  34021. import { Observable } from "babylonjs/Misc/observable";
  34022. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34023. import { Scene } from "babylonjs/scene";
  34024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34025. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34026. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34027. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34028. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34029. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34030. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34031. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34032. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34034. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34035. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34036. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34037. import "babylonjs/Engines/Extensions/engine.alpha";
  34038. import { Material } from "babylonjs/Materials/material";
  34039. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34040. /**
  34041. * Defines the interface used by display changed events
  34042. */
  34043. export interface IDisplayChangedEventArgs {
  34044. /** Gets the vrDisplay object (if any) */
  34045. vrDisplay: Nullable<any>;
  34046. /** Gets a boolean indicating if webVR is supported */
  34047. vrSupported: boolean;
  34048. }
  34049. /**
  34050. * Defines the interface used by objects containing a viewport (like a camera)
  34051. */
  34052. interface IViewportOwnerLike {
  34053. /**
  34054. * Gets or sets the viewport
  34055. */
  34056. viewport: IViewportLike;
  34057. }
  34058. /**
  34059. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34060. */
  34061. export class Engine extends ThinEngine {
  34062. /** Defines that alpha blending is disabled */
  34063. static readonly ALPHA_DISABLE: number;
  34064. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34065. static readonly ALPHA_ADD: number;
  34066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34067. static readonly ALPHA_COMBINE: number;
  34068. /** Defines that alpha blending to DEST - SRC * DEST */
  34069. static readonly ALPHA_SUBTRACT: number;
  34070. /** Defines that alpha blending to SRC * DEST */
  34071. static readonly ALPHA_MULTIPLY: number;
  34072. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34073. static readonly ALPHA_MAXIMIZED: number;
  34074. /** Defines that alpha blending to SRC + DEST */
  34075. static readonly ALPHA_ONEONE: number;
  34076. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34077. static readonly ALPHA_PREMULTIPLIED: number;
  34078. /**
  34079. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34080. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34081. */
  34082. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34083. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34084. static readonly ALPHA_INTERPOLATE: number;
  34085. /**
  34086. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34087. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34088. */
  34089. static readonly ALPHA_SCREENMODE: number;
  34090. /** Defines that the ressource is not delayed*/
  34091. static readonly DELAYLOADSTATE_NONE: number;
  34092. /** Defines that the ressource was successfully delay loaded */
  34093. static readonly DELAYLOADSTATE_LOADED: number;
  34094. /** Defines that the ressource is currently delay loading */
  34095. static readonly DELAYLOADSTATE_LOADING: number;
  34096. /** Defines that the ressource is delayed and has not started loading */
  34097. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34099. static readonly NEVER: number;
  34100. /** 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 */
  34101. static readonly ALWAYS: number;
  34102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34103. static readonly LESS: number;
  34104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34105. static readonly EQUAL: number;
  34106. /** 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 */
  34107. static readonly LEQUAL: number;
  34108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34109. static readonly GREATER: number;
  34110. /** 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 */
  34111. static readonly GEQUAL: number;
  34112. /** 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 */
  34113. static readonly NOTEQUAL: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be kept */
  34115. static readonly KEEP: number;
  34116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34117. static readonly REPLACE: number;
  34118. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34119. static readonly INCR: number;
  34120. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34121. static readonly DECR: number;
  34122. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34123. static readonly INVERT: number;
  34124. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34125. static readonly INCR_WRAP: number;
  34126. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34127. static readonly DECR_WRAP: number;
  34128. /** Texture is not repeating outside of 0..1 UVs */
  34129. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34130. /** Texture is repeating outside of 0..1 UVs */
  34131. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34132. /** Texture is repeating and mirrored */
  34133. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34134. /** ALPHA */
  34135. static readonly TEXTUREFORMAT_ALPHA: number;
  34136. /** LUMINANCE */
  34137. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34138. /** LUMINANCE_ALPHA */
  34139. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34140. /** RGB */
  34141. static readonly TEXTUREFORMAT_RGB: number;
  34142. /** RGBA */
  34143. static readonly TEXTUREFORMAT_RGBA: number;
  34144. /** RED */
  34145. static readonly TEXTUREFORMAT_RED: number;
  34146. /** RED (2nd reference) */
  34147. static readonly TEXTUREFORMAT_R: number;
  34148. /** RG */
  34149. static readonly TEXTUREFORMAT_RG: number;
  34150. /** RED_INTEGER */
  34151. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34152. /** RED_INTEGER (2nd reference) */
  34153. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34154. /** RG_INTEGER */
  34155. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34156. /** RGB_INTEGER */
  34157. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34158. /** RGBA_INTEGER */
  34159. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34160. /** UNSIGNED_BYTE */
  34161. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34162. /** UNSIGNED_BYTE (2nd reference) */
  34163. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34164. /** FLOAT */
  34165. static readonly TEXTURETYPE_FLOAT: number;
  34166. /** HALF_FLOAT */
  34167. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34168. /** BYTE */
  34169. static readonly TEXTURETYPE_BYTE: number;
  34170. /** SHORT */
  34171. static readonly TEXTURETYPE_SHORT: number;
  34172. /** UNSIGNED_SHORT */
  34173. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34174. /** INT */
  34175. static readonly TEXTURETYPE_INT: number;
  34176. /** UNSIGNED_INT */
  34177. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34178. /** UNSIGNED_SHORT_4_4_4_4 */
  34179. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34180. /** UNSIGNED_SHORT_5_5_5_1 */
  34181. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34182. /** UNSIGNED_SHORT_5_6_5 */
  34183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34184. /** UNSIGNED_INT_2_10_10_10_REV */
  34185. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34186. /** UNSIGNED_INT_24_8 */
  34187. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34188. /** UNSIGNED_INT_10F_11F_11F_REV */
  34189. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34190. /** UNSIGNED_INT_5_9_9_9_REV */
  34191. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34192. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34193. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34194. /** nearest is mag = nearest and min = nearest and mip = linear */
  34195. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34197. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34198. /** Trilinear is mag = linear and min = linear and mip = linear */
  34199. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34200. /** nearest is mag = nearest and min = nearest and mip = linear */
  34201. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34202. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34203. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34204. /** Trilinear is mag = linear and min = linear and mip = linear */
  34205. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34206. /** mag = nearest and min = nearest and mip = nearest */
  34207. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34208. /** mag = nearest and min = linear and mip = nearest */
  34209. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34210. /** mag = nearest and min = linear and mip = linear */
  34211. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34212. /** mag = nearest and min = linear and mip = none */
  34213. static readonly TEXTURE_NEAREST_LINEAR: number;
  34214. /** mag = nearest and min = nearest and mip = none */
  34215. static readonly TEXTURE_NEAREST_NEAREST: number;
  34216. /** mag = linear and min = nearest and mip = nearest */
  34217. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34218. /** mag = linear and min = nearest and mip = linear */
  34219. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34220. /** mag = linear and min = linear and mip = none */
  34221. static readonly TEXTURE_LINEAR_LINEAR: number;
  34222. /** mag = linear and min = nearest and mip = none */
  34223. static readonly TEXTURE_LINEAR_NEAREST: number;
  34224. /** Explicit coordinates mode */
  34225. static readonly TEXTURE_EXPLICIT_MODE: number;
  34226. /** Spherical coordinates mode */
  34227. static readonly TEXTURE_SPHERICAL_MODE: number;
  34228. /** Planar coordinates mode */
  34229. static readonly TEXTURE_PLANAR_MODE: number;
  34230. /** Cubic coordinates mode */
  34231. static readonly TEXTURE_CUBIC_MODE: number;
  34232. /** Projection coordinates mode */
  34233. static readonly TEXTURE_PROJECTION_MODE: number;
  34234. /** Skybox coordinates mode */
  34235. static readonly TEXTURE_SKYBOX_MODE: number;
  34236. /** Inverse Cubic coordinates mode */
  34237. static readonly TEXTURE_INVCUBIC_MODE: number;
  34238. /** Equirectangular coordinates mode */
  34239. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34240. /** Equirectangular Fixed coordinates mode */
  34241. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34242. /** Equirectangular Fixed Mirrored coordinates mode */
  34243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34244. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34245. static readonly SCALEMODE_FLOOR: number;
  34246. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34247. static readonly SCALEMODE_NEAREST: number;
  34248. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34249. static readonly SCALEMODE_CEILING: number;
  34250. /**
  34251. * Returns the current npm package of the sdk
  34252. */
  34253. static get NpmPackage(): string;
  34254. /**
  34255. * Returns the current version of the framework
  34256. */
  34257. static get Version(): string;
  34258. /** Gets the list of created engines */
  34259. static get Instances(): Engine[];
  34260. /**
  34261. * Gets the latest created engine
  34262. */
  34263. static get LastCreatedEngine(): Nullable<Engine>;
  34264. /**
  34265. * Gets the latest created scene
  34266. */
  34267. static get LastCreatedScene(): Nullable<Scene>;
  34268. /**
  34269. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34270. * @param flag defines which part of the materials must be marked as dirty
  34271. * @param predicate defines a predicate used to filter which materials should be affected
  34272. */
  34273. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34274. /**
  34275. * Method called to create the default loading screen.
  34276. * This can be overriden in your own app.
  34277. * @param canvas The rendering canvas element
  34278. * @returns The loading screen
  34279. */
  34280. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34281. /**
  34282. * Method called to create the default rescale post process on each engine.
  34283. */
  34284. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34285. /**
  34286. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34287. **/
  34288. enableOfflineSupport: boolean;
  34289. /**
  34290. * 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)
  34291. **/
  34292. disableManifestCheck: boolean;
  34293. /**
  34294. * Gets the list of created scenes
  34295. */
  34296. scenes: Scene[];
  34297. /**
  34298. * Event raised when a new scene is created
  34299. */
  34300. onNewSceneAddedObservable: Observable<Scene>;
  34301. /**
  34302. * Gets the list of created postprocesses
  34303. */
  34304. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34305. /**
  34306. * Gets a boolean indicating if the pointer is currently locked
  34307. */
  34308. isPointerLock: boolean;
  34309. /**
  34310. * Observable event triggered each time the rendering canvas is resized
  34311. */
  34312. onResizeObservable: Observable<Engine>;
  34313. /**
  34314. * Observable event triggered each time the canvas loses focus
  34315. */
  34316. onCanvasBlurObservable: Observable<Engine>;
  34317. /**
  34318. * Observable event triggered each time the canvas gains focus
  34319. */
  34320. onCanvasFocusObservable: Observable<Engine>;
  34321. /**
  34322. * Observable event triggered each time the canvas receives pointerout event
  34323. */
  34324. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34325. /**
  34326. * Observable raised when the engine begins a new frame
  34327. */
  34328. onBeginFrameObservable: Observable<Engine>;
  34329. /**
  34330. * If set, will be used to request the next animation frame for the render loop
  34331. */
  34332. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34333. /**
  34334. * Observable raised when the engine ends the current frame
  34335. */
  34336. onEndFrameObservable: Observable<Engine>;
  34337. /**
  34338. * Observable raised when the engine is about to compile a shader
  34339. */
  34340. onBeforeShaderCompilationObservable: Observable<Engine>;
  34341. /**
  34342. * Observable raised when the engine has jsut compiled a shader
  34343. */
  34344. onAfterShaderCompilationObservable: Observable<Engine>;
  34345. /**
  34346. * Gets the audio engine
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34348. * @ignorenaming
  34349. */
  34350. static audioEngine: IAudioEngine;
  34351. /**
  34352. * Default AudioEngine factory responsible of creating the Audio Engine.
  34353. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34354. */
  34355. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34356. /**
  34357. * Default offline support factory responsible of creating a tool used to store data locally.
  34358. * By default, this will create a Database object if the workload has been embedded.
  34359. */
  34360. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34361. private _loadingScreen;
  34362. private _pointerLockRequested;
  34363. private _dummyFramebuffer;
  34364. private _rescalePostProcess;
  34365. private _deterministicLockstep;
  34366. private _lockstepMaxSteps;
  34367. private _timeStep;
  34368. protected get _supportsHardwareTextureRescaling(): boolean;
  34369. private _fps;
  34370. private _deltaTime;
  34371. /** @hidden */
  34372. _drawCalls: PerfCounter;
  34373. /** 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 */
  34374. canvasTabIndex: number;
  34375. /**
  34376. * Turn this value on if you want to pause FPS computation when in background
  34377. */
  34378. disablePerformanceMonitorInBackground: boolean;
  34379. private _performanceMonitor;
  34380. /**
  34381. * Gets the performance monitor attached to this engine
  34382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34383. */
  34384. get performanceMonitor(): PerformanceMonitor;
  34385. private _onFocus;
  34386. private _onBlur;
  34387. private _onCanvasPointerOut;
  34388. private _onCanvasBlur;
  34389. private _onCanvasFocus;
  34390. private _onFullscreenChange;
  34391. private _onPointerLockChange;
  34392. /**
  34393. * Gets the HTML element used to attach event listeners
  34394. * @returns a HTML element
  34395. */
  34396. getInputElement(): Nullable<HTMLElement>;
  34397. /**
  34398. * Creates a new engine
  34399. * @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
  34400. * @param antialias defines enable antialiasing (default: false)
  34401. * @param options defines further options to be sent to the getContext() function
  34402. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34403. */
  34404. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34405. /**
  34406. * Gets current aspect ratio
  34407. * @param viewportOwner defines the camera to use to get the aspect ratio
  34408. * @param useScreen defines if screen size must be used (or the current render target if any)
  34409. * @returns a number defining the aspect ratio
  34410. */
  34411. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34412. /**
  34413. * Gets current screen aspect ratio
  34414. * @returns a number defining the aspect ratio
  34415. */
  34416. getScreenAspectRatio(): number;
  34417. /**
  34418. * Gets the client rect of the HTML canvas attached with the current webGL context
  34419. * @returns a client rectanglee
  34420. */
  34421. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34422. /**
  34423. * Gets the client rect of the HTML element used for events
  34424. * @returns a client rectanglee
  34425. */
  34426. getInputElementClientRect(): Nullable<ClientRect>;
  34427. /**
  34428. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34430. * @returns true if engine is in deterministic lock step mode
  34431. */
  34432. isDeterministicLockStep(): boolean;
  34433. /**
  34434. * Gets the max steps when engine is running in deterministic lock step
  34435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34436. * @returns the max steps
  34437. */
  34438. getLockstepMaxSteps(): number;
  34439. /**
  34440. * Returns the time in ms between steps when using deterministic lock step.
  34441. * @returns time step in (ms)
  34442. */
  34443. getTimeStep(): number;
  34444. /**
  34445. * Force the mipmap generation for the given render target texture
  34446. * @param texture defines the render target texture to use
  34447. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34448. */
  34449. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34450. /** States */
  34451. /**
  34452. * Set various states to the webGL context
  34453. * @param culling defines backface culling state
  34454. * @param zOffset defines the value to apply to zOffset (0 by default)
  34455. * @param force defines if states must be applied even if cache is up to date
  34456. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34457. */
  34458. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34459. /**
  34460. * Set the z offset to apply to current rendering
  34461. * @param value defines the offset to apply
  34462. */
  34463. setZOffset(value: number): void;
  34464. /**
  34465. * Gets the current value of the zOffset
  34466. * @returns the current zOffset state
  34467. */
  34468. getZOffset(): number;
  34469. /**
  34470. * Enable or disable depth buffering
  34471. * @param enable defines the state to set
  34472. */
  34473. setDepthBuffer(enable: boolean): void;
  34474. /**
  34475. * Gets a boolean indicating if depth writing is enabled
  34476. * @returns the current depth writing state
  34477. */
  34478. getDepthWrite(): boolean;
  34479. /**
  34480. * Enable or disable depth writing
  34481. * @param enable defines the state to set
  34482. */
  34483. setDepthWrite(enable: boolean): void;
  34484. /**
  34485. * Gets a boolean indicating if stencil buffer is enabled
  34486. * @returns the current stencil buffer state
  34487. */
  34488. getStencilBuffer(): boolean;
  34489. /**
  34490. * Enable or disable the stencil buffer
  34491. * @param enable defines if the stencil buffer must be enabled or disabled
  34492. */
  34493. setStencilBuffer(enable: boolean): void;
  34494. /**
  34495. * Gets the current stencil mask
  34496. * @returns a number defining the new stencil mask to use
  34497. */
  34498. getStencilMask(): number;
  34499. /**
  34500. * Sets the current stencil mask
  34501. * @param mask defines the new stencil mask to use
  34502. */
  34503. setStencilMask(mask: number): void;
  34504. /**
  34505. * Gets the current stencil function
  34506. * @returns a number defining the stencil function to use
  34507. */
  34508. getStencilFunction(): number;
  34509. /**
  34510. * Gets the current stencil reference value
  34511. * @returns a number defining the stencil reference value to use
  34512. */
  34513. getStencilFunctionReference(): number;
  34514. /**
  34515. * Gets the current stencil mask
  34516. * @returns a number defining the stencil mask to use
  34517. */
  34518. getStencilFunctionMask(): number;
  34519. /**
  34520. * Sets the current stencil function
  34521. * @param stencilFunc defines the new stencil function to use
  34522. */
  34523. setStencilFunction(stencilFunc: number): void;
  34524. /**
  34525. * Sets the current stencil reference
  34526. * @param reference defines the new stencil reference to use
  34527. */
  34528. setStencilFunctionReference(reference: number): void;
  34529. /**
  34530. * Sets the current stencil mask
  34531. * @param mask defines the new stencil mask to use
  34532. */
  34533. setStencilFunctionMask(mask: number): void;
  34534. /**
  34535. * Gets the current stencil operation when stencil fails
  34536. * @returns a number defining stencil operation to use when stencil fails
  34537. */
  34538. getStencilOperationFail(): number;
  34539. /**
  34540. * Gets the current stencil operation when depth fails
  34541. * @returns a number defining stencil operation to use when depth fails
  34542. */
  34543. getStencilOperationDepthFail(): number;
  34544. /**
  34545. * Gets the current stencil operation when stencil passes
  34546. * @returns a number defining stencil operation to use when stencil passes
  34547. */
  34548. getStencilOperationPass(): number;
  34549. /**
  34550. * Sets the stencil operation to use when stencil fails
  34551. * @param operation defines the stencil operation to use when stencil fails
  34552. */
  34553. setStencilOperationFail(operation: number): void;
  34554. /**
  34555. * Sets the stencil operation to use when depth fails
  34556. * @param operation defines the stencil operation to use when depth fails
  34557. */
  34558. setStencilOperationDepthFail(operation: number): void;
  34559. /**
  34560. * Sets the stencil operation to use when stencil passes
  34561. * @param operation defines the stencil operation to use when stencil passes
  34562. */
  34563. setStencilOperationPass(operation: number): void;
  34564. /**
  34565. * Sets a boolean indicating if the dithering state is enabled or disabled
  34566. * @param value defines the dithering state
  34567. */
  34568. setDitheringState(value: boolean): void;
  34569. /**
  34570. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34571. * @param value defines the rasterizer state
  34572. */
  34573. setRasterizerState(value: boolean): void;
  34574. /**
  34575. * Gets the current depth function
  34576. * @returns a number defining the depth function
  34577. */
  34578. getDepthFunction(): Nullable<number>;
  34579. /**
  34580. * Sets the current depth function
  34581. * @param depthFunc defines the function to use
  34582. */
  34583. setDepthFunction(depthFunc: number): void;
  34584. /**
  34585. * Sets the current depth function to GREATER
  34586. */
  34587. setDepthFunctionToGreater(): void;
  34588. /**
  34589. * Sets the current depth function to GEQUAL
  34590. */
  34591. setDepthFunctionToGreaterOrEqual(): void;
  34592. /**
  34593. * Sets the current depth function to LESS
  34594. */
  34595. setDepthFunctionToLess(): void;
  34596. /**
  34597. * Sets the current depth function to LEQUAL
  34598. */
  34599. setDepthFunctionToLessOrEqual(): void;
  34600. private _cachedStencilBuffer;
  34601. private _cachedStencilFunction;
  34602. private _cachedStencilMask;
  34603. private _cachedStencilOperationPass;
  34604. private _cachedStencilOperationFail;
  34605. private _cachedStencilOperationDepthFail;
  34606. private _cachedStencilReference;
  34607. /**
  34608. * Caches the the state of the stencil buffer
  34609. */
  34610. cacheStencilState(): void;
  34611. /**
  34612. * Restores the state of the stencil buffer
  34613. */
  34614. restoreStencilState(): void;
  34615. /**
  34616. * Directly set the WebGL Viewport
  34617. * @param x defines the x coordinate of the viewport (in screen space)
  34618. * @param y defines the y coordinate of the viewport (in screen space)
  34619. * @param width defines the width of the viewport (in screen space)
  34620. * @param height defines the height of the viewport (in screen space)
  34621. * @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
  34622. */
  34623. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34624. /**
  34625. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34626. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34627. * @param y defines the y-coordinate of the corner of the clear rectangle
  34628. * @param width defines the width of the clear rectangle
  34629. * @param height defines the height of the clear rectangle
  34630. * @param clearColor defines the clear color
  34631. */
  34632. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34633. /**
  34634. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34635. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34636. * @param y defines the y-coordinate of the corner of the clear rectangle
  34637. * @param width defines the width of the clear rectangle
  34638. * @param height defines the height of the clear rectangle
  34639. */
  34640. enableScissor(x: number, y: number, width: number, height: number): void;
  34641. /**
  34642. * Disable previously set scissor test rectangle
  34643. */
  34644. disableScissor(): void;
  34645. protected _reportDrawCall(): void;
  34646. /**
  34647. * Initializes a webVR display and starts listening to display change events
  34648. * The onVRDisplayChangedObservable will be notified upon these changes
  34649. * @returns The onVRDisplayChangedObservable
  34650. */
  34651. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34652. /** @hidden */
  34653. _prepareVRComponent(): void;
  34654. /** @hidden */
  34655. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34656. /** @hidden */
  34657. _submitVRFrame(): void;
  34658. /**
  34659. * Call this function to leave webVR mode
  34660. * Will do nothing if webVR is not supported or if there is no webVR device
  34661. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34662. */
  34663. disableVR(): void;
  34664. /**
  34665. * Gets a boolean indicating that the system is in VR mode and is presenting
  34666. * @returns true if VR mode is engaged
  34667. */
  34668. isVRPresenting(): boolean;
  34669. /** @hidden */
  34670. _requestVRFrame(): void;
  34671. /** @hidden */
  34672. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34673. /**
  34674. * Gets the source code of the vertex shader associated with a specific webGL program
  34675. * @param program defines the program to use
  34676. * @returns a string containing the source code of the vertex shader associated with the program
  34677. */
  34678. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34679. /**
  34680. * Gets the source code of the fragment shader associated with a specific webGL program
  34681. * @param program defines the program to use
  34682. * @returns a string containing the source code of the fragment shader associated with the program
  34683. */
  34684. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34685. /**
  34686. * Sets a depth stencil texture from a render target to the according uniform.
  34687. * @param channel The texture channel
  34688. * @param uniform The uniform to set
  34689. * @param texture The render target texture containing the depth stencil texture to apply
  34690. */
  34691. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34692. /**
  34693. * Sets a texture to the webGL context from a postprocess
  34694. * @param channel defines the channel to use
  34695. * @param postProcess defines the source postprocess
  34696. */
  34697. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34698. /**
  34699. * Binds the output of the passed in post process to the texture channel specified
  34700. * @param channel The channel the texture should be bound to
  34701. * @param postProcess The post process which's output should be bound
  34702. */
  34703. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34704. /** @hidden */
  34705. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34706. protected _rebuildBuffers(): void;
  34707. /** @hidden */
  34708. _renderFrame(): void;
  34709. _renderLoop(): void;
  34710. /** @hidden */
  34711. _renderViews(): boolean;
  34712. /**
  34713. * Toggle full screen mode
  34714. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34715. */
  34716. switchFullscreen(requestPointerLock: boolean): void;
  34717. /**
  34718. * Enters full screen mode
  34719. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34720. */
  34721. enterFullscreen(requestPointerLock: boolean): void;
  34722. /**
  34723. * Exits full screen mode
  34724. */
  34725. exitFullscreen(): void;
  34726. /**
  34727. * Enters Pointerlock mode
  34728. */
  34729. enterPointerlock(): void;
  34730. /**
  34731. * Exits Pointerlock mode
  34732. */
  34733. exitPointerlock(): void;
  34734. /**
  34735. * Begin a new frame
  34736. */
  34737. beginFrame(): void;
  34738. /**
  34739. * Enf the current frame
  34740. */
  34741. endFrame(): void;
  34742. resize(): void;
  34743. /**
  34744. * Force a specific size of the canvas
  34745. * @param width defines the new canvas' width
  34746. * @param height defines the new canvas' height
  34747. */
  34748. setSize(width: number, height: number): void;
  34749. /**
  34750. * Updates a dynamic vertex buffer.
  34751. * @param vertexBuffer the vertex buffer to update
  34752. * @param data the data used to update the vertex buffer
  34753. * @param byteOffset the byte offset of the data
  34754. * @param byteLength the byte length of the data
  34755. */
  34756. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34757. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34758. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34759. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34760. _releaseTexture(texture: InternalTexture): void;
  34761. /**
  34762. * @hidden
  34763. * Rescales a texture
  34764. * @param source input texutre
  34765. * @param destination destination texture
  34766. * @param scene scene to use to render the resize
  34767. * @param internalFormat format to use when resizing
  34768. * @param onComplete callback to be called when resize has completed
  34769. */
  34770. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34771. /**
  34772. * Gets the current framerate
  34773. * @returns a number representing the framerate
  34774. */
  34775. getFps(): number;
  34776. /**
  34777. * Gets the time spent between current and previous frame
  34778. * @returns a number representing the delta time in ms
  34779. */
  34780. getDeltaTime(): number;
  34781. private _measureFps;
  34782. /** @hidden */
  34783. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34784. /**
  34785. * Update a dynamic index buffer
  34786. * @param indexBuffer defines the target index buffer
  34787. * @param indices defines the data to update
  34788. * @param offset defines the offset in the target index buffer where update should start
  34789. */
  34790. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34791. /**
  34792. * Updates the sample count of a render target texture
  34793. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34794. * @param texture defines the texture to update
  34795. * @param samples defines the sample count to set
  34796. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34797. */
  34798. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34799. /**
  34800. * Updates a depth texture Comparison Mode and Function.
  34801. * If the comparison Function is equal to 0, the mode will be set to none.
  34802. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34803. * @param texture The texture to set the comparison function for
  34804. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34805. */
  34806. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34807. /**
  34808. * Creates a webGL buffer to use with instanciation
  34809. * @param capacity defines the size of the buffer
  34810. * @returns the webGL buffer
  34811. */
  34812. createInstancesBuffer(capacity: number): DataBuffer;
  34813. /**
  34814. * Delete a webGL buffer used with instanciation
  34815. * @param buffer defines the webGL buffer to delete
  34816. */
  34817. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34818. private _clientWaitAsync;
  34819. /** @hidden */
  34820. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34821. /** @hidden */
  34822. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34823. dispose(): void;
  34824. private _disableTouchAction;
  34825. /**
  34826. * Display the loading screen
  34827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34828. */
  34829. displayLoadingUI(): void;
  34830. /**
  34831. * Hide the loading screen
  34832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34833. */
  34834. hideLoadingUI(): void;
  34835. /**
  34836. * Gets the current loading screen object
  34837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34838. */
  34839. get loadingScreen(): ILoadingScreen;
  34840. /**
  34841. * Sets the current loading screen object
  34842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34843. */
  34844. set loadingScreen(loadingScreen: ILoadingScreen);
  34845. /**
  34846. * Sets the current loading screen text
  34847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34848. */
  34849. set loadingUIText(text: string);
  34850. /**
  34851. * Sets the current loading screen background color
  34852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34853. */
  34854. set loadingUIBackgroundColor(color: string);
  34855. /** Pointerlock and fullscreen */
  34856. /**
  34857. * Ask the browser to promote the current element to pointerlock mode
  34858. * @param element defines the DOM element to promote
  34859. */
  34860. static _RequestPointerlock(element: HTMLElement): void;
  34861. /**
  34862. * Asks the browser to exit pointerlock mode
  34863. */
  34864. static _ExitPointerlock(): void;
  34865. /**
  34866. * Ask the browser to promote the current element to fullscreen rendering mode
  34867. * @param element defines the DOM element to promote
  34868. */
  34869. static _RequestFullscreen(element: HTMLElement): void;
  34870. /**
  34871. * Asks the browser to exit fullscreen mode
  34872. */
  34873. static _ExitFullscreen(): void;
  34874. }
  34875. }
  34876. declare module "babylonjs/Engines/engineStore" {
  34877. import { Nullable } from "babylonjs/types";
  34878. import { Engine } from "babylonjs/Engines/engine";
  34879. import { Scene } from "babylonjs/scene";
  34880. /**
  34881. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34882. * during the life time of the application.
  34883. */
  34884. export class EngineStore {
  34885. /** Gets the list of created engines */
  34886. static Instances: import("babylonjs/Engines/engine").Engine[];
  34887. /** @hidden */
  34888. static _LastCreatedScene: Nullable<Scene>;
  34889. /**
  34890. * Gets the latest created engine
  34891. */
  34892. static get LastCreatedEngine(): Nullable<Engine>;
  34893. /**
  34894. * Gets the latest created scene
  34895. */
  34896. static get LastCreatedScene(): Nullable<Scene>;
  34897. /**
  34898. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34899. * @ignorenaming
  34900. */
  34901. static UseFallbackTexture: boolean;
  34902. /**
  34903. * Texture content used if a texture cannot loaded
  34904. * @ignorenaming
  34905. */
  34906. static FallbackTexture: string;
  34907. }
  34908. }
  34909. declare module "babylonjs/Misc/promise" {
  34910. /**
  34911. * Helper class that provides a small promise polyfill
  34912. */
  34913. export class PromisePolyfill {
  34914. /**
  34915. * Static function used to check if the polyfill is required
  34916. * If this is the case then the function will inject the polyfill to window.Promise
  34917. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34918. */
  34919. static Apply(force?: boolean): void;
  34920. }
  34921. }
  34922. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34923. /**
  34924. * Interface for screenshot methods with describe argument called `size` as object with options
  34925. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34926. */
  34927. export interface IScreenshotSize {
  34928. /**
  34929. * number in pixels for canvas height
  34930. */
  34931. height?: number;
  34932. /**
  34933. * multiplier allowing render at a higher or lower resolution
  34934. * If value is defined then height and width will be ignored and taken from camera
  34935. */
  34936. precision?: number;
  34937. /**
  34938. * number in pixels for canvas width
  34939. */
  34940. width?: number;
  34941. }
  34942. }
  34943. declare module "babylonjs/Misc/tools" {
  34944. import { Nullable, float } from "babylonjs/types";
  34945. import { DomManagement } from "babylonjs/Misc/domManagement";
  34946. import { WebRequest } from "babylonjs/Misc/webRequest";
  34947. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34948. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34949. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34950. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34951. import { Camera } from "babylonjs/Cameras/camera";
  34952. import { Engine } from "babylonjs/Engines/engine";
  34953. interface IColor4Like {
  34954. r: float;
  34955. g: float;
  34956. b: float;
  34957. a: float;
  34958. }
  34959. /**
  34960. * Class containing a set of static utilities functions
  34961. */
  34962. export class Tools {
  34963. /**
  34964. * Gets or sets the base URL to use to load assets
  34965. */
  34966. static get BaseUrl(): string;
  34967. static set BaseUrl(value: string);
  34968. /**
  34969. * Enable/Disable Custom HTTP Request Headers globally.
  34970. * default = false
  34971. * @see CustomRequestHeaders
  34972. */
  34973. static UseCustomRequestHeaders: boolean;
  34974. /**
  34975. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34976. * i.e. when loading files, where the server/service expects an Authorization header
  34977. */
  34978. static CustomRequestHeaders: {
  34979. [key: string]: string;
  34980. };
  34981. /**
  34982. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34983. */
  34984. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34985. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34986. /**
  34987. * Default behaviour for cors in the application.
  34988. * It can be a string if the expected behavior is identical in the entire app.
  34989. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34990. */
  34991. static CorsBehavior: string | ((url: string | string[]) => string);
  34992. /**
  34993. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34994. * @ignorenaming
  34995. */
  34996. static get UseFallbackTexture(): boolean;
  34997. static set UseFallbackTexture(value: boolean);
  34998. /**
  34999. * Use this object to register external classes like custom textures or material
  35000. * to allow the laoders to instantiate them
  35001. */
  35002. static get RegisteredExternalClasses(): {
  35003. [key: string]: Object;
  35004. };
  35005. static set RegisteredExternalClasses(classes: {
  35006. [key: string]: Object;
  35007. });
  35008. /**
  35009. * Texture content used if a texture cannot loaded
  35010. * @ignorenaming
  35011. */
  35012. static get fallbackTexture(): string;
  35013. static set fallbackTexture(value: string);
  35014. /**
  35015. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35016. * @param u defines the coordinate on X axis
  35017. * @param v defines the coordinate on Y axis
  35018. * @param width defines the width of the source data
  35019. * @param height defines the height of the source data
  35020. * @param pixels defines the source byte array
  35021. * @param color defines the output color
  35022. */
  35023. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35024. /**
  35025. * Interpolates between a and b via alpha
  35026. * @param a The lower value (returned when alpha = 0)
  35027. * @param b The upper value (returned when alpha = 1)
  35028. * @param alpha The interpolation-factor
  35029. * @return The mixed value
  35030. */
  35031. static Mix(a: number, b: number, alpha: number): number;
  35032. /**
  35033. * Tries to instantiate a new object from a given class name
  35034. * @param className defines the class name to instantiate
  35035. * @returns the new object or null if the system was not able to do the instantiation
  35036. */
  35037. static Instantiate(className: string): any;
  35038. /**
  35039. * Provides a slice function that will work even on IE
  35040. * @param data defines the array to slice
  35041. * @param start defines the start of the data (optional)
  35042. * @param end defines the end of the data (optional)
  35043. * @returns the new sliced array
  35044. */
  35045. static Slice<T>(data: T, start?: number, end?: number): T;
  35046. /**
  35047. * Polyfill for setImmediate
  35048. * @param action defines the action to execute after the current execution block
  35049. */
  35050. static SetImmediate(action: () => void): void;
  35051. /**
  35052. * Function indicating if a number is an exponent of 2
  35053. * @param value defines the value to test
  35054. * @returns true if the value is an exponent of 2
  35055. */
  35056. static IsExponentOfTwo(value: number): boolean;
  35057. private static _tmpFloatArray;
  35058. /**
  35059. * Returns the nearest 32-bit single precision float representation of a Number
  35060. * @param value A Number. If the parameter is of a different type, it will get converted
  35061. * to a number or to NaN if it cannot be converted
  35062. * @returns number
  35063. */
  35064. static FloatRound(value: number): number;
  35065. /**
  35066. * Extracts the filename from a path
  35067. * @param path defines the path to use
  35068. * @returns the filename
  35069. */
  35070. static GetFilename(path: string): string;
  35071. /**
  35072. * Extracts the "folder" part of a path (everything before the filename).
  35073. * @param uri The URI to extract the info from
  35074. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35075. * @returns The "folder" part of the path
  35076. */
  35077. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35078. /**
  35079. * Extracts text content from a DOM element hierarchy
  35080. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35081. */
  35082. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35083. /**
  35084. * Convert an angle in radians to degrees
  35085. * @param angle defines the angle to convert
  35086. * @returns the angle in degrees
  35087. */
  35088. static ToDegrees(angle: number): number;
  35089. /**
  35090. * Convert an angle in degrees to radians
  35091. * @param angle defines the angle to convert
  35092. * @returns the angle in radians
  35093. */
  35094. static ToRadians(angle: number): number;
  35095. /**
  35096. * Returns an array if obj is not an array
  35097. * @param obj defines the object to evaluate as an array
  35098. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35099. * @returns either obj directly if obj is an array or a new array containing obj
  35100. */
  35101. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35102. /**
  35103. * Gets the pointer prefix to use
  35104. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35105. */
  35106. static GetPointerPrefix(): string;
  35107. /**
  35108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35109. * @param url define the url we are trying
  35110. * @param element define the dom element where to configure the cors policy
  35111. */
  35112. static SetCorsBehavior(url: string | string[], element: {
  35113. crossOrigin: string | null;
  35114. }): void;
  35115. /**
  35116. * Removes unwanted characters from an url
  35117. * @param url defines the url to clean
  35118. * @returns the cleaned url
  35119. */
  35120. static CleanUrl(url: string): string;
  35121. /**
  35122. * Gets or sets a function used to pre-process url before using them to load assets
  35123. */
  35124. static get PreprocessUrl(): (url: string) => string;
  35125. static set PreprocessUrl(processor: (url: string) => string);
  35126. /**
  35127. * Loads an image as an HTMLImageElement.
  35128. * @param input url string, ArrayBuffer, or Blob to load
  35129. * @param onLoad callback called when the image successfully loads
  35130. * @param onError callback called when the image fails to load
  35131. * @param offlineProvider offline provider for caching
  35132. * @param mimeType optional mime type
  35133. * @returns the HTMLImageElement of the loaded image
  35134. */
  35135. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35136. /**
  35137. * Loads a file from a url
  35138. * @param url url string, ArrayBuffer, or Blob to load
  35139. * @param onSuccess callback called when the file successfully loads
  35140. * @param onProgress callback called while file is loading (if the server supports this mode)
  35141. * @param offlineProvider defines the offline provider for caching
  35142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35143. * @param onError callback called when the file fails to load
  35144. * @returns a file request object
  35145. */
  35146. 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;
  35147. /**
  35148. * Loads a file from a url
  35149. * @param url the file url to load
  35150. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35151. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35152. */
  35153. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35154. /**
  35155. * Load a script (identified by an url). When the url returns, the
  35156. * content of this file is added into a new script element, attached to the DOM (body element)
  35157. * @param scriptUrl defines the url of the script to laod
  35158. * @param onSuccess defines the callback called when the script is loaded
  35159. * @param onError defines the callback to call if an error occurs
  35160. * @param scriptId defines the id of the script element
  35161. */
  35162. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35163. /**
  35164. * Load an asynchronous script (identified by an url). When the url returns, the
  35165. * content of this file is added into a new script element, attached to the DOM (body element)
  35166. * @param scriptUrl defines the url of the script to laod
  35167. * @param scriptId defines the id of the script element
  35168. * @returns a promise request object
  35169. */
  35170. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35171. /**
  35172. * Loads a file from a blob
  35173. * @param fileToLoad defines the blob to use
  35174. * @param callback defines the callback to call when data is loaded
  35175. * @param progressCallback defines the callback to call during loading process
  35176. * @returns a file request object
  35177. */
  35178. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35179. /**
  35180. * Reads a file from a File object
  35181. * @param file defines the file to load
  35182. * @param onSuccess defines the callback to call when data is loaded
  35183. * @param onProgress defines the callback to call during loading process
  35184. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35185. * @param onError defines the callback to call when an error occurs
  35186. * @returns a file request object
  35187. */
  35188. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35189. /**
  35190. * Creates a data url from a given string content
  35191. * @param content defines the content to convert
  35192. * @returns the new data url link
  35193. */
  35194. static FileAsURL(content: string): string;
  35195. /**
  35196. * Format the given number to a specific decimal format
  35197. * @param value defines the number to format
  35198. * @param decimals defines the number of decimals to use
  35199. * @returns the formatted string
  35200. */
  35201. static Format(value: number, decimals?: number): string;
  35202. /**
  35203. * Tries to copy an object by duplicating every property
  35204. * @param source defines the source object
  35205. * @param destination defines the target object
  35206. * @param doNotCopyList defines a list of properties to avoid
  35207. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35208. */
  35209. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35210. /**
  35211. * Gets a boolean indicating if the given object has no own property
  35212. * @param obj defines the object to test
  35213. * @returns true if object has no own property
  35214. */
  35215. static IsEmpty(obj: any): boolean;
  35216. /**
  35217. * Function used to register events at window level
  35218. * @param windowElement defines the Window object to use
  35219. * @param events defines the events to register
  35220. */
  35221. static RegisterTopRootEvents(windowElement: Window, events: {
  35222. name: string;
  35223. handler: Nullable<(e: FocusEvent) => any>;
  35224. }[]): void;
  35225. /**
  35226. * Function used to unregister events from window level
  35227. * @param windowElement defines the Window object to use
  35228. * @param events defines the events to unregister
  35229. */
  35230. static UnregisterTopRootEvents(windowElement: Window, events: {
  35231. name: string;
  35232. handler: Nullable<(e: FocusEvent) => any>;
  35233. }[]): void;
  35234. /**
  35235. * @ignore
  35236. */
  35237. static _ScreenshotCanvas: HTMLCanvasElement;
  35238. /**
  35239. * Dumps the current bound framebuffer
  35240. * @param width defines the rendering width
  35241. * @param height defines the rendering height
  35242. * @param engine defines the hosting engine
  35243. * @param successCallback defines the callback triggered once the data are available
  35244. * @param mimeType defines the mime type of the result
  35245. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35246. */
  35247. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35248. /**
  35249. * Converts the canvas data to blob.
  35250. * This acts as a polyfill for browsers not supporting the to blob function.
  35251. * @param canvas Defines the canvas to extract the data from
  35252. * @param successCallback Defines the callback triggered once the data are available
  35253. * @param mimeType Defines the mime type of the result
  35254. */
  35255. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35256. /**
  35257. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35258. * @param successCallback defines the callback triggered once the data are available
  35259. * @param mimeType defines the mime type of the result
  35260. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35261. */
  35262. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35263. /**
  35264. * Downloads a blob in the browser
  35265. * @param blob defines the blob to download
  35266. * @param fileName defines the name of the downloaded file
  35267. */
  35268. static Download(blob: Blob, fileName: string): void;
  35269. /**
  35270. * Captures a screenshot of the current rendering
  35271. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35272. * @param engine defines the rendering engine
  35273. * @param camera defines the source camera
  35274. * @param size This parameter can be set to a single number or to an object with the
  35275. * following (optional) properties: precision, width, height. If a single number is passed,
  35276. * it will be used for both width and height. If an object is passed, the screenshot size
  35277. * will be derived from the parameters. The precision property is a multiplier allowing
  35278. * rendering at a higher or lower resolution
  35279. * @param successCallback defines the callback receives a single parameter which contains the
  35280. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35281. * src parameter of an <img> to display it
  35282. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35283. * Check your browser for supported MIME types
  35284. */
  35285. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35286. /**
  35287. * Captures a screenshot of the current rendering
  35288. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35289. * @param engine defines the rendering engine
  35290. * @param camera defines the source camera
  35291. * @param size This parameter can be set to a single number or to an object with the
  35292. * following (optional) properties: precision, width, height. If a single number is passed,
  35293. * it will be used for both width and height. If an object is passed, the screenshot size
  35294. * will be derived from the parameters. The precision property is a multiplier allowing
  35295. * rendering at a higher or lower resolution
  35296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35297. * Check your browser for supported MIME types
  35298. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35299. * to the src parameter of an <img> to display it
  35300. */
  35301. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35302. /**
  35303. * Generates an image screenshot from the specified camera.
  35304. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35305. * @param engine The engine to use for rendering
  35306. * @param camera The camera to use for rendering
  35307. * @param size This parameter can be set to a single number or to an object with the
  35308. * following (optional) properties: precision, width, height. If a single number is passed,
  35309. * it will be used for both width and height. If an object is passed, the screenshot size
  35310. * will be derived from the parameters. The precision property is a multiplier allowing
  35311. * rendering at a higher or lower resolution
  35312. * @param successCallback The callback receives a single parameter which contains the
  35313. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35314. * src parameter of an <img> to display it
  35315. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35316. * Check your browser for supported MIME types
  35317. * @param samples Texture samples (default: 1)
  35318. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35319. * @param fileName A name for for the downloaded file.
  35320. */
  35321. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35322. /**
  35323. * Generates an image screenshot from the specified camera.
  35324. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35325. * @param engine The engine to use for rendering
  35326. * @param camera The camera to use for rendering
  35327. * @param size This parameter can be set to a single number or to an object with the
  35328. * following (optional) properties: precision, width, height. If a single number is passed,
  35329. * it will be used for both width and height. If an object is passed, the screenshot size
  35330. * will be derived from the parameters. The precision property is a multiplier allowing
  35331. * rendering at a higher or lower resolution
  35332. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35333. * Check your browser for supported MIME types
  35334. * @param samples Texture samples (default: 1)
  35335. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35336. * @param fileName A name for for the downloaded file.
  35337. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35338. * to the src parameter of an <img> to display it
  35339. */
  35340. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35341. /**
  35342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35343. * Be aware Math.random() could cause collisions, but:
  35344. * "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"
  35345. * @returns a pseudo random id
  35346. */
  35347. static RandomId(): string;
  35348. /**
  35349. * Test if the given uri is a base64 string
  35350. * @param uri The uri to test
  35351. * @return True if the uri is a base64 string or false otherwise
  35352. */
  35353. static IsBase64(uri: string): boolean;
  35354. /**
  35355. * Decode the given base64 uri.
  35356. * @param uri The uri to decode
  35357. * @return The decoded base64 data.
  35358. */
  35359. static DecodeBase64(uri: string): ArrayBuffer;
  35360. /**
  35361. * Gets the absolute url.
  35362. * @param url the input url
  35363. * @return the absolute url
  35364. */
  35365. static GetAbsoluteUrl(url: string): string;
  35366. /**
  35367. * No log
  35368. */
  35369. static readonly NoneLogLevel: number;
  35370. /**
  35371. * Only message logs
  35372. */
  35373. static readonly MessageLogLevel: number;
  35374. /**
  35375. * Only warning logs
  35376. */
  35377. static readonly WarningLogLevel: number;
  35378. /**
  35379. * Only error logs
  35380. */
  35381. static readonly ErrorLogLevel: number;
  35382. /**
  35383. * All logs
  35384. */
  35385. static readonly AllLogLevel: number;
  35386. /**
  35387. * Gets a value indicating the number of loading errors
  35388. * @ignorenaming
  35389. */
  35390. static get errorsCount(): number;
  35391. /**
  35392. * Callback called when a new log is added
  35393. */
  35394. static OnNewCacheEntry: (entry: string) => void;
  35395. /**
  35396. * Log a message to the console
  35397. * @param message defines the message to log
  35398. */
  35399. static Log(message: string): void;
  35400. /**
  35401. * Write a warning message to the console
  35402. * @param message defines the message to log
  35403. */
  35404. static Warn(message: string): void;
  35405. /**
  35406. * Write an error message to the console
  35407. * @param message defines the message to log
  35408. */
  35409. static Error(message: string): void;
  35410. /**
  35411. * Gets current log cache (list of logs)
  35412. */
  35413. static get LogCache(): string;
  35414. /**
  35415. * Clears the log cache
  35416. */
  35417. static ClearLogCache(): void;
  35418. /**
  35419. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35420. */
  35421. static set LogLevels(level: number);
  35422. /**
  35423. * Checks if the window object exists
  35424. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35425. */
  35426. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35427. /**
  35428. * No performance log
  35429. */
  35430. static readonly PerformanceNoneLogLevel: number;
  35431. /**
  35432. * Use user marks to log performance
  35433. */
  35434. static readonly PerformanceUserMarkLogLevel: number;
  35435. /**
  35436. * Log performance to the console
  35437. */
  35438. static readonly PerformanceConsoleLogLevel: number;
  35439. private static _performance;
  35440. /**
  35441. * Sets the current performance log level
  35442. */
  35443. static set PerformanceLogLevel(level: number);
  35444. private static _StartPerformanceCounterDisabled;
  35445. private static _EndPerformanceCounterDisabled;
  35446. private static _StartUserMark;
  35447. private static _EndUserMark;
  35448. private static _StartPerformanceConsole;
  35449. private static _EndPerformanceConsole;
  35450. /**
  35451. * Starts a performance counter
  35452. */
  35453. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35454. /**
  35455. * Ends a specific performance coutner
  35456. */
  35457. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35458. /**
  35459. * Gets either window.performance.now() if supported or Date.now() else
  35460. */
  35461. static get Now(): number;
  35462. /**
  35463. * This method will return the name of the class used to create the instance of the given object.
  35464. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35465. * @param object the object to get the class name from
  35466. * @param isType defines if the object is actually a type
  35467. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35468. */
  35469. static GetClassName(object: any, isType?: boolean): string;
  35470. /**
  35471. * Gets the first element of an array satisfying a given predicate
  35472. * @param array defines the array to browse
  35473. * @param predicate defines the predicate to use
  35474. * @returns null if not found or the element
  35475. */
  35476. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35477. /**
  35478. * This method will return the name of the full name of the class, including its owning module (if any).
  35479. * 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).
  35480. * @param object the object to get the class name from
  35481. * @param isType defines if the object is actually a type
  35482. * @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.
  35483. * @ignorenaming
  35484. */
  35485. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35486. /**
  35487. * Returns a promise that resolves after the given amount of time.
  35488. * @param delay Number of milliseconds to delay
  35489. * @returns Promise that resolves after the given amount of time
  35490. */
  35491. static DelayAsync(delay: number): Promise<void>;
  35492. /**
  35493. * Utility function to detect if the current user agent is Safari
  35494. * @returns whether or not the current user agent is safari
  35495. */
  35496. static IsSafari(): boolean;
  35497. }
  35498. /**
  35499. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35500. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35501. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35502. * @param name The name of the class, case should be preserved
  35503. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35504. */
  35505. export function className(name: string, module?: string): (target: Object) => void;
  35506. /**
  35507. * An implementation of a loop for asynchronous functions.
  35508. */
  35509. export class AsyncLoop {
  35510. /**
  35511. * Defines the number of iterations for the loop
  35512. */
  35513. iterations: number;
  35514. /**
  35515. * Defines the current index of the loop.
  35516. */
  35517. index: number;
  35518. private _done;
  35519. private _fn;
  35520. private _successCallback;
  35521. /**
  35522. * Constructor.
  35523. * @param iterations the number of iterations.
  35524. * @param func the function to run each iteration
  35525. * @param successCallback the callback that will be called upon succesful execution
  35526. * @param offset starting offset.
  35527. */
  35528. constructor(
  35529. /**
  35530. * Defines the number of iterations for the loop
  35531. */
  35532. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35533. /**
  35534. * Execute the next iteration. Must be called after the last iteration was finished.
  35535. */
  35536. executeNext(): void;
  35537. /**
  35538. * Break the loop and run the success callback.
  35539. */
  35540. breakLoop(): void;
  35541. /**
  35542. * Create and run an async loop.
  35543. * @param iterations the number of iterations.
  35544. * @param fn the function to run each iteration
  35545. * @param successCallback the callback that will be called upon succesful execution
  35546. * @param offset starting offset.
  35547. * @returns the created async loop object
  35548. */
  35549. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35550. /**
  35551. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35552. * @param iterations total number of iterations
  35553. * @param syncedIterations number of synchronous iterations in each async iteration.
  35554. * @param fn the function to call each iteration.
  35555. * @param callback a success call back that will be called when iterating stops.
  35556. * @param breakFunction a break condition (optional)
  35557. * @param timeout timeout settings for the setTimeout function. default - 0.
  35558. * @returns the created async loop object
  35559. */
  35560. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35561. }
  35562. }
  35563. declare module "babylonjs/Misc/stringDictionary" {
  35564. import { Nullable } from "babylonjs/types";
  35565. /**
  35566. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35567. * The underlying implementation relies on an associative array to ensure the best performances.
  35568. * The value can be anything including 'null' but except 'undefined'
  35569. */
  35570. export class StringDictionary<T> {
  35571. /**
  35572. * This will clear this dictionary and copy the content from the 'source' one.
  35573. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35574. * @param source the dictionary to take the content from and copy to this dictionary
  35575. */
  35576. copyFrom(source: StringDictionary<T>): void;
  35577. /**
  35578. * Get a value based from its key
  35579. * @param key the given key to get the matching value from
  35580. * @return the value if found, otherwise undefined is returned
  35581. */
  35582. get(key: string): T | undefined;
  35583. /**
  35584. * Get a value from its key or add it if it doesn't exist.
  35585. * This method will ensure you that a given key/data will be present in the dictionary.
  35586. * @param key the given key to get the matching value from
  35587. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35588. * The factory will only be invoked if there's no data for the given key.
  35589. * @return the value corresponding to the key.
  35590. */
  35591. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35592. /**
  35593. * Get a value from its key if present in the dictionary otherwise add it
  35594. * @param key the key to get the value from
  35595. * @param val if there's no such key/value pair in the dictionary add it with this value
  35596. * @return the value corresponding to the key
  35597. */
  35598. getOrAdd(key: string, val: T): T;
  35599. /**
  35600. * Check if there's a given key in the dictionary
  35601. * @param key the key to check for
  35602. * @return true if the key is present, false otherwise
  35603. */
  35604. contains(key: string): boolean;
  35605. /**
  35606. * Add a new key and its corresponding value
  35607. * @param key the key to add
  35608. * @param value the value corresponding to the key
  35609. * @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
  35610. */
  35611. add(key: string, value: T): boolean;
  35612. /**
  35613. * Update a specific value associated to a key
  35614. * @param key defines the key to use
  35615. * @param value defines the value to store
  35616. * @returns true if the value was updated (or false if the key was not found)
  35617. */
  35618. set(key: string, value: T): boolean;
  35619. /**
  35620. * Get the element of the given key and remove it from the dictionary
  35621. * @param key defines the key to search
  35622. * @returns the value associated with the key or null if not found
  35623. */
  35624. getAndRemove(key: string): Nullable<T>;
  35625. /**
  35626. * Remove a key/value from the dictionary.
  35627. * @param key the key to remove
  35628. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35629. */
  35630. remove(key: string): boolean;
  35631. /**
  35632. * Clear the whole content of the dictionary
  35633. */
  35634. clear(): void;
  35635. /**
  35636. * Gets the current count
  35637. */
  35638. get count(): number;
  35639. /**
  35640. * Execute a callback on each key/val of the dictionary.
  35641. * Note that you can remove any element in this dictionary in the callback implementation
  35642. * @param callback the callback to execute on a given key/value pair
  35643. */
  35644. forEach(callback: (key: string, val: T) => void): void;
  35645. /**
  35646. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35647. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35648. * Note that you can remove any element in this dictionary in the callback implementation
  35649. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35650. * @returns the first item
  35651. */
  35652. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35653. private _count;
  35654. private _data;
  35655. }
  35656. }
  35657. declare module "babylonjs/Collisions/collisionCoordinator" {
  35658. import { Nullable } from "babylonjs/types";
  35659. import { Scene } from "babylonjs/scene";
  35660. import { Vector3 } from "babylonjs/Maths/math.vector";
  35661. import { Collider } from "babylonjs/Collisions/collider";
  35662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35663. /** @hidden */
  35664. export interface ICollisionCoordinator {
  35665. createCollider(): Collider;
  35666. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35667. init(scene: Scene): void;
  35668. }
  35669. /** @hidden */
  35670. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35671. private _scene;
  35672. private _scaledPosition;
  35673. private _scaledVelocity;
  35674. private _finalPosition;
  35675. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35676. createCollider(): Collider;
  35677. init(scene: Scene): void;
  35678. private _collideWithWorld;
  35679. }
  35680. }
  35681. declare module "babylonjs/Inputs/scene.inputManager" {
  35682. import { Nullable } from "babylonjs/types";
  35683. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35684. import { Vector2 } from "babylonjs/Maths/math.vector";
  35685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35686. import { Scene } from "babylonjs/scene";
  35687. /**
  35688. * Class used to manage all inputs for the scene.
  35689. */
  35690. export class InputManager {
  35691. /** The distance in pixel that you have to move to prevent some events */
  35692. static DragMovementThreshold: number;
  35693. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35694. static LongPressDelay: number;
  35695. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35696. static DoubleClickDelay: number;
  35697. /** If you need to check double click without raising a single click at first click, enable this flag */
  35698. static ExclusiveDoubleClickMode: boolean;
  35699. private _wheelEventName;
  35700. private _onPointerMove;
  35701. private _onPointerDown;
  35702. private _onPointerUp;
  35703. private _initClickEvent;
  35704. private _initActionManager;
  35705. private _delayedSimpleClick;
  35706. private _delayedSimpleClickTimeout;
  35707. private _previousDelayedSimpleClickTimeout;
  35708. private _meshPickProceed;
  35709. private _previousButtonPressed;
  35710. private _currentPickResult;
  35711. private _previousPickResult;
  35712. private _totalPointersPressed;
  35713. private _doubleClickOccured;
  35714. private _pointerOverMesh;
  35715. private _pickedDownMesh;
  35716. private _pickedUpMesh;
  35717. private _pointerX;
  35718. private _pointerY;
  35719. private _unTranslatedPointerX;
  35720. private _unTranslatedPointerY;
  35721. private _startingPointerPosition;
  35722. private _previousStartingPointerPosition;
  35723. private _startingPointerTime;
  35724. private _previousStartingPointerTime;
  35725. private _pointerCaptures;
  35726. private _onKeyDown;
  35727. private _onKeyUp;
  35728. private _onCanvasFocusObserver;
  35729. private _onCanvasBlurObserver;
  35730. private _scene;
  35731. /**
  35732. * Creates a new InputManager
  35733. * @param scene defines the hosting scene
  35734. */
  35735. constructor(scene: Scene);
  35736. /**
  35737. * Gets the mesh that is currently under the pointer
  35738. */
  35739. get meshUnderPointer(): Nullable<AbstractMesh>;
  35740. /**
  35741. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35742. */
  35743. get unTranslatedPointer(): Vector2;
  35744. /**
  35745. * Gets or sets the current on-screen X position of the pointer
  35746. */
  35747. get pointerX(): number;
  35748. set pointerX(value: number);
  35749. /**
  35750. * Gets or sets the current on-screen Y position of the pointer
  35751. */
  35752. get pointerY(): number;
  35753. set pointerY(value: number);
  35754. private _updatePointerPosition;
  35755. private _processPointerMove;
  35756. private _setRayOnPointerInfo;
  35757. private _checkPrePointerObservable;
  35758. /**
  35759. * Use this method to simulate a pointer move on a mesh
  35760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35763. */
  35764. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35765. /**
  35766. * Use this method to simulate a pointer down on a mesh
  35767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35770. */
  35771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35772. private _processPointerDown;
  35773. /** @hidden */
  35774. _isPointerSwiping(): boolean;
  35775. /**
  35776. * Use this method to simulate a pointer up on a mesh
  35777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35780. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35781. */
  35782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35783. private _processPointerUp;
  35784. /**
  35785. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35786. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35787. * @returns true if the pointer was captured
  35788. */
  35789. isPointerCaptured(pointerId?: number): boolean;
  35790. /**
  35791. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35792. * @param attachUp defines if you want to attach events to pointerup
  35793. * @param attachDown defines if you want to attach events to pointerdown
  35794. * @param attachMove defines if you want to attach events to pointermove
  35795. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35796. */
  35797. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35798. /**
  35799. * Detaches all event handlers
  35800. */
  35801. detachControl(): void;
  35802. /**
  35803. * Force the value of meshUnderPointer
  35804. * @param mesh defines the mesh to use
  35805. */
  35806. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35807. /**
  35808. * Gets the mesh under the pointer
  35809. * @returns a Mesh or null if no mesh is under the pointer
  35810. */
  35811. getPointerOverMesh(): Nullable<AbstractMesh>;
  35812. }
  35813. }
  35814. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35815. /**
  35816. * Helper class used to generate session unique ID
  35817. */
  35818. export class UniqueIdGenerator {
  35819. private static _UniqueIdCounter;
  35820. /**
  35821. * Gets an unique (relatively to the current scene) Id
  35822. */
  35823. static get UniqueId(): number;
  35824. }
  35825. }
  35826. declare module "babylonjs/Animations/animationGroup" {
  35827. import { Animatable } from "babylonjs/Animations/animatable";
  35828. import { Animation } from "babylonjs/Animations/animation";
  35829. import { Scene, IDisposable } from "babylonjs/scene";
  35830. import { Observable } from "babylonjs/Misc/observable";
  35831. import { Nullable } from "babylonjs/types";
  35832. import "babylonjs/Animations/animatable";
  35833. /**
  35834. * This class defines the direct association between an animation and a target
  35835. */
  35836. export class TargetedAnimation {
  35837. /**
  35838. * Animation to perform
  35839. */
  35840. animation: Animation;
  35841. /**
  35842. * Target to animate
  35843. */
  35844. target: any;
  35845. /**
  35846. * Serialize the object
  35847. * @returns the JSON object representing the current entity
  35848. */
  35849. serialize(): any;
  35850. }
  35851. /**
  35852. * Use this class to create coordinated animations on multiple targets
  35853. */
  35854. export class AnimationGroup implements IDisposable {
  35855. /** The name of the animation group */
  35856. name: string;
  35857. private _scene;
  35858. private _targetedAnimations;
  35859. private _animatables;
  35860. private _from;
  35861. private _to;
  35862. private _isStarted;
  35863. private _isPaused;
  35864. private _speedRatio;
  35865. private _loopAnimation;
  35866. /**
  35867. * Gets or sets the unique id of the node
  35868. */
  35869. uniqueId: number;
  35870. /**
  35871. * This observable will notify when one animation have ended
  35872. */
  35873. onAnimationEndObservable: Observable<TargetedAnimation>;
  35874. /**
  35875. * Observer raised when one animation loops
  35876. */
  35877. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35878. /**
  35879. * Observer raised when all animations have looped
  35880. */
  35881. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35882. /**
  35883. * This observable will notify when all animations have ended.
  35884. */
  35885. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35886. /**
  35887. * This observable will notify when all animations have paused.
  35888. */
  35889. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35890. /**
  35891. * This observable will notify when all animations are playing.
  35892. */
  35893. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35894. /**
  35895. * Gets the first frame
  35896. */
  35897. get from(): number;
  35898. /**
  35899. * Gets the last frame
  35900. */
  35901. get to(): number;
  35902. /**
  35903. * Define if the animations are started
  35904. */
  35905. get isStarted(): boolean;
  35906. /**
  35907. * Gets a value indicating that the current group is playing
  35908. */
  35909. get isPlaying(): boolean;
  35910. /**
  35911. * Gets or sets the speed ratio to use for all animations
  35912. */
  35913. get speedRatio(): number;
  35914. /**
  35915. * Gets or sets the speed ratio to use for all animations
  35916. */
  35917. set speedRatio(value: number);
  35918. /**
  35919. * Gets or sets if all animations should loop or not
  35920. */
  35921. get loopAnimation(): boolean;
  35922. set loopAnimation(value: boolean);
  35923. /**
  35924. * Gets the targeted animations for this animation group
  35925. */
  35926. get targetedAnimations(): Array<TargetedAnimation>;
  35927. /**
  35928. * returning the list of animatables controlled by this animation group.
  35929. */
  35930. get animatables(): Array<Animatable>;
  35931. /**
  35932. * Instantiates a new Animation Group.
  35933. * This helps managing several animations at once.
  35934. * @see http://doc.babylonjs.com/how_to/group
  35935. * @param name Defines the name of the group
  35936. * @param scene Defines the scene the group belongs to
  35937. */
  35938. constructor(
  35939. /** The name of the animation group */
  35940. name: string, scene?: Nullable<Scene>);
  35941. /**
  35942. * Add an animation (with its target) in the group
  35943. * @param animation defines the animation we want to add
  35944. * @param target defines the target of the animation
  35945. * @returns the TargetedAnimation object
  35946. */
  35947. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35948. /**
  35949. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35950. * It can add constant keys at begin or end
  35951. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35952. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35953. * @returns the animation group
  35954. */
  35955. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35956. private _animationLoopCount;
  35957. private _animationLoopFlags;
  35958. private _processLoop;
  35959. /**
  35960. * Start all animations on given targets
  35961. * @param loop defines if animations must loop
  35962. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35963. * @param from defines the from key (optional)
  35964. * @param to defines the to key (optional)
  35965. * @returns the current animation group
  35966. */
  35967. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35968. /**
  35969. * Pause all animations
  35970. * @returns the animation group
  35971. */
  35972. pause(): AnimationGroup;
  35973. /**
  35974. * Play all animations to initial state
  35975. * This function will start() the animations if they were not started or will restart() them if they were paused
  35976. * @param loop defines if animations must loop
  35977. * @returns the animation group
  35978. */
  35979. play(loop?: boolean): AnimationGroup;
  35980. /**
  35981. * Reset all animations to initial state
  35982. * @returns the animation group
  35983. */
  35984. reset(): AnimationGroup;
  35985. /**
  35986. * Restart animations from key 0
  35987. * @returns the animation group
  35988. */
  35989. restart(): AnimationGroup;
  35990. /**
  35991. * Stop all animations
  35992. * @returns the animation group
  35993. */
  35994. stop(): AnimationGroup;
  35995. /**
  35996. * Set animation weight for all animatables
  35997. * @param weight defines the weight to use
  35998. * @return the animationGroup
  35999. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36000. */
  36001. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36002. /**
  36003. * Synchronize and normalize all animatables with a source animatable
  36004. * @param root defines the root animatable to synchronize with
  36005. * @return the animationGroup
  36006. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36007. */
  36008. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36009. /**
  36010. * Goes to a specific frame in this animation group
  36011. * @param frame the frame number to go to
  36012. * @return the animationGroup
  36013. */
  36014. goToFrame(frame: number): AnimationGroup;
  36015. /**
  36016. * Dispose all associated resources
  36017. */
  36018. dispose(): void;
  36019. private _checkAnimationGroupEnded;
  36020. /**
  36021. * Clone the current animation group and returns a copy
  36022. * @param newName defines the name of the new group
  36023. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36024. * @returns the new aniamtion group
  36025. */
  36026. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36027. /**
  36028. * Serializes the animationGroup to an object
  36029. * @returns Serialized object
  36030. */
  36031. serialize(): any;
  36032. /**
  36033. * Returns a new AnimationGroup object parsed from the source provided.
  36034. * @param parsedAnimationGroup defines the source
  36035. * @param scene defines the scene that will receive the animationGroup
  36036. * @returns a new AnimationGroup
  36037. */
  36038. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36039. /**
  36040. * Returns the string "AnimationGroup"
  36041. * @returns "AnimationGroup"
  36042. */
  36043. getClassName(): string;
  36044. /**
  36045. * Creates a detailled string about the object
  36046. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36047. * @returns a string representing the object
  36048. */
  36049. toString(fullDetails?: boolean): string;
  36050. }
  36051. }
  36052. declare module "babylonjs/scene" {
  36053. import { Nullable } from "babylonjs/types";
  36054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36055. import { Observable } from "babylonjs/Misc/observable";
  36056. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36057. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36058. import { Geometry } from "babylonjs/Meshes/geometry";
  36059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36062. import { Mesh } from "babylonjs/Meshes/mesh";
  36063. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36064. import { Bone } from "babylonjs/Bones/bone";
  36065. import { Skeleton } from "babylonjs/Bones/skeleton";
  36066. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36067. import { Camera } from "babylonjs/Cameras/camera";
  36068. import { AbstractScene } from "babylonjs/abstractScene";
  36069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36071. import { Material } from "babylonjs/Materials/material";
  36072. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36073. import { Effect } from "babylonjs/Materials/effect";
  36074. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36075. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36076. import { Light } from "babylonjs/Lights/light";
  36077. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36078. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36079. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36080. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36082. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36083. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36084. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36085. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36086. import { Engine } from "babylonjs/Engines/engine";
  36087. import { Node } from "babylonjs/node";
  36088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36089. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36090. import { WebRequest } from "babylonjs/Misc/webRequest";
  36091. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36092. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36093. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36094. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36095. import { Plane } from "babylonjs/Maths/math.plane";
  36096. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36097. import { Ray } from "babylonjs/Culling/ray";
  36098. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36099. import { Animation } from "babylonjs/Animations/animation";
  36100. import { Animatable } from "babylonjs/Animations/animatable";
  36101. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36103. import { Collider } from "babylonjs/Collisions/collider";
  36104. /**
  36105. * Define an interface for all classes that will hold resources
  36106. */
  36107. export interface IDisposable {
  36108. /**
  36109. * Releases all held resources
  36110. */
  36111. dispose(): void;
  36112. }
  36113. /** Interface defining initialization parameters for Scene class */
  36114. export interface SceneOptions {
  36115. /**
  36116. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36117. * It will improve performance when the number of geometries becomes important.
  36118. */
  36119. useGeometryUniqueIdsMap?: boolean;
  36120. /**
  36121. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36122. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36123. */
  36124. useMaterialMeshMap?: boolean;
  36125. /**
  36126. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36127. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36128. */
  36129. useClonedMeshMap?: boolean;
  36130. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36131. virtual?: boolean;
  36132. }
  36133. /**
  36134. * Represents a scene to be rendered by the engine.
  36135. * @see http://doc.babylonjs.com/features/scene
  36136. */
  36137. export class Scene extends AbstractScene implements IAnimatable {
  36138. /** The fog is deactivated */
  36139. static readonly FOGMODE_NONE: number;
  36140. /** The fog density is following an exponential function */
  36141. static readonly FOGMODE_EXP: number;
  36142. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36143. static readonly FOGMODE_EXP2: number;
  36144. /** The fog density is following a linear function. */
  36145. static readonly FOGMODE_LINEAR: number;
  36146. /**
  36147. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36148. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36149. */
  36150. static MinDeltaTime: number;
  36151. /**
  36152. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36153. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36154. */
  36155. static MaxDeltaTime: number;
  36156. /**
  36157. * Factory used to create the default material.
  36158. * @param name The name of the material to create
  36159. * @param scene The scene to create the material for
  36160. * @returns The default material
  36161. */
  36162. static DefaultMaterialFactory(scene: Scene): Material;
  36163. /**
  36164. * Factory used to create the a collision coordinator.
  36165. * @returns The collision coordinator
  36166. */
  36167. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36168. /** @hidden */
  36169. _inputManager: InputManager;
  36170. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36171. cameraToUseForPointers: Nullable<Camera>;
  36172. /** @hidden */
  36173. readonly _isScene: boolean;
  36174. /** @hidden */
  36175. _blockEntityCollection: boolean;
  36176. /**
  36177. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36178. */
  36179. autoClear: boolean;
  36180. /**
  36181. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36182. */
  36183. autoClearDepthAndStencil: boolean;
  36184. /**
  36185. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36186. */
  36187. clearColor: Color4;
  36188. /**
  36189. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36190. */
  36191. ambientColor: Color3;
  36192. /**
  36193. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36194. * It should only be one of the following (if not the default embedded one):
  36195. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36196. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36197. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36198. * The material properties need to be setup according to the type of texture in use.
  36199. */
  36200. environmentBRDFTexture: BaseTexture;
  36201. /** @hidden */
  36202. protected _environmentTexture: Nullable<BaseTexture>;
  36203. /**
  36204. * Texture used in all pbr material as the reflection texture.
  36205. * As in the majority of the scene they are the same (exception for multi room and so on),
  36206. * this is easier to reference from here than from all the materials.
  36207. */
  36208. get environmentTexture(): Nullable<BaseTexture>;
  36209. /**
  36210. * Texture used in all pbr material as the reflection texture.
  36211. * As in the majority of the scene they are the same (exception for multi room and so on),
  36212. * this is easier to set here than in all the materials.
  36213. */
  36214. set environmentTexture(value: Nullable<BaseTexture>);
  36215. /** @hidden */
  36216. protected _environmentIntensity: number;
  36217. /**
  36218. * Intensity of the environment in all pbr material.
  36219. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36220. * As in the majority of the scene they are the same (exception for multi room and so on),
  36221. * this is easier to reference from here than from all the materials.
  36222. */
  36223. get environmentIntensity(): number;
  36224. /**
  36225. * Intensity of the environment in all pbr material.
  36226. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36227. * As in the majority of the scene they are the same (exception for multi room and so on),
  36228. * this is easier to set here than in all the materials.
  36229. */
  36230. set environmentIntensity(value: number);
  36231. /** @hidden */
  36232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36233. /**
  36234. * Default image processing configuration used either in the rendering
  36235. * Forward main pass or through the imageProcessingPostProcess if present.
  36236. * As in the majority of the scene they are the same (exception for multi camera),
  36237. * this is easier to reference from here than from all the materials and post process.
  36238. *
  36239. * No setter as we it is a shared configuration, you can set the values instead.
  36240. */
  36241. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36242. private _forceWireframe;
  36243. /**
  36244. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36245. */
  36246. set forceWireframe(value: boolean);
  36247. get forceWireframe(): boolean;
  36248. private _skipFrustumClipping;
  36249. /**
  36250. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36251. */
  36252. set skipFrustumClipping(value: boolean);
  36253. get skipFrustumClipping(): boolean;
  36254. private _forcePointsCloud;
  36255. /**
  36256. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36257. */
  36258. set forcePointsCloud(value: boolean);
  36259. get forcePointsCloud(): boolean;
  36260. /**
  36261. * Gets or sets the active clipplane 1
  36262. */
  36263. clipPlane: Nullable<Plane>;
  36264. /**
  36265. * Gets or sets the active clipplane 2
  36266. */
  36267. clipPlane2: Nullable<Plane>;
  36268. /**
  36269. * Gets or sets the active clipplane 3
  36270. */
  36271. clipPlane3: Nullable<Plane>;
  36272. /**
  36273. * Gets or sets the active clipplane 4
  36274. */
  36275. clipPlane4: Nullable<Plane>;
  36276. /**
  36277. * Gets or sets the active clipplane 5
  36278. */
  36279. clipPlane5: Nullable<Plane>;
  36280. /**
  36281. * Gets or sets the active clipplane 6
  36282. */
  36283. clipPlane6: Nullable<Plane>;
  36284. /**
  36285. * Gets or sets a boolean indicating if animations are enabled
  36286. */
  36287. animationsEnabled: boolean;
  36288. private _animationPropertiesOverride;
  36289. /**
  36290. * Gets or sets the animation properties override
  36291. */
  36292. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36293. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36294. /**
  36295. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36296. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36297. */
  36298. useConstantAnimationDeltaTime: boolean;
  36299. /**
  36300. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36301. * Please note that it requires to run a ray cast through the scene on every frame
  36302. */
  36303. constantlyUpdateMeshUnderPointer: boolean;
  36304. /**
  36305. * Defines the HTML cursor to use when hovering over interactive elements
  36306. */
  36307. hoverCursor: string;
  36308. /**
  36309. * Defines the HTML default cursor to use (empty by default)
  36310. */
  36311. defaultCursor: string;
  36312. /**
  36313. * Defines whether cursors are handled by the scene.
  36314. */
  36315. doNotHandleCursors: boolean;
  36316. /**
  36317. * This is used to call preventDefault() on pointer down
  36318. * in order to block unwanted artifacts like system double clicks
  36319. */
  36320. preventDefaultOnPointerDown: boolean;
  36321. /**
  36322. * This is used to call preventDefault() on pointer up
  36323. * in order to block unwanted artifacts like system double clicks
  36324. */
  36325. preventDefaultOnPointerUp: boolean;
  36326. /**
  36327. * Gets or sets user defined metadata
  36328. */
  36329. metadata: any;
  36330. /**
  36331. * For internal use only. Please do not use.
  36332. */
  36333. reservedDataStore: any;
  36334. /**
  36335. * Gets the name of the plugin used to load this scene (null by default)
  36336. */
  36337. loadingPluginName: string;
  36338. /**
  36339. * Use this array to add regular expressions used to disable offline support for specific urls
  36340. */
  36341. disableOfflineSupportExceptionRules: RegExp[];
  36342. /**
  36343. * An event triggered when the scene is disposed.
  36344. */
  36345. onDisposeObservable: Observable<Scene>;
  36346. private _onDisposeObserver;
  36347. /** Sets a function to be executed when this scene is disposed. */
  36348. set onDispose(callback: () => void);
  36349. /**
  36350. * An event triggered before rendering the scene (right after animations and physics)
  36351. */
  36352. onBeforeRenderObservable: Observable<Scene>;
  36353. private _onBeforeRenderObserver;
  36354. /** Sets a function to be executed before rendering this scene */
  36355. set beforeRender(callback: Nullable<() => void>);
  36356. /**
  36357. * An event triggered after rendering the scene
  36358. */
  36359. onAfterRenderObservable: Observable<Scene>;
  36360. /**
  36361. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36362. */
  36363. onAfterRenderCameraObservable: Observable<Camera>;
  36364. private _onAfterRenderObserver;
  36365. /** Sets a function to be executed after rendering this scene */
  36366. set afterRender(callback: Nullable<() => void>);
  36367. /**
  36368. * An event triggered before animating the scene
  36369. */
  36370. onBeforeAnimationsObservable: Observable<Scene>;
  36371. /**
  36372. * An event triggered after animations processing
  36373. */
  36374. onAfterAnimationsObservable: Observable<Scene>;
  36375. /**
  36376. * An event triggered before draw calls are ready to be sent
  36377. */
  36378. onBeforeDrawPhaseObservable: Observable<Scene>;
  36379. /**
  36380. * An event triggered after draw calls have been sent
  36381. */
  36382. onAfterDrawPhaseObservable: Observable<Scene>;
  36383. /**
  36384. * An event triggered when the scene is ready
  36385. */
  36386. onReadyObservable: Observable<Scene>;
  36387. /**
  36388. * An event triggered before rendering a camera
  36389. */
  36390. onBeforeCameraRenderObservable: Observable<Camera>;
  36391. private _onBeforeCameraRenderObserver;
  36392. /** Sets a function to be executed before rendering a camera*/
  36393. set beforeCameraRender(callback: () => void);
  36394. /**
  36395. * An event triggered after rendering a camera
  36396. */
  36397. onAfterCameraRenderObservable: Observable<Camera>;
  36398. private _onAfterCameraRenderObserver;
  36399. /** Sets a function to be executed after rendering a camera*/
  36400. set afterCameraRender(callback: () => void);
  36401. /**
  36402. * An event triggered when active meshes evaluation is about to start
  36403. */
  36404. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36405. /**
  36406. * An event triggered when active meshes evaluation is done
  36407. */
  36408. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36409. /**
  36410. * An event triggered when particles rendering is about to start
  36411. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36412. */
  36413. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36414. /**
  36415. * An event triggered when particles rendering is done
  36416. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36417. */
  36418. onAfterParticlesRenderingObservable: Observable<Scene>;
  36419. /**
  36420. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36421. */
  36422. onDataLoadedObservable: Observable<Scene>;
  36423. /**
  36424. * An event triggered when a camera is created
  36425. */
  36426. onNewCameraAddedObservable: Observable<Camera>;
  36427. /**
  36428. * An event triggered when a camera is removed
  36429. */
  36430. onCameraRemovedObservable: Observable<Camera>;
  36431. /**
  36432. * An event triggered when a light is created
  36433. */
  36434. onNewLightAddedObservable: Observable<Light>;
  36435. /**
  36436. * An event triggered when a light is removed
  36437. */
  36438. onLightRemovedObservable: Observable<Light>;
  36439. /**
  36440. * An event triggered when a geometry is created
  36441. */
  36442. onNewGeometryAddedObservable: Observable<Geometry>;
  36443. /**
  36444. * An event triggered when a geometry is removed
  36445. */
  36446. onGeometryRemovedObservable: Observable<Geometry>;
  36447. /**
  36448. * An event triggered when a transform node is created
  36449. */
  36450. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36451. /**
  36452. * An event triggered when a transform node is removed
  36453. */
  36454. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36455. /**
  36456. * An event triggered when a mesh is created
  36457. */
  36458. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36459. /**
  36460. * An event triggered when a mesh is removed
  36461. */
  36462. onMeshRemovedObservable: Observable<AbstractMesh>;
  36463. /**
  36464. * An event triggered when a skeleton is created
  36465. */
  36466. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36467. /**
  36468. * An event triggered when a skeleton is removed
  36469. */
  36470. onSkeletonRemovedObservable: Observable<Skeleton>;
  36471. /**
  36472. * An event triggered when a material is created
  36473. */
  36474. onNewMaterialAddedObservable: Observable<Material>;
  36475. /**
  36476. * An event triggered when a material is removed
  36477. */
  36478. onMaterialRemovedObservable: Observable<Material>;
  36479. /**
  36480. * An event triggered when a texture is created
  36481. */
  36482. onNewTextureAddedObservable: Observable<BaseTexture>;
  36483. /**
  36484. * An event triggered when a texture is removed
  36485. */
  36486. onTextureRemovedObservable: Observable<BaseTexture>;
  36487. /**
  36488. * An event triggered when render targets are about to be rendered
  36489. * Can happen multiple times per frame.
  36490. */
  36491. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36492. /**
  36493. * An event triggered when render targets were rendered.
  36494. * Can happen multiple times per frame.
  36495. */
  36496. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36497. /**
  36498. * An event triggered before calculating deterministic simulation step
  36499. */
  36500. onBeforeStepObservable: Observable<Scene>;
  36501. /**
  36502. * An event triggered after calculating deterministic simulation step
  36503. */
  36504. onAfterStepObservable: Observable<Scene>;
  36505. /**
  36506. * An event triggered when the activeCamera property is updated
  36507. */
  36508. onActiveCameraChanged: Observable<Scene>;
  36509. /**
  36510. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36511. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36512. * 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)
  36513. */
  36514. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36515. /**
  36516. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36517. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36518. * 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)
  36519. */
  36520. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36521. /**
  36522. * This Observable will when a mesh has been imported into the scene.
  36523. */
  36524. onMeshImportedObservable: Observable<AbstractMesh>;
  36525. /**
  36526. * This Observable will when an animation file has been imported into the scene.
  36527. */
  36528. onAnimationFileImportedObservable: Observable<Scene>;
  36529. /**
  36530. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36531. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36532. */
  36533. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36534. /** @hidden */
  36535. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36536. /**
  36537. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36538. */
  36539. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36540. /**
  36541. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36542. */
  36543. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36544. /**
  36545. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36546. */
  36547. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36548. /** Callback called when a pointer move is detected */
  36549. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36550. /** Callback called when a pointer down is detected */
  36551. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36552. /** Callback called when a pointer up is detected */
  36553. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36554. /** Callback called when a pointer pick is detected */
  36555. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36556. /**
  36557. * 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).
  36558. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36559. */
  36560. onPrePointerObservable: Observable<PointerInfoPre>;
  36561. /**
  36562. * Observable event triggered each time an input event is received from the rendering canvas
  36563. */
  36564. onPointerObservable: Observable<PointerInfo>;
  36565. /**
  36566. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36567. */
  36568. get unTranslatedPointer(): Vector2;
  36569. /**
  36570. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36571. */
  36572. static get DragMovementThreshold(): number;
  36573. static set DragMovementThreshold(value: number);
  36574. /**
  36575. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36576. */
  36577. static get LongPressDelay(): number;
  36578. static set LongPressDelay(value: number);
  36579. /**
  36580. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36581. */
  36582. static get DoubleClickDelay(): number;
  36583. static set DoubleClickDelay(value: number);
  36584. /** If you need to check double click without raising a single click at first click, enable this flag */
  36585. static get ExclusiveDoubleClickMode(): boolean;
  36586. static set ExclusiveDoubleClickMode(value: boolean);
  36587. /** @hidden */
  36588. _mirroredCameraPosition: Nullable<Vector3>;
  36589. /**
  36590. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36591. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36592. */
  36593. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36594. /**
  36595. * Observable event triggered each time an keyboard event is received from the hosting window
  36596. */
  36597. onKeyboardObservable: Observable<KeyboardInfo>;
  36598. private _useRightHandedSystem;
  36599. /**
  36600. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36601. */
  36602. set useRightHandedSystem(value: boolean);
  36603. get useRightHandedSystem(): boolean;
  36604. private _timeAccumulator;
  36605. private _currentStepId;
  36606. private _currentInternalStep;
  36607. /**
  36608. * Sets the step Id used by deterministic lock step
  36609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36610. * @param newStepId defines the step Id
  36611. */
  36612. setStepId(newStepId: number): void;
  36613. /**
  36614. * Gets the step Id used by deterministic lock step
  36615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36616. * @returns the step Id
  36617. */
  36618. getStepId(): number;
  36619. /**
  36620. * Gets the internal step used by deterministic lock step
  36621. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36622. * @returns the internal step
  36623. */
  36624. getInternalStep(): number;
  36625. private _fogEnabled;
  36626. /**
  36627. * Gets or sets a boolean indicating if fog is enabled on this scene
  36628. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36629. * (Default is true)
  36630. */
  36631. set fogEnabled(value: boolean);
  36632. get fogEnabled(): boolean;
  36633. private _fogMode;
  36634. /**
  36635. * Gets or sets the fog mode to use
  36636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36637. * | mode | value |
  36638. * | --- | --- |
  36639. * | FOGMODE_NONE | 0 |
  36640. * | FOGMODE_EXP | 1 |
  36641. * | FOGMODE_EXP2 | 2 |
  36642. * | FOGMODE_LINEAR | 3 |
  36643. */
  36644. set fogMode(value: number);
  36645. get fogMode(): number;
  36646. /**
  36647. * Gets or sets the fog color to use
  36648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36649. * (Default is Color3(0.2, 0.2, 0.3))
  36650. */
  36651. fogColor: Color3;
  36652. /**
  36653. * Gets or sets the fog density to use
  36654. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36655. * (Default is 0.1)
  36656. */
  36657. fogDensity: number;
  36658. /**
  36659. * Gets or sets the fog start distance to use
  36660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36661. * (Default is 0)
  36662. */
  36663. fogStart: number;
  36664. /**
  36665. * Gets or sets the fog end distance to use
  36666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36667. * (Default is 1000)
  36668. */
  36669. fogEnd: number;
  36670. private _shadowsEnabled;
  36671. /**
  36672. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36673. */
  36674. set shadowsEnabled(value: boolean);
  36675. get shadowsEnabled(): boolean;
  36676. private _lightsEnabled;
  36677. /**
  36678. * Gets or sets a boolean indicating if lights are enabled on this scene
  36679. */
  36680. set lightsEnabled(value: boolean);
  36681. get lightsEnabled(): boolean;
  36682. /** All of the active cameras added to this scene. */
  36683. activeCameras: Camera[];
  36684. /** @hidden */
  36685. _activeCamera: Nullable<Camera>;
  36686. /** Gets or sets the current active camera */
  36687. get activeCamera(): Nullable<Camera>;
  36688. set activeCamera(value: Nullable<Camera>);
  36689. private _defaultMaterial;
  36690. /** The default material used on meshes when no material is affected */
  36691. get defaultMaterial(): Material;
  36692. /** The default material used on meshes when no material is affected */
  36693. set defaultMaterial(value: Material);
  36694. private _texturesEnabled;
  36695. /**
  36696. * Gets or sets a boolean indicating if textures are enabled on this scene
  36697. */
  36698. set texturesEnabled(value: boolean);
  36699. get texturesEnabled(): boolean;
  36700. /**
  36701. * Gets or sets a boolean indicating if particles are enabled on this scene
  36702. */
  36703. particlesEnabled: boolean;
  36704. /**
  36705. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36706. */
  36707. spritesEnabled: boolean;
  36708. private _skeletonsEnabled;
  36709. /**
  36710. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36711. */
  36712. set skeletonsEnabled(value: boolean);
  36713. get skeletonsEnabled(): boolean;
  36714. /**
  36715. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36716. */
  36717. lensFlaresEnabled: boolean;
  36718. /**
  36719. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36721. */
  36722. collisionsEnabled: boolean;
  36723. private _collisionCoordinator;
  36724. /** @hidden */
  36725. get collisionCoordinator(): ICollisionCoordinator;
  36726. /**
  36727. * Defines the gravity applied to this scene (used only for collisions)
  36728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36729. */
  36730. gravity: Vector3;
  36731. /**
  36732. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36733. */
  36734. postProcessesEnabled: boolean;
  36735. /**
  36736. * The list of postprocesses added to the scene
  36737. */
  36738. postProcesses: PostProcess[];
  36739. /**
  36740. * Gets the current postprocess manager
  36741. */
  36742. postProcessManager: PostProcessManager;
  36743. /**
  36744. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36745. */
  36746. renderTargetsEnabled: boolean;
  36747. /**
  36748. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36749. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36750. */
  36751. dumpNextRenderTargets: boolean;
  36752. /**
  36753. * The list of user defined render targets added to the scene
  36754. */
  36755. customRenderTargets: RenderTargetTexture[];
  36756. /**
  36757. * Defines if texture loading must be delayed
  36758. * If true, textures will only be loaded when they need to be rendered
  36759. */
  36760. useDelayedTextureLoading: boolean;
  36761. /**
  36762. * Gets the list of meshes imported to the scene through SceneLoader
  36763. */
  36764. importedMeshesFiles: String[];
  36765. /**
  36766. * Gets or sets a boolean indicating if probes are enabled on this scene
  36767. */
  36768. probesEnabled: boolean;
  36769. /**
  36770. * Gets or sets the current offline provider to use to store scene data
  36771. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36772. */
  36773. offlineProvider: IOfflineProvider;
  36774. /**
  36775. * Gets or sets the action manager associated with the scene
  36776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36777. */
  36778. actionManager: AbstractActionManager;
  36779. private _meshesForIntersections;
  36780. /**
  36781. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36782. */
  36783. proceduralTexturesEnabled: boolean;
  36784. private _engine;
  36785. private _totalVertices;
  36786. /** @hidden */
  36787. _activeIndices: PerfCounter;
  36788. /** @hidden */
  36789. _activeParticles: PerfCounter;
  36790. /** @hidden */
  36791. _activeBones: PerfCounter;
  36792. private _animationRatio;
  36793. /** @hidden */
  36794. _animationTimeLast: number;
  36795. /** @hidden */
  36796. _animationTime: number;
  36797. /**
  36798. * Gets or sets a general scale for animation speed
  36799. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36800. */
  36801. animationTimeScale: number;
  36802. /** @hidden */
  36803. _cachedMaterial: Nullable<Material>;
  36804. /** @hidden */
  36805. _cachedEffect: Nullable<Effect>;
  36806. /** @hidden */
  36807. _cachedVisibility: Nullable<number>;
  36808. private _renderId;
  36809. private _frameId;
  36810. private _executeWhenReadyTimeoutId;
  36811. private _intermediateRendering;
  36812. private _viewUpdateFlag;
  36813. private _projectionUpdateFlag;
  36814. /** @hidden */
  36815. _toBeDisposed: Nullable<IDisposable>[];
  36816. private _activeRequests;
  36817. /** @hidden */
  36818. _pendingData: any[];
  36819. private _isDisposed;
  36820. /**
  36821. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36822. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36823. */
  36824. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36825. private _activeMeshes;
  36826. private _processedMaterials;
  36827. private _renderTargets;
  36828. /** @hidden */
  36829. _activeParticleSystems: SmartArray<IParticleSystem>;
  36830. private _activeSkeletons;
  36831. private _softwareSkinnedMeshes;
  36832. private _renderingManager;
  36833. /** @hidden */
  36834. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36835. private _transformMatrix;
  36836. private _sceneUbo;
  36837. /** @hidden */
  36838. _viewMatrix: Matrix;
  36839. private _projectionMatrix;
  36840. /** @hidden */
  36841. _forcedViewPosition: Nullable<Vector3>;
  36842. /** @hidden */
  36843. _frustumPlanes: Plane[];
  36844. /**
  36845. * Gets the list of frustum planes (built from the active camera)
  36846. */
  36847. get frustumPlanes(): Plane[];
  36848. /**
  36849. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36850. * This is useful if there are more lights that the maximum simulteanous authorized
  36851. */
  36852. requireLightSorting: boolean;
  36853. /** @hidden */
  36854. readonly useMaterialMeshMap: boolean;
  36855. /** @hidden */
  36856. readonly useClonedMeshMap: boolean;
  36857. private _externalData;
  36858. private _uid;
  36859. /**
  36860. * @hidden
  36861. * Backing store of defined scene components.
  36862. */
  36863. _components: ISceneComponent[];
  36864. /**
  36865. * @hidden
  36866. * Backing store of defined scene components.
  36867. */
  36868. _serializableComponents: ISceneSerializableComponent[];
  36869. /**
  36870. * List of components to register on the next registration step.
  36871. */
  36872. private _transientComponents;
  36873. /**
  36874. * Registers the transient components if needed.
  36875. */
  36876. private _registerTransientComponents;
  36877. /**
  36878. * @hidden
  36879. * Add a component to the scene.
  36880. * Note that the ccomponent could be registered on th next frame if this is called after
  36881. * the register component stage.
  36882. * @param component Defines the component to add to the scene
  36883. */
  36884. _addComponent(component: ISceneComponent): void;
  36885. /**
  36886. * @hidden
  36887. * Gets a component from the scene.
  36888. * @param name defines the name of the component to retrieve
  36889. * @returns the component or null if not present
  36890. */
  36891. _getComponent(name: string): Nullable<ISceneComponent>;
  36892. /**
  36893. * @hidden
  36894. * Defines the actions happening before camera updates.
  36895. */
  36896. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36897. /**
  36898. * @hidden
  36899. * Defines the actions happening before clear the canvas.
  36900. */
  36901. _beforeClearStage: Stage<SimpleStageAction>;
  36902. /**
  36903. * @hidden
  36904. * Defines the actions when collecting render targets for the frame.
  36905. */
  36906. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36907. /**
  36908. * @hidden
  36909. * Defines the actions happening for one camera in the frame.
  36910. */
  36911. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36912. /**
  36913. * @hidden
  36914. * Defines the actions happening during the per mesh ready checks.
  36915. */
  36916. _isReadyForMeshStage: Stage<MeshStageAction>;
  36917. /**
  36918. * @hidden
  36919. * Defines the actions happening before evaluate active mesh checks.
  36920. */
  36921. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36922. /**
  36923. * @hidden
  36924. * Defines the actions happening during the evaluate sub mesh checks.
  36925. */
  36926. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36927. /**
  36928. * @hidden
  36929. * Defines the actions happening during the active mesh stage.
  36930. */
  36931. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36932. /**
  36933. * @hidden
  36934. * Defines the actions happening during the per camera render target step.
  36935. */
  36936. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36937. /**
  36938. * @hidden
  36939. * Defines the actions happening just before the active camera is drawing.
  36940. */
  36941. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36942. /**
  36943. * @hidden
  36944. * Defines the actions happening just before a render target is drawing.
  36945. */
  36946. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36947. /**
  36948. * @hidden
  36949. * Defines the actions happening just before a rendering group is drawing.
  36950. */
  36951. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36952. /**
  36953. * @hidden
  36954. * Defines the actions happening just before a mesh is drawing.
  36955. */
  36956. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36957. /**
  36958. * @hidden
  36959. * Defines the actions happening just after a mesh has been drawn.
  36960. */
  36961. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36962. /**
  36963. * @hidden
  36964. * Defines the actions happening just after a rendering group has been drawn.
  36965. */
  36966. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36967. /**
  36968. * @hidden
  36969. * Defines the actions happening just after the active camera has been drawn.
  36970. */
  36971. _afterCameraDrawStage: Stage<CameraStageAction>;
  36972. /**
  36973. * @hidden
  36974. * Defines the actions happening just after a render target has been drawn.
  36975. */
  36976. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36977. /**
  36978. * @hidden
  36979. * Defines the actions happening just after rendering all cameras and computing intersections.
  36980. */
  36981. _afterRenderStage: Stage<SimpleStageAction>;
  36982. /**
  36983. * @hidden
  36984. * Defines the actions happening when a pointer move event happens.
  36985. */
  36986. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36987. /**
  36988. * @hidden
  36989. * Defines the actions happening when a pointer down event happens.
  36990. */
  36991. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36992. /**
  36993. * @hidden
  36994. * Defines the actions happening when a pointer up event happens.
  36995. */
  36996. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36997. /**
  36998. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36999. */
  37000. private geometriesByUniqueId;
  37001. /**
  37002. * Creates a new Scene
  37003. * @param engine defines the engine to use to render this scene
  37004. * @param options defines the scene options
  37005. */
  37006. constructor(engine: Engine, options?: SceneOptions);
  37007. /**
  37008. * Gets a string idenfifying the name of the class
  37009. * @returns "Scene" string
  37010. */
  37011. getClassName(): string;
  37012. private _defaultMeshCandidates;
  37013. /**
  37014. * @hidden
  37015. */
  37016. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37017. private _defaultSubMeshCandidates;
  37018. /**
  37019. * @hidden
  37020. */
  37021. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37022. /**
  37023. * Sets the default candidate providers for the scene.
  37024. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37025. * and getCollidingSubMeshCandidates to their default function
  37026. */
  37027. setDefaultCandidateProviders(): void;
  37028. /**
  37029. * Gets the mesh that is currently under the pointer
  37030. */
  37031. get meshUnderPointer(): Nullable<AbstractMesh>;
  37032. /**
  37033. * Gets or sets the current on-screen X position of the pointer
  37034. */
  37035. get pointerX(): number;
  37036. set pointerX(value: number);
  37037. /**
  37038. * Gets or sets the current on-screen Y position of the pointer
  37039. */
  37040. get pointerY(): number;
  37041. set pointerY(value: number);
  37042. /**
  37043. * Gets the cached material (ie. the latest rendered one)
  37044. * @returns the cached material
  37045. */
  37046. getCachedMaterial(): Nullable<Material>;
  37047. /**
  37048. * Gets the cached effect (ie. the latest rendered one)
  37049. * @returns the cached effect
  37050. */
  37051. getCachedEffect(): Nullable<Effect>;
  37052. /**
  37053. * Gets the cached visibility state (ie. the latest rendered one)
  37054. * @returns the cached visibility state
  37055. */
  37056. getCachedVisibility(): Nullable<number>;
  37057. /**
  37058. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37059. * @param material defines the current material
  37060. * @param effect defines the current effect
  37061. * @param visibility defines the current visibility state
  37062. * @returns true if one parameter is not cached
  37063. */
  37064. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37065. /**
  37066. * Gets the engine associated with the scene
  37067. * @returns an Engine
  37068. */
  37069. getEngine(): Engine;
  37070. /**
  37071. * Gets the total number of vertices rendered per frame
  37072. * @returns the total number of vertices rendered per frame
  37073. */
  37074. getTotalVertices(): number;
  37075. /**
  37076. * Gets the performance counter for total vertices
  37077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37078. */
  37079. get totalVerticesPerfCounter(): PerfCounter;
  37080. /**
  37081. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37082. * @returns the total number of active indices rendered per frame
  37083. */
  37084. getActiveIndices(): number;
  37085. /**
  37086. * Gets the performance counter for active indices
  37087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37088. */
  37089. get totalActiveIndicesPerfCounter(): PerfCounter;
  37090. /**
  37091. * Gets the total number of active particles rendered per frame
  37092. * @returns the total number of active particles rendered per frame
  37093. */
  37094. getActiveParticles(): number;
  37095. /**
  37096. * Gets the performance counter for active particles
  37097. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37098. */
  37099. get activeParticlesPerfCounter(): PerfCounter;
  37100. /**
  37101. * Gets the total number of active bones rendered per frame
  37102. * @returns the total number of active bones rendered per frame
  37103. */
  37104. getActiveBones(): number;
  37105. /**
  37106. * Gets the performance counter for active bones
  37107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37108. */
  37109. get activeBonesPerfCounter(): PerfCounter;
  37110. /**
  37111. * Gets the array of active meshes
  37112. * @returns an array of AbstractMesh
  37113. */
  37114. getActiveMeshes(): SmartArray<AbstractMesh>;
  37115. /**
  37116. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37117. * @returns a number
  37118. */
  37119. getAnimationRatio(): number;
  37120. /**
  37121. * Gets an unique Id for the current render phase
  37122. * @returns a number
  37123. */
  37124. getRenderId(): number;
  37125. /**
  37126. * Gets an unique Id for the current frame
  37127. * @returns a number
  37128. */
  37129. getFrameId(): number;
  37130. /** Call this function if you want to manually increment the render Id*/
  37131. incrementRenderId(): void;
  37132. private _createUbo;
  37133. /**
  37134. * Use this method to simulate a pointer move on a mesh
  37135. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37136. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37137. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37138. * @returns the current scene
  37139. */
  37140. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37141. /**
  37142. * Use this method to simulate a pointer down on a mesh
  37143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37146. * @returns the current scene
  37147. */
  37148. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37149. /**
  37150. * Use this method to simulate a pointer up on a mesh
  37151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37154. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37155. * @returns the current scene
  37156. */
  37157. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37158. /**
  37159. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37160. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37161. * @returns true if the pointer was captured
  37162. */
  37163. isPointerCaptured(pointerId?: number): boolean;
  37164. /**
  37165. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37166. * @param attachUp defines if you want to attach events to pointerup
  37167. * @param attachDown defines if you want to attach events to pointerdown
  37168. * @param attachMove defines if you want to attach events to pointermove
  37169. */
  37170. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37171. /** Detaches all event handlers*/
  37172. detachControl(): void;
  37173. /**
  37174. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37175. * Delay loaded resources are not taking in account
  37176. * @return true if all required resources are ready
  37177. */
  37178. isReady(): boolean;
  37179. /** Resets all cached information relative to material (including effect and visibility) */
  37180. resetCachedMaterial(): void;
  37181. /**
  37182. * Registers a function to be called before every frame render
  37183. * @param func defines the function to register
  37184. */
  37185. registerBeforeRender(func: () => void): void;
  37186. /**
  37187. * Unregisters a function called before every frame render
  37188. * @param func defines the function to unregister
  37189. */
  37190. unregisterBeforeRender(func: () => void): void;
  37191. /**
  37192. * Registers a function to be called after every frame render
  37193. * @param func defines the function to register
  37194. */
  37195. registerAfterRender(func: () => void): void;
  37196. /**
  37197. * Unregisters a function called after every frame render
  37198. * @param func defines the function to unregister
  37199. */
  37200. unregisterAfterRender(func: () => void): void;
  37201. private _executeOnceBeforeRender;
  37202. /**
  37203. * The provided function will run before render once and will be disposed afterwards.
  37204. * A timeout delay can be provided so that the function will be executed in N ms.
  37205. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37206. * @param func The function to be executed.
  37207. * @param timeout optional delay in ms
  37208. */
  37209. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37210. /** @hidden */
  37211. _addPendingData(data: any): void;
  37212. /** @hidden */
  37213. _removePendingData(data: any): void;
  37214. /**
  37215. * Returns the number of items waiting to be loaded
  37216. * @returns the number of items waiting to be loaded
  37217. */
  37218. getWaitingItemsCount(): number;
  37219. /**
  37220. * Returns a boolean indicating if the scene is still loading data
  37221. */
  37222. get isLoading(): boolean;
  37223. /**
  37224. * Registers a function to be executed when the scene is ready
  37225. * @param {Function} func - the function to be executed
  37226. */
  37227. executeWhenReady(func: () => void): void;
  37228. /**
  37229. * Returns a promise that resolves when the scene is ready
  37230. * @returns A promise that resolves when the scene is ready
  37231. */
  37232. whenReadyAsync(): Promise<void>;
  37233. /** @hidden */
  37234. _checkIsReady(): void;
  37235. /**
  37236. * Gets all animatable attached to the scene
  37237. */
  37238. get animatables(): Animatable[];
  37239. /**
  37240. * Resets the last animation time frame.
  37241. * Useful to override when animations start running when loading a scene for the first time.
  37242. */
  37243. resetLastAnimationTimeFrame(): void;
  37244. /**
  37245. * Gets the current view matrix
  37246. * @returns a Matrix
  37247. */
  37248. getViewMatrix(): Matrix;
  37249. /**
  37250. * Gets the current projection matrix
  37251. * @returns a Matrix
  37252. */
  37253. getProjectionMatrix(): Matrix;
  37254. /**
  37255. * Gets the current transform matrix
  37256. * @returns a Matrix made of View * Projection
  37257. */
  37258. getTransformMatrix(): Matrix;
  37259. /**
  37260. * Sets the current transform matrix
  37261. * @param viewL defines the View matrix to use
  37262. * @param projectionL defines the Projection matrix to use
  37263. * @param viewR defines the right View matrix to use (if provided)
  37264. * @param projectionR defines the right Projection matrix to use (if provided)
  37265. */
  37266. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37267. /**
  37268. * Gets the uniform buffer used to store scene data
  37269. * @returns a UniformBuffer
  37270. */
  37271. getSceneUniformBuffer(): UniformBuffer;
  37272. /**
  37273. * Gets an unique (relatively to the current scene) Id
  37274. * @returns an unique number for the scene
  37275. */
  37276. getUniqueId(): number;
  37277. /**
  37278. * Add a mesh to the list of scene's meshes
  37279. * @param newMesh defines the mesh to add
  37280. * @param recursive if all child meshes should also be added to the scene
  37281. */
  37282. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37283. /**
  37284. * Remove a mesh for the list of scene's meshes
  37285. * @param toRemove defines the mesh to remove
  37286. * @param recursive if all child meshes should also be removed from the scene
  37287. * @returns the index where the mesh was in the mesh list
  37288. */
  37289. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37290. /**
  37291. * Add a transform node to the list of scene's transform nodes
  37292. * @param newTransformNode defines the transform node to add
  37293. */
  37294. addTransformNode(newTransformNode: TransformNode): void;
  37295. /**
  37296. * Remove a transform node for the list of scene's transform nodes
  37297. * @param toRemove defines the transform node to remove
  37298. * @returns the index where the transform node was in the transform node list
  37299. */
  37300. removeTransformNode(toRemove: TransformNode): number;
  37301. /**
  37302. * Remove a skeleton for the list of scene's skeletons
  37303. * @param toRemove defines the skeleton to remove
  37304. * @returns the index where the skeleton was in the skeleton list
  37305. */
  37306. removeSkeleton(toRemove: Skeleton): number;
  37307. /**
  37308. * Remove a morph target for the list of scene's morph targets
  37309. * @param toRemove defines the morph target to remove
  37310. * @returns the index where the morph target was in the morph target list
  37311. */
  37312. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37313. /**
  37314. * Remove a light for the list of scene's lights
  37315. * @param toRemove defines the light to remove
  37316. * @returns the index where the light was in the light list
  37317. */
  37318. removeLight(toRemove: Light): number;
  37319. /**
  37320. * Remove a camera for the list of scene's cameras
  37321. * @param toRemove defines the camera to remove
  37322. * @returns the index where the camera was in the camera list
  37323. */
  37324. removeCamera(toRemove: Camera): number;
  37325. /**
  37326. * Remove a particle system for the list of scene's particle systems
  37327. * @param toRemove defines the particle system to remove
  37328. * @returns the index where the particle system was in the particle system list
  37329. */
  37330. removeParticleSystem(toRemove: IParticleSystem): number;
  37331. /**
  37332. * Remove a animation for the list of scene's animations
  37333. * @param toRemove defines the animation to remove
  37334. * @returns the index where the animation was in the animation list
  37335. */
  37336. removeAnimation(toRemove: Animation): number;
  37337. /**
  37338. * Will stop the animation of the given target
  37339. * @param target - the target
  37340. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37341. * @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)
  37342. */
  37343. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37344. /**
  37345. * Removes the given animation group from this scene.
  37346. * @param toRemove The animation group to remove
  37347. * @returns The index of the removed animation group
  37348. */
  37349. removeAnimationGroup(toRemove: AnimationGroup): number;
  37350. /**
  37351. * Removes the given multi-material from this scene.
  37352. * @param toRemove The multi-material to remove
  37353. * @returns The index of the removed multi-material
  37354. */
  37355. removeMultiMaterial(toRemove: MultiMaterial): number;
  37356. /**
  37357. * Removes the given material from this scene.
  37358. * @param toRemove The material to remove
  37359. * @returns The index of the removed material
  37360. */
  37361. removeMaterial(toRemove: Material): number;
  37362. /**
  37363. * Removes the given action manager from this scene.
  37364. * @param toRemove The action manager to remove
  37365. * @returns The index of the removed action manager
  37366. */
  37367. removeActionManager(toRemove: AbstractActionManager): number;
  37368. /**
  37369. * Removes the given texture from this scene.
  37370. * @param toRemove The texture to remove
  37371. * @returns The index of the removed texture
  37372. */
  37373. removeTexture(toRemove: BaseTexture): number;
  37374. /**
  37375. * Adds the given light to this scene
  37376. * @param newLight The light to add
  37377. */
  37378. addLight(newLight: Light): void;
  37379. /**
  37380. * Sorts the list list based on light priorities
  37381. */
  37382. sortLightsByPriority(): void;
  37383. /**
  37384. * Adds the given camera to this scene
  37385. * @param newCamera The camera to add
  37386. */
  37387. addCamera(newCamera: Camera): void;
  37388. /**
  37389. * Adds the given skeleton to this scene
  37390. * @param newSkeleton The skeleton to add
  37391. */
  37392. addSkeleton(newSkeleton: Skeleton): void;
  37393. /**
  37394. * Adds the given particle system to this scene
  37395. * @param newParticleSystem The particle system to add
  37396. */
  37397. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37398. /**
  37399. * Adds the given animation to this scene
  37400. * @param newAnimation The animation to add
  37401. */
  37402. addAnimation(newAnimation: Animation): void;
  37403. /**
  37404. * Adds the given animation group to this scene.
  37405. * @param newAnimationGroup The animation group to add
  37406. */
  37407. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37408. /**
  37409. * Adds the given multi-material to this scene
  37410. * @param newMultiMaterial The multi-material to add
  37411. */
  37412. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37413. /**
  37414. * Adds the given material to this scene
  37415. * @param newMaterial The material to add
  37416. */
  37417. addMaterial(newMaterial: Material): void;
  37418. /**
  37419. * Adds the given morph target to this scene
  37420. * @param newMorphTargetManager The morph target to add
  37421. */
  37422. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37423. /**
  37424. * Adds the given geometry to this scene
  37425. * @param newGeometry The geometry to add
  37426. */
  37427. addGeometry(newGeometry: Geometry): void;
  37428. /**
  37429. * Adds the given action manager to this scene
  37430. * @param newActionManager The action manager to add
  37431. */
  37432. addActionManager(newActionManager: AbstractActionManager): void;
  37433. /**
  37434. * Adds the given texture to this scene.
  37435. * @param newTexture The texture to add
  37436. */
  37437. addTexture(newTexture: BaseTexture): void;
  37438. /**
  37439. * Switch active camera
  37440. * @param newCamera defines the new active camera
  37441. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37442. */
  37443. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37444. /**
  37445. * sets the active camera of the scene using its ID
  37446. * @param id defines the camera's ID
  37447. * @return the new active camera or null if none found.
  37448. */
  37449. setActiveCameraByID(id: string): Nullable<Camera>;
  37450. /**
  37451. * sets the active camera of the scene using its name
  37452. * @param name defines the camera's name
  37453. * @returns the new active camera or null if none found.
  37454. */
  37455. setActiveCameraByName(name: string): Nullable<Camera>;
  37456. /**
  37457. * get an animation group using its name
  37458. * @param name defines the material's name
  37459. * @return the animation group or null if none found.
  37460. */
  37461. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37462. /**
  37463. * Get a material using its unique id
  37464. * @param uniqueId defines the material's unique id
  37465. * @return the material or null if none found.
  37466. */
  37467. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37468. /**
  37469. * get a material using its id
  37470. * @param id defines the material's ID
  37471. * @return the material or null if none found.
  37472. */
  37473. getMaterialByID(id: string): Nullable<Material>;
  37474. /**
  37475. * Gets a the last added material using a given id
  37476. * @param id defines the material's ID
  37477. * @return the last material with the given id or null if none found.
  37478. */
  37479. getLastMaterialByID(id: string): Nullable<Material>;
  37480. /**
  37481. * Gets a material using its name
  37482. * @param name defines the material's name
  37483. * @return the material or null if none found.
  37484. */
  37485. getMaterialByName(name: string): Nullable<Material>;
  37486. /**
  37487. * Get a texture using its unique id
  37488. * @param uniqueId defines the texture's unique id
  37489. * @return the texture or null if none found.
  37490. */
  37491. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37492. /**
  37493. * Gets a camera using its id
  37494. * @param id defines the id to look for
  37495. * @returns the camera or null if not found
  37496. */
  37497. getCameraByID(id: string): Nullable<Camera>;
  37498. /**
  37499. * Gets a camera using its unique id
  37500. * @param uniqueId defines the unique id to look for
  37501. * @returns the camera or null if not found
  37502. */
  37503. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37504. /**
  37505. * Gets a camera using its name
  37506. * @param name defines the camera's name
  37507. * @return the camera or null if none found.
  37508. */
  37509. getCameraByName(name: string): Nullable<Camera>;
  37510. /**
  37511. * Gets a bone using its id
  37512. * @param id defines the bone's id
  37513. * @return the bone or null if not found
  37514. */
  37515. getBoneByID(id: string): Nullable<Bone>;
  37516. /**
  37517. * Gets a bone using its id
  37518. * @param name defines the bone's name
  37519. * @return the bone or null if not found
  37520. */
  37521. getBoneByName(name: string): Nullable<Bone>;
  37522. /**
  37523. * Gets a light node using its name
  37524. * @param name defines the the light's name
  37525. * @return the light or null if none found.
  37526. */
  37527. getLightByName(name: string): Nullable<Light>;
  37528. /**
  37529. * Gets a light node using its id
  37530. * @param id defines the light's id
  37531. * @return the light or null if none found.
  37532. */
  37533. getLightByID(id: string): Nullable<Light>;
  37534. /**
  37535. * Gets a light node using its scene-generated unique ID
  37536. * @param uniqueId defines the light's unique id
  37537. * @return the light or null if none found.
  37538. */
  37539. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37540. /**
  37541. * Gets a particle system by id
  37542. * @param id defines the particle system id
  37543. * @return the corresponding system or null if none found
  37544. */
  37545. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37546. /**
  37547. * Gets a geometry using its ID
  37548. * @param id defines the geometry's id
  37549. * @return the geometry or null if none found.
  37550. */
  37551. getGeometryByID(id: string): Nullable<Geometry>;
  37552. private _getGeometryByUniqueID;
  37553. /**
  37554. * Add a new geometry to this scene
  37555. * @param geometry defines the geometry to be added to the scene.
  37556. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37557. * @return a boolean defining if the geometry was added or not
  37558. */
  37559. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37560. /**
  37561. * Removes an existing geometry
  37562. * @param geometry defines the geometry to be removed from the scene
  37563. * @return a boolean defining if the geometry was removed or not
  37564. */
  37565. removeGeometry(geometry: Geometry): boolean;
  37566. /**
  37567. * Gets the list of geometries attached to the scene
  37568. * @returns an array of Geometry
  37569. */
  37570. getGeometries(): Geometry[];
  37571. /**
  37572. * Gets the first added mesh found of a given ID
  37573. * @param id defines the id to search for
  37574. * @return the mesh found or null if not found at all
  37575. */
  37576. getMeshByID(id: string): Nullable<AbstractMesh>;
  37577. /**
  37578. * Gets a list of meshes using their id
  37579. * @param id defines the id to search for
  37580. * @returns a list of meshes
  37581. */
  37582. getMeshesByID(id: string): Array<AbstractMesh>;
  37583. /**
  37584. * Gets the first added transform node found of a given ID
  37585. * @param id defines the id to search for
  37586. * @return the found transform node or null if not found at all.
  37587. */
  37588. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37589. /**
  37590. * Gets a transform node with its auto-generated unique id
  37591. * @param uniqueId efines the unique id to search for
  37592. * @return the found transform node or null if not found at all.
  37593. */
  37594. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37595. /**
  37596. * Gets a list of transform nodes using their id
  37597. * @param id defines the id to search for
  37598. * @returns a list of transform nodes
  37599. */
  37600. getTransformNodesByID(id: string): Array<TransformNode>;
  37601. /**
  37602. * Gets a mesh with its auto-generated unique id
  37603. * @param uniqueId defines the unique id to search for
  37604. * @return the found mesh or null if not found at all.
  37605. */
  37606. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37607. /**
  37608. * Gets a the last added mesh using a given id
  37609. * @param id defines the id to search for
  37610. * @return the found mesh or null if not found at all.
  37611. */
  37612. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37613. /**
  37614. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37615. * @param id defines the id to search for
  37616. * @return the found node or null if not found at all
  37617. */
  37618. getLastEntryByID(id: string): Nullable<Node>;
  37619. /**
  37620. * Gets a node (Mesh, Camera, Light) using a given id
  37621. * @param id defines the id to search for
  37622. * @return the found node or null if not found at all
  37623. */
  37624. getNodeByID(id: string): Nullable<Node>;
  37625. /**
  37626. * Gets a node (Mesh, Camera, Light) using a given name
  37627. * @param name defines the name to search for
  37628. * @return the found node or null if not found at all.
  37629. */
  37630. getNodeByName(name: string): Nullable<Node>;
  37631. /**
  37632. * Gets a mesh using a given name
  37633. * @param name defines the name to search for
  37634. * @return the found mesh or null if not found at all.
  37635. */
  37636. getMeshByName(name: string): Nullable<AbstractMesh>;
  37637. /**
  37638. * Gets a transform node using a given name
  37639. * @param name defines the name to search for
  37640. * @return the found transform node or null if not found at all.
  37641. */
  37642. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37643. /**
  37644. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37645. * @param id defines the id to search for
  37646. * @return the found skeleton or null if not found at all.
  37647. */
  37648. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37649. /**
  37650. * Gets a skeleton using a given auto generated unique id
  37651. * @param uniqueId defines the unique id to search for
  37652. * @return the found skeleton or null if not found at all.
  37653. */
  37654. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37655. /**
  37656. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37657. * @param id defines the id to search for
  37658. * @return the found skeleton or null if not found at all.
  37659. */
  37660. getSkeletonById(id: string): Nullable<Skeleton>;
  37661. /**
  37662. * Gets a skeleton using a given name
  37663. * @param name defines the name to search for
  37664. * @return the found skeleton or null if not found at all.
  37665. */
  37666. getSkeletonByName(name: string): Nullable<Skeleton>;
  37667. /**
  37668. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37669. * @param id defines the id to search for
  37670. * @return the found morph target manager or null if not found at all.
  37671. */
  37672. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37673. /**
  37674. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37675. * @param id defines the id to search for
  37676. * @return the found morph target or null if not found at all.
  37677. */
  37678. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37679. /**
  37680. * Gets a boolean indicating if the given mesh is active
  37681. * @param mesh defines the mesh to look for
  37682. * @returns true if the mesh is in the active list
  37683. */
  37684. isActiveMesh(mesh: AbstractMesh): boolean;
  37685. /**
  37686. * Return a unique id as a string which can serve as an identifier for the scene
  37687. */
  37688. get uid(): string;
  37689. /**
  37690. * Add an externaly attached data from its key.
  37691. * This method call will fail and return false, if such key already exists.
  37692. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37693. * @param key the unique key that identifies the data
  37694. * @param data the data object to associate to the key for this Engine instance
  37695. * @return true if no such key were already present and the data was added successfully, false otherwise
  37696. */
  37697. addExternalData<T>(key: string, data: T): boolean;
  37698. /**
  37699. * Get an externaly attached data from its key
  37700. * @param key the unique key that identifies the data
  37701. * @return the associated data, if present (can be null), or undefined if not present
  37702. */
  37703. getExternalData<T>(key: string): Nullable<T>;
  37704. /**
  37705. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37706. * @param key the unique key that identifies the data
  37707. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37708. * @return the associated data, can be null if the factory returned null.
  37709. */
  37710. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37711. /**
  37712. * Remove an externaly attached data from the Engine instance
  37713. * @param key the unique key that identifies the data
  37714. * @return true if the data was successfully removed, false if it doesn't exist
  37715. */
  37716. removeExternalData(key: string): boolean;
  37717. private _evaluateSubMesh;
  37718. /**
  37719. * Clear the processed materials smart array preventing retention point in material dispose.
  37720. */
  37721. freeProcessedMaterials(): void;
  37722. private _preventFreeActiveMeshesAndRenderingGroups;
  37723. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37724. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37725. * when disposing several meshes in a row or a hierarchy of meshes.
  37726. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37727. */
  37728. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37729. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37730. /**
  37731. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37732. */
  37733. freeActiveMeshes(): void;
  37734. /**
  37735. * Clear the info related to rendering groups preventing retention points during dispose.
  37736. */
  37737. freeRenderingGroups(): void;
  37738. /** @hidden */
  37739. _isInIntermediateRendering(): boolean;
  37740. /**
  37741. * Lambda returning the list of potentially active meshes.
  37742. */
  37743. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37744. /**
  37745. * Lambda returning the list of potentially active sub meshes.
  37746. */
  37747. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37748. /**
  37749. * Lambda returning the list of potentially intersecting sub meshes.
  37750. */
  37751. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37752. /**
  37753. * Lambda returning the list of potentially colliding sub meshes.
  37754. */
  37755. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37756. private _activeMeshesFrozen;
  37757. private _skipEvaluateActiveMeshesCompletely;
  37758. /**
  37759. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37760. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37761. * @returns the current scene
  37762. */
  37763. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37764. /**
  37765. * Use this function to restart evaluating active meshes on every frame
  37766. * @returns the current scene
  37767. */
  37768. unfreezeActiveMeshes(): Scene;
  37769. private _evaluateActiveMeshes;
  37770. private _activeMesh;
  37771. /**
  37772. * Update the transform matrix to update from the current active camera
  37773. * @param force defines a boolean used to force the update even if cache is up to date
  37774. */
  37775. updateTransformMatrix(force?: boolean): void;
  37776. private _bindFrameBuffer;
  37777. /** @hidden */
  37778. _allowPostProcessClearColor: boolean;
  37779. /** @hidden */
  37780. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37781. private _processSubCameras;
  37782. private _checkIntersections;
  37783. /** @hidden */
  37784. _advancePhysicsEngineStep(step: number): void;
  37785. /**
  37786. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37787. */
  37788. getDeterministicFrameTime: () => number;
  37789. /** @hidden */
  37790. _animate(): void;
  37791. /** Execute all animations (for a frame) */
  37792. animate(): void;
  37793. /**
  37794. * Render the scene
  37795. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37796. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37797. */
  37798. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37799. /**
  37800. * Freeze all materials
  37801. * A frozen material will not be updatable but should be faster to render
  37802. */
  37803. freezeMaterials(): void;
  37804. /**
  37805. * Unfreeze all materials
  37806. * A frozen material will not be updatable but should be faster to render
  37807. */
  37808. unfreezeMaterials(): void;
  37809. /**
  37810. * Releases all held ressources
  37811. */
  37812. dispose(): void;
  37813. /**
  37814. * Gets if the scene is already disposed
  37815. */
  37816. get isDisposed(): boolean;
  37817. /**
  37818. * Call this function to reduce memory footprint of the scene.
  37819. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37820. */
  37821. clearCachedVertexData(): void;
  37822. /**
  37823. * This function will remove the local cached buffer data from texture.
  37824. * It will save memory but will prevent the texture from being rebuilt
  37825. */
  37826. cleanCachedTextureBuffer(): void;
  37827. /**
  37828. * Get the world extend vectors with an optional filter
  37829. *
  37830. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37831. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37832. */
  37833. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37834. min: Vector3;
  37835. max: Vector3;
  37836. };
  37837. /**
  37838. * Creates a ray that can be used to pick in the scene
  37839. * @param x defines the x coordinate of the origin (on-screen)
  37840. * @param y defines the y coordinate of the origin (on-screen)
  37841. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37842. * @param camera defines the camera to use for the picking
  37843. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37844. * @returns a Ray
  37845. */
  37846. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37847. /**
  37848. * Creates a ray that can be used to pick in the scene
  37849. * @param x defines the x coordinate of the origin (on-screen)
  37850. * @param y defines the y coordinate of the origin (on-screen)
  37851. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37852. * @param result defines the ray where to store the picking ray
  37853. * @param camera defines the camera to use for the picking
  37854. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37855. * @returns the current scene
  37856. */
  37857. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37858. /**
  37859. * Creates a ray that can be used to pick in the scene
  37860. * @param x defines the x coordinate of the origin (on-screen)
  37861. * @param y defines the y coordinate of the origin (on-screen)
  37862. * @param camera defines the camera to use for the picking
  37863. * @returns a Ray
  37864. */
  37865. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37866. /**
  37867. * Creates a ray that can be used to pick in the scene
  37868. * @param x defines the x coordinate of the origin (on-screen)
  37869. * @param y defines the y coordinate of the origin (on-screen)
  37870. * @param result defines the ray where to store the picking ray
  37871. * @param camera defines the camera to use for the picking
  37872. * @returns the current scene
  37873. */
  37874. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37875. /** Launch a ray to try to pick a mesh in the scene
  37876. * @param x position on screen
  37877. * @param y position on screen
  37878. * @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
  37879. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37880. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37882. * @returns a PickingInfo
  37883. */
  37884. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37885. /** Use the given ray to pick a mesh in the scene
  37886. * @param ray The ray to use to pick meshes
  37887. * @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
  37888. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37890. * @returns a PickingInfo
  37891. */
  37892. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37893. /**
  37894. * Launch a ray to try to pick a mesh in the scene
  37895. * @param x X position on screen
  37896. * @param y Y position on screen
  37897. * @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
  37898. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37900. * @returns an array of PickingInfo
  37901. */
  37902. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37903. /**
  37904. * Launch a ray to try to pick a mesh in the scene
  37905. * @param ray Ray to use
  37906. * @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
  37907. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37908. * @returns an array of PickingInfo
  37909. */
  37910. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37911. /**
  37912. * Force the value of meshUnderPointer
  37913. * @param mesh defines the mesh to use
  37914. */
  37915. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37916. /**
  37917. * Gets the mesh under the pointer
  37918. * @returns a Mesh or null if no mesh is under the pointer
  37919. */
  37920. getPointerOverMesh(): Nullable<AbstractMesh>;
  37921. /** @hidden */
  37922. _rebuildGeometries(): void;
  37923. /** @hidden */
  37924. _rebuildTextures(): void;
  37925. private _getByTags;
  37926. /**
  37927. * Get a list of meshes by tags
  37928. * @param tagsQuery defines the tags query to use
  37929. * @param forEach defines a predicate used to filter results
  37930. * @returns an array of Mesh
  37931. */
  37932. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37933. /**
  37934. * Get a list of cameras by tags
  37935. * @param tagsQuery defines the tags query to use
  37936. * @param forEach defines a predicate used to filter results
  37937. * @returns an array of Camera
  37938. */
  37939. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37940. /**
  37941. * Get a list of lights by tags
  37942. * @param tagsQuery defines the tags query to use
  37943. * @param forEach defines a predicate used to filter results
  37944. * @returns an array of Light
  37945. */
  37946. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37947. /**
  37948. * Get a list of materials by tags
  37949. * @param tagsQuery defines the tags query to use
  37950. * @param forEach defines a predicate used to filter results
  37951. * @returns an array of Material
  37952. */
  37953. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37954. /**
  37955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37956. * This allowed control for front to back rendering or reversly depending of the special needs.
  37957. *
  37958. * @param renderingGroupId The rendering group id corresponding to its index
  37959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37962. */
  37963. 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;
  37964. /**
  37965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37966. *
  37967. * @param renderingGroupId The rendering group id corresponding to its index
  37968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37969. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37970. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37971. */
  37972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37973. /**
  37974. * Gets the current auto clear configuration for one rendering group of the rendering
  37975. * manager.
  37976. * @param index the rendering group index to get the information for
  37977. * @returns The auto clear setup for the requested rendering group
  37978. */
  37979. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37980. private _blockMaterialDirtyMechanism;
  37981. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37982. get blockMaterialDirtyMechanism(): boolean;
  37983. set blockMaterialDirtyMechanism(value: boolean);
  37984. /**
  37985. * Will flag all materials as dirty to trigger new shader compilation
  37986. * @param flag defines the flag used to specify which material part must be marked as dirty
  37987. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37988. */
  37989. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37990. /** @hidden */
  37991. _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;
  37992. /** @hidden */
  37993. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37994. /** @hidden */
  37995. _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;
  37996. /** @hidden */
  37997. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37998. /** @hidden */
  37999. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38000. /** @hidden */
  38001. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38002. }
  38003. }
  38004. declare module "babylonjs/assetContainer" {
  38005. import { AbstractScene } from "babylonjs/abstractScene";
  38006. import { Scene } from "babylonjs/scene";
  38007. import { Mesh } from "babylonjs/Meshes/mesh";
  38008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38009. import { Skeleton } from "babylonjs/Bones/skeleton";
  38010. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38011. import { Animatable } from "babylonjs/Animations/animatable";
  38012. import { Nullable } from "babylonjs/types";
  38013. import { Node } from "babylonjs/node";
  38014. /**
  38015. * Set of assets to keep when moving a scene into an asset container.
  38016. */
  38017. export class KeepAssets extends AbstractScene {
  38018. }
  38019. /**
  38020. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38021. */
  38022. export class InstantiatedEntries {
  38023. /**
  38024. * List of new root nodes (eg. nodes with no parent)
  38025. */
  38026. rootNodes: TransformNode[];
  38027. /**
  38028. * List of new skeletons
  38029. */
  38030. skeletons: Skeleton[];
  38031. /**
  38032. * List of new animation groups
  38033. */
  38034. animationGroups: AnimationGroup[];
  38035. }
  38036. /**
  38037. * Container with a set of assets that can be added or removed from a scene.
  38038. */
  38039. export class AssetContainer extends AbstractScene {
  38040. private _wasAddedToScene;
  38041. /**
  38042. * The scene the AssetContainer belongs to.
  38043. */
  38044. scene: Scene;
  38045. /**
  38046. * Instantiates an AssetContainer.
  38047. * @param scene The scene the AssetContainer belongs to.
  38048. */
  38049. constructor(scene: Scene);
  38050. /**
  38051. * Instantiate or clone all meshes and add the new ones to the scene.
  38052. * Skeletons and animation groups will all be cloned
  38053. * @param nameFunction defines an optional function used to get new names for clones
  38054. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38055. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38056. */
  38057. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38058. /**
  38059. * Adds all the assets from the container to the scene.
  38060. */
  38061. addAllToScene(): void;
  38062. /**
  38063. * Removes all the assets in the container from the scene
  38064. */
  38065. removeAllFromScene(): void;
  38066. /**
  38067. * Disposes all the assets in the container
  38068. */
  38069. dispose(): void;
  38070. private _moveAssets;
  38071. /**
  38072. * Removes all the assets contained in the scene and adds them to the container.
  38073. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38074. */
  38075. moveAllFromScene(keepAssets?: KeepAssets): void;
  38076. /**
  38077. * 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.
  38078. * @returns the root mesh
  38079. */
  38080. createRootMesh(): Mesh;
  38081. /**
  38082. * Merge animations from this asset container into a scene
  38083. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38084. * @param animatables set of animatables to retarget to a node from the scene
  38085. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38086. */
  38087. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38088. }
  38089. }
  38090. declare module "babylonjs/abstractScene" {
  38091. import { Scene } from "babylonjs/scene";
  38092. import { Nullable } from "babylonjs/types";
  38093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38094. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38095. import { Geometry } from "babylonjs/Meshes/geometry";
  38096. import { Skeleton } from "babylonjs/Bones/skeleton";
  38097. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38098. import { AssetContainer } from "babylonjs/assetContainer";
  38099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38100. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38102. import { Material } from "babylonjs/Materials/material";
  38103. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38104. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38105. import { Camera } from "babylonjs/Cameras/camera";
  38106. import { Light } from "babylonjs/Lights/light";
  38107. import { Node } from "babylonjs/node";
  38108. import { Animation } from "babylonjs/Animations/animation";
  38109. /**
  38110. * Defines how the parser contract is defined.
  38111. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38112. */
  38113. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38114. /**
  38115. * Defines how the individual parser contract is defined.
  38116. * These parser can parse an individual asset
  38117. */
  38118. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38119. /**
  38120. * Base class of the scene acting as a container for the different elements composing a scene.
  38121. * This class is dynamically extended by the different components of the scene increasing
  38122. * flexibility and reducing coupling
  38123. */
  38124. export abstract class AbstractScene {
  38125. /**
  38126. * Stores the list of available parsers in the application.
  38127. */
  38128. private static _BabylonFileParsers;
  38129. /**
  38130. * Stores the list of available individual parsers in the application.
  38131. */
  38132. private static _IndividualBabylonFileParsers;
  38133. /**
  38134. * Adds a parser in the list of available ones
  38135. * @param name Defines the name of the parser
  38136. * @param parser Defines the parser to add
  38137. */
  38138. static AddParser(name: string, parser: BabylonFileParser): void;
  38139. /**
  38140. * Gets a general parser from the list of avaialble ones
  38141. * @param name Defines the name of the parser
  38142. * @returns the requested parser or null
  38143. */
  38144. static GetParser(name: string): Nullable<BabylonFileParser>;
  38145. /**
  38146. * Adds n individual parser in the list of available ones
  38147. * @param name Defines the name of the parser
  38148. * @param parser Defines the parser to add
  38149. */
  38150. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38151. /**
  38152. * Gets an individual parser from the list of avaialble ones
  38153. * @param name Defines the name of the parser
  38154. * @returns the requested parser or null
  38155. */
  38156. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38157. /**
  38158. * Parser json data and populate both a scene and its associated container object
  38159. * @param jsonData Defines the data to parse
  38160. * @param scene Defines the scene to parse the data for
  38161. * @param container Defines the container attached to the parsing sequence
  38162. * @param rootUrl Defines the root url of the data
  38163. */
  38164. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38165. /**
  38166. * Gets the list of root nodes (ie. nodes with no parent)
  38167. */
  38168. rootNodes: Node[];
  38169. /** All of the cameras added to this scene
  38170. * @see http://doc.babylonjs.com/babylon101/cameras
  38171. */
  38172. cameras: Camera[];
  38173. /**
  38174. * All of the lights added to this scene
  38175. * @see http://doc.babylonjs.com/babylon101/lights
  38176. */
  38177. lights: Light[];
  38178. /**
  38179. * All of the (abstract) meshes added to this scene
  38180. */
  38181. meshes: AbstractMesh[];
  38182. /**
  38183. * The list of skeletons added to the scene
  38184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38185. */
  38186. skeletons: Skeleton[];
  38187. /**
  38188. * All of the particle systems added to this scene
  38189. * @see http://doc.babylonjs.com/babylon101/particles
  38190. */
  38191. particleSystems: IParticleSystem[];
  38192. /**
  38193. * Gets a list of Animations associated with the scene
  38194. */
  38195. animations: Animation[];
  38196. /**
  38197. * All of the animation groups added to this scene
  38198. * @see http://doc.babylonjs.com/how_to/group
  38199. */
  38200. animationGroups: AnimationGroup[];
  38201. /**
  38202. * All of the multi-materials added to this scene
  38203. * @see http://doc.babylonjs.com/how_to/multi_materials
  38204. */
  38205. multiMaterials: MultiMaterial[];
  38206. /**
  38207. * All of the materials added to this scene
  38208. * In the context of a Scene, it is not supposed to be modified manually.
  38209. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38210. * Note also that the order of the Material within the array is not significant and might change.
  38211. * @see http://doc.babylonjs.com/babylon101/materials
  38212. */
  38213. materials: Material[];
  38214. /**
  38215. * The list of morph target managers added to the scene
  38216. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38217. */
  38218. morphTargetManagers: MorphTargetManager[];
  38219. /**
  38220. * The list of geometries used in the scene.
  38221. */
  38222. geometries: Geometry[];
  38223. /**
  38224. * All of the tranform nodes added to this scene
  38225. * In the context of a Scene, it is not supposed to be modified manually.
  38226. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38227. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38228. * @see http://doc.babylonjs.com/how_to/transformnode
  38229. */
  38230. transformNodes: TransformNode[];
  38231. /**
  38232. * ActionManagers available on the scene.
  38233. */
  38234. actionManagers: AbstractActionManager[];
  38235. /**
  38236. * Textures to keep.
  38237. */
  38238. textures: BaseTexture[];
  38239. /**
  38240. * Environment texture for the scene
  38241. */
  38242. environmentTexture: Nullable<BaseTexture>;
  38243. /**
  38244. * @returns all meshes, lights, cameras, transformNodes and bones
  38245. */
  38246. getNodes(): Array<Node>;
  38247. }
  38248. }
  38249. declare module "babylonjs/Audio/sound" {
  38250. import { Observable } from "babylonjs/Misc/observable";
  38251. import { Vector3 } from "babylonjs/Maths/math.vector";
  38252. import { Nullable } from "babylonjs/types";
  38253. import { Scene } from "babylonjs/scene";
  38254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38255. /**
  38256. * Interface used to define options for Sound class
  38257. */
  38258. export interface ISoundOptions {
  38259. /**
  38260. * Does the sound autoplay once loaded.
  38261. */
  38262. autoplay?: boolean;
  38263. /**
  38264. * Does the sound loop after it finishes playing once.
  38265. */
  38266. loop?: boolean;
  38267. /**
  38268. * Sound's volume
  38269. */
  38270. volume?: number;
  38271. /**
  38272. * Is it a spatial sound?
  38273. */
  38274. spatialSound?: boolean;
  38275. /**
  38276. * Maximum distance to hear that sound
  38277. */
  38278. maxDistance?: number;
  38279. /**
  38280. * Uses user defined attenuation function
  38281. */
  38282. useCustomAttenuation?: boolean;
  38283. /**
  38284. * Define the roll off factor of spatial sounds.
  38285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38286. */
  38287. rolloffFactor?: number;
  38288. /**
  38289. * Define the reference distance the sound should be heard perfectly.
  38290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38291. */
  38292. refDistance?: number;
  38293. /**
  38294. * Define the distance attenuation model the sound will follow.
  38295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38296. */
  38297. distanceModel?: string;
  38298. /**
  38299. * Defines the playback speed (1 by default)
  38300. */
  38301. playbackRate?: number;
  38302. /**
  38303. * Defines if the sound is from a streaming source
  38304. */
  38305. streaming?: boolean;
  38306. /**
  38307. * Defines an optional length (in seconds) inside the sound file
  38308. */
  38309. length?: number;
  38310. /**
  38311. * Defines an optional offset (in seconds) inside the sound file
  38312. */
  38313. offset?: number;
  38314. /**
  38315. * If true, URLs will not be required to state the audio file codec to use.
  38316. */
  38317. skipCodecCheck?: boolean;
  38318. }
  38319. /**
  38320. * Defines a sound that can be played in the application.
  38321. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38323. */
  38324. export class Sound {
  38325. /**
  38326. * The name of the sound in the scene.
  38327. */
  38328. name: string;
  38329. /**
  38330. * Does the sound autoplay once loaded.
  38331. */
  38332. autoplay: boolean;
  38333. /**
  38334. * Does the sound loop after it finishes playing once.
  38335. */
  38336. loop: boolean;
  38337. /**
  38338. * Does the sound use a custom attenuation curve to simulate the falloff
  38339. * happening when the source gets further away from the camera.
  38340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38341. */
  38342. useCustomAttenuation: boolean;
  38343. /**
  38344. * The sound track id this sound belongs to.
  38345. */
  38346. soundTrackId: number;
  38347. /**
  38348. * Is this sound currently played.
  38349. */
  38350. isPlaying: boolean;
  38351. /**
  38352. * Is this sound currently paused.
  38353. */
  38354. isPaused: boolean;
  38355. /**
  38356. * Does this sound enables spatial sound.
  38357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38358. */
  38359. spatialSound: boolean;
  38360. /**
  38361. * Define the reference distance the sound should be heard perfectly.
  38362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38363. */
  38364. refDistance: number;
  38365. /**
  38366. * Define the roll off factor of spatial sounds.
  38367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38368. */
  38369. rolloffFactor: number;
  38370. /**
  38371. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38373. */
  38374. maxDistance: number;
  38375. /**
  38376. * Define the distance attenuation model the sound will follow.
  38377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38378. */
  38379. distanceModel: string;
  38380. /**
  38381. * @hidden
  38382. * Back Compat
  38383. **/
  38384. onended: () => any;
  38385. /**
  38386. * Observable event when the current playing sound finishes.
  38387. */
  38388. onEndedObservable: Observable<Sound>;
  38389. private _panningModel;
  38390. private _playbackRate;
  38391. private _streaming;
  38392. private _startTime;
  38393. private _startOffset;
  38394. private _position;
  38395. /** @hidden */
  38396. _positionInEmitterSpace: boolean;
  38397. private _localDirection;
  38398. private _volume;
  38399. private _isReadyToPlay;
  38400. private _isDirectional;
  38401. private _readyToPlayCallback;
  38402. private _audioBuffer;
  38403. private _soundSource;
  38404. private _streamingSource;
  38405. private _soundPanner;
  38406. private _soundGain;
  38407. private _inputAudioNode;
  38408. private _outputAudioNode;
  38409. private _coneInnerAngle;
  38410. private _coneOuterAngle;
  38411. private _coneOuterGain;
  38412. private _scene;
  38413. private _connectedTransformNode;
  38414. private _customAttenuationFunction;
  38415. private _registerFunc;
  38416. private _isOutputConnected;
  38417. private _htmlAudioElement;
  38418. private _urlType;
  38419. private _length?;
  38420. private _offset?;
  38421. /** @hidden */
  38422. static _SceneComponentInitialization: (scene: Scene) => void;
  38423. /**
  38424. * Create a sound and attach it to a scene
  38425. * @param name Name of your sound
  38426. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38427. * @param scene defines the scene the sound belongs to
  38428. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38429. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38430. */
  38431. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38432. /**
  38433. * Release the sound and its associated resources
  38434. */
  38435. dispose(): void;
  38436. /**
  38437. * Gets if the sounds is ready to be played or not.
  38438. * @returns true if ready, otherwise false
  38439. */
  38440. isReady(): boolean;
  38441. private _soundLoaded;
  38442. /**
  38443. * Sets the data of the sound from an audiobuffer
  38444. * @param audioBuffer The audioBuffer containing the data
  38445. */
  38446. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38447. /**
  38448. * Updates the current sounds options such as maxdistance, loop...
  38449. * @param options A JSON object containing values named as the object properties
  38450. */
  38451. updateOptions(options: ISoundOptions): void;
  38452. private _createSpatialParameters;
  38453. private _updateSpatialParameters;
  38454. /**
  38455. * Switch the panning model to HRTF:
  38456. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38458. */
  38459. switchPanningModelToHRTF(): void;
  38460. /**
  38461. * Switch the panning model to Equal Power:
  38462. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38464. */
  38465. switchPanningModelToEqualPower(): void;
  38466. private _switchPanningModel;
  38467. /**
  38468. * Connect this sound to a sound track audio node like gain...
  38469. * @param soundTrackAudioNode the sound track audio node to connect to
  38470. */
  38471. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38472. /**
  38473. * Transform this sound into a directional source
  38474. * @param coneInnerAngle Size of the inner cone in degree
  38475. * @param coneOuterAngle Size of the outer cone in degree
  38476. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38477. */
  38478. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38479. /**
  38480. * Gets or sets the inner angle for the directional cone.
  38481. */
  38482. get directionalConeInnerAngle(): number;
  38483. /**
  38484. * Gets or sets the inner angle for the directional cone.
  38485. */
  38486. set directionalConeInnerAngle(value: number);
  38487. /**
  38488. * Gets or sets the outer angle for the directional cone.
  38489. */
  38490. get directionalConeOuterAngle(): number;
  38491. /**
  38492. * Gets or sets the outer angle for the directional cone.
  38493. */
  38494. set directionalConeOuterAngle(value: number);
  38495. /**
  38496. * Sets the position of the emitter if spatial sound is enabled
  38497. * @param newPosition Defines the new posisiton
  38498. */
  38499. setPosition(newPosition: Vector3): void;
  38500. /**
  38501. * Sets the local direction of the emitter if spatial sound is enabled
  38502. * @param newLocalDirection Defines the new local direction
  38503. */
  38504. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38505. private _updateDirection;
  38506. /** @hidden */
  38507. updateDistanceFromListener(): void;
  38508. /**
  38509. * Sets a new custom attenuation function for the sound.
  38510. * @param callback Defines the function used for the attenuation
  38511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38512. */
  38513. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38514. /**
  38515. * Play the sound
  38516. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38517. * @param offset (optional) Start the sound at a specific time in seconds
  38518. * @param length (optional) Sound duration (in seconds)
  38519. */
  38520. play(time?: number, offset?: number, length?: number): void;
  38521. private _onended;
  38522. /**
  38523. * Stop the sound
  38524. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38525. */
  38526. stop(time?: number): void;
  38527. /**
  38528. * Put the sound in pause
  38529. */
  38530. pause(): void;
  38531. /**
  38532. * Sets a dedicated volume for this sounds
  38533. * @param newVolume Define the new volume of the sound
  38534. * @param time Define time for gradual change to new volume
  38535. */
  38536. setVolume(newVolume: number, time?: number): void;
  38537. /**
  38538. * Set the sound play back rate
  38539. * @param newPlaybackRate Define the playback rate the sound should be played at
  38540. */
  38541. setPlaybackRate(newPlaybackRate: number): void;
  38542. /**
  38543. * Gets the volume of the sound.
  38544. * @returns the volume of the sound
  38545. */
  38546. getVolume(): number;
  38547. /**
  38548. * Attach the sound to a dedicated mesh
  38549. * @param transformNode The transform node to connect the sound with
  38550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38551. */
  38552. attachToMesh(transformNode: TransformNode): void;
  38553. /**
  38554. * Detach the sound from the previously attached mesh
  38555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38556. */
  38557. detachFromMesh(): void;
  38558. private _onRegisterAfterWorldMatrixUpdate;
  38559. /**
  38560. * Clone the current sound in the scene.
  38561. * @returns the new sound clone
  38562. */
  38563. clone(): Nullable<Sound>;
  38564. /**
  38565. * Gets the current underlying audio buffer containing the data
  38566. * @returns the audio buffer
  38567. */
  38568. getAudioBuffer(): Nullable<AudioBuffer>;
  38569. /**
  38570. * Serializes the Sound in a JSON representation
  38571. * @returns the JSON representation of the sound
  38572. */
  38573. serialize(): any;
  38574. /**
  38575. * Parse a JSON representation of a sound to innstantiate in a given scene
  38576. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38577. * @param scene Define the scene the new parsed sound should be created in
  38578. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38579. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38580. * @returns the newly parsed sound
  38581. */
  38582. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38583. }
  38584. }
  38585. declare module "babylonjs/Actions/directAudioActions" {
  38586. import { Action } from "babylonjs/Actions/action";
  38587. import { Condition } from "babylonjs/Actions/condition";
  38588. import { Sound } from "babylonjs/Audio/sound";
  38589. /**
  38590. * This defines an action helpful to play a defined sound on a triggered action.
  38591. */
  38592. export class PlaySoundAction extends Action {
  38593. private _sound;
  38594. /**
  38595. * Instantiate the action
  38596. * @param triggerOptions defines the trigger options
  38597. * @param sound defines the sound to play
  38598. * @param condition defines the trigger related conditions
  38599. */
  38600. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38601. /** @hidden */
  38602. _prepare(): void;
  38603. /**
  38604. * Execute the action and play the sound.
  38605. */
  38606. execute(): void;
  38607. /**
  38608. * Serializes the actions and its related information.
  38609. * @param parent defines the object to serialize in
  38610. * @returns the serialized object
  38611. */
  38612. serialize(parent: any): any;
  38613. }
  38614. /**
  38615. * This defines an action helpful to stop a defined sound on a triggered action.
  38616. */
  38617. export class StopSoundAction extends Action {
  38618. private _sound;
  38619. /**
  38620. * Instantiate the action
  38621. * @param triggerOptions defines the trigger options
  38622. * @param sound defines the sound to stop
  38623. * @param condition defines the trigger related conditions
  38624. */
  38625. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38626. /** @hidden */
  38627. _prepare(): void;
  38628. /**
  38629. * Execute the action and stop the sound.
  38630. */
  38631. execute(): void;
  38632. /**
  38633. * Serializes the actions and its related information.
  38634. * @param parent defines the object to serialize in
  38635. * @returns the serialized object
  38636. */
  38637. serialize(parent: any): any;
  38638. }
  38639. }
  38640. declare module "babylonjs/Actions/interpolateValueAction" {
  38641. import { Action } from "babylonjs/Actions/action";
  38642. import { Condition } from "babylonjs/Actions/condition";
  38643. import { Observable } from "babylonjs/Misc/observable";
  38644. /**
  38645. * This defines an action responsible to change the value of a property
  38646. * by interpolating between its current value and the newly set one once triggered.
  38647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38648. */
  38649. export class InterpolateValueAction extends Action {
  38650. /**
  38651. * Defines the path of the property where the value should be interpolated
  38652. */
  38653. propertyPath: string;
  38654. /**
  38655. * Defines the target value at the end of the interpolation.
  38656. */
  38657. value: any;
  38658. /**
  38659. * Defines the time it will take for the property to interpolate to the value.
  38660. */
  38661. duration: number;
  38662. /**
  38663. * Defines if the other scene animations should be stopped when the action has been triggered
  38664. */
  38665. stopOtherAnimations?: boolean;
  38666. /**
  38667. * Defines a callback raised once the interpolation animation has been done.
  38668. */
  38669. onInterpolationDone?: () => void;
  38670. /**
  38671. * Observable triggered once the interpolation animation has been done.
  38672. */
  38673. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38674. private _target;
  38675. private _effectiveTarget;
  38676. private _property;
  38677. /**
  38678. * Instantiate the action
  38679. * @param triggerOptions defines the trigger options
  38680. * @param target defines the object containing the value to interpolate
  38681. * @param propertyPath defines the path to the property in the target object
  38682. * @param value defines the target value at the end of the interpolation
  38683. * @param duration deines the time it will take for the property to interpolate to the value.
  38684. * @param condition defines the trigger related conditions
  38685. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38686. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38687. */
  38688. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38689. /** @hidden */
  38690. _prepare(): void;
  38691. /**
  38692. * Execute the action starts the value interpolation.
  38693. */
  38694. execute(): void;
  38695. /**
  38696. * Serializes the actions and its related information.
  38697. * @param parent defines the object to serialize in
  38698. * @returns the serialized object
  38699. */
  38700. serialize(parent: any): any;
  38701. }
  38702. }
  38703. declare module "babylonjs/Actions/index" {
  38704. export * from "babylonjs/Actions/abstractActionManager";
  38705. export * from "babylonjs/Actions/action";
  38706. export * from "babylonjs/Actions/actionEvent";
  38707. export * from "babylonjs/Actions/actionManager";
  38708. export * from "babylonjs/Actions/condition";
  38709. export * from "babylonjs/Actions/directActions";
  38710. export * from "babylonjs/Actions/directAudioActions";
  38711. export * from "babylonjs/Actions/interpolateValueAction";
  38712. }
  38713. declare module "babylonjs/Animations/index" {
  38714. export * from "babylonjs/Animations/animatable";
  38715. export * from "babylonjs/Animations/animation";
  38716. export * from "babylonjs/Animations/animationGroup";
  38717. export * from "babylonjs/Animations/animationPropertiesOverride";
  38718. export * from "babylonjs/Animations/easing";
  38719. export * from "babylonjs/Animations/runtimeAnimation";
  38720. export * from "babylonjs/Animations/animationEvent";
  38721. export * from "babylonjs/Animations/animationGroup";
  38722. export * from "babylonjs/Animations/animationKey";
  38723. export * from "babylonjs/Animations/animationRange";
  38724. export * from "babylonjs/Animations/animatable.interface";
  38725. }
  38726. declare module "babylonjs/Audio/soundTrack" {
  38727. import { Sound } from "babylonjs/Audio/sound";
  38728. import { Analyser } from "babylonjs/Audio/analyser";
  38729. import { Scene } from "babylonjs/scene";
  38730. /**
  38731. * Options allowed during the creation of a sound track.
  38732. */
  38733. export interface ISoundTrackOptions {
  38734. /**
  38735. * The volume the sound track should take during creation
  38736. */
  38737. volume?: number;
  38738. /**
  38739. * Define if the sound track is the main sound track of the scene
  38740. */
  38741. mainTrack?: boolean;
  38742. }
  38743. /**
  38744. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38745. * It will be also used in a future release to apply effects on a specific track.
  38746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38747. */
  38748. export class SoundTrack {
  38749. /**
  38750. * The unique identifier of the sound track in the scene.
  38751. */
  38752. id: number;
  38753. /**
  38754. * The list of sounds included in the sound track.
  38755. */
  38756. soundCollection: Array<Sound>;
  38757. private _outputAudioNode;
  38758. private _scene;
  38759. private _connectedAnalyser;
  38760. private _options;
  38761. private _isInitialized;
  38762. /**
  38763. * Creates a new sound track.
  38764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38765. * @param scene Define the scene the sound track belongs to
  38766. * @param options
  38767. */
  38768. constructor(scene: Scene, options?: ISoundTrackOptions);
  38769. private _initializeSoundTrackAudioGraph;
  38770. /**
  38771. * Release the sound track and its associated resources
  38772. */
  38773. dispose(): void;
  38774. /**
  38775. * Adds a sound to this sound track
  38776. * @param sound define the cound to add
  38777. * @ignoreNaming
  38778. */
  38779. AddSound(sound: Sound): void;
  38780. /**
  38781. * Removes a sound to this sound track
  38782. * @param sound define the cound to remove
  38783. * @ignoreNaming
  38784. */
  38785. RemoveSound(sound: Sound): void;
  38786. /**
  38787. * Set a global volume for the full sound track.
  38788. * @param newVolume Define the new volume of the sound track
  38789. */
  38790. setVolume(newVolume: number): void;
  38791. /**
  38792. * Switch the panning model to HRTF:
  38793. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38795. */
  38796. switchPanningModelToHRTF(): void;
  38797. /**
  38798. * Switch the panning model to Equal Power:
  38799. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38801. */
  38802. switchPanningModelToEqualPower(): void;
  38803. /**
  38804. * Connect the sound track to an audio analyser allowing some amazing
  38805. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38807. * @param analyser The analyser to connect to the engine
  38808. */
  38809. connectToAnalyser(analyser: Analyser): void;
  38810. }
  38811. }
  38812. declare module "babylonjs/Audio/audioSceneComponent" {
  38813. import { Sound } from "babylonjs/Audio/sound";
  38814. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38815. import { Nullable } from "babylonjs/types";
  38816. import { Vector3 } from "babylonjs/Maths/math.vector";
  38817. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38818. import { Scene } from "babylonjs/scene";
  38819. import { AbstractScene } from "babylonjs/abstractScene";
  38820. import "babylonjs/Audio/audioEngine";
  38821. module "babylonjs/abstractScene" {
  38822. interface AbstractScene {
  38823. /**
  38824. * The list of sounds used in the scene.
  38825. */
  38826. sounds: Nullable<Array<Sound>>;
  38827. }
  38828. }
  38829. module "babylonjs/scene" {
  38830. interface Scene {
  38831. /**
  38832. * @hidden
  38833. * Backing field
  38834. */
  38835. _mainSoundTrack: SoundTrack;
  38836. /**
  38837. * The main sound track played by the scene.
  38838. * It cotains your primary collection of sounds.
  38839. */
  38840. mainSoundTrack: SoundTrack;
  38841. /**
  38842. * The list of sound tracks added to the scene
  38843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38844. */
  38845. soundTracks: Nullable<Array<SoundTrack>>;
  38846. /**
  38847. * Gets a sound using a given name
  38848. * @param name defines the name to search for
  38849. * @return the found sound or null if not found at all.
  38850. */
  38851. getSoundByName(name: string): Nullable<Sound>;
  38852. /**
  38853. * Gets or sets if audio support is enabled
  38854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38855. */
  38856. audioEnabled: boolean;
  38857. /**
  38858. * Gets or sets if audio will be output to headphones
  38859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38860. */
  38861. headphone: boolean;
  38862. /**
  38863. * Gets or sets custom audio listener position provider
  38864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38865. */
  38866. audioListenerPositionProvider: Nullable<() => Vector3>;
  38867. /**
  38868. * Gets or sets a refresh rate when using 3D audio positioning
  38869. */
  38870. audioPositioningRefreshRate: number;
  38871. }
  38872. }
  38873. /**
  38874. * Defines the sound scene component responsible to manage any sounds
  38875. * in a given scene.
  38876. */
  38877. export class AudioSceneComponent implements ISceneSerializableComponent {
  38878. /**
  38879. * The component name helpfull to identify the component in the list of scene components.
  38880. */
  38881. readonly name: string;
  38882. /**
  38883. * The scene the component belongs to.
  38884. */
  38885. scene: Scene;
  38886. private _audioEnabled;
  38887. /**
  38888. * Gets whether audio is enabled or not.
  38889. * Please use related enable/disable method to switch state.
  38890. */
  38891. get audioEnabled(): boolean;
  38892. private _headphone;
  38893. /**
  38894. * Gets whether audio is outputing to headphone or not.
  38895. * Please use the according Switch methods to change output.
  38896. */
  38897. get headphone(): boolean;
  38898. /**
  38899. * Gets or sets a refresh rate when using 3D audio positioning
  38900. */
  38901. audioPositioningRefreshRate: number;
  38902. private _audioListenerPositionProvider;
  38903. /**
  38904. * Gets the current audio listener position provider
  38905. */
  38906. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38907. /**
  38908. * Sets a custom listener position for all sounds in the scene
  38909. * By default, this is the position of the first active camera
  38910. */
  38911. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38912. /**
  38913. * Creates a new instance of the component for the given scene
  38914. * @param scene Defines the scene to register the component in
  38915. */
  38916. constructor(scene: Scene);
  38917. /**
  38918. * Registers the component in a given scene
  38919. */
  38920. register(): void;
  38921. /**
  38922. * Rebuilds the elements related to this component in case of
  38923. * context lost for instance.
  38924. */
  38925. rebuild(): void;
  38926. /**
  38927. * Serializes the component data to the specified json object
  38928. * @param serializationObject The object to serialize to
  38929. */
  38930. serialize(serializationObject: any): void;
  38931. /**
  38932. * Adds all the elements from the container to the scene
  38933. * @param container the container holding the elements
  38934. */
  38935. addFromContainer(container: AbstractScene): void;
  38936. /**
  38937. * Removes all the elements in the container from the scene
  38938. * @param container contains the elements to remove
  38939. * @param dispose if the removed element should be disposed (default: false)
  38940. */
  38941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38942. /**
  38943. * Disposes the component and the associated ressources.
  38944. */
  38945. dispose(): void;
  38946. /**
  38947. * Disables audio in the associated scene.
  38948. */
  38949. disableAudio(): void;
  38950. /**
  38951. * Enables audio in the associated scene.
  38952. */
  38953. enableAudio(): void;
  38954. /**
  38955. * Switch audio to headphone output.
  38956. */
  38957. switchAudioModeForHeadphones(): void;
  38958. /**
  38959. * Switch audio to normal speakers.
  38960. */
  38961. switchAudioModeForNormalSpeakers(): void;
  38962. private _cachedCameraDirection;
  38963. private _cachedCameraPosition;
  38964. private _lastCheck;
  38965. private _afterRender;
  38966. }
  38967. }
  38968. declare module "babylonjs/Audio/weightedsound" {
  38969. import { Sound } from "babylonjs/Audio/sound";
  38970. /**
  38971. * Wraps one or more Sound objects and selects one with random weight for playback.
  38972. */
  38973. export class WeightedSound {
  38974. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38975. loop: boolean;
  38976. private _coneInnerAngle;
  38977. private _coneOuterAngle;
  38978. private _volume;
  38979. /** A Sound is currently playing. */
  38980. isPlaying: boolean;
  38981. /** A Sound is currently paused. */
  38982. isPaused: boolean;
  38983. private _sounds;
  38984. private _weights;
  38985. private _currentIndex?;
  38986. /**
  38987. * Creates a new WeightedSound from the list of sounds given.
  38988. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38989. * @param sounds Array of Sounds that will be selected from.
  38990. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38991. */
  38992. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38993. /**
  38994. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38995. */
  38996. get directionalConeInnerAngle(): number;
  38997. /**
  38998. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38999. */
  39000. set directionalConeInnerAngle(value: number);
  39001. /**
  39002. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39003. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39004. */
  39005. get directionalConeOuterAngle(): number;
  39006. /**
  39007. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39008. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39009. */
  39010. set directionalConeOuterAngle(value: number);
  39011. /**
  39012. * Playback volume.
  39013. */
  39014. get volume(): number;
  39015. /**
  39016. * Playback volume.
  39017. */
  39018. set volume(value: number);
  39019. private _onended;
  39020. /**
  39021. * Suspend playback
  39022. */
  39023. pause(): void;
  39024. /**
  39025. * Stop playback
  39026. */
  39027. stop(): void;
  39028. /**
  39029. * Start playback.
  39030. * @param startOffset Position the clip head at a specific time in seconds.
  39031. */
  39032. play(startOffset?: number): void;
  39033. }
  39034. }
  39035. declare module "babylonjs/Audio/index" {
  39036. export * from "babylonjs/Audio/analyser";
  39037. export * from "babylonjs/Audio/audioEngine";
  39038. export * from "babylonjs/Audio/audioSceneComponent";
  39039. export * from "babylonjs/Audio/sound";
  39040. export * from "babylonjs/Audio/soundTrack";
  39041. export * from "babylonjs/Audio/weightedsound";
  39042. }
  39043. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39044. import { Behavior } from "babylonjs/Behaviors/behavior";
  39045. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39046. import { BackEase } from "babylonjs/Animations/easing";
  39047. /**
  39048. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39049. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39050. */
  39051. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39052. /**
  39053. * Gets the name of the behavior.
  39054. */
  39055. get name(): string;
  39056. /**
  39057. * The easing function used by animations
  39058. */
  39059. static EasingFunction: BackEase;
  39060. /**
  39061. * The easing mode used by animations
  39062. */
  39063. static EasingMode: number;
  39064. /**
  39065. * The duration of the animation, in milliseconds
  39066. */
  39067. transitionDuration: number;
  39068. /**
  39069. * Length of the distance animated by the transition when lower radius is reached
  39070. */
  39071. lowerRadiusTransitionRange: number;
  39072. /**
  39073. * Length of the distance animated by the transition when upper radius is reached
  39074. */
  39075. upperRadiusTransitionRange: number;
  39076. private _autoTransitionRange;
  39077. /**
  39078. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39079. */
  39080. get autoTransitionRange(): boolean;
  39081. /**
  39082. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39083. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39084. */
  39085. set autoTransitionRange(value: boolean);
  39086. private _attachedCamera;
  39087. private _onAfterCheckInputsObserver;
  39088. private _onMeshTargetChangedObserver;
  39089. /**
  39090. * Initializes the behavior.
  39091. */
  39092. init(): void;
  39093. /**
  39094. * Attaches the behavior to its arc rotate camera.
  39095. * @param camera Defines the camera to attach the behavior to
  39096. */
  39097. attach(camera: ArcRotateCamera): void;
  39098. /**
  39099. * Detaches the behavior from its current arc rotate camera.
  39100. */
  39101. detach(): void;
  39102. private _radiusIsAnimating;
  39103. private _radiusBounceTransition;
  39104. private _animatables;
  39105. private _cachedWheelPrecision;
  39106. /**
  39107. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39108. * @param radiusLimit The limit to check against.
  39109. * @return Bool to indicate if at limit.
  39110. */
  39111. private _isRadiusAtLimit;
  39112. /**
  39113. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39114. * @param radiusDelta The delta by which to animate to. Can be negative.
  39115. */
  39116. private _applyBoundRadiusAnimation;
  39117. /**
  39118. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39119. */
  39120. protected _clearAnimationLocks(): void;
  39121. /**
  39122. * Stops and removes all animations that have been applied to the camera
  39123. */
  39124. stopAllAnimations(): void;
  39125. }
  39126. }
  39127. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39128. import { Behavior } from "babylonjs/Behaviors/behavior";
  39129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39130. import { ExponentialEase } from "babylonjs/Animations/easing";
  39131. import { Nullable } from "babylonjs/types";
  39132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39133. import { Vector3 } from "babylonjs/Maths/math.vector";
  39134. /**
  39135. * 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.
  39136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39137. */
  39138. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39139. /**
  39140. * Gets the name of the behavior.
  39141. */
  39142. get name(): string;
  39143. private _mode;
  39144. private _radiusScale;
  39145. private _positionScale;
  39146. private _defaultElevation;
  39147. private _elevationReturnTime;
  39148. private _elevationReturnWaitTime;
  39149. private _zoomStopsAnimation;
  39150. private _framingTime;
  39151. /**
  39152. * The easing function used by animations
  39153. */
  39154. static EasingFunction: ExponentialEase;
  39155. /**
  39156. * The easing mode used by animations
  39157. */
  39158. static EasingMode: number;
  39159. /**
  39160. * Sets the current mode used by the behavior
  39161. */
  39162. set mode(mode: number);
  39163. /**
  39164. * Gets current mode used by the behavior.
  39165. */
  39166. get mode(): number;
  39167. /**
  39168. * Sets the scale applied to the radius (1 by default)
  39169. */
  39170. set radiusScale(radius: number);
  39171. /**
  39172. * Gets the scale applied to the radius
  39173. */
  39174. get radiusScale(): number;
  39175. /**
  39176. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39177. */
  39178. set positionScale(scale: number);
  39179. /**
  39180. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39181. */
  39182. get positionScale(): number;
  39183. /**
  39184. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39185. * behaviour is triggered, in radians.
  39186. */
  39187. set defaultElevation(elevation: number);
  39188. /**
  39189. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39190. * behaviour is triggered, in radians.
  39191. */
  39192. get defaultElevation(): number;
  39193. /**
  39194. * Sets the time (in milliseconds) taken to return to the default beta position.
  39195. * Negative value indicates camera should not return to default.
  39196. */
  39197. set elevationReturnTime(speed: number);
  39198. /**
  39199. * Gets the time (in milliseconds) taken to return to the default beta position.
  39200. * Negative value indicates camera should not return to default.
  39201. */
  39202. get elevationReturnTime(): number;
  39203. /**
  39204. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39205. */
  39206. set elevationReturnWaitTime(time: number);
  39207. /**
  39208. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39209. */
  39210. get elevationReturnWaitTime(): number;
  39211. /**
  39212. * Sets the flag that indicates if user zooming should stop animation.
  39213. */
  39214. set zoomStopsAnimation(flag: boolean);
  39215. /**
  39216. * Gets the flag that indicates if user zooming should stop animation.
  39217. */
  39218. get zoomStopsAnimation(): boolean;
  39219. /**
  39220. * Sets the transition time when framing the mesh, in milliseconds
  39221. */
  39222. set framingTime(time: number);
  39223. /**
  39224. * Gets the transition time when framing the mesh, in milliseconds
  39225. */
  39226. get framingTime(): number;
  39227. /**
  39228. * Define if the behavior should automatically change the configured
  39229. * camera limits and sensibilities.
  39230. */
  39231. autoCorrectCameraLimitsAndSensibility: boolean;
  39232. private _onPrePointerObservableObserver;
  39233. private _onAfterCheckInputsObserver;
  39234. private _onMeshTargetChangedObserver;
  39235. private _attachedCamera;
  39236. private _isPointerDown;
  39237. private _lastInteractionTime;
  39238. /**
  39239. * Initializes the behavior.
  39240. */
  39241. init(): void;
  39242. /**
  39243. * Attaches the behavior to its arc rotate camera.
  39244. * @param camera Defines the camera to attach the behavior to
  39245. */
  39246. attach(camera: ArcRotateCamera): void;
  39247. /**
  39248. * Detaches the behavior from its current arc rotate camera.
  39249. */
  39250. detach(): void;
  39251. private _animatables;
  39252. private _betaIsAnimating;
  39253. private _betaTransition;
  39254. private _radiusTransition;
  39255. private _vectorTransition;
  39256. /**
  39257. * Targets the given mesh and updates zoom level accordingly.
  39258. * @param mesh The mesh to target.
  39259. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39260. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39261. */
  39262. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39263. /**
  39264. * Targets the given mesh with its children and updates zoom level accordingly.
  39265. * @param mesh The mesh to target.
  39266. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39267. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39268. */
  39269. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39270. /**
  39271. * Targets the given meshes with their children and updates zoom level accordingly.
  39272. * @param meshes The mesh to target.
  39273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39275. */
  39276. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39277. /**
  39278. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39279. * @param minimumWorld Determines the smaller position of the bounding box extend
  39280. * @param maximumWorld Determines the bigger position of the bounding box extend
  39281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39283. */
  39284. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39285. /**
  39286. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39287. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39288. * frustum width.
  39289. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39290. * to fully enclose the mesh in the viewing frustum.
  39291. */
  39292. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39293. /**
  39294. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39295. * is automatically returned to its default position (expected to be above ground plane).
  39296. */
  39297. private _maintainCameraAboveGround;
  39298. /**
  39299. * Returns the frustum slope based on the canvas ratio and camera FOV
  39300. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39301. */
  39302. private _getFrustumSlope;
  39303. /**
  39304. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39305. */
  39306. private _clearAnimationLocks;
  39307. /**
  39308. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39309. */
  39310. private _applyUserInteraction;
  39311. /**
  39312. * Stops and removes all animations that have been applied to the camera
  39313. */
  39314. stopAllAnimations(): void;
  39315. /**
  39316. * Gets a value indicating if the user is moving the camera
  39317. */
  39318. get isUserIsMoving(): boolean;
  39319. /**
  39320. * The camera can move all the way towards the mesh.
  39321. */
  39322. static IgnoreBoundsSizeMode: number;
  39323. /**
  39324. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39325. */
  39326. static FitFrustumSidesMode: number;
  39327. }
  39328. }
  39329. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39330. import { Nullable } from "babylonjs/types";
  39331. import { Camera } from "babylonjs/Cameras/camera";
  39332. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39333. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39334. /**
  39335. * Base class for Camera Pointer Inputs.
  39336. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39337. * for example usage.
  39338. */
  39339. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39340. /**
  39341. * Defines the camera the input is attached to.
  39342. */
  39343. abstract camera: Camera;
  39344. /**
  39345. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39346. */
  39347. protected _altKey: boolean;
  39348. protected _ctrlKey: boolean;
  39349. protected _metaKey: boolean;
  39350. protected _shiftKey: boolean;
  39351. /**
  39352. * Which mouse buttons were pressed at time of last mouse event.
  39353. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39354. */
  39355. protected _buttonsPressed: number;
  39356. /**
  39357. * Defines the buttons associated with the input to handle camera move.
  39358. */
  39359. buttons: number[];
  39360. /**
  39361. * Attach the input controls to a specific dom element to get the input from.
  39362. * @param element Defines the element the controls should be listened from
  39363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39364. */
  39365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39366. /**
  39367. * Detach the current controls from the specified dom element.
  39368. * @param element Defines the element to stop listening the inputs from
  39369. */
  39370. detachControl(element: Nullable<HTMLElement>): void;
  39371. /**
  39372. * Gets the class name of the current input.
  39373. * @returns the class name
  39374. */
  39375. getClassName(): string;
  39376. /**
  39377. * Get the friendly name associated with the input class.
  39378. * @returns the input friendly name
  39379. */
  39380. getSimpleName(): string;
  39381. /**
  39382. * Called on pointer POINTERDOUBLETAP event.
  39383. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39384. */
  39385. protected onDoubleTap(type: string): void;
  39386. /**
  39387. * Called on pointer POINTERMOVE event if only a single touch is active.
  39388. * Override this method to provide functionality.
  39389. */
  39390. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39391. /**
  39392. * Called on pointer POINTERMOVE event if multiple touches are active.
  39393. * Override this method to provide functionality.
  39394. */
  39395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39396. /**
  39397. * Called on JS contextmenu event.
  39398. * Override this method to provide functionality.
  39399. */
  39400. protected onContextMenu(evt: PointerEvent): void;
  39401. /**
  39402. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39403. * press.
  39404. * Override this method to provide functionality.
  39405. */
  39406. protected onButtonDown(evt: PointerEvent): void;
  39407. /**
  39408. * Called each time a new POINTERUP event occurs. Ie, for each button
  39409. * release.
  39410. * Override this method to provide functionality.
  39411. */
  39412. protected onButtonUp(evt: PointerEvent): void;
  39413. /**
  39414. * Called when window becomes inactive.
  39415. * Override this method to provide functionality.
  39416. */
  39417. protected onLostFocus(): void;
  39418. private _pointerInput;
  39419. private _observer;
  39420. private _onLostFocus;
  39421. private pointA;
  39422. private pointB;
  39423. }
  39424. }
  39425. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39426. import { Nullable } from "babylonjs/types";
  39427. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39428. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39429. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39430. /**
  39431. * Manage the pointers inputs to control an arc rotate camera.
  39432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39433. */
  39434. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39435. /**
  39436. * Defines the camera the input is attached to.
  39437. */
  39438. camera: ArcRotateCamera;
  39439. /**
  39440. * Gets the class name of the current input.
  39441. * @returns the class name
  39442. */
  39443. getClassName(): string;
  39444. /**
  39445. * Defines the buttons associated with the input to handle camera move.
  39446. */
  39447. buttons: number[];
  39448. /**
  39449. * Defines the pointer angular sensibility along the X axis or how fast is
  39450. * the camera rotating.
  39451. */
  39452. angularSensibilityX: number;
  39453. /**
  39454. * Defines the pointer angular sensibility along the Y axis or how fast is
  39455. * the camera rotating.
  39456. */
  39457. angularSensibilityY: number;
  39458. /**
  39459. * Defines the pointer pinch precision or how fast is the camera zooming.
  39460. */
  39461. pinchPrecision: number;
  39462. /**
  39463. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39464. * from 0.
  39465. * It defines the percentage of current camera.radius to use as delta when
  39466. * pinch zoom is used.
  39467. */
  39468. pinchDeltaPercentage: number;
  39469. /**
  39470. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39471. * that any object in the plane at the camera's target point will scale
  39472. * perfectly with finger motion.
  39473. * Overrides pinchDeltaPercentage and pinchPrecision.
  39474. */
  39475. useNaturalPinchZoom: boolean;
  39476. /**
  39477. * Defines the pointer panning sensibility or how fast is the camera moving.
  39478. */
  39479. panningSensibility: number;
  39480. /**
  39481. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39482. */
  39483. multiTouchPanning: boolean;
  39484. /**
  39485. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39486. * zoom (pinch) through multitouch.
  39487. */
  39488. multiTouchPanAndZoom: boolean;
  39489. /**
  39490. * Revers pinch action direction.
  39491. */
  39492. pinchInwards: boolean;
  39493. private _isPanClick;
  39494. private _twoFingerActivityCount;
  39495. private _isPinching;
  39496. /**
  39497. * Called on pointer POINTERMOVE event if only a single touch is active.
  39498. */
  39499. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39500. /**
  39501. * Called on pointer POINTERDOUBLETAP event.
  39502. */
  39503. protected onDoubleTap(type: string): void;
  39504. /**
  39505. * Called on pointer POINTERMOVE event if multiple touches are active.
  39506. */
  39507. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39508. /**
  39509. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39510. * press.
  39511. */
  39512. protected onButtonDown(evt: PointerEvent): void;
  39513. /**
  39514. * Called each time a new POINTERUP event occurs. Ie, for each button
  39515. * release.
  39516. */
  39517. protected onButtonUp(evt: PointerEvent): void;
  39518. /**
  39519. * Called when window becomes inactive.
  39520. */
  39521. protected onLostFocus(): void;
  39522. }
  39523. }
  39524. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39525. import { Nullable } from "babylonjs/types";
  39526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39527. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39528. /**
  39529. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39531. */
  39532. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39533. /**
  39534. * Defines the camera the input is attached to.
  39535. */
  39536. camera: ArcRotateCamera;
  39537. /**
  39538. * Defines the list of key codes associated with the up action (increase alpha)
  39539. */
  39540. keysUp: number[];
  39541. /**
  39542. * Defines the list of key codes associated with the down action (decrease alpha)
  39543. */
  39544. keysDown: number[];
  39545. /**
  39546. * Defines the list of key codes associated with the left action (increase beta)
  39547. */
  39548. keysLeft: number[];
  39549. /**
  39550. * Defines the list of key codes associated with the right action (decrease beta)
  39551. */
  39552. keysRight: number[];
  39553. /**
  39554. * Defines the list of key codes associated with the reset action.
  39555. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39556. */
  39557. keysReset: number[];
  39558. /**
  39559. * Defines the panning sensibility of the inputs.
  39560. * (How fast is the camera panning)
  39561. */
  39562. panningSensibility: number;
  39563. /**
  39564. * Defines the zooming sensibility of the inputs.
  39565. * (How fast is the camera zooming)
  39566. */
  39567. zoomingSensibility: number;
  39568. /**
  39569. * Defines whether maintaining the alt key down switch the movement mode from
  39570. * orientation to zoom.
  39571. */
  39572. useAltToZoom: boolean;
  39573. /**
  39574. * Rotation speed of the camera
  39575. */
  39576. angularSpeed: number;
  39577. private _keys;
  39578. private _ctrlPressed;
  39579. private _altPressed;
  39580. private _onCanvasBlurObserver;
  39581. private _onKeyboardObserver;
  39582. private _engine;
  39583. private _scene;
  39584. /**
  39585. * Attach the input controls to a specific dom element to get the input from.
  39586. * @param element Defines the element the controls should be listened from
  39587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39588. */
  39589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39590. /**
  39591. * Detach the current controls from the specified dom element.
  39592. * @param element Defines the element to stop listening the inputs from
  39593. */
  39594. detachControl(element: Nullable<HTMLElement>): void;
  39595. /**
  39596. * Update the current camera state depending on the inputs that have been used this frame.
  39597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39598. */
  39599. checkInputs(): void;
  39600. /**
  39601. * Gets the class name of the current intput.
  39602. * @returns the class name
  39603. */
  39604. getClassName(): string;
  39605. /**
  39606. * Get the friendly name associated with the input class.
  39607. * @returns the input friendly name
  39608. */
  39609. getSimpleName(): string;
  39610. }
  39611. }
  39612. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39613. import { Nullable } from "babylonjs/types";
  39614. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39616. /**
  39617. * Manage the mouse wheel inputs to control an arc rotate camera.
  39618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39619. */
  39620. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39621. /**
  39622. * Defines the camera the input is attached to.
  39623. */
  39624. camera: ArcRotateCamera;
  39625. /**
  39626. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39627. */
  39628. wheelPrecision: number;
  39629. /**
  39630. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39631. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39632. */
  39633. wheelDeltaPercentage: number;
  39634. private _wheel;
  39635. private _observer;
  39636. private computeDeltaFromMouseWheelLegacyEvent;
  39637. /**
  39638. * Attach the input controls to a specific dom element to get the input from.
  39639. * @param element Defines the element the controls should be listened from
  39640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39641. */
  39642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39643. /**
  39644. * Detach the current controls from the specified dom element.
  39645. * @param element Defines the element to stop listening the inputs from
  39646. */
  39647. detachControl(element: Nullable<HTMLElement>): void;
  39648. /**
  39649. * Gets the class name of the current intput.
  39650. * @returns the class name
  39651. */
  39652. getClassName(): string;
  39653. /**
  39654. * Get the friendly name associated with the input class.
  39655. * @returns the input friendly name
  39656. */
  39657. getSimpleName(): string;
  39658. }
  39659. }
  39660. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39661. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39662. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39663. /**
  39664. * Default Inputs manager for the ArcRotateCamera.
  39665. * It groups all the default supported inputs for ease of use.
  39666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39667. */
  39668. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39669. /**
  39670. * Instantiates a new ArcRotateCameraInputsManager.
  39671. * @param camera Defines the camera the inputs belong to
  39672. */
  39673. constructor(camera: ArcRotateCamera);
  39674. /**
  39675. * Add mouse wheel input support to the input manager.
  39676. * @returns the current input manager
  39677. */
  39678. addMouseWheel(): ArcRotateCameraInputsManager;
  39679. /**
  39680. * Add pointers input support to the input manager.
  39681. * @returns the current input manager
  39682. */
  39683. addPointers(): ArcRotateCameraInputsManager;
  39684. /**
  39685. * Add keyboard input support to the input manager.
  39686. * @returns the current input manager
  39687. */
  39688. addKeyboard(): ArcRotateCameraInputsManager;
  39689. }
  39690. }
  39691. declare module "babylonjs/Cameras/arcRotateCamera" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Nullable } from "babylonjs/types";
  39694. import { Scene } from "babylonjs/scene";
  39695. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39697. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39698. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39699. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39700. import { Camera } from "babylonjs/Cameras/camera";
  39701. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39702. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39703. import { Collider } from "babylonjs/Collisions/collider";
  39704. /**
  39705. * This represents an orbital type of camera.
  39706. *
  39707. * 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.
  39708. * 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.
  39709. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39710. */
  39711. export class ArcRotateCamera extends TargetCamera {
  39712. /**
  39713. * Defines the rotation angle of the camera along the longitudinal axis.
  39714. */
  39715. alpha: number;
  39716. /**
  39717. * Defines the rotation angle of the camera along the latitudinal axis.
  39718. */
  39719. beta: number;
  39720. /**
  39721. * Defines the radius of the camera from it s target point.
  39722. */
  39723. radius: number;
  39724. protected _target: Vector3;
  39725. protected _targetHost: Nullable<AbstractMesh>;
  39726. /**
  39727. * Defines the target point of the camera.
  39728. * The camera looks towards it form the radius distance.
  39729. */
  39730. get target(): Vector3;
  39731. set target(value: Vector3);
  39732. /**
  39733. * Define the current local position of the camera in the scene
  39734. */
  39735. get position(): Vector3;
  39736. set position(newPosition: Vector3);
  39737. protected _upVector: Vector3;
  39738. protected _upToYMatrix: Matrix;
  39739. protected _YToUpMatrix: Matrix;
  39740. /**
  39741. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39742. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39743. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39744. */
  39745. set upVector(vec: Vector3);
  39746. get upVector(): Vector3;
  39747. /**
  39748. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39749. */
  39750. setMatUp(): void;
  39751. /**
  39752. * Current inertia value on the longitudinal axis.
  39753. * The bigger this number the longer it will take for the camera to stop.
  39754. */
  39755. inertialAlphaOffset: number;
  39756. /**
  39757. * Current inertia value on the latitudinal axis.
  39758. * The bigger this number the longer it will take for the camera to stop.
  39759. */
  39760. inertialBetaOffset: number;
  39761. /**
  39762. * Current inertia value on the radius axis.
  39763. * The bigger this number the longer it will take for the camera to stop.
  39764. */
  39765. inertialRadiusOffset: number;
  39766. /**
  39767. * Minimum allowed angle on the longitudinal axis.
  39768. * This can help limiting how the Camera is able to move in the scene.
  39769. */
  39770. lowerAlphaLimit: Nullable<number>;
  39771. /**
  39772. * Maximum allowed angle on the longitudinal axis.
  39773. * This can help limiting how the Camera is able to move in the scene.
  39774. */
  39775. upperAlphaLimit: Nullable<number>;
  39776. /**
  39777. * Minimum allowed angle on the latitudinal axis.
  39778. * This can help limiting how the Camera is able to move in the scene.
  39779. */
  39780. lowerBetaLimit: number;
  39781. /**
  39782. * Maximum allowed angle on the latitudinal axis.
  39783. * This can help limiting how the Camera is able to move in the scene.
  39784. */
  39785. upperBetaLimit: number;
  39786. /**
  39787. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39788. * This can help limiting how the Camera is able to move in the scene.
  39789. */
  39790. lowerRadiusLimit: Nullable<number>;
  39791. /**
  39792. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39793. * This can help limiting how the Camera is able to move in the scene.
  39794. */
  39795. upperRadiusLimit: Nullable<number>;
  39796. /**
  39797. * Defines the current inertia value used during panning of the camera along the X axis.
  39798. */
  39799. inertialPanningX: number;
  39800. /**
  39801. * Defines the current inertia value used during panning of the camera along the Y axis.
  39802. */
  39803. inertialPanningY: number;
  39804. /**
  39805. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39806. * Basically if your fingers moves away from more than this distance you will be considered
  39807. * in pinch mode.
  39808. */
  39809. pinchToPanMaxDistance: number;
  39810. /**
  39811. * Defines the maximum distance the camera can pan.
  39812. * This could help keeping the cammera always in your scene.
  39813. */
  39814. panningDistanceLimit: Nullable<number>;
  39815. /**
  39816. * Defines the target of the camera before paning.
  39817. */
  39818. panningOriginTarget: Vector3;
  39819. /**
  39820. * Defines the value of the inertia used during panning.
  39821. * 0 would mean stop inertia and one would mean no decelleration at all.
  39822. */
  39823. panningInertia: number;
  39824. /**
  39825. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39826. */
  39827. get angularSensibilityX(): number;
  39828. set angularSensibilityX(value: number);
  39829. /**
  39830. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39831. */
  39832. get angularSensibilityY(): number;
  39833. set angularSensibilityY(value: number);
  39834. /**
  39835. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39836. */
  39837. get pinchPrecision(): number;
  39838. set pinchPrecision(value: number);
  39839. /**
  39840. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39841. * It will be used instead of pinchDeltaPrecision if different from 0.
  39842. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39843. */
  39844. get pinchDeltaPercentage(): number;
  39845. set pinchDeltaPercentage(value: number);
  39846. /**
  39847. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39848. * and pinch delta percentage.
  39849. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39850. * that any object in the plane at the camera's target point will scale
  39851. * perfectly with finger motion.
  39852. */
  39853. get useNaturalPinchZoom(): boolean;
  39854. set useNaturalPinchZoom(value: boolean);
  39855. /**
  39856. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39857. */
  39858. get panningSensibility(): number;
  39859. set panningSensibility(value: number);
  39860. /**
  39861. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39862. */
  39863. get keysUp(): number[];
  39864. set keysUp(value: number[]);
  39865. /**
  39866. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39867. */
  39868. get keysDown(): number[];
  39869. set keysDown(value: number[]);
  39870. /**
  39871. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39872. */
  39873. get keysLeft(): number[];
  39874. set keysLeft(value: number[]);
  39875. /**
  39876. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39877. */
  39878. get keysRight(): number[];
  39879. set keysRight(value: number[]);
  39880. /**
  39881. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39882. */
  39883. get wheelPrecision(): number;
  39884. set wheelPrecision(value: number);
  39885. /**
  39886. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39887. * It will be used instead of pinchDeltaPrecision if different from 0.
  39888. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39889. */
  39890. get wheelDeltaPercentage(): number;
  39891. set wheelDeltaPercentage(value: number);
  39892. /**
  39893. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39894. */
  39895. zoomOnFactor: number;
  39896. /**
  39897. * Defines a screen offset for the camera position.
  39898. */
  39899. targetScreenOffset: Vector2;
  39900. /**
  39901. * Allows the camera to be completely reversed.
  39902. * If false the camera can not arrive upside down.
  39903. */
  39904. allowUpsideDown: boolean;
  39905. /**
  39906. * Define if double tap/click is used to restore the previously saved state of the camera.
  39907. */
  39908. useInputToRestoreState: boolean;
  39909. /** @hidden */
  39910. _viewMatrix: Matrix;
  39911. /** @hidden */
  39912. _useCtrlForPanning: boolean;
  39913. /** @hidden */
  39914. _panningMouseButton: number;
  39915. /**
  39916. * Defines the input associated to the camera.
  39917. */
  39918. inputs: ArcRotateCameraInputsManager;
  39919. /** @hidden */
  39920. _reset: () => void;
  39921. /**
  39922. * Defines the allowed panning axis.
  39923. */
  39924. panningAxis: Vector3;
  39925. protected _localDirection: Vector3;
  39926. protected _transformedDirection: Vector3;
  39927. private _bouncingBehavior;
  39928. /**
  39929. * Gets the bouncing behavior of the camera if it has been enabled.
  39930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39931. */
  39932. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39933. /**
  39934. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39936. */
  39937. get useBouncingBehavior(): boolean;
  39938. set useBouncingBehavior(value: boolean);
  39939. private _framingBehavior;
  39940. /**
  39941. * Gets the framing behavior of the camera if it has been enabled.
  39942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39943. */
  39944. get framingBehavior(): Nullable<FramingBehavior>;
  39945. /**
  39946. * Defines if the framing behavior of the camera is enabled on the camera.
  39947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39948. */
  39949. get useFramingBehavior(): boolean;
  39950. set useFramingBehavior(value: boolean);
  39951. private _autoRotationBehavior;
  39952. /**
  39953. * Gets the auto rotation behavior of the camera if it has been enabled.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39955. */
  39956. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39957. /**
  39958. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39960. */
  39961. get useAutoRotationBehavior(): boolean;
  39962. set useAutoRotationBehavior(value: boolean);
  39963. /**
  39964. * Observable triggered when the mesh target has been changed on the camera.
  39965. */
  39966. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39967. /**
  39968. * Event raised when the camera is colliding with a mesh.
  39969. */
  39970. onCollide: (collidedMesh: AbstractMesh) => void;
  39971. /**
  39972. * Defines whether the camera should check collision with the objects oh the scene.
  39973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39974. */
  39975. checkCollisions: boolean;
  39976. /**
  39977. * Defines the collision radius of the camera.
  39978. * This simulates a sphere around the camera.
  39979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39980. */
  39981. collisionRadius: Vector3;
  39982. protected _collider: Collider;
  39983. protected _previousPosition: Vector3;
  39984. protected _collisionVelocity: Vector3;
  39985. protected _newPosition: Vector3;
  39986. protected _previousAlpha: number;
  39987. protected _previousBeta: number;
  39988. protected _previousRadius: number;
  39989. protected _collisionTriggered: boolean;
  39990. protected _targetBoundingCenter: Nullable<Vector3>;
  39991. private _computationVector;
  39992. /**
  39993. * Instantiates a new ArcRotateCamera in a given scene
  39994. * @param name Defines the name of the camera
  39995. * @param alpha Defines the camera rotation along the logitudinal axis
  39996. * @param beta Defines the camera rotation along the latitudinal axis
  39997. * @param radius Defines the camera distance from its target
  39998. * @param target Defines the camera target
  39999. * @param scene Defines the scene the camera belongs to
  40000. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40001. */
  40002. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40003. /** @hidden */
  40004. _initCache(): void;
  40005. /** @hidden */
  40006. _updateCache(ignoreParentClass?: boolean): void;
  40007. protected _getTargetPosition(): Vector3;
  40008. private _storedAlpha;
  40009. private _storedBeta;
  40010. private _storedRadius;
  40011. private _storedTarget;
  40012. private _storedTargetScreenOffset;
  40013. /**
  40014. * Stores the current state of the camera (alpha, beta, radius and target)
  40015. * @returns the camera itself
  40016. */
  40017. storeState(): Camera;
  40018. /**
  40019. * @hidden
  40020. * Restored camera state. You must call storeState() first
  40021. */
  40022. _restoreStateValues(): boolean;
  40023. /** @hidden */
  40024. _isSynchronizedViewMatrix(): boolean;
  40025. /**
  40026. * Attached controls to the current camera.
  40027. * @param element Defines the element the controls should be listened from
  40028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40029. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40030. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40031. */
  40032. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40033. /**
  40034. * Detach the current controls from the camera.
  40035. * The camera will stop reacting to inputs.
  40036. * @param element Defines the element to stop listening the inputs from
  40037. */
  40038. detachControl(element: HTMLElement): void;
  40039. /** @hidden */
  40040. _checkInputs(): void;
  40041. protected _checkLimits(): void;
  40042. /**
  40043. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40044. */
  40045. rebuildAnglesAndRadius(): void;
  40046. /**
  40047. * Use a position to define the current camera related information like alpha, beta and radius
  40048. * @param position Defines the position to set the camera at
  40049. */
  40050. setPosition(position: Vector3): void;
  40051. /**
  40052. * Defines the target the camera should look at.
  40053. * This will automatically adapt alpha beta and radius to fit within the new target.
  40054. * @param target Defines the new target as a Vector or a mesh
  40055. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40056. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40057. */
  40058. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40059. /** @hidden */
  40060. _getViewMatrix(): Matrix;
  40061. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40062. /**
  40063. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40064. * @param meshes Defines the mesh to zoom on
  40065. * @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)
  40066. */
  40067. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40068. /**
  40069. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40070. * The target will be changed but the radius
  40071. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40072. * @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)
  40073. */
  40074. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40075. min: Vector3;
  40076. max: Vector3;
  40077. distance: number;
  40078. }, doNotUpdateMaxZ?: boolean): void;
  40079. /**
  40080. * @override
  40081. * Override Camera.createRigCamera
  40082. */
  40083. createRigCamera(name: string, cameraIndex: number): Camera;
  40084. /**
  40085. * @hidden
  40086. * @override
  40087. * Override Camera._updateRigCameras
  40088. */
  40089. _updateRigCameras(): void;
  40090. /**
  40091. * Destroy the camera and release the current resources hold by it.
  40092. */
  40093. dispose(): void;
  40094. /**
  40095. * Gets the current object class name.
  40096. * @return the class name
  40097. */
  40098. getClassName(): string;
  40099. }
  40100. }
  40101. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40102. import { Behavior } from "babylonjs/Behaviors/behavior";
  40103. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40104. /**
  40105. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40107. */
  40108. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40109. /**
  40110. * Gets the name of the behavior.
  40111. */
  40112. get name(): string;
  40113. private _zoomStopsAnimation;
  40114. private _idleRotationSpeed;
  40115. private _idleRotationWaitTime;
  40116. private _idleRotationSpinupTime;
  40117. /**
  40118. * Sets the flag that indicates if user zooming should stop animation.
  40119. */
  40120. set zoomStopsAnimation(flag: boolean);
  40121. /**
  40122. * Gets the flag that indicates if user zooming should stop animation.
  40123. */
  40124. get zoomStopsAnimation(): boolean;
  40125. /**
  40126. * Sets the default speed at which the camera rotates around the model.
  40127. */
  40128. set idleRotationSpeed(speed: number);
  40129. /**
  40130. * Gets the default speed at which the camera rotates around the model.
  40131. */
  40132. get idleRotationSpeed(): number;
  40133. /**
  40134. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40135. */
  40136. set idleRotationWaitTime(time: number);
  40137. /**
  40138. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40139. */
  40140. get idleRotationWaitTime(): number;
  40141. /**
  40142. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40143. */
  40144. set idleRotationSpinupTime(time: number);
  40145. /**
  40146. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40147. */
  40148. get idleRotationSpinupTime(): number;
  40149. /**
  40150. * Gets a value indicating if the camera is currently rotating because of this behavior
  40151. */
  40152. get rotationInProgress(): boolean;
  40153. private _onPrePointerObservableObserver;
  40154. private _onAfterCheckInputsObserver;
  40155. private _attachedCamera;
  40156. private _isPointerDown;
  40157. private _lastFrameTime;
  40158. private _lastInteractionTime;
  40159. private _cameraRotationSpeed;
  40160. /**
  40161. * Initializes the behavior.
  40162. */
  40163. init(): void;
  40164. /**
  40165. * Attaches the behavior to its arc rotate camera.
  40166. * @param camera Defines the camera to attach the behavior to
  40167. */
  40168. attach(camera: ArcRotateCamera): void;
  40169. /**
  40170. * Detaches the behavior from its current arc rotate camera.
  40171. */
  40172. detach(): void;
  40173. /**
  40174. * Returns true if user is scrolling.
  40175. * @return true if user is scrolling.
  40176. */
  40177. private _userIsZooming;
  40178. private _lastFrameRadius;
  40179. private _shouldAnimationStopForInteraction;
  40180. /**
  40181. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40182. */
  40183. private _applyUserInteraction;
  40184. private _userIsMoving;
  40185. }
  40186. }
  40187. declare module "babylonjs/Behaviors/Cameras/index" {
  40188. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40189. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40190. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40191. }
  40192. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40193. import { Mesh } from "babylonjs/Meshes/mesh";
  40194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40195. import { Behavior } from "babylonjs/Behaviors/behavior";
  40196. /**
  40197. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40198. */
  40199. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40200. private ui;
  40201. /**
  40202. * The name of the behavior
  40203. */
  40204. name: string;
  40205. /**
  40206. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40207. */
  40208. distanceAwayFromFace: number;
  40209. /**
  40210. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40211. */
  40212. distanceAwayFromBottomOfFace: number;
  40213. private _faceVectors;
  40214. private _target;
  40215. private _scene;
  40216. private _onRenderObserver;
  40217. private _tmpMatrix;
  40218. private _tmpVector;
  40219. /**
  40220. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40221. * @param ui The transform node that should be attched to the mesh
  40222. */
  40223. constructor(ui: TransformNode);
  40224. /**
  40225. * Initializes the behavior
  40226. */
  40227. init(): void;
  40228. private _closestFace;
  40229. private _zeroVector;
  40230. private _lookAtTmpMatrix;
  40231. private _lookAtToRef;
  40232. /**
  40233. * Attaches the AttachToBoxBehavior to the passed in mesh
  40234. * @param target The mesh that the specified node will be attached to
  40235. */
  40236. attach(target: Mesh): void;
  40237. /**
  40238. * Detaches the behavior from the mesh
  40239. */
  40240. detach(): void;
  40241. }
  40242. }
  40243. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40244. import { Behavior } from "babylonjs/Behaviors/behavior";
  40245. import { Mesh } from "babylonjs/Meshes/mesh";
  40246. /**
  40247. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40248. */
  40249. export class FadeInOutBehavior implements Behavior<Mesh> {
  40250. /**
  40251. * Time in milliseconds to delay before fading in (Default: 0)
  40252. */
  40253. delay: number;
  40254. /**
  40255. * Time in milliseconds for the mesh to fade in (Default: 300)
  40256. */
  40257. fadeInTime: number;
  40258. private _millisecondsPerFrame;
  40259. private _hovered;
  40260. private _hoverValue;
  40261. private _ownerNode;
  40262. /**
  40263. * Instatiates the FadeInOutBehavior
  40264. */
  40265. constructor();
  40266. /**
  40267. * The name of the behavior
  40268. */
  40269. get name(): string;
  40270. /**
  40271. * Initializes the behavior
  40272. */
  40273. init(): void;
  40274. /**
  40275. * Attaches the fade behavior on the passed in mesh
  40276. * @param ownerNode The mesh that will be faded in/out once attached
  40277. */
  40278. attach(ownerNode: Mesh): void;
  40279. /**
  40280. * Detaches the behavior from the mesh
  40281. */
  40282. detach(): void;
  40283. /**
  40284. * Triggers the mesh to begin fading in or out
  40285. * @param value if the object should fade in or out (true to fade in)
  40286. */
  40287. fadeIn(value: boolean): void;
  40288. private _update;
  40289. private _setAllVisibility;
  40290. }
  40291. }
  40292. declare module "babylonjs/Misc/pivotTools" {
  40293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40294. /**
  40295. * Class containing a set of static utilities functions for managing Pivots
  40296. * @hidden
  40297. */
  40298. export class PivotTools {
  40299. private static _PivotCached;
  40300. private static _OldPivotPoint;
  40301. private static _PivotTranslation;
  40302. private static _PivotTmpVector;
  40303. /** @hidden */
  40304. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40305. /** @hidden */
  40306. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40307. }
  40308. }
  40309. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40310. import { Scene } from "babylonjs/scene";
  40311. import { Vector4 } from "babylonjs/Maths/math.vector";
  40312. import { Mesh } from "babylonjs/Meshes/mesh";
  40313. import { Nullable } from "babylonjs/types";
  40314. import { Plane } from "babylonjs/Maths/math.plane";
  40315. /**
  40316. * Class containing static functions to help procedurally build meshes
  40317. */
  40318. export class PlaneBuilder {
  40319. /**
  40320. * Creates a plane mesh
  40321. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40322. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40323. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40327. * @param name defines the name of the mesh
  40328. * @param options defines the options used to create the mesh
  40329. * @param scene defines the hosting scene
  40330. * @returns the plane mesh
  40331. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40332. */
  40333. static CreatePlane(name: string, options: {
  40334. size?: number;
  40335. width?: number;
  40336. height?: number;
  40337. sideOrientation?: number;
  40338. frontUVs?: Vector4;
  40339. backUVs?: Vector4;
  40340. updatable?: boolean;
  40341. sourcePlane?: Plane;
  40342. }, scene?: Nullable<Scene>): Mesh;
  40343. }
  40344. }
  40345. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40346. import { Behavior } from "babylonjs/Behaviors/behavior";
  40347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40348. import { Observable } from "babylonjs/Misc/observable";
  40349. import { Vector3 } from "babylonjs/Maths/math.vector";
  40350. import { Ray } from "babylonjs/Culling/ray";
  40351. import "babylonjs/Meshes/Builders/planeBuilder";
  40352. /**
  40353. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40354. */
  40355. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40356. private static _AnyMouseID;
  40357. /**
  40358. * Abstract mesh the behavior is set on
  40359. */
  40360. attachedNode: AbstractMesh;
  40361. private _dragPlane;
  40362. private _scene;
  40363. private _pointerObserver;
  40364. private _beforeRenderObserver;
  40365. private static _planeScene;
  40366. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40367. /**
  40368. * 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)
  40369. */
  40370. maxDragAngle: number;
  40371. /**
  40372. * @hidden
  40373. */
  40374. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40375. /**
  40376. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40377. */
  40378. currentDraggingPointerID: number;
  40379. /**
  40380. * The last position where the pointer hit the drag plane in world space
  40381. */
  40382. lastDragPosition: Vector3;
  40383. /**
  40384. * If the behavior is currently in a dragging state
  40385. */
  40386. dragging: boolean;
  40387. /**
  40388. * 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)
  40389. */
  40390. dragDeltaRatio: number;
  40391. /**
  40392. * If the drag plane orientation should be updated during the dragging (Default: true)
  40393. */
  40394. updateDragPlane: boolean;
  40395. private _debugMode;
  40396. private _moving;
  40397. /**
  40398. * Fires each time the attached mesh is dragged with the pointer
  40399. * * delta between last drag position and current drag position in world space
  40400. * * dragDistance along the drag axis
  40401. * * dragPlaneNormal normal of the current drag plane used during the drag
  40402. * * dragPlanePoint in world space where the drag intersects the drag plane
  40403. */
  40404. onDragObservable: Observable<{
  40405. delta: Vector3;
  40406. dragPlanePoint: Vector3;
  40407. dragPlaneNormal: Vector3;
  40408. dragDistance: number;
  40409. pointerId: number;
  40410. }>;
  40411. /**
  40412. * Fires each time a drag begins (eg. mouse down on mesh)
  40413. */
  40414. onDragStartObservable: Observable<{
  40415. dragPlanePoint: Vector3;
  40416. pointerId: number;
  40417. }>;
  40418. /**
  40419. * Fires each time a drag ends (eg. mouse release after drag)
  40420. */
  40421. onDragEndObservable: Observable<{
  40422. dragPlanePoint: Vector3;
  40423. pointerId: number;
  40424. }>;
  40425. /**
  40426. * If the attached mesh should be moved when dragged
  40427. */
  40428. moveAttached: boolean;
  40429. /**
  40430. * If the drag behavior will react to drag events (Default: true)
  40431. */
  40432. enabled: boolean;
  40433. /**
  40434. * If pointer events should start and release the drag (Default: true)
  40435. */
  40436. startAndReleaseDragOnPointerEvents: boolean;
  40437. /**
  40438. * If camera controls should be detached during the drag
  40439. */
  40440. detachCameraControls: boolean;
  40441. /**
  40442. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40443. */
  40444. useObjectOrientationForDragging: boolean;
  40445. private _options;
  40446. /**
  40447. * Gets the options used by the behavior
  40448. */
  40449. get options(): {
  40450. dragAxis?: Vector3;
  40451. dragPlaneNormal?: Vector3;
  40452. };
  40453. /**
  40454. * Sets the options used by the behavior
  40455. */
  40456. set options(options: {
  40457. dragAxis?: Vector3;
  40458. dragPlaneNormal?: Vector3;
  40459. });
  40460. /**
  40461. * Creates a pointer drag behavior that can be attached to a mesh
  40462. * @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)
  40463. */
  40464. constructor(options?: {
  40465. dragAxis?: Vector3;
  40466. dragPlaneNormal?: Vector3;
  40467. });
  40468. /**
  40469. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40470. */
  40471. validateDrag: (targetPosition: Vector3) => boolean;
  40472. /**
  40473. * The name of the behavior
  40474. */
  40475. get name(): string;
  40476. /**
  40477. * Initializes the behavior
  40478. */
  40479. init(): void;
  40480. private _tmpVector;
  40481. private _alternatePickedPoint;
  40482. private _worldDragAxis;
  40483. private _targetPosition;
  40484. private _attachedElement;
  40485. /**
  40486. * Attaches the drag behavior the passed in mesh
  40487. * @param ownerNode The mesh that will be dragged around once attached
  40488. * @param predicate Predicate to use for pick filtering
  40489. */
  40490. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40491. /**
  40492. * Force relase the drag action by code.
  40493. */
  40494. releaseDrag(): void;
  40495. private _startDragRay;
  40496. private _lastPointerRay;
  40497. /**
  40498. * Simulates the start of a pointer drag event on the behavior
  40499. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40500. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40501. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40502. */
  40503. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40504. private _startDrag;
  40505. private _dragDelta;
  40506. private _moveDrag;
  40507. private _pickWithRayOnDragPlane;
  40508. private _pointA;
  40509. private _pointB;
  40510. private _pointC;
  40511. private _lineA;
  40512. private _lineB;
  40513. private _localAxis;
  40514. private _lookAt;
  40515. private _updateDragPlanePosition;
  40516. /**
  40517. * Detaches the behavior from the mesh
  40518. */
  40519. detach(): void;
  40520. }
  40521. }
  40522. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40523. import { Mesh } from "babylonjs/Meshes/mesh";
  40524. import { Behavior } from "babylonjs/Behaviors/behavior";
  40525. /**
  40526. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40527. */
  40528. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40529. private _dragBehaviorA;
  40530. private _dragBehaviorB;
  40531. private _startDistance;
  40532. private _initialScale;
  40533. private _targetScale;
  40534. private _ownerNode;
  40535. private _sceneRenderObserver;
  40536. /**
  40537. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40538. */
  40539. constructor();
  40540. /**
  40541. * The name of the behavior
  40542. */
  40543. get name(): string;
  40544. /**
  40545. * Initializes the behavior
  40546. */
  40547. init(): void;
  40548. private _getCurrentDistance;
  40549. /**
  40550. * Attaches the scale behavior the passed in mesh
  40551. * @param ownerNode The mesh that will be scaled around once attached
  40552. */
  40553. attach(ownerNode: Mesh): void;
  40554. /**
  40555. * Detaches the behavior from the mesh
  40556. */
  40557. detach(): void;
  40558. }
  40559. }
  40560. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40561. import { Behavior } from "babylonjs/Behaviors/behavior";
  40562. import { Mesh } from "babylonjs/Meshes/mesh";
  40563. import { Observable } from "babylonjs/Misc/observable";
  40564. /**
  40565. * 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
  40566. */
  40567. export class SixDofDragBehavior implements Behavior<Mesh> {
  40568. private static _virtualScene;
  40569. private _ownerNode;
  40570. private _sceneRenderObserver;
  40571. private _scene;
  40572. private _targetPosition;
  40573. private _virtualOriginMesh;
  40574. private _virtualDragMesh;
  40575. private _pointerObserver;
  40576. private _moving;
  40577. private _startingOrientation;
  40578. /**
  40579. * 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)
  40580. */
  40581. private zDragFactor;
  40582. /**
  40583. * If the object should rotate to face the drag origin
  40584. */
  40585. rotateDraggedObject: boolean;
  40586. /**
  40587. * If the behavior is currently in a dragging state
  40588. */
  40589. dragging: boolean;
  40590. /**
  40591. * 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)
  40592. */
  40593. dragDeltaRatio: number;
  40594. /**
  40595. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40596. */
  40597. currentDraggingPointerID: number;
  40598. /**
  40599. * If camera controls should be detached during the drag
  40600. */
  40601. detachCameraControls: boolean;
  40602. /**
  40603. * Fires each time a drag starts
  40604. */
  40605. onDragStartObservable: Observable<{}>;
  40606. /**
  40607. * Fires each time a drag ends (eg. mouse release after drag)
  40608. */
  40609. onDragEndObservable: Observable<{}>;
  40610. /**
  40611. * 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
  40612. */
  40613. constructor();
  40614. /**
  40615. * The name of the behavior
  40616. */
  40617. get name(): string;
  40618. /**
  40619. * Initializes the behavior
  40620. */
  40621. init(): void;
  40622. /**
  40623. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40624. */
  40625. private get _pointerCamera();
  40626. /**
  40627. * Attaches the scale behavior the passed in mesh
  40628. * @param ownerNode The mesh that will be scaled around once attached
  40629. */
  40630. attach(ownerNode: Mesh): void;
  40631. /**
  40632. * Detaches the behavior from the mesh
  40633. */
  40634. detach(): void;
  40635. }
  40636. }
  40637. declare module "babylonjs/Behaviors/Meshes/index" {
  40638. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40639. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40640. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40641. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40642. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40643. }
  40644. declare module "babylonjs/Behaviors/index" {
  40645. export * from "babylonjs/Behaviors/behavior";
  40646. export * from "babylonjs/Behaviors/Cameras/index";
  40647. export * from "babylonjs/Behaviors/Meshes/index";
  40648. }
  40649. declare module "babylonjs/Bones/boneIKController" {
  40650. import { Bone } from "babylonjs/Bones/bone";
  40651. import { Vector3 } from "babylonjs/Maths/math.vector";
  40652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40653. import { Nullable } from "babylonjs/types";
  40654. /**
  40655. * Class used to apply inverse kinematics to bones
  40656. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40657. */
  40658. export class BoneIKController {
  40659. private static _tmpVecs;
  40660. private static _tmpQuat;
  40661. private static _tmpMats;
  40662. /**
  40663. * Gets or sets the target mesh
  40664. */
  40665. targetMesh: AbstractMesh;
  40666. /** Gets or sets the mesh used as pole */
  40667. poleTargetMesh: AbstractMesh;
  40668. /**
  40669. * Gets or sets the bone used as pole
  40670. */
  40671. poleTargetBone: Nullable<Bone>;
  40672. /**
  40673. * Gets or sets the target position
  40674. */
  40675. targetPosition: Vector3;
  40676. /**
  40677. * Gets or sets the pole target position
  40678. */
  40679. poleTargetPosition: Vector3;
  40680. /**
  40681. * Gets or sets the pole target local offset
  40682. */
  40683. poleTargetLocalOffset: Vector3;
  40684. /**
  40685. * Gets or sets the pole angle
  40686. */
  40687. poleAngle: number;
  40688. /**
  40689. * Gets or sets the mesh associated with the controller
  40690. */
  40691. mesh: AbstractMesh;
  40692. /**
  40693. * 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)
  40694. */
  40695. slerpAmount: number;
  40696. private _bone1Quat;
  40697. private _bone1Mat;
  40698. private _bone2Ang;
  40699. private _bone1;
  40700. private _bone2;
  40701. private _bone1Length;
  40702. private _bone2Length;
  40703. private _maxAngle;
  40704. private _maxReach;
  40705. private _rightHandedSystem;
  40706. private _bendAxis;
  40707. private _slerping;
  40708. private _adjustRoll;
  40709. /**
  40710. * Gets or sets maximum allowed angle
  40711. */
  40712. get maxAngle(): number;
  40713. set maxAngle(value: number);
  40714. /**
  40715. * Creates a new BoneIKController
  40716. * @param mesh defines the mesh to control
  40717. * @param bone defines the bone to control
  40718. * @param options defines options to set up the controller
  40719. */
  40720. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40721. targetMesh?: AbstractMesh;
  40722. poleTargetMesh?: AbstractMesh;
  40723. poleTargetBone?: Bone;
  40724. poleTargetLocalOffset?: Vector3;
  40725. poleAngle?: number;
  40726. bendAxis?: Vector3;
  40727. maxAngle?: number;
  40728. slerpAmount?: number;
  40729. });
  40730. private _setMaxAngle;
  40731. /**
  40732. * Force the controller to update the bones
  40733. */
  40734. update(): void;
  40735. }
  40736. }
  40737. declare module "babylonjs/Bones/boneLookController" {
  40738. import { Vector3 } from "babylonjs/Maths/math.vector";
  40739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40740. import { Bone } from "babylonjs/Bones/bone";
  40741. import { Space } from "babylonjs/Maths/math.axis";
  40742. /**
  40743. * Class used to make a bone look toward a point in space
  40744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40745. */
  40746. export class BoneLookController {
  40747. private static _tmpVecs;
  40748. private static _tmpQuat;
  40749. private static _tmpMats;
  40750. /**
  40751. * The target Vector3 that the bone will look at
  40752. */
  40753. target: Vector3;
  40754. /**
  40755. * The mesh that the bone is attached to
  40756. */
  40757. mesh: AbstractMesh;
  40758. /**
  40759. * The bone that will be looking to the target
  40760. */
  40761. bone: Bone;
  40762. /**
  40763. * The up axis of the coordinate system that is used when the bone is rotated
  40764. */
  40765. upAxis: Vector3;
  40766. /**
  40767. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40768. */
  40769. upAxisSpace: Space;
  40770. /**
  40771. * Used to make an adjustment to the yaw of the bone
  40772. */
  40773. adjustYaw: number;
  40774. /**
  40775. * Used to make an adjustment to the pitch of the bone
  40776. */
  40777. adjustPitch: number;
  40778. /**
  40779. * Used to make an adjustment to the roll of the bone
  40780. */
  40781. adjustRoll: number;
  40782. /**
  40783. * 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)
  40784. */
  40785. slerpAmount: number;
  40786. private _minYaw;
  40787. private _maxYaw;
  40788. private _minPitch;
  40789. private _maxPitch;
  40790. private _minYawSin;
  40791. private _minYawCos;
  40792. private _maxYawSin;
  40793. private _maxYawCos;
  40794. private _midYawConstraint;
  40795. private _minPitchTan;
  40796. private _maxPitchTan;
  40797. private _boneQuat;
  40798. private _slerping;
  40799. private _transformYawPitch;
  40800. private _transformYawPitchInv;
  40801. private _firstFrameSkipped;
  40802. private _yawRange;
  40803. private _fowardAxis;
  40804. /**
  40805. * Gets or sets the minimum yaw angle that the bone can look to
  40806. */
  40807. get minYaw(): number;
  40808. set minYaw(value: number);
  40809. /**
  40810. * Gets or sets the maximum yaw angle that the bone can look to
  40811. */
  40812. get maxYaw(): number;
  40813. set maxYaw(value: number);
  40814. /**
  40815. * Gets or sets the minimum pitch angle that the bone can look to
  40816. */
  40817. get minPitch(): number;
  40818. set minPitch(value: number);
  40819. /**
  40820. * Gets or sets the maximum pitch angle that the bone can look to
  40821. */
  40822. get maxPitch(): number;
  40823. set maxPitch(value: number);
  40824. /**
  40825. * Create a BoneLookController
  40826. * @param mesh the mesh that the bone belongs to
  40827. * @param bone the bone that will be looking to the target
  40828. * @param target the target Vector3 to look at
  40829. * @param options optional settings:
  40830. * * maxYaw: the maximum angle the bone will yaw to
  40831. * * minYaw: the minimum angle the bone will yaw to
  40832. * * maxPitch: the maximum angle the bone will pitch to
  40833. * * minPitch: the minimum angle the bone will yaw to
  40834. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40835. * * upAxis: the up axis of the coordinate system
  40836. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40837. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40838. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40839. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40840. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40841. * * adjustRoll: used to make an adjustment to the roll of the bone
  40842. **/
  40843. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40844. maxYaw?: number;
  40845. minYaw?: number;
  40846. maxPitch?: number;
  40847. minPitch?: number;
  40848. slerpAmount?: number;
  40849. upAxis?: Vector3;
  40850. upAxisSpace?: Space;
  40851. yawAxis?: Vector3;
  40852. pitchAxis?: Vector3;
  40853. adjustYaw?: number;
  40854. adjustPitch?: number;
  40855. adjustRoll?: number;
  40856. });
  40857. /**
  40858. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40859. */
  40860. update(): void;
  40861. private _getAngleDiff;
  40862. private _getAngleBetween;
  40863. private _isAngleBetween;
  40864. }
  40865. }
  40866. declare module "babylonjs/Bones/index" {
  40867. export * from "babylonjs/Bones/bone";
  40868. export * from "babylonjs/Bones/boneIKController";
  40869. export * from "babylonjs/Bones/boneLookController";
  40870. export * from "babylonjs/Bones/skeleton";
  40871. }
  40872. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40873. import { Nullable } from "babylonjs/types";
  40874. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40875. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40876. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40877. /**
  40878. * Manage the gamepad inputs to control an arc rotate camera.
  40879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40880. */
  40881. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40882. /**
  40883. * Defines the camera the input is attached to.
  40884. */
  40885. camera: ArcRotateCamera;
  40886. /**
  40887. * Defines the gamepad the input is gathering event from.
  40888. */
  40889. gamepad: Nullable<Gamepad>;
  40890. /**
  40891. * Defines the gamepad rotation sensiblity.
  40892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40893. */
  40894. gamepadRotationSensibility: number;
  40895. /**
  40896. * Defines the gamepad move sensiblity.
  40897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40898. */
  40899. gamepadMoveSensibility: number;
  40900. private _yAxisScale;
  40901. /**
  40902. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40903. */
  40904. get invertYAxis(): boolean;
  40905. set invertYAxis(value: boolean);
  40906. private _onGamepadConnectedObserver;
  40907. private _onGamepadDisconnectedObserver;
  40908. /**
  40909. * Attach the input controls to a specific dom element to get the input from.
  40910. * @param element Defines the element the controls should be listened from
  40911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40912. */
  40913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40914. /**
  40915. * Detach the current controls from the specified dom element.
  40916. * @param element Defines the element to stop listening the inputs from
  40917. */
  40918. detachControl(element: Nullable<HTMLElement>): void;
  40919. /**
  40920. * Update the current camera state depending on the inputs that have been used this frame.
  40921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40922. */
  40923. checkInputs(): void;
  40924. /**
  40925. * Gets the class name of the current intput.
  40926. * @returns the class name
  40927. */
  40928. getClassName(): string;
  40929. /**
  40930. * Get the friendly name associated with the input class.
  40931. * @returns the input friendly name
  40932. */
  40933. getSimpleName(): string;
  40934. }
  40935. }
  40936. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40937. import { Nullable } from "babylonjs/types";
  40938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40940. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40941. interface ArcRotateCameraInputsManager {
  40942. /**
  40943. * Add orientation input support to the input manager.
  40944. * @returns the current input manager
  40945. */
  40946. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40947. }
  40948. }
  40949. /**
  40950. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40952. */
  40953. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40954. /**
  40955. * Defines the camera the input is attached to.
  40956. */
  40957. camera: ArcRotateCamera;
  40958. /**
  40959. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40960. */
  40961. alphaCorrection: number;
  40962. /**
  40963. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40964. */
  40965. gammaCorrection: number;
  40966. private _alpha;
  40967. private _gamma;
  40968. private _dirty;
  40969. private _deviceOrientationHandler;
  40970. /**
  40971. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40972. */
  40973. constructor();
  40974. /**
  40975. * Attach the input controls to a specific dom element to get the input from.
  40976. * @param element Defines the element the controls should be listened from
  40977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40978. */
  40979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40980. /** @hidden */
  40981. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40982. /**
  40983. * Update the current camera state depending on the inputs that have been used this frame.
  40984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40985. */
  40986. checkInputs(): void;
  40987. /**
  40988. * Detach the current controls from the specified dom element.
  40989. * @param element Defines the element to stop listening the inputs from
  40990. */
  40991. detachControl(element: Nullable<HTMLElement>): void;
  40992. /**
  40993. * Gets the class name of the current intput.
  40994. * @returns the class name
  40995. */
  40996. getClassName(): string;
  40997. /**
  40998. * Get the friendly name associated with the input class.
  40999. * @returns the input friendly name
  41000. */
  41001. getSimpleName(): string;
  41002. }
  41003. }
  41004. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41005. import { Nullable } from "babylonjs/types";
  41006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41007. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41008. /**
  41009. * Listen to mouse events to control the camera.
  41010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41011. */
  41012. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41013. /**
  41014. * Defines the camera the input is attached to.
  41015. */
  41016. camera: FlyCamera;
  41017. /**
  41018. * Defines if touch is enabled. (Default is true.)
  41019. */
  41020. touchEnabled: boolean;
  41021. /**
  41022. * Defines the buttons associated with the input to handle camera rotation.
  41023. */
  41024. buttons: number[];
  41025. /**
  41026. * Assign buttons for Yaw control.
  41027. */
  41028. buttonsYaw: number[];
  41029. /**
  41030. * Assign buttons for Pitch control.
  41031. */
  41032. buttonsPitch: number[];
  41033. /**
  41034. * Assign buttons for Roll control.
  41035. */
  41036. buttonsRoll: number[];
  41037. /**
  41038. * Detect if any button is being pressed while mouse is moved.
  41039. * -1 = Mouse locked.
  41040. * 0 = Left button.
  41041. * 1 = Middle Button.
  41042. * 2 = Right Button.
  41043. */
  41044. activeButton: number;
  41045. /**
  41046. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41047. * Higher values reduce its sensitivity.
  41048. */
  41049. angularSensibility: number;
  41050. private _mousemoveCallback;
  41051. private _observer;
  41052. private _rollObserver;
  41053. private previousPosition;
  41054. private noPreventDefault;
  41055. private element;
  41056. /**
  41057. * Listen to mouse events to control the camera.
  41058. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41060. */
  41061. constructor(touchEnabled?: boolean);
  41062. /**
  41063. * Attach the mouse control to the HTML DOM element.
  41064. * @param element Defines the element that listens to the input events.
  41065. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41066. */
  41067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41068. /**
  41069. * Detach the current controls from the specified dom element.
  41070. * @param element Defines the element to stop listening the inputs from
  41071. */
  41072. detachControl(element: Nullable<HTMLElement>): void;
  41073. /**
  41074. * Gets the class name of the current input.
  41075. * @returns the class name.
  41076. */
  41077. getClassName(): string;
  41078. /**
  41079. * Get the friendly name associated with the input class.
  41080. * @returns the input's friendly name.
  41081. */
  41082. getSimpleName(): string;
  41083. private _pointerInput;
  41084. private _onMouseMove;
  41085. /**
  41086. * Rotate camera by mouse offset.
  41087. */
  41088. private rotateCamera;
  41089. }
  41090. }
  41091. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41092. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41093. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41094. /**
  41095. * Default Inputs manager for the FlyCamera.
  41096. * It groups all the default supported inputs for ease of use.
  41097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41098. */
  41099. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41100. /**
  41101. * Instantiates a new FlyCameraInputsManager.
  41102. * @param camera Defines the camera the inputs belong to.
  41103. */
  41104. constructor(camera: FlyCamera);
  41105. /**
  41106. * Add keyboard input support to the input manager.
  41107. * @returns the new FlyCameraKeyboardMoveInput().
  41108. */
  41109. addKeyboard(): FlyCameraInputsManager;
  41110. /**
  41111. * Add mouse input support to the input manager.
  41112. * @param touchEnabled Enable touch screen support.
  41113. * @returns the new FlyCameraMouseInput().
  41114. */
  41115. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/flyCamera" {
  41119. import { Scene } from "babylonjs/scene";
  41120. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41122. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41123. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41124. /**
  41125. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41126. * such as in a 3D Space Shooter or a Flight Simulator.
  41127. */
  41128. export class FlyCamera extends TargetCamera {
  41129. /**
  41130. * Define the collision ellipsoid of the camera.
  41131. * This is helpful for simulating a camera body, like a player's body.
  41132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41133. */
  41134. ellipsoid: Vector3;
  41135. /**
  41136. * Define an offset for the position of the ellipsoid around the camera.
  41137. * This can be helpful if the camera is attached away from the player's body center,
  41138. * such as at its head.
  41139. */
  41140. ellipsoidOffset: Vector3;
  41141. /**
  41142. * Enable or disable collisions of the camera with the rest of the scene objects.
  41143. */
  41144. checkCollisions: boolean;
  41145. /**
  41146. * Enable or disable gravity on the camera.
  41147. */
  41148. applyGravity: boolean;
  41149. /**
  41150. * Define the current direction the camera is moving to.
  41151. */
  41152. cameraDirection: Vector3;
  41153. /**
  41154. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41155. * This overrides and empties cameraRotation.
  41156. */
  41157. rotationQuaternion: Quaternion;
  41158. /**
  41159. * Track Roll to maintain the wanted Rolling when looking around.
  41160. */
  41161. _trackRoll: number;
  41162. /**
  41163. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41164. */
  41165. rollCorrect: number;
  41166. /**
  41167. * Mimic a banked turn, Rolling the camera when Yawing.
  41168. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41169. */
  41170. bankedTurn: boolean;
  41171. /**
  41172. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41173. */
  41174. bankedTurnLimit: number;
  41175. /**
  41176. * Value of 0 disables the banked Roll.
  41177. * Value of 1 is equal to the Yaw angle in radians.
  41178. */
  41179. bankedTurnMultiplier: number;
  41180. /**
  41181. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41182. */
  41183. inputs: FlyCameraInputsManager;
  41184. /**
  41185. * Gets the input sensibility for mouse input.
  41186. * Higher values reduce sensitivity.
  41187. */
  41188. get angularSensibility(): number;
  41189. /**
  41190. * Sets the input sensibility for a mouse input.
  41191. * Higher values reduce sensitivity.
  41192. */
  41193. set angularSensibility(value: number);
  41194. /**
  41195. * Get the keys for camera movement forward.
  41196. */
  41197. get keysForward(): number[];
  41198. /**
  41199. * Set the keys for camera movement forward.
  41200. */
  41201. set keysForward(value: number[]);
  41202. /**
  41203. * Get the keys for camera movement backward.
  41204. */
  41205. get keysBackward(): number[];
  41206. set keysBackward(value: number[]);
  41207. /**
  41208. * Get the keys for camera movement up.
  41209. */
  41210. get keysUp(): number[];
  41211. /**
  41212. * Set the keys for camera movement up.
  41213. */
  41214. set keysUp(value: number[]);
  41215. /**
  41216. * Get the keys for camera movement down.
  41217. */
  41218. get keysDown(): number[];
  41219. /**
  41220. * Set the keys for camera movement down.
  41221. */
  41222. set keysDown(value: number[]);
  41223. /**
  41224. * Get the keys for camera movement left.
  41225. */
  41226. get keysLeft(): number[];
  41227. /**
  41228. * Set the keys for camera movement left.
  41229. */
  41230. set keysLeft(value: number[]);
  41231. /**
  41232. * Set the keys for camera movement right.
  41233. */
  41234. get keysRight(): number[];
  41235. /**
  41236. * Set the keys for camera movement right.
  41237. */
  41238. set keysRight(value: number[]);
  41239. /**
  41240. * Event raised when the camera collides with a mesh in the scene.
  41241. */
  41242. onCollide: (collidedMesh: AbstractMesh) => void;
  41243. private _collider;
  41244. private _needMoveForGravity;
  41245. private _oldPosition;
  41246. private _diffPosition;
  41247. private _newPosition;
  41248. /** @hidden */
  41249. _localDirection: Vector3;
  41250. /** @hidden */
  41251. _transformedDirection: Vector3;
  41252. /**
  41253. * Instantiates a FlyCamera.
  41254. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41255. * such as in a 3D Space Shooter or a Flight Simulator.
  41256. * @param name Define the name of the camera in the scene.
  41257. * @param position Define the starting position of the camera in the scene.
  41258. * @param scene Define the scene the camera belongs to.
  41259. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41260. */
  41261. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41262. /**
  41263. * Attach a control to the HTML DOM element.
  41264. * @param element Defines the element that listens to the input events.
  41265. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41266. */
  41267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41268. /**
  41269. * Detach a control from the HTML DOM element.
  41270. * The camera will stop reacting to that input.
  41271. * @param element Defines the element that listens to the input events.
  41272. */
  41273. detachControl(element: HTMLElement): void;
  41274. private _collisionMask;
  41275. /**
  41276. * Get the mask that the camera ignores in collision events.
  41277. */
  41278. get collisionMask(): number;
  41279. /**
  41280. * Set the mask that the camera ignores in collision events.
  41281. */
  41282. set collisionMask(mask: number);
  41283. /** @hidden */
  41284. _collideWithWorld(displacement: Vector3): void;
  41285. /** @hidden */
  41286. private _onCollisionPositionChange;
  41287. /** @hidden */
  41288. _checkInputs(): void;
  41289. /** @hidden */
  41290. _decideIfNeedsToMove(): boolean;
  41291. /** @hidden */
  41292. _updatePosition(): void;
  41293. /**
  41294. * Restore the Roll to its target value at the rate specified.
  41295. * @param rate - Higher means slower restoring.
  41296. * @hidden
  41297. */
  41298. restoreRoll(rate: number): void;
  41299. /**
  41300. * Destroy the camera and release the current resources held by it.
  41301. */
  41302. dispose(): void;
  41303. /**
  41304. * Get the current object class name.
  41305. * @returns the class name.
  41306. */
  41307. getClassName(): string;
  41308. }
  41309. }
  41310. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41311. import { Nullable } from "babylonjs/types";
  41312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41313. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41314. /**
  41315. * Listen to keyboard events to control the camera.
  41316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41317. */
  41318. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41319. /**
  41320. * Defines the camera the input is attached to.
  41321. */
  41322. camera: FlyCamera;
  41323. /**
  41324. * The list of keyboard keys used to control the forward move of the camera.
  41325. */
  41326. keysForward: number[];
  41327. /**
  41328. * The list of keyboard keys used to control the backward move of the camera.
  41329. */
  41330. keysBackward: number[];
  41331. /**
  41332. * The list of keyboard keys used to control the forward move of the camera.
  41333. */
  41334. keysUp: number[];
  41335. /**
  41336. * The list of keyboard keys used to control the backward move of the camera.
  41337. */
  41338. keysDown: number[];
  41339. /**
  41340. * The list of keyboard keys used to control the right strafe move of the camera.
  41341. */
  41342. keysRight: number[];
  41343. /**
  41344. * The list of keyboard keys used to control the left strafe move of the camera.
  41345. */
  41346. keysLeft: number[];
  41347. private _keys;
  41348. private _onCanvasBlurObserver;
  41349. private _onKeyboardObserver;
  41350. private _engine;
  41351. private _scene;
  41352. /**
  41353. * Attach the input controls to a specific dom element to get the input from.
  41354. * @param element Defines the element the controls should be listened from
  41355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41356. */
  41357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41358. /**
  41359. * Detach the current controls from the specified dom element.
  41360. * @param element Defines the element to stop listening the inputs from
  41361. */
  41362. detachControl(element: Nullable<HTMLElement>): void;
  41363. /**
  41364. * Gets the class name of the current intput.
  41365. * @returns the class name
  41366. */
  41367. getClassName(): string;
  41368. /** @hidden */
  41369. _onLostFocus(e: FocusEvent): void;
  41370. /**
  41371. * Get the friendly name associated with the input class.
  41372. * @returns the input friendly name
  41373. */
  41374. getSimpleName(): string;
  41375. /**
  41376. * Update the current camera state depending on the inputs that have been used this frame.
  41377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41378. */
  41379. checkInputs(): void;
  41380. }
  41381. }
  41382. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41383. import { Nullable } from "babylonjs/types";
  41384. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41385. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41386. /**
  41387. * Manage the mouse wheel inputs to control a follow camera.
  41388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41389. */
  41390. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41391. /**
  41392. * Defines the camera the input is attached to.
  41393. */
  41394. camera: FollowCamera;
  41395. /**
  41396. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41397. */
  41398. axisControlRadius: boolean;
  41399. /**
  41400. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41401. */
  41402. axisControlHeight: boolean;
  41403. /**
  41404. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41405. */
  41406. axisControlRotation: boolean;
  41407. /**
  41408. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41409. * relation to mouseWheel events.
  41410. */
  41411. wheelPrecision: number;
  41412. /**
  41413. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41414. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41415. */
  41416. wheelDeltaPercentage: number;
  41417. private _wheel;
  41418. private _observer;
  41419. /**
  41420. * Attach the input controls to a specific dom element to get the input from.
  41421. * @param element Defines the element the controls should be listened from
  41422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41423. */
  41424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41425. /**
  41426. * Detach the current controls from the specified dom element.
  41427. * @param element Defines the element to stop listening the inputs from
  41428. */
  41429. detachControl(element: Nullable<HTMLElement>): void;
  41430. /**
  41431. * Gets the class name of the current intput.
  41432. * @returns the class name
  41433. */
  41434. getClassName(): string;
  41435. /**
  41436. * Get the friendly name associated with the input class.
  41437. * @returns the input friendly name
  41438. */
  41439. getSimpleName(): string;
  41440. }
  41441. }
  41442. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41443. import { Nullable } from "babylonjs/types";
  41444. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41445. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41446. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41447. /**
  41448. * Manage the pointers inputs to control an follow camera.
  41449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41450. */
  41451. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41452. /**
  41453. * Defines the camera the input is attached to.
  41454. */
  41455. camera: FollowCamera;
  41456. /**
  41457. * Gets the class name of the current input.
  41458. * @returns the class name
  41459. */
  41460. getClassName(): string;
  41461. /**
  41462. * Defines the pointer angular sensibility along the X axis or how fast is
  41463. * the camera rotating.
  41464. * A negative number will reverse the axis direction.
  41465. */
  41466. angularSensibilityX: number;
  41467. /**
  41468. * Defines the pointer angular sensibility along the Y axis or how fast is
  41469. * the camera rotating.
  41470. * A negative number will reverse the axis direction.
  41471. */
  41472. angularSensibilityY: number;
  41473. /**
  41474. * Defines the pointer pinch precision or how fast is the camera zooming.
  41475. * A negative number will reverse the axis direction.
  41476. */
  41477. pinchPrecision: number;
  41478. /**
  41479. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41480. * from 0.
  41481. * It defines the percentage of current camera.radius to use as delta when
  41482. * pinch zoom is used.
  41483. */
  41484. pinchDeltaPercentage: number;
  41485. /**
  41486. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41487. */
  41488. axisXControlRadius: boolean;
  41489. /**
  41490. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41491. */
  41492. axisXControlHeight: boolean;
  41493. /**
  41494. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41495. */
  41496. axisXControlRotation: boolean;
  41497. /**
  41498. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41499. */
  41500. axisYControlRadius: boolean;
  41501. /**
  41502. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41503. */
  41504. axisYControlHeight: boolean;
  41505. /**
  41506. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41507. */
  41508. axisYControlRotation: boolean;
  41509. /**
  41510. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41511. */
  41512. axisPinchControlRadius: boolean;
  41513. /**
  41514. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41515. */
  41516. axisPinchControlHeight: boolean;
  41517. /**
  41518. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41519. */
  41520. axisPinchControlRotation: boolean;
  41521. /**
  41522. * Log error messages if basic misconfiguration has occurred.
  41523. */
  41524. warningEnable: boolean;
  41525. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41526. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41527. private _warningCounter;
  41528. private _warning;
  41529. }
  41530. }
  41531. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41532. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41533. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41534. /**
  41535. * Default Inputs manager for the FollowCamera.
  41536. * It groups all the default supported inputs for ease of use.
  41537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41538. */
  41539. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41540. /**
  41541. * Instantiates a new FollowCameraInputsManager.
  41542. * @param camera Defines the camera the inputs belong to
  41543. */
  41544. constructor(camera: FollowCamera);
  41545. /**
  41546. * Add keyboard input support to the input manager.
  41547. * @returns the current input manager
  41548. */
  41549. addKeyboard(): FollowCameraInputsManager;
  41550. /**
  41551. * Add mouse wheel input support to the input manager.
  41552. * @returns the current input manager
  41553. */
  41554. addMouseWheel(): FollowCameraInputsManager;
  41555. /**
  41556. * Add pointers input support to the input manager.
  41557. * @returns the current input manager
  41558. */
  41559. addPointers(): FollowCameraInputsManager;
  41560. /**
  41561. * Add orientation input support to the input manager.
  41562. * @returns the current input manager
  41563. */
  41564. addVRDeviceOrientation(): FollowCameraInputsManager;
  41565. }
  41566. }
  41567. declare module "babylonjs/Cameras/followCamera" {
  41568. import { Nullable } from "babylonjs/types";
  41569. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41570. import { Scene } from "babylonjs/scene";
  41571. import { Vector3 } from "babylonjs/Maths/math.vector";
  41572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41573. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41574. /**
  41575. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41576. * an arc rotate version arcFollowCamera are available.
  41577. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41578. */
  41579. export class FollowCamera extends TargetCamera {
  41580. /**
  41581. * Distance the follow camera should follow an object at
  41582. */
  41583. radius: number;
  41584. /**
  41585. * Minimum allowed distance of the camera to the axis of rotation
  41586. * (The camera can not get closer).
  41587. * This can help limiting how the Camera is able to move in the scene.
  41588. */
  41589. lowerRadiusLimit: Nullable<number>;
  41590. /**
  41591. * Maximum allowed distance of the camera to the axis of rotation
  41592. * (The camera can not get further).
  41593. * This can help limiting how the Camera is able to move in the scene.
  41594. */
  41595. upperRadiusLimit: Nullable<number>;
  41596. /**
  41597. * Define a rotation offset between the camera and the object it follows
  41598. */
  41599. rotationOffset: number;
  41600. /**
  41601. * Minimum allowed angle to camera position relative to target object.
  41602. * This can help limiting how the Camera is able to move in the scene.
  41603. */
  41604. lowerRotationOffsetLimit: Nullable<number>;
  41605. /**
  41606. * Maximum allowed angle to camera position relative to target object.
  41607. * This can help limiting how the Camera is able to move in the scene.
  41608. */
  41609. upperRotationOffsetLimit: Nullable<number>;
  41610. /**
  41611. * Define a height offset between the camera and the object it follows.
  41612. * It can help following an object from the top (like a car chaing a plane)
  41613. */
  41614. heightOffset: number;
  41615. /**
  41616. * Minimum allowed height of camera position relative to target object.
  41617. * This can help limiting how the Camera is able to move in the scene.
  41618. */
  41619. lowerHeightOffsetLimit: Nullable<number>;
  41620. /**
  41621. * Maximum allowed height of camera position relative to target object.
  41622. * This can help limiting how the Camera is able to move in the scene.
  41623. */
  41624. upperHeightOffsetLimit: Nullable<number>;
  41625. /**
  41626. * Define how fast the camera can accelerate to follow it s target.
  41627. */
  41628. cameraAcceleration: number;
  41629. /**
  41630. * Define the speed limit of the camera following an object.
  41631. */
  41632. maxCameraSpeed: number;
  41633. /**
  41634. * Define the target of the camera.
  41635. */
  41636. lockedTarget: Nullable<AbstractMesh>;
  41637. /**
  41638. * Defines the input associated with the camera.
  41639. */
  41640. inputs: FollowCameraInputsManager;
  41641. /**
  41642. * Instantiates the follow camera.
  41643. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41644. * @param name Define the name of the camera in the scene
  41645. * @param position Define the position of the camera
  41646. * @param scene Define the scene the camera belong to
  41647. * @param lockedTarget Define the target of the camera
  41648. */
  41649. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41650. private _follow;
  41651. /**
  41652. * Attached controls to the current camera.
  41653. * @param element Defines the element the controls should be listened from
  41654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41655. */
  41656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41657. /**
  41658. * Detach the current controls from the camera.
  41659. * The camera will stop reacting to inputs.
  41660. * @param element Defines the element to stop listening the inputs from
  41661. */
  41662. detachControl(element: HTMLElement): void;
  41663. /** @hidden */
  41664. _checkInputs(): void;
  41665. private _checkLimits;
  41666. /**
  41667. * Gets the camera class name.
  41668. * @returns the class name
  41669. */
  41670. getClassName(): string;
  41671. }
  41672. /**
  41673. * Arc Rotate version of the follow camera.
  41674. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41675. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41676. */
  41677. export class ArcFollowCamera extends TargetCamera {
  41678. /** The longitudinal angle of the camera */
  41679. alpha: number;
  41680. /** The latitudinal angle of the camera */
  41681. beta: number;
  41682. /** The radius of the camera from its target */
  41683. radius: number;
  41684. /** Define the camera target (the messh it should follow) */
  41685. target: Nullable<AbstractMesh>;
  41686. private _cartesianCoordinates;
  41687. /**
  41688. * Instantiates a new ArcFollowCamera
  41689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41690. * @param name Define the name of the camera
  41691. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41692. * @param beta Define the rotation angle of the camera around the elevation axis
  41693. * @param radius Define the radius of the camera from its target point
  41694. * @param target Define the target of the camera
  41695. * @param scene Define the scene the camera belongs to
  41696. */
  41697. constructor(name: string,
  41698. /** The longitudinal angle of the camera */
  41699. alpha: number,
  41700. /** The latitudinal angle of the camera */
  41701. beta: number,
  41702. /** The radius of the camera from its target */
  41703. radius: number,
  41704. /** Define the camera target (the messh it should follow) */
  41705. target: Nullable<AbstractMesh>, scene: Scene);
  41706. private _follow;
  41707. /** @hidden */
  41708. _checkInputs(): void;
  41709. /**
  41710. * Returns the class name of the object.
  41711. * It is mostly used internally for serialization purposes.
  41712. */
  41713. getClassName(): string;
  41714. }
  41715. }
  41716. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41718. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41719. import { Nullable } from "babylonjs/types";
  41720. /**
  41721. * Manage the keyboard inputs to control the movement of a follow camera.
  41722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41723. */
  41724. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41725. /**
  41726. * Defines the camera the input is attached to.
  41727. */
  41728. camera: FollowCamera;
  41729. /**
  41730. * Defines the list of key codes associated with the up action (increase heightOffset)
  41731. */
  41732. keysHeightOffsetIncr: number[];
  41733. /**
  41734. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41735. */
  41736. keysHeightOffsetDecr: number[];
  41737. /**
  41738. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41739. */
  41740. keysHeightOffsetModifierAlt: boolean;
  41741. /**
  41742. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41743. */
  41744. keysHeightOffsetModifierCtrl: boolean;
  41745. /**
  41746. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41747. */
  41748. keysHeightOffsetModifierShift: boolean;
  41749. /**
  41750. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41751. */
  41752. keysRotationOffsetIncr: number[];
  41753. /**
  41754. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41755. */
  41756. keysRotationOffsetDecr: number[];
  41757. /**
  41758. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41759. */
  41760. keysRotationOffsetModifierAlt: boolean;
  41761. /**
  41762. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41763. */
  41764. keysRotationOffsetModifierCtrl: boolean;
  41765. /**
  41766. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41767. */
  41768. keysRotationOffsetModifierShift: boolean;
  41769. /**
  41770. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41771. */
  41772. keysRadiusIncr: number[];
  41773. /**
  41774. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41775. */
  41776. keysRadiusDecr: number[];
  41777. /**
  41778. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41779. */
  41780. keysRadiusModifierAlt: boolean;
  41781. /**
  41782. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41783. */
  41784. keysRadiusModifierCtrl: boolean;
  41785. /**
  41786. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41787. */
  41788. keysRadiusModifierShift: boolean;
  41789. /**
  41790. * Defines the rate of change of heightOffset.
  41791. */
  41792. heightSensibility: number;
  41793. /**
  41794. * Defines the rate of change of rotationOffset.
  41795. */
  41796. rotationSensibility: number;
  41797. /**
  41798. * Defines the rate of change of radius.
  41799. */
  41800. radiusSensibility: number;
  41801. private _keys;
  41802. private _ctrlPressed;
  41803. private _altPressed;
  41804. private _shiftPressed;
  41805. private _onCanvasBlurObserver;
  41806. private _onKeyboardObserver;
  41807. private _engine;
  41808. private _scene;
  41809. /**
  41810. * Attach the input controls to a specific dom element to get the input from.
  41811. * @param element Defines the element the controls should be listened from
  41812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41813. */
  41814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41815. /**
  41816. * Detach the current controls from the specified dom element.
  41817. * @param element Defines the element to stop listening the inputs from
  41818. */
  41819. detachControl(element: Nullable<HTMLElement>): void;
  41820. /**
  41821. * Update the current camera state depending on the inputs that have been used this frame.
  41822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41823. */
  41824. checkInputs(): void;
  41825. /**
  41826. * Gets the class name of the current input.
  41827. * @returns the class name
  41828. */
  41829. getClassName(): string;
  41830. /**
  41831. * Get the friendly name associated with the input class.
  41832. * @returns the input friendly name
  41833. */
  41834. getSimpleName(): string;
  41835. /**
  41836. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41837. * allow modification of the heightOffset value.
  41838. */
  41839. private _modifierHeightOffset;
  41840. /**
  41841. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41842. * allow modification of the rotationOffset value.
  41843. */
  41844. private _modifierRotationOffset;
  41845. /**
  41846. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41847. * allow modification of the radius value.
  41848. */
  41849. private _modifierRadius;
  41850. }
  41851. }
  41852. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41853. import { Nullable } from "babylonjs/types";
  41854. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41856. import { Observable } from "babylonjs/Misc/observable";
  41857. module "babylonjs/Cameras/freeCameraInputsManager" {
  41858. interface FreeCameraInputsManager {
  41859. /**
  41860. * @hidden
  41861. */
  41862. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41863. /**
  41864. * Add orientation input support to the input manager.
  41865. * @returns the current input manager
  41866. */
  41867. addDeviceOrientation(): FreeCameraInputsManager;
  41868. }
  41869. }
  41870. /**
  41871. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41872. * Screen rotation is taken into account.
  41873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41874. */
  41875. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41876. private _camera;
  41877. private _screenOrientationAngle;
  41878. private _constantTranform;
  41879. private _screenQuaternion;
  41880. private _alpha;
  41881. private _beta;
  41882. private _gamma;
  41883. /**
  41884. * Can be used to detect if a device orientation sensor is available on a device
  41885. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41886. * @returns a promise that will resolve on orientation change
  41887. */
  41888. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41889. /**
  41890. * @hidden
  41891. */
  41892. _onDeviceOrientationChangedObservable: Observable<void>;
  41893. /**
  41894. * Instantiates a new input
  41895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41896. */
  41897. constructor();
  41898. /**
  41899. * Define the camera controlled by the input.
  41900. */
  41901. get camera(): FreeCamera;
  41902. set camera(camera: FreeCamera);
  41903. /**
  41904. * Attach the input controls to a specific dom element to get the input from.
  41905. * @param element Defines the element the controls should be listened from
  41906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41907. */
  41908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41909. private _orientationChanged;
  41910. private _deviceOrientation;
  41911. /**
  41912. * Detach the current controls from the specified dom element.
  41913. * @param element Defines the element to stop listening the inputs from
  41914. */
  41915. detachControl(element: Nullable<HTMLElement>): void;
  41916. /**
  41917. * Update the current camera state depending on the inputs that have been used this frame.
  41918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41919. */
  41920. checkInputs(): void;
  41921. /**
  41922. * Gets the class name of the current intput.
  41923. * @returns the class name
  41924. */
  41925. getClassName(): string;
  41926. /**
  41927. * Get the friendly name associated with the input class.
  41928. * @returns the input friendly name
  41929. */
  41930. getSimpleName(): string;
  41931. }
  41932. }
  41933. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41934. import { Nullable } from "babylonjs/types";
  41935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41937. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41938. /**
  41939. * Manage the gamepad inputs to control a free camera.
  41940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41941. */
  41942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41943. /**
  41944. * Define the camera the input is attached to.
  41945. */
  41946. camera: FreeCamera;
  41947. /**
  41948. * Define the Gamepad controlling the input
  41949. */
  41950. gamepad: Nullable<Gamepad>;
  41951. /**
  41952. * Defines the gamepad rotation sensiblity.
  41953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41954. */
  41955. gamepadAngularSensibility: number;
  41956. /**
  41957. * Defines the gamepad move sensiblity.
  41958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41959. */
  41960. gamepadMoveSensibility: number;
  41961. private _yAxisScale;
  41962. /**
  41963. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41964. */
  41965. get invertYAxis(): boolean;
  41966. set invertYAxis(value: boolean);
  41967. private _onGamepadConnectedObserver;
  41968. private _onGamepadDisconnectedObserver;
  41969. private _cameraTransform;
  41970. private _deltaTransform;
  41971. private _vector3;
  41972. private _vector2;
  41973. /**
  41974. * Attach the input controls to a specific dom element to get the input from.
  41975. * @param element Defines the element the controls should be listened from
  41976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41977. */
  41978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41979. /**
  41980. * Detach the current controls from the specified dom element.
  41981. * @param element Defines the element to stop listening the inputs from
  41982. */
  41983. detachControl(element: Nullable<HTMLElement>): void;
  41984. /**
  41985. * Update the current camera state depending on the inputs that have been used this frame.
  41986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41987. */
  41988. checkInputs(): void;
  41989. /**
  41990. * Gets the class name of the current intput.
  41991. * @returns the class name
  41992. */
  41993. getClassName(): string;
  41994. /**
  41995. * Get the friendly name associated with the input class.
  41996. * @returns the input friendly name
  41997. */
  41998. getSimpleName(): string;
  41999. }
  42000. }
  42001. declare module "babylonjs/Misc/virtualJoystick" {
  42002. import { Nullable } from "babylonjs/types";
  42003. import { Vector3 } from "babylonjs/Maths/math.vector";
  42004. /**
  42005. * Defines the potential axis of a Joystick
  42006. */
  42007. export enum JoystickAxis {
  42008. /** X axis */
  42009. X = 0,
  42010. /** Y axis */
  42011. Y = 1,
  42012. /** Z axis */
  42013. Z = 2
  42014. }
  42015. /**
  42016. * Class used to define virtual joystick (used in touch mode)
  42017. */
  42018. export class VirtualJoystick {
  42019. /**
  42020. * Gets or sets a boolean indicating that left and right values must be inverted
  42021. */
  42022. reverseLeftRight: boolean;
  42023. /**
  42024. * Gets or sets a boolean indicating that up and down values must be inverted
  42025. */
  42026. reverseUpDown: boolean;
  42027. /**
  42028. * Gets the offset value for the position (ie. the change of the position value)
  42029. */
  42030. deltaPosition: Vector3;
  42031. /**
  42032. * Gets a boolean indicating if the virtual joystick was pressed
  42033. */
  42034. pressed: boolean;
  42035. /**
  42036. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42037. */
  42038. static Canvas: Nullable<HTMLCanvasElement>;
  42039. private static _globalJoystickIndex;
  42040. private static vjCanvasContext;
  42041. private static vjCanvasWidth;
  42042. private static vjCanvasHeight;
  42043. private static halfWidth;
  42044. private _action;
  42045. private _axisTargetedByLeftAndRight;
  42046. private _axisTargetedByUpAndDown;
  42047. private _joystickSensibility;
  42048. private _inversedSensibility;
  42049. private _joystickPointerID;
  42050. private _joystickColor;
  42051. private _joystickPointerPos;
  42052. private _joystickPreviousPointerPos;
  42053. private _joystickPointerStartPos;
  42054. private _deltaJoystickVector;
  42055. private _leftJoystick;
  42056. private _touches;
  42057. private _onPointerDownHandlerRef;
  42058. private _onPointerMoveHandlerRef;
  42059. private _onPointerUpHandlerRef;
  42060. private _onResize;
  42061. /**
  42062. * Creates a new virtual joystick
  42063. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42064. */
  42065. constructor(leftJoystick?: boolean);
  42066. /**
  42067. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42068. * @param newJoystickSensibility defines the new sensibility
  42069. */
  42070. setJoystickSensibility(newJoystickSensibility: number): void;
  42071. private _onPointerDown;
  42072. private _onPointerMove;
  42073. private _onPointerUp;
  42074. /**
  42075. * Change the color of the virtual joystick
  42076. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42077. */
  42078. setJoystickColor(newColor: string): void;
  42079. /**
  42080. * Defines a callback to call when the joystick is touched
  42081. * @param action defines the callback
  42082. */
  42083. setActionOnTouch(action: () => any): void;
  42084. /**
  42085. * Defines which axis you'd like to control for left & right
  42086. * @param axis defines the axis to use
  42087. */
  42088. setAxisForLeftRight(axis: JoystickAxis): void;
  42089. /**
  42090. * Defines which axis you'd like to control for up & down
  42091. * @param axis defines the axis to use
  42092. */
  42093. setAxisForUpDown(axis: JoystickAxis): void;
  42094. private _drawVirtualJoystick;
  42095. /**
  42096. * Release internal HTML canvas
  42097. */
  42098. releaseCanvas(): void;
  42099. }
  42100. }
  42101. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42102. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42103. import { Nullable } from "babylonjs/types";
  42104. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42105. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42106. module "babylonjs/Cameras/freeCameraInputsManager" {
  42107. interface FreeCameraInputsManager {
  42108. /**
  42109. * Add virtual joystick input support to the input manager.
  42110. * @returns the current input manager
  42111. */
  42112. addVirtualJoystick(): FreeCameraInputsManager;
  42113. }
  42114. }
  42115. /**
  42116. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42118. */
  42119. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42120. /**
  42121. * Defines the camera the input is attached to.
  42122. */
  42123. camera: FreeCamera;
  42124. private _leftjoystick;
  42125. private _rightjoystick;
  42126. /**
  42127. * Gets the left stick of the virtual joystick.
  42128. * @returns The virtual Joystick
  42129. */
  42130. getLeftJoystick(): VirtualJoystick;
  42131. /**
  42132. * Gets the right stick of the virtual joystick.
  42133. * @returns The virtual Joystick
  42134. */
  42135. getRightJoystick(): VirtualJoystick;
  42136. /**
  42137. * Update the current camera state depending on the inputs that have been used this frame.
  42138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42139. */
  42140. checkInputs(): void;
  42141. /**
  42142. * Attach the input controls to a specific dom element to get the input from.
  42143. * @param element Defines the element the controls should be listened from
  42144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42145. */
  42146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42147. /**
  42148. * Detach the current controls from the specified dom element.
  42149. * @param element Defines the element to stop listening the inputs from
  42150. */
  42151. detachControl(element: Nullable<HTMLElement>): void;
  42152. /**
  42153. * Gets the class name of the current intput.
  42154. * @returns the class name
  42155. */
  42156. getClassName(): string;
  42157. /**
  42158. * Get the friendly name associated with the input class.
  42159. * @returns the input friendly name
  42160. */
  42161. getSimpleName(): string;
  42162. }
  42163. }
  42164. declare module "babylonjs/Cameras/Inputs/index" {
  42165. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42166. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42167. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42168. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42169. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42170. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42171. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42172. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42173. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42174. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42175. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42176. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42177. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42178. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42179. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42180. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42181. }
  42182. declare module "babylonjs/Cameras/touchCamera" {
  42183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42184. import { Scene } from "babylonjs/scene";
  42185. import { Vector3 } from "babylonjs/Maths/math.vector";
  42186. /**
  42187. * This represents a FPS type of camera controlled by touch.
  42188. * This is like a universal camera minus the Gamepad controls.
  42189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42190. */
  42191. export class TouchCamera extends FreeCamera {
  42192. /**
  42193. * Defines the touch sensibility for rotation.
  42194. * The higher the faster.
  42195. */
  42196. get touchAngularSensibility(): number;
  42197. set touchAngularSensibility(value: number);
  42198. /**
  42199. * Defines the touch sensibility for move.
  42200. * The higher the faster.
  42201. */
  42202. get touchMoveSensibility(): number;
  42203. set touchMoveSensibility(value: number);
  42204. /**
  42205. * Instantiates a new touch camera.
  42206. * This represents a FPS type of camera controlled by touch.
  42207. * This is like a universal camera minus the Gamepad controls.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. * @param name Define the name of the camera in the scene
  42210. * @param position Define the start position of the camera in the scene
  42211. * @param scene Define the scene the camera belongs to
  42212. */
  42213. constructor(name: string, position: Vector3, scene: Scene);
  42214. /**
  42215. * Gets the current object class name.
  42216. * @return the class name
  42217. */
  42218. getClassName(): string;
  42219. /** @hidden */
  42220. _setupInputs(): void;
  42221. }
  42222. }
  42223. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42225. import { Scene } from "babylonjs/scene";
  42226. import { Vector3 } from "babylonjs/Maths/math.vector";
  42227. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42228. import { Axis } from "babylonjs/Maths/math.axis";
  42229. /**
  42230. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42231. * being tilted forward or back and left or right.
  42232. */
  42233. export class DeviceOrientationCamera extends FreeCamera {
  42234. private _initialQuaternion;
  42235. private _quaternionCache;
  42236. private _tmpDragQuaternion;
  42237. private _disablePointerInputWhenUsingDeviceOrientation;
  42238. /**
  42239. * Creates a new device orientation camera
  42240. * @param name The name of the camera
  42241. * @param position The start position camera
  42242. * @param scene The scene the camera belongs to
  42243. */
  42244. constructor(name: string, position: Vector3, scene: Scene);
  42245. /**
  42246. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42247. */
  42248. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42249. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42250. private _dragFactor;
  42251. /**
  42252. * Enabled turning on the y axis when the orientation sensor is active
  42253. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42254. */
  42255. enableHorizontalDragging(dragFactor?: number): void;
  42256. /**
  42257. * Gets the current instance class name ("DeviceOrientationCamera").
  42258. * This helps avoiding instanceof at run time.
  42259. * @returns the class name
  42260. */
  42261. getClassName(): string;
  42262. /**
  42263. * @hidden
  42264. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42265. */
  42266. _checkInputs(): void;
  42267. /**
  42268. * Reset the camera to its default orientation on the specified axis only.
  42269. * @param axis The axis to reset
  42270. */
  42271. resetToCurrentRotation(axis?: Axis): void;
  42272. }
  42273. }
  42274. declare module "babylonjs/Gamepads/xboxGamepad" {
  42275. import { Observable } from "babylonjs/Misc/observable";
  42276. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42277. /**
  42278. * Defines supported buttons for XBox360 compatible gamepads
  42279. */
  42280. export enum Xbox360Button {
  42281. /** A */
  42282. A = 0,
  42283. /** B */
  42284. B = 1,
  42285. /** X */
  42286. X = 2,
  42287. /** Y */
  42288. Y = 3,
  42289. /** Left button */
  42290. LB = 4,
  42291. /** Right button */
  42292. RB = 5,
  42293. /** Back */
  42294. Back = 8,
  42295. /** Start */
  42296. Start = 9,
  42297. /** Left stick */
  42298. LeftStick = 10,
  42299. /** Right stick */
  42300. RightStick = 11
  42301. }
  42302. /** Defines values for XBox360 DPad */
  42303. export enum Xbox360Dpad {
  42304. /** Up */
  42305. Up = 12,
  42306. /** Down */
  42307. Down = 13,
  42308. /** Left */
  42309. Left = 14,
  42310. /** Right */
  42311. Right = 15
  42312. }
  42313. /**
  42314. * Defines a XBox360 gamepad
  42315. */
  42316. export class Xbox360Pad extends Gamepad {
  42317. private _leftTrigger;
  42318. private _rightTrigger;
  42319. private _onlefttriggerchanged;
  42320. private _onrighttriggerchanged;
  42321. private _onbuttondown;
  42322. private _onbuttonup;
  42323. private _ondpaddown;
  42324. private _ondpadup;
  42325. /** Observable raised when a button is pressed */
  42326. onButtonDownObservable: Observable<Xbox360Button>;
  42327. /** Observable raised when a button is released */
  42328. onButtonUpObservable: Observable<Xbox360Button>;
  42329. /** Observable raised when a pad is pressed */
  42330. onPadDownObservable: Observable<Xbox360Dpad>;
  42331. /** Observable raised when a pad is released */
  42332. onPadUpObservable: Observable<Xbox360Dpad>;
  42333. private _buttonA;
  42334. private _buttonB;
  42335. private _buttonX;
  42336. private _buttonY;
  42337. private _buttonBack;
  42338. private _buttonStart;
  42339. private _buttonLB;
  42340. private _buttonRB;
  42341. private _buttonLeftStick;
  42342. private _buttonRightStick;
  42343. private _dPadUp;
  42344. private _dPadDown;
  42345. private _dPadLeft;
  42346. private _dPadRight;
  42347. private _isXboxOnePad;
  42348. /**
  42349. * Creates a new XBox360 gamepad object
  42350. * @param id defines the id of this gamepad
  42351. * @param index defines its index
  42352. * @param gamepad defines the internal HTML gamepad object
  42353. * @param xboxOne defines if it is a XBox One gamepad
  42354. */
  42355. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42356. /**
  42357. * Defines the callback to call when left trigger is pressed
  42358. * @param callback defines the callback to use
  42359. */
  42360. onlefttriggerchanged(callback: (value: number) => void): void;
  42361. /**
  42362. * Defines the callback to call when right trigger is pressed
  42363. * @param callback defines the callback to use
  42364. */
  42365. onrighttriggerchanged(callback: (value: number) => void): void;
  42366. /**
  42367. * Gets the left trigger value
  42368. */
  42369. get leftTrigger(): number;
  42370. /**
  42371. * Sets the left trigger value
  42372. */
  42373. set leftTrigger(newValue: number);
  42374. /**
  42375. * Gets the right trigger value
  42376. */
  42377. get rightTrigger(): number;
  42378. /**
  42379. * Sets the right trigger value
  42380. */
  42381. set rightTrigger(newValue: number);
  42382. /**
  42383. * Defines the callback to call when a button is pressed
  42384. * @param callback defines the callback to use
  42385. */
  42386. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42387. /**
  42388. * Defines the callback to call when a button is released
  42389. * @param callback defines the callback to use
  42390. */
  42391. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42392. /**
  42393. * Defines the callback to call when a pad is pressed
  42394. * @param callback defines the callback to use
  42395. */
  42396. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42397. /**
  42398. * Defines the callback to call when a pad is released
  42399. * @param callback defines the callback to use
  42400. */
  42401. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42402. private _setButtonValue;
  42403. private _setDPadValue;
  42404. /**
  42405. * Gets the value of the `A` button
  42406. */
  42407. get buttonA(): number;
  42408. /**
  42409. * Sets the value of the `A` button
  42410. */
  42411. set buttonA(value: number);
  42412. /**
  42413. * Gets the value of the `B` button
  42414. */
  42415. get buttonB(): number;
  42416. /**
  42417. * Sets the value of the `B` button
  42418. */
  42419. set buttonB(value: number);
  42420. /**
  42421. * Gets the value of the `X` button
  42422. */
  42423. get buttonX(): number;
  42424. /**
  42425. * Sets the value of the `X` button
  42426. */
  42427. set buttonX(value: number);
  42428. /**
  42429. * Gets the value of the `Y` button
  42430. */
  42431. get buttonY(): number;
  42432. /**
  42433. * Sets the value of the `Y` button
  42434. */
  42435. set buttonY(value: number);
  42436. /**
  42437. * Gets the value of the `Start` button
  42438. */
  42439. get buttonStart(): number;
  42440. /**
  42441. * Sets the value of the `Start` button
  42442. */
  42443. set buttonStart(value: number);
  42444. /**
  42445. * Gets the value of the `Back` button
  42446. */
  42447. get buttonBack(): number;
  42448. /**
  42449. * Sets the value of the `Back` button
  42450. */
  42451. set buttonBack(value: number);
  42452. /**
  42453. * Gets the value of the `Left` button
  42454. */
  42455. get buttonLB(): number;
  42456. /**
  42457. * Sets the value of the `Left` button
  42458. */
  42459. set buttonLB(value: number);
  42460. /**
  42461. * Gets the value of the `Right` button
  42462. */
  42463. get buttonRB(): number;
  42464. /**
  42465. * Sets the value of the `Right` button
  42466. */
  42467. set buttonRB(value: number);
  42468. /**
  42469. * Gets the value of the Left joystick
  42470. */
  42471. get buttonLeftStick(): number;
  42472. /**
  42473. * Sets the value of the Left joystick
  42474. */
  42475. set buttonLeftStick(value: number);
  42476. /**
  42477. * Gets the value of the Right joystick
  42478. */
  42479. get buttonRightStick(): number;
  42480. /**
  42481. * Sets the value of the Right joystick
  42482. */
  42483. set buttonRightStick(value: number);
  42484. /**
  42485. * Gets the value of D-pad up
  42486. */
  42487. get dPadUp(): number;
  42488. /**
  42489. * Sets the value of D-pad up
  42490. */
  42491. set dPadUp(value: number);
  42492. /**
  42493. * Gets the value of D-pad down
  42494. */
  42495. get dPadDown(): number;
  42496. /**
  42497. * Sets the value of D-pad down
  42498. */
  42499. set dPadDown(value: number);
  42500. /**
  42501. * Gets the value of D-pad left
  42502. */
  42503. get dPadLeft(): number;
  42504. /**
  42505. * Sets the value of D-pad left
  42506. */
  42507. set dPadLeft(value: number);
  42508. /**
  42509. * Gets the value of D-pad right
  42510. */
  42511. get dPadRight(): number;
  42512. /**
  42513. * Sets the value of D-pad right
  42514. */
  42515. set dPadRight(value: number);
  42516. /**
  42517. * Force the gamepad to synchronize with device values
  42518. */
  42519. update(): void;
  42520. /**
  42521. * Disposes the gamepad
  42522. */
  42523. dispose(): void;
  42524. }
  42525. }
  42526. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42527. import { Observable } from "babylonjs/Misc/observable";
  42528. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42529. /**
  42530. * Defines supported buttons for DualShock compatible gamepads
  42531. */
  42532. export enum DualShockButton {
  42533. /** Cross */
  42534. Cross = 0,
  42535. /** Circle */
  42536. Circle = 1,
  42537. /** Square */
  42538. Square = 2,
  42539. /** Triangle */
  42540. Triangle = 3,
  42541. /** L1 */
  42542. L1 = 4,
  42543. /** R1 */
  42544. R1 = 5,
  42545. /** Share */
  42546. Share = 8,
  42547. /** Options */
  42548. Options = 9,
  42549. /** Left stick */
  42550. LeftStick = 10,
  42551. /** Right stick */
  42552. RightStick = 11
  42553. }
  42554. /** Defines values for DualShock DPad */
  42555. export enum DualShockDpad {
  42556. /** Up */
  42557. Up = 12,
  42558. /** Down */
  42559. Down = 13,
  42560. /** Left */
  42561. Left = 14,
  42562. /** Right */
  42563. Right = 15
  42564. }
  42565. /**
  42566. * Defines a DualShock gamepad
  42567. */
  42568. export class DualShockPad extends Gamepad {
  42569. private _leftTrigger;
  42570. private _rightTrigger;
  42571. private _onlefttriggerchanged;
  42572. private _onrighttriggerchanged;
  42573. private _onbuttondown;
  42574. private _onbuttonup;
  42575. private _ondpaddown;
  42576. private _ondpadup;
  42577. /** Observable raised when a button is pressed */
  42578. onButtonDownObservable: Observable<DualShockButton>;
  42579. /** Observable raised when a button is released */
  42580. onButtonUpObservable: Observable<DualShockButton>;
  42581. /** Observable raised when a pad is pressed */
  42582. onPadDownObservable: Observable<DualShockDpad>;
  42583. /** Observable raised when a pad is released */
  42584. onPadUpObservable: Observable<DualShockDpad>;
  42585. private _buttonCross;
  42586. private _buttonCircle;
  42587. private _buttonSquare;
  42588. private _buttonTriangle;
  42589. private _buttonShare;
  42590. private _buttonOptions;
  42591. private _buttonL1;
  42592. private _buttonR1;
  42593. private _buttonLeftStick;
  42594. private _buttonRightStick;
  42595. private _dPadUp;
  42596. private _dPadDown;
  42597. private _dPadLeft;
  42598. private _dPadRight;
  42599. /**
  42600. * Creates a new DualShock gamepad object
  42601. * @param id defines the id of this gamepad
  42602. * @param index defines its index
  42603. * @param gamepad defines the internal HTML gamepad object
  42604. */
  42605. constructor(id: string, index: number, gamepad: any);
  42606. /**
  42607. * Defines the callback to call when left trigger is pressed
  42608. * @param callback defines the callback to use
  42609. */
  42610. onlefttriggerchanged(callback: (value: number) => void): void;
  42611. /**
  42612. * Defines the callback to call when right trigger is pressed
  42613. * @param callback defines the callback to use
  42614. */
  42615. onrighttriggerchanged(callback: (value: number) => void): void;
  42616. /**
  42617. * Gets the left trigger value
  42618. */
  42619. get leftTrigger(): number;
  42620. /**
  42621. * Sets the left trigger value
  42622. */
  42623. set leftTrigger(newValue: number);
  42624. /**
  42625. * Gets the right trigger value
  42626. */
  42627. get rightTrigger(): number;
  42628. /**
  42629. * Sets the right trigger value
  42630. */
  42631. set rightTrigger(newValue: number);
  42632. /**
  42633. * Defines the callback to call when a button is pressed
  42634. * @param callback defines the callback to use
  42635. */
  42636. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42637. /**
  42638. * Defines the callback to call when a button is released
  42639. * @param callback defines the callback to use
  42640. */
  42641. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42642. /**
  42643. * Defines the callback to call when a pad is pressed
  42644. * @param callback defines the callback to use
  42645. */
  42646. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42647. /**
  42648. * Defines the callback to call when a pad is released
  42649. * @param callback defines the callback to use
  42650. */
  42651. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42652. private _setButtonValue;
  42653. private _setDPadValue;
  42654. /**
  42655. * Gets the value of the `Cross` button
  42656. */
  42657. get buttonCross(): number;
  42658. /**
  42659. * Sets the value of the `Cross` button
  42660. */
  42661. set buttonCross(value: number);
  42662. /**
  42663. * Gets the value of the `Circle` button
  42664. */
  42665. get buttonCircle(): number;
  42666. /**
  42667. * Sets the value of the `Circle` button
  42668. */
  42669. set buttonCircle(value: number);
  42670. /**
  42671. * Gets the value of the `Square` button
  42672. */
  42673. get buttonSquare(): number;
  42674. /**
  42675. * Sets the value of the `Square` button
  42676. */
  42677. set buttonSquare(value: number);
  42678. /**
  42679. * Gets the value of the `Triangle` button
  42680. */
  42681. get buttonTriangle(): number;
  42682. /**
  42683. * Sets the value of the `Triangle` button
  42684. */
  42685. set buttonTriangle(value: number);
  42686. /**
  42687. * Gets the value of the `Options` button
  42688. */
  42689. get buttonOptions(): number;
  42690. /**
  42691. * Sets the value of the `Options` button
  42692. */
  42693. set buttonOptions(value: number);
  42694. /**
  42695. * Gets the value of the `Share` button
  42696. */
  42697. get buttonShare(): number;
  42698. /**
  42699. * Sets the value of the `Share` button
  42700. */
  42701. set buttonShare(value: number);
  42702. /**
  42703. * Gets the value of the `L1` button
  42704. */
  42705. get buttonL1(): number;
  42706. /**
  42707. * Sets the value of the `L1` button
  42708. */
  42709. set buttonL1(value: number);
  42710. /**
  42711. * Gets the value of the `R1` button
  42712. */
  42713. get buttonR1(): number;
  42714. /**
  42715. * Sets the value of the `R1` button
  42716. */
  42717. set buttonR1(value: number);
  42718. /**
  42719. * Gets the value of the Left joystick
  42720. */
  42721. get buttonLeftStick(): number;
  42722. /**
  42723. * Sets the value of the Left joystick
  42724. */
  42725. set buttonLeftStick(value: number);
  42726. /**
  42727. * Gets the value of the Right joystick
  42728. */
  42729. get buttonRightStick(): number;
  42730. /**
  42731. * Sets the value of the Right joystick
  42732. */
  42733. set buttonRightStick(value: number);
  42734. /**
  42735. * Gets the value of D-pad up
  42736. */
  42737. get dPadUp(): number;
  42738. /**
  42739. * Sets the value of D-pad up
  42740. */
  42741. set dPadUp(value: number);
  42742. /**
  42743. * Gets the value of D-pad down
  42744. */
  42745. get dPadDown(): number;
  42746. /**
  42747. * Sets the value of D-pad down
  42748. */
  42749. set dPadDown(value: number);
  42750. /**
  42751. * Gets the value of D-pad left
  42752. */
  42753. get dPadLeft(): number;
  42754. /**
  42755. * Sets the value of D-pad left
  42756. */
  42757. set dPadLeft(value: number);
  42758. /**
  42759. * Gets the value of D-pad right
  42760. */
  42761. get dPadRight(): number;
  42762. /**
  42763. * Sets the value of D-pad right
  42764. */
  42765. set dPadRight(value: number);
  42766. /**
  42767. * Force the gamepad to synchronize with device values
  42768. */
  42769. update(): void;
  42770. /**
  42771. * Disposes the gamepad
  42772. */
  42773. dispose(): void;
  42774. }
  42775. }
  42776. declare module "babylonjs/Gamepads/gamepadManager" {
  42777. import { Observable } from "babylonjs/Misc/observable";
  42778. import { Nullable } from "babylonjs/types";
  42779. import { Scene } from "babylonjs/scene";
  42780. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42781. /**
  42782. * Manager for handling gamepads
  42783. */
  42784. export class GamepadManager {
  42785. private _scene?;
  42786. private _babylonGamepads;
  42787. private _oneGamepadConnected;
  42788. /** @hidden */
  42789. _isMonitoring: boolean;
  42790. private _gamepadEventSupported;
  42791. private _gamepadSupport?;
  42792. /**
  42793. * observable to be triggered when the gamepad controller has been connected
  42794. */
  42795. onGamepadConnectedObservable: Observable<Gamepad>;
  42796. /**
  42797. * observable to be triggered when the gamepad controller has been disconnected
  42798. */
  42799. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42800. private _onGamepadConnectedEvent;
  42801. private _onGamepadDisconnectedEvent;
  42802. /**
  42803. * Initializes the gamepad manager
  42804. * @param _scene BabylonJS scene
  42805. */
  42806. constructor(_scene?: Scene | undefined);
  42807. /**
  42808. * The gamepads in the game pad manager
  42809. */
  42810. get gamepads(): Gamepad[];
  42811. /**
  42812. * Get the gamepad controllers based on type
  42813. * @param type The type of gamepad controller
  42814. * @returns Nullable gamepad
  42815. */
  42816. getGamepadByType(type?: number): Nullable<Gamepad>;
  42817. /**
  42818. * Disposes the gamepad manager
  42819. */
  42820. dispose(): void;
  42821. private _addNewGamepad;
  42822. private _startMonitoringGamepads;
  42823. private _stopMonitoringGamepads;
  42824. /** @hidden */
  42825. _checkGamepadsStatus(): void;
  42826. private _updateGamepadObjects;
  42827. }
  42828. }
  42829. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42830. import { Nullable } from "babylonjs/types";
  42831. import { Scene } from "babylonjs/scene";
  42832. import { ISceneComponent } from "babylonjs/sceneComponent";
  42833. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42834. module "babylonjs/scene" {
  42835. interface Scene {
  42836. /** @hidden */
  42837. _gamepadManager: Nullable<GamepadManager>;
  42838. /**
  42839. * Gets the gamepad manager associated with the scene
  42840. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42841. */
  42842. gamepadManager: GamepadManager;
  42843. }
  42844. }
  42845. module "babylonjs/Cameras/freeCameraInputsManager" {
  42846. /**
  42847. * Interface representing a free camera inputs manager
  42848. */
  42849. interface FreeCameraInputsManager {
  42850. /**
  42851. * Adds gamepad input support to the FreeCameraInputsManager.
  42852. * @returns the FreeCameraInputsManager
  42853. */
  42854. addGamepad(): FreeCameraInputsManager;
  42855. }
  42856. }
  42857. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42858. /**
  42859. * Interface representing an arc rotate camera inputs manager
  42860. */
  42861. interface ArcRotateCameraInputsManager {
  42862. /**
  42863. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42864. * @returns the camera inputs manager
  42865. */
  42866. addGamepad(): ArcRotateCameraInputsManager;
  42867. }
  42868. }
  42869. /**
  42870. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42871. */
  42872. export class GamepadSystemSceneComponent implements ISceneComponent {
  42873. /**
  42874. * The component name helpfull to identify the component in the list of scene components.
  42875. */
  42876. readonly name: string;
  42877. /**
  42878. * The scene the component belongs to.
  42879. */
  42880. scene: Scene;
  42881. /**
  42882. * Creates a new instance of the component for the given scene
  42883. * @param scene Defines the scene to register the component in
  42884. */
  42885. constructor(scene: Scene);
  42886. /**
  42887. * Registers the component in a given scene
  42888. */
  42889. register(): void;
  42890. /**
  42891. * Rebuilds the elements related to this component in case of
  42892. * context lost for instance.
  42893. */
  42894. rebuild(): void;
  42895. /**
  42896. * Disposes the component and the associated ressources
  42897. */
  42898. dispose(): void;
  42899. private _beforeCameraUpdate;
  42900. }
  42901. }
  42902. declare module "babylonjs/Cameras/universalCamera" {
  42903. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42904. import { Scene } from "babylonjs/scene";
  42905. import { Vector3 } from "babylonjs/Maths/math.vector";
  42906. import "babylonjs/Gamepads/gamepadSceneComponent";
  42907. /**
  42908. * 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,
  42909. * which still works and will still be found in many Playgrounds.
  42910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42911. */
  42912. export class UniversalCamera extends TouchCamera {
  42913. /**
  42914. * Defines the gamepad rotation sensiblity.
  42915. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42916. */
  42917. get gamepadAngularSensibility(): number;
  42918. set gamepadAngularSensibility(value: number);
  42919. /**
  42920. * Defines the gamepad move sensiblity.
  42921. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42922. */
  42923. get gamepadMoveSensibility(): number;
  42924. set gamepadMoveSensibility(value: number);
  42925. /**
  42926. * 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,
  42927. * which still works and will still be found in many Playgrounds.
  42928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42929. * @param name Define the name of the camera in the scene
  42930. * @param position Define the start position of the camera in the scene
  42931. * @param scene Define the scene the camera belongs to
  42932. */
  42933. constructor(name: string, position: Vector3, scene: Scene);
  42934. /**
  42935. * Gets the current object class name.
  42936. * @return the class name
  42937. */
  42938. getClassName(): string;
  42939. }
  42940. }
  42941. declare module "babylonjs/Cameras/gamepadCamera" {
  42942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42943. import { Scene } from "babylonjs/scene";
  42944. import { Vector3 } from "babylonjs/Maths/math.vector";
  42945. /**
  42946. * This represents a FPS type of camera. This is only here for back compat purpose.
  42947. * Please use the UniversalCamera instead as both are identical.
  42948. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42949. */
  42950. export class GamepadCamera extends UniversalCamera {
  42951. /**
  42952. * Instantiates a new Gamepad Camera
  42953. * This represents a FPS type of camera. This is only here for back compat purpose.
  42954. * Please use the UniversalCamera instead as both are identical.
  42955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42956. * @param name Define the name of the camera in the scene
  42957. * @param position Define the start position of the camera in the scene
  42958. * @param scene Define the scene the camera belongs to
  42959. */
  42960. constructor(name: string, position: Vector3, scene: Scene);
  42961. /**
  42962. * Gets the current object class name.
  42963. * @return the class name
  42964. */
  42965. getClassName(): string;
  42966. }
  42967. }
  42968. declare module "babylonjs/Shaders/pass.fragment" {
  42969. /** @hidden */
  42970. export var passPixelShader: {
  42971. name: string;
  42972. shader: string;
  42973. };
  42974. }
  42975. declare module "babylonjs/Shaders/passCube.fragment" {
  42976. /** @hidden */
  42977. export var passCubePixelShader: {
  42978. name: string;
  42979. shader: string;
  42980. };
  42981. }
  42982. declare module "babylonjs/PostProcesses/passPostProcess" {
  42983. import { Nullable } from "babylonjs/types";
  42984. import { Camera } from "babylonjs/Cameras/camera";
  42985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42986. import { Engine } from "babylonjs/Engines/engine";
  42987. import "babylonjs/Shaders/pass.fragment";
  42988. import "babylonjs/Shaders/passCube.fragment";
  42989. /**
  42990. * PassPostProcess which produces an output the same as it's input
  42991. */
  42992. export class PassPostProcess extends PostProcess {
  42993. /**
  42994. * Creates the PassPostProcess
  42995. * @param name The name of the effect.
  42996. * @param options The required width/height ratio to downsize to before computing the render pass.
  42997. * @param camera The camera to apply the render pass to.
  42998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42999. * @param engine The engine which the post process will be applied. (default: current engine)
  43000. * @param reusable If the post process can be reused on the same frame. (default: false)
  43001. * @param textureType The type of texture to be used when performing the post processing.
  43002. * @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)
  43003. */
  43004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43005. }
  43006. /**
  43007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43008. */
  43009. export class PassCubePostProcess extends PostProcess {
  43010. private _face;
  43011. /**
  43012. * Gets or sets the cube face to display.
  43013. * * 0 is +X
  43014. * * 1 is -X
  43015. * * 2 is +Y
  43016. * * 3 is -Y
  43017. * * 4 is +Z
  43018. * * 5 is -Z
  43019. */
  43020. get face(): number;
  43021. set face(value: number);
  43022. /**
  43023. * Creates the PassCubePostProcess
  43024. * @param name The name of the effect.
  43025. * @param options The required width/height ratio to downsize to before computing the render pass.
  43026. * @param camera The camera to apply the render pass to.
  43027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43028. * @param engine The engine which the post process will be applied. (default: current engine)
  43029. * @param reusable If the post process can be reused on the same frame. (default: false)
  43030. * @param textureType The type of texture to be used when performing the post processing.
  43031. * @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)
  43032. */
  43033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43034. }
  43035. }
  43036. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43037. /** @hidden */
  43038. export var anaglyphPixelShader: {
  43039. name: string;
  43040. shader: string;
  43041. };
  43042. }
  43043. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43044. import { Engine } from "babylonjs/Engines/engine";
  43045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43046. import { Camera } from "babylonjs/Cameras/camera";
  43047. import "babylonjs/Shaders/anaglyph.fragment";
  43048. /**
  43049. * Postprocess used to generate anaglyphic rendering
  43050. */
  43051. export class AnaglyphPostProcess extends PostProcess {
  43052. private _passedProcess;
  43053. /**
  43054. * Creates a new AnaglyphPostProcess
  43055. * @param name defines postprocess name
  43056. * @param options defines creation options or target ratio scale
  43057. * @param rigCameras defines cameras using this postprocess
  43058. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43059. * @param engine defines hosting engine
  43060. * @param reusable defines if the postprocess will be reused multiple times per frame
  43061. */
  43062. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43063. }
  43064. }
  43065. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43066. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43067. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43068. import { Scene } from "babylonjs/scene";
  43069. import { Vector3 } from "babylonjs/Maths/math.vector";
  43070. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43071. /**
  43072. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43074. */
  43075. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43076. /**
  43077. * Creates a new AnaglyphArcRotateCamera
  43078. * @param name defines camera name
  43079. * @param alpha defines alpha angle (in radians)
  43080. * @param beta defines beta angle (in radians)
  43081. * @param radius defines radius
  43082. * @param target defines camera target
  43083. * @param interaxialDistance defines distance between each color axis
  43084. * @param scene defines the hosting scene
  43085. */
  43086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43087. /**
  43088. * Gets camera class name
  43089. * @returns AnaglyphArcRotateCamera
  43090. */
  43091. getClassName(): string;
  43092. }
  43093. }
  43094. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43096. import { Scene } from "babylonjs/scene";
  43097. import { Vector3 } from "babylonjs/Maths/math.vector";
  43098. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43099. /**
  43100. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43101. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43102. */
  43103. export class AnaglyphFreeCamera extends FreeCamera {
  43104. /**
  43105. * Creates a new AnaglyphFreeCamera
  43106. * @param name defines camera name
  43107. * @param position defines initial position
  43108. * @param interaxialDistance defines distance between each color axis
  43109. * @param scene defines the hosting scene
  43110. */
  43111. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43112. /**
  43113. * Gets camera class name
  43114. * @returns AnaglyphFreeCamera
  43115. */
  43116. getClassName(): string;
  43117. }
  43118. }
  43119. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43120. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43121. import { Scene } from "babylonjs/scene";
  43122. import { Vector3 } from "babylonjs/Maths/math.vector";
  43123. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43124. /**
  43125. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43126. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43127. */
  43128. export class AnaglyphGamepadCamera extends GamepadCamera {
  43129. /**
  43130. * Creates a new AnaglyphGamepadCamera
  43131. * @param name defines camera name
  43132. * @param position defines initial position
  43133. * @param interaxialDistance defines distance between each color axis
  43134. * @param scene defines the hosting scene
  43135. */
  43136. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43137. /**
  43138. * Gets camera class name
  43139. * @returns AnaglyphGamepadCamera
  43140. */
  43141. getClassName(): string;
  43142. }
  43143. }
  43144. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43145. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43146. import { Scene } from "babylonjs/scene";
  43147. import { Vector3 } from "babylonjs/Maths/math.vector";
  43148. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43149. /**
  43150. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43151. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43152. */
  43153. export class AnaglyphUniversalCamera extends UniversalCamera {
  43154. /**
  43155. * Creates a new AnaglyphUniversalCamera
  43156. * @param name defines camera name
  43157. * @param position defines initial position
  43158. * @param interaxialDistance defines distance between each color axis
  43159. * @param scene defines the hosting scene
  43160. */
  43161. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43162. /**
  43163. * Gets camera class name
  43164. * @returns AnaglyphUniversalCamera
  43165. */
  43166. getClassName(): string;
  43167. }
  43168. }
  43169. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43170. /** @hidden */
  43171. export var stereoscopicInterlacePixelShader: {
  43172. name: string;
  43173. shader: string;
  43174. };
  43175. }
  43176. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43177. import { Camera } from "babylonjs/Cameras/camera";
  43178. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43179. import { Engine } from "babylonjs/Engines/engine";
  43180. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43181. /**
  43182. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43183. */
  43184. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43185. private _stepSize;
  43186. private _passedProcess;
  43187. /**
  43188. * Initializes a StereoscopicInterlacePostProcessI
  43189. * @param name The name of the effect.
  43190. * @param rigCameras The rig cameras to be appled to the post process
  43191. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43192. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43194. * @param engine The engine which the post process will be applied. (default: current engine)
  43195. * @param reusable If the post process can be reused on the same frame. (default: false)
  43196. */
  43197. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43198. }
  43199. /**
  43200. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43201. */
  43202. export class StereoscopicInterlacePostProcess extends PostProcess {
  43203. private _stepSize;
  43204. private _passedProcess;
  43205. /**
  43206. * Initializes a StereoscopicInterlacePostProcess
  43207. * @param name The name of the effect.
  43208. * @param rigCameras The rig cameras to be appled to the post process
  43209. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43211. * @param engine The engine which the post process will be applied. (default: current engine)
  43212. * @param reusable If the post process can be reused on the same frame. (default: false)
  43213. */
  43214. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43215. }
  43216. }
  43217. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43218. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43219. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43220. import { Scene } from "babylonjs/scene";
  43221. import { Vector3 } from "babylonjs/Maths/math.vector";
  43222. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43223. /**
  43224. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43225. * @see http://doc.babylonjs.com/features/cameras
  43226. */
  43227. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43228. /**
  43229. * Creates a new StereoscopicArcRotateCamera
  43230. * @param name defines camera name
  43231. * @param alpha defines alpha angle (in radians)
  43232. * @param beta defines beta angle (in radians)
  43233. * @param radius defines radius
  43234. * @param target defines camera target
  43235. * @param interaxialDistance defines distance between each color axis
  43236. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43237. * @param scene defines the hosting scene
  43238. */
  43239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43240. /**
  43241. * Gets camera class name
  43242. * @returns StereoscopicArcRotateCamera
  43243. */
  43244. getClassName(): string;
  43245. }
  43246. }
  43247. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43249. import { Scene } from "babylonjs/scene";
  43250. import { Vector3 } from "babylonjs/Maths/math.vector";
  43251. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43252. /**
  43253. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43254. * @see http://doc.babylonjs.com/features/cameras
  43255. */
  43256. export class StereoscopicFreeCamera extends FreeCamera {
  43257. /**
  43258. * Creates a new StereoscopicFreeCamera
  43259. * @param name defines camera name
  43260. * @param position defines initial position
  43261. * @param interaxialDistance defines distance between each color axis
  43262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43263. * @param scene defines the hosting scene
  43264. */
  43265. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43266. /**
  43267. * Gets camera class name
  43268. * @returns StereoscopicFreeCamera
  43269. */
  43270. getClassName(): string;
  43271. }
  43272. }
  43273. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43274. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43275. import { Scene } from "babylonjs/scene";
  43276. import { Vector3 } from "babylonjs/Maths/math.vector";
  43277. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43278. /**
  43279. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43280. * @see http://doc.babylonjs.com/features/cameras
  43281. */
  43282. export class StereoscopicGamepadCamera extends GamepadCamera {
  43283. /**
  43284. * Creates a new StereoscopicGamepadCamera
  43285. * @param name defines camera name
  43286. * @param position defines initial position
  43287. * @param interaxialDistance defines distance between each color axis
  43288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43289. * @param scene defines the hosting scene
  43290. */
  43291. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43292. /**
  43293. * Gets camera class name
  43294. * @returns StereoscopicGamepadCamera
  43295. */
  43296. getClassName(): string;
  43297. }
  43298. }
  43299. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43300. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43301. import { Scene } from "babylonjs/scene";
  43302. import { Vector3 } from "babylonjs/Maths/math.vector";
  43303. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43304. /**
  43305. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43306. * @see http://doc.babylonjs.com/features/cameras
  43307. */
  43308. export class StereoscopicUniversalCamera extends UniversalCamera {
  43309. /**
  43310. * Creates a new StereoscopicUniversalCamera
  43311. * @param name defines camera name
  43312. * @param position defines initial position
  43313. * @param interaxialDistance defines distance between each color axis
  43314. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43315. * @param scene defines the hosting scene
  43316. */
  43317. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43318. /**
  43319. * Gets camera class name
  43320. * @returns StereoscopicUniversalCamera
  43321. */
  43322. getClassName(): string;
  43323. }
  43324. }
  43325. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43326. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43327. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43328. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43329. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43330. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43331. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43332. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43333. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43334. }
  43335. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43336. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43337. import { Scene } from "babylonjs/scene";
  43338. import { Vector3 } from "babylonjs/Maths/math.vector";
  43339. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43340. /**
  43341. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43342. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43343. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43344. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43345. */
  43346. export class VirtualJoysticksCamera extends FreeCamera {
  43347. /**
  43348. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43349. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43350. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43351. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43352. * @param name Define the name of the camera in the scene
  43353. * @param position Define the start position of the camera in the scene
  43354. * @param scene Define the scene the camera belongs to
  43355. */
  43356. constructor(name: string, position: Vector3, scene: Scene);
  43357. /**
  43358. * Gets the current object class name.
  43359. * @return the class name
  43360. */
  43361. getClassName(): string;
  43362. }
  43363. }
  43364. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43365. import { Matrix } from "babylonjs/Maths/math.vector";
  43366. /**
  43367. * This represents all the required metrics to create a VR camera.
  43368. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43369. */
  43370. export class VRCameraMetrics {
  43371. /**
  43372. * Define the horizontal resolution off the screen.
  43373. */
  43374. hResolution: number;
  43375. /**
  43376. * Define the vertical resolution off the screen.
  43377. */
  43378. vResolution: number;
  43379. /**
  43380. * Define the horizontal screen size.
  43381. */
  43382. hScreenSize: number;
  43383. /**
  43384. * Define the vertical screen size.
  43385. */
  43386. vScreenSize: number;
  43387. /**
  43388. * Define the vertical screen center position.
  43389. */
  43390. vScreenCenter: number;
  43391. /**
  43392. * Define the distance of the eyes to the screen.
  43393. */
  43394. eyeToScreenDistance: number;
  43395. /**
  43396. * Define the distance between both lenses
  43397. */
  43398. lensSeparationDistance: number;
  43399. /**
  43400. * Define the distance between both viewer's eyes.
  43401. */
  43402. interpupillaryDistance: number;
  43403. /**
  43404. * Define the distortion factor of the VR postprocess.
  43405. * Please, touch with care.
  43406. */
  43407. distortionK: number[];
  43408. /**
  43409. * Define the chromatic aberration correction factors for the VR post process.
  43410. */
  43411. chromaAbCorrection: number[];
  43412. /**
  43413. * Define the scale factor of the post process.
  43414. * The smaller the better but the slower.
  43415. */
  43416. postProcessScaleFactor: number;
  43417. /**
  43418. * Define an offset for the lens center.
  43419. */
  43420. lensCenterOffset: number;
  43421. /**
  43422. * Define if the current vr camera should compensate the distortion of the lense or not.
  43423. */
  43424. compensateDistortion: boolean;
  43425. /**
  43426. * Defines if multiview should be enabled when rendering (Default: false)
  43427. */
  43428. multiviewEnabled: boolean;
  43429. /**
  43430. * Gets the rendering aspect ratio based on the provided resolutions.
  43431. */
  43432. get aspectRatio(): number;
  43433. /**
  43434. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43435. */
  43436. get aspectRatioFov(): number;
  43437. /**
  43438. * @hidden
  43439. */
  43440. get leftHMatrix(): Matrix;
  43441. /**
  43442. * @hidden
  43443. */
  43444. get rightHMatrix(): Matrix;
  43445. /**
  43446. * @hidden
  43447. */
  43448. get leftPreViewMatrix(): Matrix;
  43449. /**
  43450. * @hidden
  43451. */
  43452. get rightPreViewMatrix(): Matrix;
  43453. /**
  43454. * Get the default VRMetrics based on the most generic setup.
  43455. * @returns the default vr metrics
  43456. */
  43457. static GetDefault(): VRCameraMetrics;
  43458. }
  43459. }
  43460. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43461. /** @hidden */
  43462. export var vrDistortionCorrectionPixelShader: {
  43463. name: string;
  43464. shader: string;
  43465. };
  43466. }
  43467. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43468. import { Camera } from "babylonjs/Cameras/camera";
  43469. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43471. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43472. /**
  43473. * VRDistortionCorrectionPostProcess used for mobile VR
  43474. */
  43475. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43476. private _isRightEye;
  43477. private _distortionFactors;
  43478. private _postProcessScaleFactor;
  43479. private _lensCenterOffset;
  43480. private _scaleIn;
  43481. private _scaleFactor;
  43482. private _lensCenter;
  43483. /**
  43484. * Initializes the VRDistortionCorrectionPostProcess
  43485. * @param name The name of the effect.
  43486. * @param camera The camera to apply the render pass to.
  43487. * @param isRightEye If this is for the right eye distortion
  43488. * @param vrMetrics All the required metrics for the VR camera
  43489. */
  43490. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43491. }
  43492. }
  43493. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43494. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43496. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43497. import { Scene } from "babylonjs/scene";
  43498. import { Vector3 } from "babylonjs/Maths/math.vector";
  43499. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43500. import "babylonjs/Cameras/RigModes/vrRigMode";
  43501. /**
  43502. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43504. */
  43505. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43506. /**
  43507. * Creates a new VRDeviceOrientationArcRotateCamera
  43508. * @param name defines camera name
  43509. * @param alpha defines the camera rotation along the logitudinal axis
  43510. * @param beta defines the camera rotation along the latitudinal axis
  43511. * @param radius defines the camera distance from its target
  43512. * @param target defines the camera target
  43513. * @param scene defines the scene the camera belongs to
  43514. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43515. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43516. */
  43517. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43518. /**
  43519. * Gets camera class name
  43520. * @returns VRDeviceOrientationArcRotateCamera
  43521. */
  43522. getClassName(): string;
  43523. }
  43524. }
  43525. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43526. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43527. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43528. import { Scene } from "babylonjs/scene";
  43529. import { Vector3 } from "babylonjs/Maths/math.vector";
  43530. import "babylonjs/Cameras/RigModes/vrRigMode";
  43531. /**
  43532. * Camera used to simulate VR rendering (based on FreeCamera)
  43533. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43534. */
  43535. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43536. /**
  43537. * Creates a new VRDeviceOrientationFreeCamera
  43538. * @param name defines camera name
  43539. * @param position defines the start position of the camera
  43540. * @param scene defines the scene the camera belongs to
  43541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43543. */
  43544. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43545. /**
  43546. * Gets camera class name
  43547. * @returns VRDeviceOrientationFreeCamera
  43548. */
  43549. getClassName(): string;
  43550. }
  43551. }
  43552. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43553. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43554. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43555. import { Scene } from "babylonjs/scene";
  43556. import { Vector3 } from "babylonjs/Maths/math.vector";
  43557. import "babylonjs/Gamepads/gamepadSceneComponent";
  43558. /**
  43559. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43560. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43561. */
  43562. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43563. /**
  43564. * Creates a new VRDeviceOrientationGamepadCamera
  43565. * @param name defines camera name
  43566. * @param position defines the start position of the camera
  43567. * @param scene defines the scene the camera belongs to
  43568. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43569. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43570. */
  43571. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43572. /**
  43573. * Gets camera class name
  43574. * @returns VRDeviceOrientationGamepadCamera
  43575. */
  43576. getClassName(): string;
  43577. }
  43578. }
  43579. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43580. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43582. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43583. /** @hidden */
  43584. export var imageProcessingPixelShader: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43590. import { Nullable } from "babylonjs/types";
  43591. import { Color4 } from "babylonjs/Maths/math.color";
  43592. import { Camera } from "babylonjs/Cameras/camera";
  43593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43594. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43595. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43597. import { Engine } from "babylonjs/Engines/engine";
  43598. import "babylonjs/Shaders/imageProcessing.fragment";
  43599. import "babylonjs/Shaders/postprocess.vertex";
  43600. /**
  43601. * ImageProcessingPostProcess
  43602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43603. */
  43604. export class ImageProcessingPostProcess extends PostProcess {
  43605. /**
  43606. * Default configuration related to image processing available in the PBR Material.
  43607. */
  43608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43609. /**
  43610. * Gets the image processing configuration used either in this material.
  43611. */
  43612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43613. /**
  43614. * Sets the Default image processing configuration used either in the this material.
  43615. *
  43616. * If sets to null, the scene one is in use.
  43617. */
  43618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43619. /**
  43620. * Keep track of the image processing observer to allow dispose and replace.
  43621. */
  43622. private _imageProcessingObserver;
  43623. /**
  43624. * Attaches a new image processing configuration to the PBR Material.
  43625. * @param configuration
  43626. */
  43627. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43628. /**
  43629. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43630. */
  43631. get colorCurves(): Nullable<ColorCurves>;
  43632. /**
  43633. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43634. */
  43635. set colorCurves(value: Nullable<ColorCurves>);
  43636. /**
  43637. * Gets wether the color curves effect is enabled.
  43638. */
  43639. get colorCurvesEnabled(): boolean;
  43640. /**
  43641. * Sets wether the color curves effect is enabled.
  43642. */
  43643. set colorCurvesEnabled(value: boolean);
  43644. /**
  43645. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43646. */
  43647. get colorGradingTexture(): Nullable<BaseTexture>;
  43648. /**
  43649. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43650. */
  43651. set colorGradingTexture(value: Nullable<BaseTexture>);
  43652. /**
  43653. * Gets wether the color grading effect is enabled.
  43654. */
  43655. get colorGradingEnabled(): boolean;
  43656. /**
  43657. * Gets wether the color grading effect is enabled.
  43658. */
  43659. set colorGradingEnabled(value: boolean);
  43660. /**
  43661. * Gets exposure used in the effect.
  43662. */
  43663. get exposure(): number;
  43664. /**
  43665. * Sets exposure used in the effect.
  43666. */
  43667. set exposure(value: number);
  43668. /**
  43669. * Gets wether tonemapping is enabled or not.
  43670. */
  43671. get toneMappingEnabled(): boolean;
  43672. /**
  43673. * Sets wether tonemapping is enabled or not
  43674. */
  43675. set toneMappingEnabled(value: boolean);
  43676. /**
  43677. * Gets the type of tone mapping effect.
  43678. */
  43679. get toneMappingType(): number;
  43680. /**
  43681. * Sets the type of tone mapping effect.
  43682. */
  43683. set toneMappingType(value: number);
  43684. /**
  43685. * Gets contrast used in the effect.
  43686. */
  43687. get contrast(): number;
  43688. /**
  43689. * Sets contrast used in the effect.
  43690. */
  43691. set contrast(value: number);
  43692. /**
  43693. * Gets Vignette stretch size.
  43694. */
  43695. get vignetteStretch(): number;
  43696. /**
  43697. * Sets Vignette stretch size.
  43698. */
  43699. set vignetteStretch(value: number);
  43700. /**
  43701. * Gets Vignette centre X Offset.
  43702. */
  43703. get vignetteCentreX(): number;
  43704. /**
  43705. * Sets Vignette centre X Offset.
  43706. */
  43707. set vignetteCentreX(value: number);
  43708. /**
  43709. * Gets Vignette centre Y Offset.
  43710. */
  43711. get vignetteCentreY(): number;
  43712. /**
  43713. * Sets Vignette centre Y Offset.
  43714. */
  43715. set vignetteCentreY(value: number);
  43716. /**
  43717. * Gets Vignette weight or intensity of the vignette effect.
  43718. */
  43719. get vignetteWeight(): number;
  43720. /**
  43721. * Sets Vignette weight or intensity of the vignette effect.
  43722. */
  43723. set vignetteWeight(value: number);
  43724. /**
  43725. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43726. * if vignetteEnabled is set to true.
  43727. */
  43728. get vignetteColor(): Color4;
  43729. /**
  43730. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43731. * if vignetteEnabled is set to true.
  43732. */
  43733. set vignetteColor(value: Color4);
  43734. /**
  43735. * Gets Camera field of view used by the Vignette effect.
  43736. */
  43737. get vignetteCameraFov(): number;
  43738. /**
  43739. * Sets Camera field of view used by the Vignette effect.
  43740. */
  43741. set vignetteCameraFov(value: number);
  43742. /**
  43743. * Gets the vignette blend mode allowing different kind of effect.
  43744. */
  43745. get vignetteBlendMode(): number;
  43746. /**
  43747. * Sets the vignette blend mode allowing different kind of effect.
  43748. */
  43749. set vignetteBlendMode(value: number);
  43750. /**
  43751. * Gets wether the vignette effect is enabled.
  43752. */
  43753. get vignetteEnabled(): boolean;
  43754. /**
  43755. * Sets wether the vignette effect is enabled.
  43756. */
  43757. set vignetteEnabled(value: boolean);
  43758. private _fromLinearSpace;
  43759. /**
  43760. * Gets wether the input of the processing is in Gamma or Linear Space.
  43761. */
  43762. get fromLinearSpace(): boolean;
  43763. /**
  43764. * Sets wether the input of the processing is in Gamma or Linear Space.
  43765. */
  43766. set fromLinearSpace(value: boolean);
  43767. /**
  43768. * Defines cache preventing GC.
  43769. */
  43770. private _defines;
  43771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43772. /**
  43773. * "ImageProcessingPostProcess"
  43774. * @returns "ImageProcessingPostProcess"
  43775. */
  43776. getClassName(): string;
  43777. protected _updateParameters(): void;
  43778. dispose(camera?: Camera): void;
  43779. }
  43780. }
  43781. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43782. import { Scene } from "babylonjs/scene";
  43783. import { Color3 } from "babylonjs/Maths/math.color";
  43784. import { Mesh } from "babylonjs/Meshes/mesh";
  43785. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43786. import { Nullable } from "babylonjs/types";
  43787. /**
  43788. * Class containing static functions to help procedurally build meshes
  43789. */
  43790. export class GroundBuilder {
  43791. /**
  43792. * Creates a ground mesh
  43793. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43794. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43796. * @param name defines the name of the mesh
  43797. * @param options defines the options used to create the mesh
  43798. * @param scene defines the hosting scene
  43799. * @returns the ground mesh
  43800. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43801. */
  43802. static CreateGround(name: string, options: {
  43803. width?: number;
  43804. height?: number;
  43805. subdivisions?: number;
  43806. subdivisionsX?: number;
  43807. subdivisionsY?: number;
  43808. updatable?: boolean;
  43809. }, scene: any): Mesh;
  43810. /**
  43811. * Creates a tiled ground mesh
  43812. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43813. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43814. * * 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
  43815. * * 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
  43816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43817. * @param name defines the name of the mesh
  43818. * @param options defines the options used to create the mesh
  43819. * @param scene defines the hosting scene
  43820. * @returns the tiled ground mesh
  43821. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43822. */
  43823. static CreateTiledGround(name: string, options: {
  43824. xmin: number;
  43825. zmin: number;
  43826. xmax: number;
  43827. zmax: number;
  43828. subdivisions?: {
  43829. w: number;
  43830. h: number;
  43831. };
  43832. precision?: {
  43833. w: number;
  43834. h: number;
  43835. };
  43836. updatable?: boolean;
  43837. }, scene?: Nullable<Scene>): Mesh;
  43838. /**
  43839. * Creates a ground mesh from a height map
  43840. * * The parameter `url` sets the URL of the height map image resource.
  43841. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43842. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43843. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43844. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43845. * * 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.
  43846. * * 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).
  43847. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43849. * @param name defines the name of the mesh
  43850. * @param url defines the url to the height map
  43851. * @param options defines the options used to create the mesh
  43852. * @param scene defines the hosting scene
  43853. * @returns the ground mesh
  43854. * @see https://doc.babylonjs.com/babylon101/height_map
  43855. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43856. */
  43857. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43858. width?: number;
  43859. height?: number;
  43860. subdivisions?: number;
  43861. minHeight?: number;
  43862. maxHeight?: number;
  43863. colorFilter?: Color3;
  43864. alphaFilter?: number;
  43865. updatable?: boolean;
  43866. onReady?: (mesh: GroundMesh) => void;
  43867. }, scene?: Nullable<Scene>): GroundMesh;
  43868. }
  43869. }
  43870. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43871. import { Vector4 } from "babylonjs/Maths/math.vector";
  43872. import { Mesh } from "babylonjs/Meshes/mesh";
  43873. /**
  43874. * Class containing static functions to help procedurally build meshes
  43875. */
  43876. export class TorusBuilder {
  43877. /**
  43878. * Creates a torus mesh
  43879. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43880. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43881. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43885. * @param name defines the name of the mesh
  43886. * @param options defines the options used to create the mesh
  43887. * @param scene defines the hosting scene
  43888. * @returns the torus mesh
  43889. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43890. */
  43891. static CreateTorus(name: string, options: {
  43892. diameter?: number;
  43893. thickness?: number;
  43894. tessellation?: number;
  43895. updatable?: boolean;
  43896. sideOrientation?: number;
  43897. frontUVs?: Vector4;
  43898. backUVs?: Vector4;
  43899. }, scene: any): Mesh;
  43900. }
  43901. }
  43902. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43903. import { Vector4 } from "babylonjs/Maths/math.vector";
  43904. import { Color4 } from "babylonjs/Maths/math.color";
  43905. import { Mesh } from "babylonjs/Meshes/mesh";
  43906. /**
  43907. * Class containing static functions to help procedurally build meshes
  43908. */
  43909. export class CylinderBuilder {
  43910. /**
  43911. * Creates a cylinder or a cone mesh
  43912. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43913. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43914. * * 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.
  43915. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43916. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43917. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43918. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43919. * * 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).
  43920. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43921. * * 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).
  43922. * * 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
  43923. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43924. * * 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
  43925. * * 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.
  43926. * * If `enclose` is false, a ring surface is one element.
  43927. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43928. * * 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
  43929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43932. * @param name defines the name of the mesh
  43933. * @param options defines the options used to create the mesh
  43934. * @param scene defines the hosting scene
  43935. * @returns the cylinder mesh
  43936. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43937. */
  43938. static CreateCylinder(name: string, options: {
  43939. height?: number;
  43940. diameterTop?: number;
  43941. diameterBottom?: number;
  43942. diameter?: number;
  43943. tessellation?: number;
  43944. subdivisions?: number;
  43945. arc?: number;
  43946. faceColors?: Color4[];
  43947. faceUV?: Vector4[];
  43948. updatable?: boolean;
  43949. hasRings?: boolean;
  43950. enclose?: boolean;
  43951. cap?: number;
  43952. sideOrientation?: number;
  43953. frontUVs?: Vector4;
  43954. backUVs?: Vector4;
  43955. }, scene: any): Mesh;
  43956. }
  43957. }
  43958. declare module "babylonjs/XR/webXRTypes" {
  43959. import { Nullable } from "babylonjs/types";
  43960. import { IDisposable } from "babylonjs/scene";
  43961. /**
  43962. * States of the webXR experience
  43963. */
  43964. export enum WebXRState {
  43965. /**
  43966. * Transitioning to being in XR mode
  43967. */
  43968. ENTERING_XR = 0,
  43969. /**
  43970. * Transitioning to non XR mode
  43971. */
  43972. EXITING_XR = 1,
  43973. /**
  43974. * In XR mode and presenting
  43975. */
  43976. IN_XR = 2,
  43977. /**
  43978. * Not entered XR mode
  43979. */
  43980. NOT_IN_XR = 3
  43981. }
  43982. /**
  43983. * Abstraction of the XR render target
  43984. */
  43985. export interface WebXRRenderTarget extends IDisposable {
  43986. /**
  43987. * xrpresent context of the canvas which can be used to display/mirror xr content
  43988. */
  43989. canvasContext: WebGLRenderingContext;
  43990. /**
  43991. * xr layer for the canvas
  43992. */
  43993. xrLayer: Nullable<XRWebGLLayer>;
  43994. /**
  43995. * Initializes the xr layer for the session
  43996. * @param xrSession xr session
  43997. * @returns a promise that will resolve once the XR Layer has been created
  43998. */
  43999. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44000. }
  44001. }
  44002. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44003. import { Nullable } from "babylonjs/types";
  44004. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44005. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44006. /**
  44007. * COnfiguration object for WebXR output canvas
  44008. */
  44009. export class WebXRManagedOutputCanvasOptions {
  44010. /**
  44011. * An optional canvas in case you wish to create it yourself and provide it here.
  44012. * If not provided, a new canvas will be created
  44013. */
  44014. canvasElement?: HTMLCanvasElement;
  44015. /**
  44016. * Options for this XR Layer output
  44017. */
  44018. canvasOptions?: XRWebGLLayerOptions;
  44019. /**
  44020. * CSS styling for a newly created canvas (if not provided)
  44021. */
  44022. newCanvasCssStyle?: string;
  44023. /**
  44024. * Get the default values of the configuration object
  44025. * @returns default values of this configuration object
  44026. */
  44027. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44028. }
  44029. /**
  44030. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44031. */
  44032. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44033. private _options;
  44034. private _canvas;
  44035. private _engine;
  44036. /**
  44037. * Rendering context of the canvas which can be used to display/mirror xr content
  44038. */
  44039. canvasContext: WebGLRenderingContext;
  44040. /**
  44041. * xr layer for the canvas
  44042. */
  44043. xrLayer: Nullable<XRWebGLLayer>;
  44044. /**
  44045. * Initializes the canvas to be added/removed upon entering/exiting xr
  44046. * @param _xrSessionManager The XR Session manager
  44047. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44048. */
  44049. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44050. /**
  44051. * Disposes of the object
  44052. */
  44053. dispose(): void;
  44054. /**
  44055. * Initializes the xr layer for the session
  44056. * @param xrSession xr session
  44057. * @returns a promise that will resolve once the XR Layer has been created
  44058. */
  44059. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44060. private _addCanvas;
  44061. private _removeCanvas;
  44062. private _setManagedOutputCanvas;
  44063. }
  44064. }
  44065. declare module "babylonjs/XR/webXRSessionManager" {
  44066. import { Observable } from "babylonjs/Misc/observable";
  44067. import { Nullable } from "babylonjs/types";
  44068. import { IDisposable, Scene } from "babylonjs/scene";
  44069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44070. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44071. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44072. /**
  44073. * Manages an XRSession to work with Babylon's engine
  44074. * @see https://doc.babylonjs.com/how_to/webxr
  44075. */
  44076. export class WebXRSessionManager implements IDisposable {
  44077. /** The scene which the session should be created for */
  44078. scene: Scene;
  44079. private _referenceSpace;
  44080. private _rttProvider;
  44081. private _sessionEnded;
  44082. private _xrNavigator;
  44083. private baseLayer;
  44084. /**
  44085. * The base reference space from which the session started. good if you want to reset your
  44086. * reference space
  44087. */
  44088. baseReferenceSpace: XRReferenceSpace;
  44089. /**
  44090. * Current XR frame
  44091. */
  44092. currentFrame: Nullable<XRFrame>;
  44093. /** WebXR timestamp updated every frame */
  44094. currentTimestamp: number;
  44095. /**
  44096. * Used just in case of a failure to initialize an immersive session.
  44097. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44098. */
  44099. defaultHeightCompensation: number;
  44100. /**
  44101. * Fires every time a new xrFrame arrives which can be used to update the camera
  44102. */
  44103. onXRFrameObservable: Observable<XRFrame>;
  44104. /**
  44105. * Fires when the reference space changed
  44106. */
  44107. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44108. /**
  44109. * Fires when the xr session is ended either by the device or manually done
  44110. */
  44111. onXRSessionEnded: Observable<any>;
  44112. /**
  44113. * Fires when the xr session is ended either by the device or manually done
  44114. */
  44115. onXRSessionInit: Observable<XRSession>;
  44116. /**
  44117. * Underlying xr session
  44118. */
  44119. session: XRSession;
  44120. /**
  44121. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44122. * or get the offset the player is currently at.
  44123. */
  44124. viewerReferenceSpace: XRReferenceSpace;
  44125. /**
  44126. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44127. * @param scene The scene which the session should be created for
  44128. */
  44129. constructor(
  44130. /** The scene which the session should be created for */
  44131. scene: Scene);
  44132. /**
  44133. * The current reference space used in this session. This reference space can constantly change!
  44134. * It is mainly used to offset the camera's position.
  44135. */
  44136. get referenceSpace(): XRReferenceSpace;
  44137. /**
  44138. * Set a new reference space and triggers the observable
  44139. */
  44140. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44141. /**
  44142. * Disposes of the session manager
  44143. */
  44144. dispose(): void;
  44145. /**
  44146. * Stops the xrSession and restores the render loop
  44147. * @returns Promise which resolves after it exits XR
  44148. */
  44149. exitXRAsync(): Promise<void>;
  44150. /**
  44151. * Gets the correct render target texture to be rendered this frame for this eye
  44152. * @param eye the eye for which to get the render target
  44153. * @returns the render target for the specified eye
  44154. */
  44155. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44156. /**
  44157. * Creates a WebXRRenderTarget object for the XR session
  44158. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44159. * @param options optional options to provide when creating a new render target
  44160. * @returns a WebXR render target to which the session can render
  44161. */
  44162. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44163. /**
  44164. * Initializes the manager
  44165. * After initialization enterXR can be called to start an XR session
  44166. * @returns Promise which resolves after it is initialized
  44167. */
  44168. initializeAsync(): Promise<void>;
  44169. /**
  44170. * Initializes an xr session
  44171. * @param xrSessionMode mode to initialize
  44172. * @param xrSessionInit defines optional and required values to pass to the session builder
  44173. * @returns a promise which will resolve once the session has been initialized
  44174. */
  44175. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44176. /**
  44177. * Checks if a session would be supported for the creation options specified
  44178. * @param sessionMode session mode to check if supported eg. immersive-vr
  44179. * @returns A Promise that resolves to true if supported and false if not
  44180. */
  44181. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44182. /**
  44183. * Resets the reference space to the one started the session
  44184. */
  44185. resetReferenceSpace(): void;
  44186. /**
  44187. * Starts rendering to the xr layer
  44188. */
  44189. runXRRenderLoop(): void;
  44190. /**
  44191. * Sets the reference space on the xr session
  44192. * @param referenceSpaceType space to set
  44193. * @returns a promise that will resolve once the reference space has been set
  44194. */
  44195. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44196. /**
  44197. * Updates the render state of the session
  44198. * @param state state to set
  44199. * @returns a promise that resolves once the render state has been updated
  44200. */
  44201. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44202. /**
  44203. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44204. * @param sessionMode defines the session to test
  44205. * @returns a promise with boolean as final value
  44206. */
  44207. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44208. private _createRenderTargetTexture;
  44209. }
  44210. }
  44211. declare module "babylonjs/XR/webXRCamera" {
  44212. import { Scene } from "babylonjs/scene";
  44213. import { Camera } from "babylonjs/Cameras/camera";
  44214. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44215. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44216. /**
  44217. * WebXR Camera which holds the views for the xrSession
  44218. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44219. */
  44220. export class WebXRCamera extends FreeCamera {
  44221. private _xrSessionManager;
  44222. private _firstFrame;
  44223. private _referenceQuaternion;
  44224. private _referencedPosition;
  44225. private _xrInvPositionCache;
  44226. private _xrInvQuaternionCache;
  44227. /**
  44228. * Should position compensation execute on first frame.
  44229. * This is used when copying the position from a native (non XR) camera
  44230. */
  44231. compensateOnFirstFrame: boolean;
  44232. /**
  44233. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44234. * @param name the name of the camera
  44235. * @param scene the scene to add the camera to
  44236. * @param _xrSessionManager a constructed xr session manager
  44237. */
  44238. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44239. /**
  44240. * Return the user's height, unrelated to the current ground.
  44241. * This will be the y position of this camera, when ground level is 0.
  44242. */
  44243. get realWorldHeight(): number;
  44244. /** @hidden */
  44245. _updateForDualEyeDebugging(): void;
  44246. /**
  44247. * Sets this camera's transformation based on a non-vr camera
  44248. * @param otherCamera the non-vr camera to copy the transformation from
  44249. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44250. */
  44251. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44252. /**
  44253. * Gets the current instance class name ("WebXRCamera").
  44254. * @returns the class name
  44255. */
  44256. getClassName(): string;
  44257. private _updateFromXRSession;
  44258. private _updateNumberOfRigCameras;
  44259. private _updateReferenceSpace;
  44260. private _updateReferenceSpaceOffset;
  44261. }
  44262. }
  44263. declare module "babylonjs/XR/webXRFeaturesManager" {
  44264. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44265. import { IDisposable } from "babylonjs/scene";
  44266. /**
  44267. * Defining the interface required for a (webxr) feature
  44268. */
  44269. export interface IWebXRFeature extends IDisposable {
  44270. /**
  44271. * Is this feature attached
  44272. */
  44273. attached: boolean;
  44274. /**
  44275. * Should auto-attach be disabled?
  44276. */
  44277. disableAutoAttach: boolean;
  44278. /**
  44279. * Attach the feature to the session
  44280. * Will usually be called by the features manager
  44281. *
  44282. * @param force should attachment be forced (even when already attached)
  44283. * @returns true if successful.
  44284. */
  44285. attach(force?: boolean): boolean;
  44286. /**
  44287. * Detach the feature from the session
  44288. * Will usually be called by the features manager
  44289. *
  44290. * @returns true if successful.
  44291. */
  44292. detach(): boolean;
  44293. }
  44294. /**
  44295. * A list of the currently available features without referencing them
  44296. */
  44297. export class WebXRFeatureName {
  44298. /**
  44299. * The name of the anchor system feature
  44300. */
  44301. static ANCHOR_SYSTEM: string;
  44302. /**
  44303. * The name of the background remover feature
  44304. */
  44305. static BACKGROUND_REMOVER: string;
  44306. /**
  44307. * The name of the hit test feature
  44308. */
  44309. static HIT_TEST: string;
  44310. /**
  44311. * physics impostors for xr controllers feature
  44312. */
  44313. static PHYSICS_CONTROLLERS: string;
  44314. /**
  44315. * The name of the plane detection feature
  44316. */
  44317. static PLANE_DETECTION: string;
  44318. /**
  44319. * The name of the pointer selection feature
  44320. */
  44321. static POINTER_SELECTION: string;
  44322. /**
  44323. * The name of the teleportation feature
  44324. */
  44325. static TELEPORTATION: string;
  44326. }
  44327. /**
  44328. * Defining the constructor of a feature. Used to register the modules.
  44329. */
  44330. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44331. /**
  44332. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44333. * It is mainly used in AR sessions.
  44334. *
  44335. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44336. */
  44337. export class WebXRFeaturesManager implements IDisposable {
  44338. private _xrSessionManager;
  44339. private static readonly _AvailableFeatures;
  44340. private _features;
  44341. /**
  44342. * constructs a new features manages.
  44343. *
  44344. * @param _xrSessionManager an instance of WebXRSessionManager
  44345. */
  44346. constructor(_xrSessionManager: WebXRSessionManager);
  44347. /**
  44348. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44349. * Mainly used internally.
  44350. *
  44351. * @param featureName the name of the feature to register
  44352. * @param constructorFunction the function used to construct the module
  44353. * @param version the (babylon) version of the module
  44354. * @param stable is that a stable version of this module
  44355. */
  44356. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44357. /**
  44358. * Returns a constructor of a specific feature.
  44359. *
  44360. * @param featureName the name of the feature to construct
  44361. * @param version the version of the feature to load
  44362. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44363. * @param options optional options provided to the module.
  44364. * @returns a function that, when called, will return a new instance of this feature
  44365. */
  44366. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44367. /**
  44368. * Can be used to return the list of features currently registered
  44369. *
  44370. * @returns an Array of available features
  44371. */
  44372. static GetAvailableFeatures(): string[];
  44373. /**
  44374. * Gets the versions available for a specific feature
  44375. * @param featureName the name of the feature
  44376. * @returns an array with the available versions
  44377. */
  44378. static GetAvailableVersions(featureName: string): string[];
  44379. /**
  44380. * Return the latest unstable version of this feature
  44381. * @param featureName the name of the feature to search
  44382. * @returns the version number. if not found will return -1
  44383. */
  44384. static GetLatestVersionOfFeature(featureName: string): number;
  44385. /**
  44386. * Return the latest stable version of this feature
  44387. * @param featureName the name of the feature to search
  44388. * @returns the version number. if not found will return -1
  44389. */
  44390. static GetStableVersionOfFeature(featureName: string): number;
  44391. /**
  44392. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44393. * Can be used during a session to start a feature
  44394. * @param featureName the name of feature to attach
  44395. */
  44396. attachFeature(featureName: string): void;
  44397. /**
  44398. * Can be used inside a session or when the session ends to detach a specific feature
  44399. * @param featureName the name of the feature to detach
  44400. */
  44401. detachFeature(featureName: string): void;
  44402. /**
  44403. * Used to disable an already-enabled feature
  44404. * The feature will be disposed and will be recreated once enabled.
  44405. * @param featureName the feature to disable
  44406. * @returns true if disable was successful
  44407. */
  44408. disableFeature(featureName: string | {
  44409. Name: string;
  44410. }): boolean;
  44411. /**
  44412. * dispose this features manager
  44413. */
  44414. dispose(): void;
  44415. /**
  44416. * 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.
  44417. * 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.
  44418. *
  44419. * @param featureName the name of the feature to load or the class of the feature
  44420. * @param version optional version to load. if not provided the latest version will be enabled
  44421. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44422. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44423. * @returns a new constructed feature or throws an error if feature not found.
  44424. */
  44425. enableFeature(featureName: string | {
  44426. Name: string;
  44427. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44428. /**
  44429. * get the implementation of an enabled feature.
  44430. * @param featureName the name of the feature to load
  44431. * @returns the feature class, if found
  44432. */
  44433. getEnabledFeature(featureName: string): IWebXRFeature;
  44434. /**
  44435. * Get the list of enabled features
  44436. * @returns an array of enabled features
  44437. */
  44438. getEnabledFeatures(): string[];
  44439. }
  44440. }
  44441. declare module "babylonjs/XR/webXRExperienceHelper" {
  44442. import { Observable } from "babylonjs/Misc/observable";
  44443. import { IDisposable, Scene } from "babylonjs/scene";
  44444. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44445. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44446. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44447. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44448. /**
  44449. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44450. * @see https://doc.babylonjs.com/how_to/webxr
  44451. */
  44452. export class WebXRExperienceHelper implements IDisposable {
  44453. private scene;
  44454. private _nonVRCamera;
  44455. private _originalSceneAutoClear;
  44456. private _supported;
  44457. /**
  44458. * Camera used to render xr content
  44459. */
  44460. camera: WebXRCamera;
  44461. /** A features manager for this xr session */
  44462. featuresManager: WebXRFeaturesManager;
  44463. /**
  44464. * Observers registered here will be triggered after the camera's initial transformation is set
  44465. * This can be used to set a different ground level or an extra rotation.
  44466. *
  44467. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44468. * to the position set after this observable is done executing.
  44469. */
  44470. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44471. /**
  44472. * Fires when the state of the experience helper has changed
  44473. */
  44474. onStateChangedObservable: Observable<WebXRState>;
  44475. /** Session manager used to keep track of xr session */
  44476. sessionManager: WebXRSessionManager;
  44477. /**
  44478. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44479. */
  44480. state: WebXRState;
  44481. /**
  44482. * Creates a WebXRExperienceHelper
  44483. * @param scene The scene the helper should be created in
  44484. */
  44485. private constructor();
  44486. /**
  44487. * Creates the experience helper
  44488. * @param scene the scene to attach the experience helper to
  44489. * @returns a promise for the experience helper
  44490. */
  44491. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44492. /**
  44493. * Disposes of the experience helper
  44494. */
  44495. dispose(): void;
  44496. /**
  44497. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44498. * @param sessionMode options for the XR session
  44499. * @param referenceSpaceType frame of reference of the XR session
  44500. * @param renderTarget the output canvas that will be used to enter XR mode
  44501. * @returns promise that resolves after xr mode has entered
  44502. */
  44503. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44504. /**
  44505. * Exits XR mode and returns the scene to its original state
  44506. * @returns promise that resolves after xr mode has exited
  44507. */
  44508. exitXRAsync(): Promise<void>;
  44509. private _nonXRToXRCamera;
  44510. private _setState;
  44511. }
  44512. }
  44513. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44514. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44515. import { Observable } from "babylonjs/Misc/observable";
  44516. import { IDisposable } from "babylonjs/scene";
  44517. /**
  44518. * X-Y values for axes in WebXR
  44519. */
  44520. export interface IWebXRMotionControllerAxesValue {
  44521. /**
  44522. * The value of the x axis
  44523. */
  44524. x: number;
  44525. /**
  44526. * The value of the y-axis
  44527. */
  44528. y: number;
  44529. }
  44530. /**
  44531. * changed / previous values for the values of this component
  44532. */
  44533. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44534. /**
  44535. * current (this frame) value
  44536. */
  44537. current: T;
  44538. /**
  44539. * previous (last change) value
  44540. */
  44541. previous: T;
  44542. }
  44543. /**
  44544. * Represents changes in the component between current frame and last values recorded
  44545. */
  44546. export interface IWebXRMotionControllerComponentChanges {
  44547. /**
  44548. * will be populated with previous and current values if axes changed
  44549. */
  44550. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44551. /**
  44552. * will be populated with previous and current values if pressed changed
  44553. */
  44554. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44555. /**
  44556. * will be populated with previous and current values if touched changed
  44557. */
  44558. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44559. /**
  44560. * will be populated with previous and current values if value changed
  44561. */
  44562. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44563. }
  44564. /**
  44565. * This class represents a single component (for example button or thumbstick) of a motion controller
  44566. */
  44567. export class WebXRControllerComponent implements IDisposable {
  44568. /**
  44569. * the id of this component
  44570. */
  44571. id: string;
  44572. /**
  44573. * the type of the component
  44574. */
  44575. type: MotionControllerComponentType;
  44576. private _buttonIndex;
  44577. private _axesIndices;
  44578. private _axes;
  44579. private _changes;
  44580. private _currentValue;
  44581. private _hasChanges;
  44582. private _pressed;
  44583. private _touched;
  44584. /**
  44585. * button component type
  44586. */
  44587. static BUTTON_TYPE: MotionControllerComponentType;
  44588. /**
  44589. * squeeze component type
  44590. */
  44591. static SQUEEZE_TYPE: MotionControllerComponentType;
  44592. /**
  44593. * Thumbstick component type
  44594. */
  44595. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44596. /**
  44597. * Touchpad component type
  44598. */
  44599. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44600. /**
  44601. * trigger component type
  44602. */
  44603. static TRIGGER_TYPE: MotionControllerComponentType;
  44604. /**
  44605. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44606. * the axes data changes
  44607. */
  44608. onAxisValueChangedObservable: Observable<{
  44609. x: number;
  44610. y: number;
  44611. }>;
  44612. /**
  44613. * Observers registered here will be triggered when the state of a button changes
  44614. * State change is either pressed / touched / value
  44615. */
  44616. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44617. /**
  44618. * Creates a new component for a motion controller.
  44619. * It is created by the motion controller itself
  44620. *
  44621. * @param id the id of this component
  44622. * @param type the type of the component
  44623. * @param _buttonIndex index in the buttons array of the gamepad
  44624. * @param _axesIndices indices of the values in the axes array of the gamepad
  44625. */
  44626. constructor(
  44627. /**
  44628. * the id of this component
  44629. */
  44630. id: string,
  44631. /**
  44632. * the type of the component
  44633. */
  44634. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44635. /**
  44636. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44637. */
  44638. get axes(): IWebXRMotionControllerAxesValue;
  44639. /**
  44640. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44641. */
  44642. get changes(): IWebXRMotionControllerComponentChanges;
  44643. /**
  44644. * Return whether or not the component changed the last frame
  44645. */
  44646. get hasChanges(): boolean;
  44647. /**
  44648. * is the button currently pressed
  44649. */
  44650. get pressed(): boolean;
  44651. /**
  44652. * is the button currently touched
  44653. */
  44654. get touched(): boolean;
  44655. /**
  44656. * Get the current value of this component
  44657. */
  44658. get value(): number;
  44659. /**
  44660. * Dispose this component
  44661. */
  44662. dispose(): void;
  44663. /**
  44664. * Are there axes correlating to this component
  44665. * @return true is axes data is available
  44666. */
  44667. isAxes(): boolean;
  44668. /**
  44669. * Is this component a button (hence - pressable)
  44670. * @returns true if can be pressed
  44671. */
  44672. isButton(): boolean;
  44673. /**
  44674. * update this component using the gamepad object it is in. Called on every frame
  44675. * @param nativeController the native gamepad controller object
  44676. */
  44677. update(nativeController: IMinimalMotionControllerObject): void;
  44678. }
  44679. }
  44680. declare module "babylonjs/Loading/sceneLoader" {
  44681. import { Observable } from "babylonjs/Misc/observable";
  44682. import { Nullable } from "babylonjs/types";
  44683. import { Scene } from "babylonjs/scene";
  44684. import { Engine } from "babylonjs/Engines/engine";
  44685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44686. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44687. import { AssetContainer } from "babylonjs/assetContainer";
  44688. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44689. import { Skeleton } from "babylonjs/Bones/skeleton";
  44690. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44691. import { WebRequest } from "babylonjs/Misc/webRequest";
  44692. /**
  44693. * Class used to represent data loading progression
  44694. */
  44695. export class SceneLoaderProgressEvent {
  44696. /** defines if data length to load can be evaluated */
  44697. readonly lengthComputable: boolean;
  44698. /** defines the loaded data length */
  44699. readonly loaded: number;
  44700. /** defines the data length to load */
  44701. readonly total: number;
  44702. /**
  44703. * Create a new progress event
  44704. * @param lengthComputable defines if data length to load can be evaluated
  44705. * @param loaded defines the loaded data length
  44706. * @param total defines the data length to load
  44707. */
  44708. constructor(
  44709. /** defines if data length to load can be evaluated */
  44710. lengthComputable: boolean,
  44711. /** defines the loaded data length */
  44712. loaded: number,
  44713. /** defines the data length to load */
  44714. total: number);
  44715. /**
  44716. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44717. * @param event defines the source event
  44718. * @returns a new SceneLoaderProgressEvent
  44719. */
  44720. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44721. }
  44722. /**
  44723. * Interface used by SceneLoader plugins to define supported file extensions
  44724. */
  44725. export interface ISceneLoaderPluginExtensions {
  44726. /**
  44727. * Defines the list of supported extensions
  44728. */
  44729. [extension: string]: {
  44730. isBinary: boolean;
  44731. };
  44732. }
  44733. /**
  44734. * Interface used by SceneLoader plugin factory
  44735. */
  44736. export interface ISceneLoaderPluginFactory {
  44737. /**
  44738. * Defines the name of the factory
  44739. */
  44740. name: string;
  44741. /**
  44742. * Function called to create a new plugin
  44743. * @return the new plugin
  44744. */
  44745. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44746. /**
  44747. * The callback that returns true if the data can be directly loaded.
  44748. * @param data string containing the file data
  44749. * @returns if the data can be loaded directly
  44750. */
  44751. canDirectLoad?(data: string): boolean;
  44752. }
  44753. /**
  44754. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44755. */
  44756. export interface ISceneLoaderPluginBase {
  44757. /**
  44758. * The friendly name of this plugin.
  44759. */
  44760. name: string;
  44761. /**
  44762. * The file extensions supported by this plugin.
  44763. */
  44764. extensions: string | ISceneLoaderPluginExtensions;
  44765. /**
  44766. * The callback called when loading from a url.
  44767. * @param scene scene loading this url
  44768. * @param url url to load
  44769. * @param onSuccess callback called when the file successfully loads
  44770. * @param onProgress callback called while file is loading (if the server supports this mode)
  44771. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44772. * @param onError callback called when the file fails to load
  44773. * @returns a file request object
  44774. */
  44775. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44776. /**
  44777. * The callback called when loading from a file object.
  44778. * @param scene scene loading this file
  44779. * @param file defines the file to load
  44780. * @param onSuccess defines the callback to call when data is loaded
  44781. * @param onProgress defines the callback to call during loading process
  44782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44783. * @param onError defines the callback to call when an error occurs
  44784. * @returns a file request object
  44785. */
  44786. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44787. /**
  44788. * The callback that returns true if the data can be directly loaded.
  44789. * @param data string containing the file data
  44790. * @returns if the data can be loaded directly
  44791. */
  44792. canDirectLoad?(data: string): boolean;
  44793. /**
  44794. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44795. * @param scene scene loading this data
  44796. * @param data string containing the data
  44797. * @returns data to pass to the plugin
  44798. */
  44799. directLoad?(scene: Scene, data: string): any;
  44800. /**
  44801. * The callback that allows custom handling of the root url based on the response url.
  44802. * @param rootUrl the original root url
  44803. * @param responseURL the response url if available
  44804. * @returns the new root url
  44805. */
  44806. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44807. }
  44808. /**
  44809. * Interface used to define a SceneLoader plugin
  44810. */
  44811. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44812. /**
  44813. * Import meshes into a scene.
  44814. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44815. * @param scene The scene to import into
  44816. * @param data The data to import
  44817. * @param rootUrl The root url for scene and resources
  44818. * @param meshes The meshes array to import into
  44819. * @param particleSystems The particle systems array to import into
  44820. * @param skeletons The skeletons array to import into
  44821. * @param onError The callback when import fails
  44822. * @returns True if successful or false otherwise
  44823. */
  44824. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44825. /**
  44826. * Load into a scene.
  44827. * @param scene The scene to load into
  44828. * @param data The data to import
  44829. * @param rootUrl The root url for scene and resources
  44830. * @param onError The callback when import fails
  44831. * @returns True if successful or false otherwise
  44832. */
  44833. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44834. /**
  44835. * Load into an asset container.
  44836. * @param scene The scene to load into
  44837. * @param data The data to import
  44838. * @param rootUrl The root url for scene and resources
  44839. * @param onError The callback when import fails
  44840. * @returns The loaded asset container
  44841. */
  44842. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44843. }
  44844. /**
  44845. * Interface used to define an async SceneLoader plugin
  44846. */
  44847. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44848. /**
  44849. * Import meshes into a scene.
  44850. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44851. * @param scene The scene to import into
  44852. * @param data The data to import
  44853. * @param rootUrl The root url for scene and resources
  44854. * @param onProgress The callback when the load progresses
  44855. * @param fileName Defines the name of the file to load
  44856. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44857. */
  44858. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44859. meshes: AbstractMesh[];
  44860. particleSystems: IParticleSystem[];
  44861. skeletons: Skeleton[];
  44862. animationGroups: AnimationGroup[];
  44863. }>;
  44864. /**
  44865. * Load into a scene.
  44866. * @param scene The scene to load into
  44867. * @param data The data to import
  44868. * @param rootUrl The root url for scene and resources
  44869. * @param onProgress The callback when the load progresses
  44870. * @param fileName Defines the name of the file to load
  44871. * @returns Nothing
  44872. */
  44873. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44874. /**
  44875. * Load into an asset container.
  44876. * @param scene The scene to load into
  44877. * @param data The data to import
  44878. * @param rootUrl The root url for scene and resources
  44879. * @param onProgress The callback when the load progresses
  44880. * @param fileName Defines the name of the file to load
  44881. * @returns The loaded asset container
  44882. */
  44883. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44884. }
  44885. /**
  44886. * Mode that determines how to handle old animation groups before loading new ones.
  44887. */
  44888. export enum SceneLoaderAnimationGroupLoadingMode {
  44889. /**
  44890. * Reset all old animations to initial state then dispose them.
  44891. */
  44892. Clean = 0,
  44893. /**
  44894. * Stop all old animations.
  44895. */
  44896. Stop = 1,
  44897. /**
  44898. * Restart old animations from first frame.
  44899. */
  44900. Sync = 2,
  44901. /**
  44902. * Old animations remains untouched.
  44903. */
  44904. NoSync = 3
  44905. }
  44906. /**
  44907. * Class used to load scene from various file formats using registered plugins
  44908. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44909. */
  44910. export class SceneLoader {
  44911. /**
  44912. * No logging while loading
  44913. */
  44914. static readonly NO_LOGGING: number;
  44915. /**
  44916. * Minimal logging while loading
  44917. */
  44918. static readonly MINIMAL_LOGGING: number;
  44919. /**
  44920. * Summary logging while loading
  44921. */
  44922. static readonly SUMMARY_LOGGING: number;
  44923. /**
  44924. * Detailled logging while loading
  44925. */
  44926. static readonly DETAILED_LOGGING: number;
  44927. /**
  44928. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44929. */
  44930. static get ForceFullSceneLoadingForIncremental(): boolean;
  44931. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44932. /**
  44933. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44934. */
  44935. static get ShowLoadingScreen(): boolean;
  44936. static set ShowLoadingScreen(value: boolean);
  44937. /**
  44938. * Defines the current logging level (while loading the scene)
  44939. * @ignorenaming
  44940. */
  44941. static get loggingLevel(): number;
  44942. static set loggingLevel(value: number);
  44943. /**
  44944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44945. */
  44946. static get CleanBoneMatrixWeights(): boolean;
  44947. static set CleanBoneMatrixWeights(value: boolean);
  44948. /**
  44949. * Event raised when a plugin is used to load a scene
  44950. */
  44951. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44952. private static _registeredPlugins;
  44953. private static _getDefaultPlugin;
  44954. private static _getPluginForExtension;
  44955. private static _getPluginForDirectLoad;
  44956. private static _getPluginForFilename;
  44957. private static _getDirectLoad;
  44958. private static _loadData;
  44959. private static _getFileInfo;
  44960. /**
  44961. * Gets a plugin that can load the given extension
  44962. * @param extension defines the extension to load
  44963. * @returns a plugin or null if none works
  44964. */
  44965. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44966. /**
  44967. * Gets a boolean indicating that the given extension can be loaded
  44968. * @param extension defines the extension to load
  44969. * @returns true if the extension is supported
  44970. */
  44971. static IsPluginForExtensionAvailable(extension: string): boolean;
  44972. /**
  44973. * Adds a new plugin to the list of registered plugins
  44974. * @param plugin defines the plugin to add
  44975. */
  44976. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44977. /**
  44978. * Import meshes into a scene
  44979. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44980. * @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)
  44981. * @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)
  44982. * @param scene the instance of BABYLON.Scene to append to
  44983. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44984. * @param onProgress a callback with a progress event for each file being loaded
  44985. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44986. * @param pluginExtension the extension used to determine the plugin
  44987. * @returns The loaded plugin
  44988. */
  44989. 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>;
  44990. /**
  44991. * Import meshes into a scene
  44992. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44993. * @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)
  44994. * @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)
  44995. * @param scene the instance of BABYLON.Scene to append to
  44996. * @param onProgress a callback with a progress event for each file being loaded
  44997. * @param pluginExtension the extension used to determine the plugin
  44998. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44999. */
  45000. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45001. meshes: AbstractMesh[];
  45002. particleSystems: IParticleSystem[];
  45003. skeletons: Skeleton[];
  45004. animationGroups: AnimationGroup[];
  45005. }>;
  45006. /**
  45007. * Load a scene
  45008. * @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)
  45009. * @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)
  45010. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45011. * @param onSuccess a callback with the scene when import succeeds
  45012. * @param onProgress a callback with a progress event for each file being loaded
  45013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45014. * @param pluginExtension the extension used to determine the plugin
  45015. * @returns The loaded plugin
  45016. */
  45017. 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>;
  45018. /**
  45019. * Load a scene
  45020. * @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)
  45021. * @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)
  45022. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45023. * @param onProgress a callback with a progress event for each file being loaded
  45024. * @param pluginExtension the extension used to determine the plugin
  45025. * @returns The loaded scene
  45026. */
  45027. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45028. /**
  45029. * Append a scene
  45030. * @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)
  45031. * @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)
  45032. * @param scene is the instance of BABYLON.Scene to append to
  45033. * @param onSuccess a callback with the scene when import succeeds
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45036. * @param pluginExtension the extension used to determine the plugin
  45037. * @returns The loaded plugin
  45038. */
  45039. 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>;
  45040. /**
  45041. * Append a scene
  45042. * @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)
  45043. * @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)
  45044. * @param scene is the instance of BABYLON.Scene to append to
  45045. * @param onProgress a callback with a progress event for each file being loaded
  45046. * @param pluginExtension the extension used to determine the plugin
  45047. * @returns The given scene
  45048. */
  45049. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45050. /**
  45051. * Load a scene into an asset container
  45052. * @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)
  45053. * @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)
  45054. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45055. * @param onSuccess a callback with the scene when import succeeds
  45056. * @param onProgress a callback with a progress event for each file being loaded
  45057. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45058. * @param pluginExtension the extension used to determine the plugin
  45059. * @returns The loaded plugin
  45060. */
  45061. 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>;
  45062. /**
  45063. * Load a scene into an asset container
  45064. * @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)
  45065. * @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)
  45066. * @param scene is the instance of Scene to append to
  45067. * @param onProgress a callback with a progress event for each file being loaded
  45068. * @param pluginExtension the extension used to determine the plugin
  45069. * @returns The loaded asset container
  45070. */
  45071. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45072. /**
  45073. * Import animations from a file into a scene
  45074. * @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)
  45075. * @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)
  45076. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45077. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45078. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45079. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45080. * @param onSuccess a callback with the scene when import succeeds
  45081. * @param onProgress a callback with a progress event for each file being loaded
  45082. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45083. */
  45084. 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;
  45085. /**
  45086. * Import animations from a file into a scene
  45087. * @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)
  45088. * @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)
  45089. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45090. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45091. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45092. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45093. * @param onSuccess a callback with the scene when import succeeds
  45094. * @param onProgress a callback with a progress event for each file being loaded
  45095. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45096. * @returns the updated scene with imported animations
  45097. */
  45098. 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>;
  45099. }
  45100. }
  45101. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45102. import { IDisposable, Scene } from "babylonjs/scene";
  45103. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45104. import { Observable } from "babylonjs/Misc/observable";
  45105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45106. import { Nullable } from "babylonjs/types";
  45107. /**
  45108. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45109. */
  45110. export type MotionControllerHandness = "none" | "left" | "right";
  45111. /**
  45112. * The type of components available in motion controllers.
  45113. * This is not the name of the component.
  45114. */
  45115. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45116. /**
  45117. * The state of a controller component
  45118. */
  45119. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45120. /**
  45121. * The schema of motion controller layout.
  45122. * No object will be initialized using this interface
  45123. * This is used just to define the profile.
  45124. */
  45125. export interface IMotionControllerLayout {
  45126. /**
  45127. * Path to load the assets. Usually relative to the base path
  45128. */
  45129. assetPath: string;
  45130. /**
  45131. * Available components (unsorted)
  45132. */
  45133. components: {
  45134. /**
  45135. * A map of component Ids
  45136. */
  45137. [componentId: string]: {
  45138. /**
  45139. * The type of input the component outputs
  45140. */
  45141. type: MotionControllerComponentType;
  45142. /**
  45143. * The indices of this component in the gamepad object
  45144. */
  45145. gamepadIndices: {
  45146. /**
  45147. * Index of button
  45148. */
  45149. button?: number;
  45150. /**
  45151. * If available, index of x-axis
  45152. */
  45153. xAxis?: number;
  45154. /**
  45155. * If available, index of y-axis
  45156. */
  45157. yAxis?: number;
  45158. };
  45159. /**
  45160. * The mesh's root node name
  45161. */
  45162. rootNodeName: string;
  45163. /**
  45164. * Animation definitions for this model
  45165. */
  45166. visualResponses: {
  45167. [stateKey: string]: {
  45168. /**
  45169. * What property will be animated
  45170. */
  45171. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45172. /**
  45173. * What states influence this visual response
  45174. */
  45175. states: MotionControllerComponentStateType[];
  45176. /**
  45177. * Type of animation - movement or visibility
  45178. */
  45179. valueNodeProperty: "transform" | "visibility";
  45180. /**
  45181. * Base node name to move. Its position will be calculated according to the min and max nodes
  45182. */
  45183. valueNodeName?: string;
  45184. /**
  45185. * Minimum movement node
  45186. */
  45187. minNodeName?: string;
  45188. /**
  45189. * Max movement node
  45190. */
  45191. maxNodeName?: string;
  45192. };
  45193. };
  45194. /**
  45195. * If touch enabled, what is the name of node to display user feedback
  45196. */
  45197. touchPointNodeName?: string;
  45198. };
  45199. };
  45200. /**
  45201. * Is it xr standard mapping or not
  45202. */
  45203. gamepadMapping: "" | "xr-standard";
  45204. /**
  45205. * Base root node of this entire model
  45206. */
  45207. rootNodeName: string;
  45208. /**
  45209. * Defines the main button component id
  45210. */
  45211. selectComponentId: string;
  45212. }
  45213. /**
  45214. * A definition for the layout map in the input profile
  45215. */
  45216. export interface IMotionControllerLayoutMap {
  45217. /**
  45218. * Layouts with handness type as a key
  45219. */
  45220. [handness: string]: IMotionControllerLayout;
  45221. }
  45222. /**
  45223. * The XR Input profile schema
  45224. * Profiles can be found here:
  45225. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45226. */
  45227. export interface IMotionControllerProfile {
  45228. /**
  45229. * fallback profiles for this profileId
  45230. */
  45231. fallbackProfileIds: string[];
  45232. /**
  45233. * The layout map, with handness as key
  45234. */
  45235. layouts: IMotionControllerLayoutMap;
  45236. /**
  45237. * The id of this profile
  45238. * correlates to the profile(s) in the xrInput.profiles array
  45239. */
  45240. profileId: string;
  45241. }
  45242. /**
  45243. * A helper-interface for the 3 meshes needed for controller button animation
  45244. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45245. */
  45246. export interface IMotionControllerButtonMeshMap {
  45247. /**
  45248. * the mesh that defines the pressed value mesh position.
  45249. * This is used to find the max-position of this button
  45250. */
  45251. pressedMesh: AbstractMesh;
  45252. /**
  45253. * the mesh that defines the unpressed value mesh position.
  45254. * This is used to find the min (or initial) position of this button
  45255. */
  45256. unpressedMesh: AbstractMesh;
  45257. /**
  45258. * The mesh that will be changed when value changes
  45259. */
  45260. valueMesh: AbstractMesh;
  45261. }
  45262. /**
  45263. * A helper-interface for the 3 meshes needed for controller axis animation.
  45264. * This will be expanded when touchpad animations are fully supported
  45265. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45266. */
  45267. export interface IMotionControllerMeshMap {
  45268. /**
  45269. * the mesh that defines the maximum value mesh position.
  45270. */
  45271. maxMesh?: AbstractMesh;
  45272. /**
  45273. * the mesh that defines the minimum value mesh position.
  45274. */
  45275. minMesh?: AbstractMesh;
  45276. /**
  45277. * The mesh that will be changed when axis value changes
  45278. */
  45279. valueMesh: AbstractMesh;
  45280. }
  45281. /**
  45282. * The elements needed for change-detection of the gamepad objects in motion controllers
  45283. */
  45284. export interface IMinimalMotionControllerObject {
  45285. /**
  45286. * Available axes of this controller
  45287. */
  45288. axes: number[];
  45289. /**
  45290. * An array of available buttons
  45291. */
  45292. buttons: Array<{
  45293. /**
  45294. * Value of the button/trigger
  45295. */
  45296. value: number;
  45297. /**
  45298. * If the button/trigger is currently touched
  45299. */
  45300. touched: boolean;
  45301. /**
  45302. * If the button/trigger is currently pressed
  45303. */
  45304. pressed: boolean;
  45305. }>;
  45306. }
  45307. /**
  45308. * An Abstract Motion controller
  45309. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45310. * Each component has an observable to check for changes in value and state
  45311. */
  45312. export abstract class WebXRAbstractMotionController implements IDisposable {
  45313. protected scene: Scene;
  45314. protected layout: IMotionControllerLayout;
  45315. /**
  45316. * The gamepad object correlating to this controller
  45317. */
  45318. gamepadObject: IMinimalMotionControllerObject;
  45319. /**
  45320. * handness (left/right/none) of this controller
  45321. */
  45322. handness: MotionControllerHandness;
  45323. private _initComponent;
  45324. private _modelReady;
  45325. /**
  45326. * A map of components (WebXRControllerComponent) in this motion controller
  45327. * Components have a ComponentType and can also have both button and axis definitions
  45328. */
  45329. readonly components: {
  45330. [id: string]: WebXRControllerComponent;
  45331. };
  45332. /**
  45333. * Disable the model's animation. Can be set at any time.
  45334. */
  45335. disableAnimation: boolean;
  45336. /**
  45337. * Observers registered here will be triggered when the model of this controller is done loading
  45338. */
  45339. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45340. /**
  45341. * The profile id of this motion controller
  45342. */
  45343. abstract profileId: string;
  45344. /**
  45345. * The root mesh of the model. It is null if the model was not yet initialized
  45346. */
  45347. rootMesh: Nullable<AbstractMesh>;
  45348. /**
  45349. * constructs a new abstract motion controller
  45350. * @param scene the scene to which the model of the controller will be added
  45351. * @param layout The profile layout to load
  45352. * @param gamepadObject The gamepad object correlating to this controller
  45353. * @param handness handness (left/right/none) of this controller
  45354. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45355. */
  45356. constructor(scene: Scene, layout: IMotionControllerLayout,
  45357. /**
  45358. * The gamepad object correlating to this controller
  45359. */
  45360. gamepadObject: IMinimalMotionControllerObject,
  45361. /**
  45362. * handness (left/right/none) of this controller
  45363. */
  45364. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45365. /**
  45366. * Dispose this controller, the model mesh and all its components
  45367. */
  45368. dispose(): void;
  45369. /**
  45370. * Returns all components of specific type
  45371. * @param type the type to search for
  45372. * @return an array of components with this type
  45373. */
  45374. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45375. /**
  45376. * get a component based an its component id as defined in layout.components
  45377. * @param id the id of the component
  45378. * @returns the component correlates to the id or undefined if not found
  45379. */
  45380. getComponent(id: string): WebXRControllerComponent;
  45381. /**
  45382. * Get the list of components available in this motion controller
  45383. * @returns an array of strings correlating to available components
  45384. */
  45385. getComponentIds(): string[];
  45386. /**
  45387. * Get the first component of specific type
  45388. * @param type type of component to find
  45389. * @return a controller component or null if not found
  45390. */
  45391. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45392. /**
  45393. * Get the main (Select) component of this controller as defined in the layout
  45394. * @returns the main component of this controller
  45395. */
  45396. getMainComponent(): WebXRControllerComponent;
  45397. /**
  45398. * Loads the model correlating to this controller
  45399. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45400. * @returns A promise fulfilled with the result of the model loading
  45401. */
  45402. loadModel(): Promise<boolean>;
  45403. /**
  45404. * Update this model using the current XRFrame
  45405. * @param xrFrame the current xr frame to use and update the model
  45406. */
  45407. updateFromXRFrame(xrFrame: XRFrame): void;
  45408. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45409. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45410. /**
  45411. * Moves the axis on the controller mesh based on its current state
  45412. * @param axis the index of the axis
  45413. * @param axisValue the value of the axis which determines the meshes new position
  45414. * @hidden
  45415. */
  45416. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45417. /**
  45418. * Update the model itself with the current frame data
  45419. * @param xrFrame the frame to use for updating the model mesh
  45420. */
  45421. protected updateModel(xrFrame: XRFrame): void;
  45422. /**
  45423. * Get the filename and path for this controller's model
  45424. * @returns a map of filename and path
  45425. */
  45426. protected abstract _getFilenameAndPath(): {
  45427. filename: string;
  45428. path: string;
  45429. };
  45430. /**
  45431. * This function is called before the mesh is loaded. It checks for loading constraints.
  45432. * For example, this function can check if the GLB loader is available
  45433. * If this function returns false, the generic controller will be loaded instead
  45434. * @returns Is the client ready to load the mesh
  45435. */
  45436. protected abstract _getModelLoadingConstraints(): boolean;
  45437. /**
  45438. * This function will be called after the model was successfully loaded and can be used
  45439. * for mesh transformations before it is available for the user
  45440. * @param meshes the loaded meshes
  45441. */
  45442. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45443. /**
  45444. * Set the root mesh for this controller. Important for the WebXR controller class
  45445. * @param meshes the loaded meshes
  45446. */
  45447. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45448. /**
  45449. * A function executed each frame that updates the mesh (if needed)
  45450. * @param xrFrame the current xrFrame
  45451. */
  45452. protected abstract _updateModel(xrFrame: XRFrame): void;
  45453. private _getGenericFilenameAndPath;
  45454. private _getGenericParentMesh;
  45455. }
  45456. }
  45457. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45458. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45460. import { Scene } from "babylonjs/scene";
  45461. /**
  45462. * A generic trigger-only motion controller for WebXR
  45463. */
  45464. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45465. /**
  45466. * Static version of the profile id of this controller
  45467. */
  45468. static ProfileId: string;
  45469. profileId: string;
  45470. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45471. protected _getFilenameAndPath(): {
  45472. filename: string;
  45473. path: string;
  45474. };
  45475. protected _getModelLoadingConstraints(): boolean;
  45476. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45477. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45478. protected _updateModel(): void;
  45479. }
  45480. }
  45481. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45482. import { Vector4 } from "babylonjs/Maths/math.vector";
  45483. import { Mesh } from "babylonjs/Meshes/mesh";
  45484. import { Scene } from "babylonjs/scene";
  45485. import { Nullable } from "babylonjs/types";
  45486. /**
  45487. * Class containing static functions to help procedurally build meshes
  45488. */
  45489. export class SphereBuilder {
  45490. /**
  45491. * Creates a sphere mesh
  45492. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45493. * * 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`)
  45494. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45495. * * 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
  45496. * * 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)
  45497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45500. * @param name defines the name of the mesh
  45501. * @param options defines the options used to create the mesh
  45502. * @param scene defines the hosting scene
  45503. * @returns the sphere mesh
  45504. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45505. */
  45506. static CreateSphere(name: string, options: {
  45507. segments?: number;
  45508. diameter?: number;
  45509. diameterX?: number;
  45510. diameterY?: number;
  45511. diameterZ?: number;
  45512. arc?: number;
  45513. slice?: number;
  45514. sideOrientation?: number;
  45515. frontUVs?: Vector4;
  45516. backUVs?: Vector4;
  45517. updatable?: boolean;
  45518. }, scene?: Nullable<Scene>): Mesh;
  45519. }
  45520. }
  45521. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45523. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45524. import { Scene } from "babylonjs/scene";
  45525. /**
  45526. * A profiled motion controller has its profile loaded from an online repository.
  45527. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45528. */
  45529. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45530. private _repositoryUrl;
  45531. private _buttonMeshMapping;
  45532. private _touchDots;
  45533. /**
  45534. * The profile ID of this controller. Will be populated when the controller initializes.
  45535. */
  45536. profileId: string;
  45537. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45538. dispose(): void;
  45539. protected _getFilenameAndPath(): {
  45540. filename: string;
  45541. path: string;
  45542. };
  45543. protected _getModelLoadingConstraints(): boolean;
  45544. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45545. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45546. protected _updateModel(_xrFrame: XRFrame): void;
  45547. }
  45548. }
  45549. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45550. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45551. import { Scene } from "babylonjs/scene";
  45552. /**
  45553. * A construction function type to create a new controller based on an xrInput object
  45554. */
  45555. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45556. /**
  45557. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45558. *
  45559. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45560. * it should be replaced with auto-loaded controllers.
  45561. *
  45562. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45563. */
  45564. export class WebXRMotionControllerManager {
  45565. private static _AvailableControllers;
  45566. private static _Fallbacks;
  45567. private static _ProfileLoadingPromises;
  45568. private static _ProfilesList;
  45569. /**
  45570. * The base URL of the online controller repository. Can be changed at any time.
  45571. */
  45572. static BaseRepositoryUrl: string;
  45573. /**
  45574. * Which repository gets priority - local or online
  45575. */
  45576. static PrioritizeOnlineRepository: boolean;
  45577. /**
  45578. * Use the online repository, or use only locally-defined controllers
  45579. */
  45580. static UseOnlineRepository: boolean;
  45581. /**
  45582. * Clear the cache used for profile loading and reload when requested again
  45583. */
  45584. static ClearProfilesCache(): void;
  45585. /**
  45586. * Register the default fallbacks.
  45587. * This function is called automatically when this file is imported.
  45588. */
  45589. static DefaultFallbacks(): void;
  45590. /**
  45591. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45592. * @param profileId the profile to which a fallback needs to be found
  45593. * @return an array with corresponding fallback profiles
  45594. */
  45595. static FindFallbackWithProfileId(profileId: string): string[];
  45596. /**
  45597. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45598. * The order of search:
  45599. *
  45600. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45601. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45602. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45603. * 4) return the generic trigger controller if none were found
  45604. *
  45605. * @param xrInput the xrInput to which a new controller is initialized
  45606. * @param scene the scene to which the model will be added
  45607. * @param forceProfile force a certain profile for this controller
  45608. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45609. */
  45610. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45611. /**
  45612. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45613. *
  45614. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45615. *
  45616. * @param type the profile type to register
  45617. * @param constructFunction the function to be called when loading this profile
  45618. */
  45619. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45620. /**
  45621. * Register a fallback to a specific profile.
  45622. * @param profileId the profileId that will receive the fallbacks
  45623. * @param fallbacks A list of fallback profiles
  45624. */
  45625. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45626. /**
  45627. * Will update the list of profiles available in the repository
  45628. * @return a promise that resolves to a map of profiles available online
  45629. */
  45630. static UpdateProfilesList(): Promise<{
  45631. [profile: string]: string;
  45632. }>;
  45633. private static _LoadProfileFromRepository;
  45634. private static _LoadProfilesFromAvailableControllers;
  45635. }
  45636. }
  45637. declare module "babylonjs/XR/webXRInputSource" {
  45638. import { Observable } from "babylonjs/Misc/observable";
  45639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45640. import { Ray } from "babylonjs/Culling/ray";
  45641. import { Scene } from "babylonjs/scene";
  45642. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45643. /**
  45644. * Configuration options for the WebXR controller creation
  45645. */
  45646. export interface IWebXRControllerOptions {
  45647. /**
  45648. * Should the controller mesh be animated when a user interacts with it
  45649. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45650. */
  45651. disableMotionControllerAnimation?: boolean;
  45652. /**
  45653. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45654. */
  45655. doNotLoadControllerMesh?: boolean;
  45656. /**
  45657. * Force a specific controller type for this controller.
  45658. * This can be used when creating your own profile or when testing different controllers
  45659. */
  45660. forceControllerProfile?: string;
  45661. }
  45662. /**
  45663. * Represents an XR controller
  45664. */
  45665. export class WebXRInputSource {
  45666. private _scene;
  45667. /** The underlying input source for the controller */
  45668. inputSource: XRInputSource;
  45669. private _options;
  45670. private _tmpQuaternion;
  45671. private _tmpVector;
  45672. private _uniqueId;
  45673. /**
  45674. * 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
  45675. */
  45676. grip?: AbstractMesh;
  45677. /**
  45678. * If available, this is the gamepad object related to this controller.
  45679. * Using this object it is possible to get click events and trackpad changes of the
  45680. * webxr controller that is currently being used.
  45681. */
  45682. motionController?: WebXRAbstractMotionController;
  45683. /**
  45684. * Event that fires when the controller is removed/disposed.
  45685. * The object provided as event data is this controller, after associated assets were disposed.
  45686. * uniqueId is still available.
  45687. */
  45688. onDisposeObservable: Observable<WebXRInputSource>;
  45689. /**
  45690. * Will be triggered when the mesh associated with the motion controller is done loading.
  45691. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45692. * A shortened version of controller -> motion controller -> on mesh loaded.
  45693. */
  45694. onMeshLoadedObservable: Observable<AbstractMesh>;
  45695. /**
  45696. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45697. */
  45698. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45699. /**
  45700. * Pointer which can be used to select objects or attach a visible laser to
  45701. */
  45702. pointer: AbstractMesh;
  45703. /**
  45704. * Creates the controller
  45705. * @see https://doc.babylonjs.com/how_to/webxr
  45706. * @param _scene the scene which the controller should be associated to
  45707. * @param inputSource the underlying input source for the controller
  45708. * @param _options options for this controller creation
  45709. */
  45710. constructor(_scene: Scene,
  45711. /** The underlying input source for the controller */
  45712. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45713. /**
  45714. * Get this controllers unique id
  45715. */
  45716. get uniqueId(): string;
  45717. /**
  45718. * Disposes of the object
  45719. */
  45720. dispose(): void;
  45721. /**
  45722. * Gets a world space ray coming from the pointer or grip
  45723. * @param result the resulting ray
  45724. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45725. */
  45726. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45727. /**
  45728. * Updates the controller pose based on the given XRFrame
  45729. * @param xrFrame xr frame to update the pose with
  45730. * @param referenceSpace reference space to use
  45731. */
  45732. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45733. }
  45734. }
  45735. declare module "babylonjs/XR/webXRInput" {
  45736. import { Observable } from "babylonjs/Misc/observable";
  45737. import { IDisposable } from "babylonjs/scene";
  45738. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45739. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45740. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45741. /**
  45742. * The schema for initialization options of the XR Input class
  45743. */
  45744. export interface IWebXRInputOptions {
  45745. /**
  45746. * If set to true no model will be automatically loaded
  45747. */
  45748. doNotLoadControllerMeshes?: boolean;
  45749. /**
  45750. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45751. * If not found, the xr input profile data will be used.
  45752. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45753. */
  45754. forceInputProfile?: string;
  45755. /**
  45756. * Do not send a request to the controller repository to load the profile.
  45757. *
  45758. * Instead, use the controllers available in babylon itself.
  45759. */
  45760. disableOnlineControllerRepository?: boolean;
  45761. /**
  45762. * A custom URL for the controllers repository
  45763. */
  45764. customControllersRepositoryURL?: string;
  45765. /**
  45766. * Should the controller model's components not move according to the user input
  45767. */
  45768. disableControllerAnimation?: boolean;
  45769. }
  45770. /**
  45771. * XR input used to track XR inputs such as controllers/rays
  45772. */
  45773. export class WebXRInput implements IDisposable {
  45774. /**
  45775. * the xr session manager for this session
  45776. */
  45777. xrSessionManager: WebXRSessionManager;
  45778. /**
  45779. * the WebXR camera for this session. Mainly used for teleportation
  45780. */
  45781. xrCamera: WebXRCamera;
  45782. private readonly options;
  45783. /**
  45784. * XR controllers being tracked
  45785. */
  45786. controllers: Array<WebXRInputSource>;
  45787. private _frameObserver;
  45788. private _sessionEndedObserver;
  45789. private _sessionInitObserver;
  45790. /**
  45791. * Event when a controller has been connected/added
  45792. */
  45793. onControllerAddedObservable: Observable<WebXRInputSource>;
  45794. /**
  45795. * Event when a controller has been removed/disconnected
  45796. */
  45797. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45798. /**
  45799. * Initializes the WebXRInput
  45800. * @param xrSessionManager the xr session manager for this session
  45801. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45802. * @param options = initialization options for this xr input
  45803. */
  45804. constructor(
  45805. /**
  45806. * the xr session manager for this session
  45807. */
  45808. xrSessionManager: WebXRSessionManager,
  45809. /**
  45810. * the WebXR camera for this session. Mainly used for teleportation
  45811. */
  45812. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45813. private _onInputSourcesChange;
  45814. private _addAndRemoveControllers;
  45815. /**
  45816. * Disposes of the object
  45817. */
  45818. dispose(): void;
  45819. }
  45820. }
  45821. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45822. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45823. import { Observable, EventState } from "babylonjs/Misc/observable";
  45824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45825. /**
  45826. * This is the base class for all WebXR features.
  45827. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45828. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45829. */
  45830. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45831. protected _xrSessionManager: WebXRSessionManager;
  45832. private _attached;
  45833. private _removeOnDetach;
  45834. /**
  45835. * Should auto-attach be disabled?
  45836. */
  45837. disableAutoAttach: boolean;
  45838. /**
  45839. * Construct a new (abstract) WebXR feature
  45840. * @param _xrSessionManager the xr session manager for this feature
  45841. */
  45842. constructor(_xrSessionManager: WebXRSessionManager);
  45843. /**
  45844. * Is this feature attached
  45845. */
  45846. get attached(): boolean;
  45847. /**
  45848. * attach this feature
  45849. *
  45850. * @param force should attachment be forced (even when already attached)
  45851. * @returns true if successful, false is failed or already attached
  45852. */
  45853. attach(force?: boolean): boolean;
  45854. /**
  45855. * detach this feature.
  45856. *
  45857. * @returns true if successful, false if failed or already detached
  45858. */
  45859. detach(): boolean;
  45860. /**
  45861. * Dispose this feature and all of the resources attached
  45862. */
  45863. dispose(): void;
  45864. /**
  45865. * This is used to register callbacks that will automatically be removed when detach is called.
  45866. * @param observable the observable to which the observer will be attached
  45867. * @param callback the callback to register
  45868. */
  45869. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45870. /**
  45871. * Code in this function will be executed on each xrFrame received from the browser.
  45872. * This function will not execute after the feature is detached.
  45873. * @param _xrFrame the current frame
  45874. */
  45875. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45876. }
  45877. }
  45878. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45879. import { IDisposable, Scene } from "babylonjs/scene";
  45880. import { Nullable } from "babylonjs/types";
  45881. import { Observable } from "babylonjs/Misc/observable";
  45882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45883. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45884. import { Camera } from "babylonjs/Cameras/camera";
  45885. /**
  45886. * Renders a layer on top of an existing scene
  45887. */
  45888. export class UtilityLayerRenderer implements IDisposable {
  45889. /** the original scene that will be rendered on top of */
  45890. originalScene: Scene;
  45891. private _pointerCaptures;
  45892. private _lastPointerEvents;
  45893. private static _DefaultUtilityLayer;
  45894. private static _DefaultKeepDepthUtilityLayer;
  45895. private _sharedGizmoLight;
  45896. private _renderCamera;
  45897. /**
  45898. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45899. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45900. * @returns the camera that is used when rendering the utility layer
  45901. */
  45902. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45903. /**
  45904. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45905. * @param cam the camera that should be used when rendering the utility layer
  45906. */
  45907. setRenderCamera(cam: Nullable<Camera>): void;
  45908. /**
  45909. * @hidden
  45910. * Light which used by gizmos to get light shading
  45911. */
  45912. _getSharedGizmoLight(): HemisphericLight;
  45913. /**
  45914. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45915. */
  45916. pickUtilitySceneFirst: boolean;
  45917. /**
  45918. * 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)
  45919. */
  45920. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45921. /**
  45922. * 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)
  45923. */
  45924. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45925. /**
  45926. * The scene that is rendered on top of the original scene
  45927. */
  45928. utilityLayerScene: Scene;
  45929. /**
  45930. * If the utility layer should automatically be rendered on top of existing scene
  45931. */
  45932. shouldRender: boolean;
  45933. /**
  45934. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45935. */
  45936. onlyCheckPointerDownEvents: boolean;
  45937. /**
  45938. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45939. */
  45940. processAllEvents: boolean;
  45941. /**
  45942. * Observable raised when the pointer move from the utility layer scene to the main scene
  45943. */
  45944. onPointerOutObservable: Observable<number>;
  45945. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45946. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45947. private _afterRenderObserver;
  45948. private _sceneDisposeObserver;
  45949. private _originalPointerObserver;
  45950. /**
  45951. * Instantiates a UtilityLayerRenderer
  45952. * @param originalScene the original scene that will be rendered on top of
  45953. * @param handleEvents boolean indicating if the utility layer should handle events
  45954. */
  45955. constructor(
  45956. /** the original scene that will be rendered on top of */
  45957. originalScene: Scene, handleEvents?: boolean);
  45958. private _notifyObservers;
  45959. /**
  45960. * Renders the utility layers scene on top of the original scene
  45961. */
  45962. render(): void;
  45963. /**
  45964. * Disposes of the renderer
  45965. */
  45966. dispose(): void;
  45967. private _updateCamera;
  45968. }
  45969. }
  45970. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45971. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45973. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45974. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45975. import { Scene } from "babylonjs/scene";
  45976. import { Nullable } from "babylonjs/types";
  45977. import { Color3 } from "babylonjs/Maths/math.color";
  45978. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45979. /**
  45980. * Options interface for the pointer selection module
  45981. */
  45982. export interface IWebXRControllerPointerSelectionOptions {
  45983. /**
  45984. * if provided, this scene will be used to render meshes.
  45985. */
  45986. customUtilityLayerScene?: Scene;
  45987. /**
  45988. * 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)
  45989. * If not disabled, the last picked point will be used to execute a pointer up event
  45990. * If disabled, pointer up event will be triggered right after the pointer down event.
  45991. * Used in screen and gaze target ray mode only
  45992. */
  45993. disablePointerUpOnTouchOut: boolean;
  45994. /**
  45995. * For gaze mode (time to select instead of press)
  45996. */
  45997. forceGazeMode: boolean;
  45998. /**
  45999. * 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
  46000. * to start a new countdown to the pointer down event.
  46001. * Defaults to 1.
  46002. */
  46003. gazeModePointerMovedFactor?: number;
  46004. /**
  46005. * Different button type to use instead of the main component
  46006. */
  46007. overrideButtonId?: string;
  46008. /**
  46009. * use this rendering group id for the meshes (optional)
  46010. */
  46011. renderingGroupId?: number;
  46012. /**
  46013. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46014. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46015. * 3000 means 3 seconds between pointing at something and selecting it
  46016. */
  46017. timeToSelect?: number;
  46018. /**
  46019. * Should meshes created here be added to a utility layer or the main scene
  46020. */
  46021. useUtilityLayer?: boolean;
  46022. /**
  46023. * the xr input to use with this pointer selection
  46024. */
  46025. xrInput: WebXRInput;
  46026. }
  46027. /**
  46028. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46029. */
  46030. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46031. private readonly _options;
  46032. private static _idCounter;
  46033. private _attachController;
  46034. private _controllers;
  46035. private _scene;
  46036. private _tmpVectorForPickCompare;
  46037. /**
  46038. * The module's name
  46039. */
  46040. static readonly Name: string;
  46041. /**
  46042. * The (Babylon) version of this module.
  46043. * This is an integer representing the implementation version.
  46044. * This number does not correspond to the WebXR specs version
  46045. */
  46046. static readonly Version: number;
  46047. /**
  46048. * Disable lighting on the laser pointer (so it will always be visible)
  46049. */
  46050. disablePointerLighting: boolean;
  46051. /**
  46052. * Disable lighting on the selection mesh (so it will always be visible)
  46053. */
  46054. disableSelectionMeshLighting: boolean;
  46055. /**
  46056. * Should the laser pointer be displayed
  46057. */
  46058. displayLaserPointer: boolean;
  46059. /**
  46060. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46061. */
  46062. displaySelectionMesh: boolean;
  46063. /**
  46064. * This color will be set to the laser pointer when selection is triggered
  46065. */
  46066. laserPointerPickedColor: Color3;
  46067. /**
  46068. * Default color of the laser pointer
  46069. */
  46070. lasterPointerDefaultColor: Color3;
  46071. /**
  46072. * default color of the selection ring
  46073. */
  46074. selectionMeshDefaultColor: Color3;
  46075. /**
  46076. * This color will be applied to the selection ring when selection is triggered
  46077. */
  46078. selectionMeshPickedColor: Color3;
  46079. /**
  46080. * constructs a new background remover module
  46081. * @param _xrSessionManager the session manager for this module
  46082. * @param _options read-only options to be used in this module
  46083. */
  46084. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46085. /**
  46086. * attach this feature
  46087. * Will usually be called by the features manager
  46088. *
  46089. * @returns true if successful.
  46090. */
  46091. attach(): boolean;
  46092. /**
  46093. * detach this feature.
  46094. * Will usually be called by the features manager
  46095. *
  46096. * @returns true if successful.
  46097. */
  46098. detach(): boolean;
  46099. /**
  46100. * Will get the mesh under a specific pointer.
  46101. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46102. * @param controllerId the controllerId to check
  46103. * @returns The mesh under pointer or null if no mesh is under the pointer
  46104. */
  46105. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46106. /**
  46107. * Get the xr controller that correlates to the pointer id in the pointer event
  46108. *
  46109. * @param id the pointer id to search for
  46110. * @returns the controller that correlates to this id or null if not found
  46111. */
  46112. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46113. protected _onXRFrame(_xrFrame: XRFrame): void;
  46114. private _attachGazeMode;
  46115. private _attachScreenRayMode;
  46116. private _attachTrackedPointerRayMode;
  46117. private _convertNormalToDirectionOfRay;
  46118. private _detachController;
  46119. private _generateNewMeshPair;
  46120. private _pickingMoved;
  46121. private _updatePointerDistance;
  46122. }
  46123. }
  46124. declare module "babylonjs/XR/webXREnterExitUI" {
  46125. import { Nullable } from "babylonjs/types";
  46126. import { Observable } from "babylonjs/Misc/observable";
  46127. import { IDisposable, Scene } from "babylonjs/scene";
  46128. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46129. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46130. /**
  46131. * Button which can be used to enter a different mode of XR
  46132. */
  46133. export class WebXREnterExitUIButton {
  46134. /** button element */
  46135. element: HTMLElement;
  46136. /** XR initialization options for the button */
  46137. sessionMode: XRSessionMode;
  46138. /** Reference space type */
  46139. referenceSpaceType: XRReferenceSpaceType;
  46140. /**
  46141. * Creates a WebXREnterExitUIButton
  46142. * @param element button element
  46143. * @param sessionMode XR initialization session mode
  46144. * @param referenceSpaceType the type of reference space to be used
  46145. */
  46146. constructor(
  46147. /** button element */
  46148. element: HTMLElement,
  46149. /** XR initialization options for the button */
  46150. sessionMode: XRSessionMode,
  46151. /** Reference space type */
  46152. referenceSpaceType: XRReferenceSpaceType);
  46153. /**
  46154. * Extendable function which can be used to update the button's visuals when the state changes
  46155. * @param activeButton the current active button in the UI
  46156. */
  46157. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46158. }
  46159. /**
  46160. * Options to create the webXR UI
  46161. */
  46162. export class WebXREnterExitUIOptions {
  46163. /**
  46164. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46165. */
  46166. customButtons?: Array<WebXREnterExitUIButton>;
  46167. /**
  46168. * A reference space type to use when creating the default button.
  46169. * Default is local-floor
  46170. */
  46171. referenceSpaceType?: XRReferenceSpaceType;
  46172. /**
  46173. * Context to enter xr with
  46174. */
  46175. renderTarget?: Nullable<WebXRRenderTarget>;
  46176. /**
  46177. * A session mode to use when creating the default button.
  46178. * Default is immersive-vr
  46179. */
  46180. sessionMode?: XRSessionMode;
  46181. }
  46182. /**
  46183. * UI to allow the user to enter/exit XR mode
  46184. */
  46185. export class WebXREnterExitUI implements IDisposable {
  46186. private scene;
  46187. /** version of the options passed to this UI */
  46188. options: WebXREnterExitUIOptions;
  46189. private _activeButton;
  46190. private _buttons;
  46191. private _overlay;
  46192. /**
  46193. * Fired every time the active button is changed.
  46194. *
  46195. * When xr is entered via a button that launches xr that button will be the callback parameter
  46196. *
  46197. * When exiting xr the callback parameter will be null)
  46198. */
  46199. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46200. /**
  46201. *
  46202. * @param scene babylon scene object to use
  46203. * @param options (read-only) version of the options passed to this UI
  46204. */
  46205. private constructor();
  46206. /**
  46207. * Creates UI to allow the user to enter/exit XR mode
  46208. * @param scene the scene to add the ui to
  46209. * @param helper the xr experience helper to enter/exit xr with
  46210. * @param options options to configure the UI
  46211. * @returns the created ui
  46212. */
  46213. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46214. /**
  46215. * Disposes of the XR UI component
  46216. */
  46217. dispose(): void;
  46218. private _updateButtons;
  46219. }
  46220. }
  46221. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46222. import { Vector3 } from "babylonjs/Maths/math.vector";
  46223. import { Color4 } from "babylonjs/Maths/math.color";
  46224. import { Nullable } from "babylonjs/types";
  46225. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46226. import { Scene } from "babylonjs/scene";
  46227. /**
  46228. * Class containing static functions to help procedurally build meshes
  46229. */
  46230. export class LinesBuilder {
  46231. /**
  46232. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46233. * * 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
  46234. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46235. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46236. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46237. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46238. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46239. * * 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
  46240. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46243. * @param name defines the name of the new line system
  46244. * @param options defines the options used to create the line system
  46245. * @param scene defines the hosting scene
  46246. * @returns a new line system mesh
  46247. */
  46248. static CreateLineSystem(name: string, options: {
  46249. lines: Vector3[][];
  46250. updatable?: boolean;
  46251. instance?: Nullable<LinesMesh>;
  46252. colors?: Nullable<Color4[][]>;
  46253. useVertexAlpha?: boolean;
  46254. }, scene: Nullable<Scene>): LinesMesh;
  46255. /**
  46256. * Creates a line mesh
  46257. * 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
  46258. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46259. * * The parameter `points` is an array successive Vector3
  46260. * * 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
  46261. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46262. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46263. * * When updating an instance, remember that only point positions can change, not the number of points
  46264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46266. * @param name defines the name of the new line system
  46267. * @param options defines the options used to create the line system
  46268. * @param scene defines the hosting scene
  46269. * @returns a new line mesh
  46270. */
  46271. static CreateLines(name: string, options: {
  46272. points: Vector3[];
  46273. updatable?: boolean;
  46274. instance?: Nullable<LinesMesh>;
  46275. colors?: Color4[];
  46276. useVertexAlpha?: boolean;
  46277. }, scene?: Nullable<Scene>): LinesMesh;
  46278. /**
  46279. * Creates a dashed line mesh
  46280. * * 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
  46281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46282. * * The parameter `points` is an array successive Vector3
  46283. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46284. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46285. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46286. * * 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
  46287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46288. * * When updating an instance, remember that only point positions can change, not the number of points
  46289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46290. * @param name defines the name of the mesh
  46291. * @param options defines the options used to create the mesh
  46292. * @param scene defines the hosting scene
  46293. * @returns the dashed line mesh
  46294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46295. */
  46296. static CreateDashedLines(name: string, options: {
  46297. points: Vector3[];
  46298. dashSize?: number;
  46299. gapSize?: number;
  46300. dashNb?: number;
  46301. updatable?: boolean;
  46302. instance?: LinesMesh;
  46303. useVertexAlpha?: boolean;
  46304. }, scene?: Nullable<Scene>): LinesMesh;
  46305. }
  46306. }
  46307. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46308. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46309. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46310. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46312. import { Vector3 } from "babylonjs/Maths/math.vector";
  46313. import { Material } from "babylonjs/Materials/material";
  46314. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46315. import { Scene } from "babylonjs/scene";
  46316. /**
  46317. * The options container for the teleportation module
  46318. */
  46319. export interface IWebXRTeleportationOptions {
  46320. /**
  46321. * if provided, this scene will be used to render meshes.
  46322. */
  46323. customUtilityLayerScene?: Scene;
  46324. /**
  46325. * Values to configure the default target mesh
  46326. */
  46327. defaultTargetMeshOptions?: {
  46328. /**
  46329. * Fill color of the teleportation area
  46330. */
  46331. teleportationFillColor?: string;
  46332. /**
  46333. * Border color for the teleportation area
  46334. */
  46335. teleportationBorderColor?: string;
  46336. /**
  46337. * Disable the mesh's animation sequence
  46338. */
  46339. disableAnimation?: boolean;
  46340. /**
  46341. * Disable lighting on the material or the ring and arrow
  46342. */
  46343. disableLighting?: boolean;
  46344. /**
  46345. * Override the default material of the torus and arrow
  46346. */
  46347. torusArrowMaterial?: Material;
  46348. };
  46349. /**
  46350. * A list of meshes to use as floor meshes.
  46351. * Meshes can be added and removed after initializing the feature using the
  46352. * addFloorMesh and removeFloorMesh functions
  46353. * If empty, rotation will still work
  46354. */
  46355. floorMeshes?: AbstractMesh[];
  46356. /**
  46357. * use this rendering group id for the meshes (optional)
  46358. */
  46359. renderingGroupId?: number;
  46360. /**
  46361. * Should teleportation move only to snap points
  46362. */
  46363. snapPointsOnly?: boolean;
  46364. /**
  46365. * An array of points to which the teleportation will snap to.
  46366. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46367. */
  46368. snapPositions?: Vector3[];
  46369. /**
  46370. * How close should the teleportation ray be in order to snap to position.
  46371. * Default to 0.8 units (meters)
  46372. */
  46373. snapToPositionRadius?: number;
  46374. /**
  46375. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46376. * If you want to support rotation, make sure your mesh has a direction indicator.
  46377. *
  46378. * When left untouched, the default mesh will be initialized.
  46379. */
  46380. teleportationTargetMesh?: AbstractMesh;
  46381. /**
  46382. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46383. */
  46384. timeToTeleport?: number;
  46385. /**
  46386. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46387. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46388. */
  46389. useMainComponentOnly?: boolean;
  46390. /**
  46391. * Should meshes created here be added to a utility layer or the main scene
  46392. */
  46393. useUtilityLayer?: boolean;
  46394. /**
  46395. * Babylon XR Input class for controller
  46396. */
  46397. xrInput: WebXRInput;
  46398. }
  46399. /**
  46400. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46401. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46402. * the input of the attached controllers.
  46403. */
  46404. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46405. private _options;
  46406. private _controllers;
  46407. private _currentTeleportationControllerId;
  46408. private _floorMeshes;
  46409. private _quadraticBezierCurve;
  46410. private _selectionFeature;
  46411. private _snapToPositions;
  46412. private _snappedToPoint;
  46413. private _teleportationRingMaterial?;
  46414. private _tmpRay;
  46415. private _tmpVector;
  46416. /**
  46417. * The module's name
  46418. */
  46419. static readonly Name: string;
  46420. /**
  46421. * The (Babylon) version of this module.
  46422. * This is an integer representing the implementation version.
  46423. * This number does not correspond to the webxr specs version
  46424. */
  46425. static readonly Version: number;
  46426. /**
  46427. * Is movement backwards enabled
  46428. */
  46429. backwardsMovementEnabled: boolean;
  46430. /**
  46431. * Distance to travel when moving backwards
  46432. */
  46433. backwardsTeleportationDistance: number;
  46434. /**
  46435. * The distance from the user to the inspection point in the direction of the controller
  46436. * A higher number will allow the user to move further
  46437. * defaults to 5 (meters, in xr units)
  46438. */
  46439. parabolicCheckRadius: number;
  46440. /**
  46441. * Should the module support parabolic ray on top of direct ray
  46442. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46443. * Very helpful when moving between floors / different heights
  46444. */
  46445. parabolicRayEnabled: boolean;
  46446. /**
  46447. * How much rotation should be applied when rotating right and left
  46448. */
  46449. rotationAngle: number;
  46450. /**
  46451. * Is rotation enabled when moving forward?
  46452. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46453. */
  46454. rotationEnabled: boolean;
  46455. /**
  46456. * constructs a new anchor system
  46457. * @param _xrSessionManager an instance of WebXRSessionManager
  46458. * @param _options configuration object for this feature
  46459. */
  46460. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46461. /**
  46462. * Get the snapPointsOnly flag
  46463. */
  46464. get snapPointsOnly(): boolean;
  46465. /**
  46466. * Sets the snapPointsOnly flag
  46467. * @param snapToPoints should teleportation be exclusively to snap points
  46468. */
  46469. set snapPointsOnly(snapToPoints: boolean);
  46470. /**
  46471. * Add a new mesh to the floor meshes array
  46472. * @param mesh the mesh to use as floor mesh
  46473. */
  46474. addFloorMesh(mesh: AbstractMesh): void;
  46475. /**
  46476. * Add a new snap-to point to fix teleportation to this position
  46477. * @param newSnapPoint The new Snap-To point
  46478. */
  46479. addSnapPoint(newSnapPoint: Vector3): void;
  46480. attach(): boolean;
  46481. detach(): boolean;
  46482. dispose(): void;
  46483. /**
  46484. * Remove a mesh from the floor meshes array
  46485. * @param mesh the mesh to remove
  46486. */
  46487. removeFloorMesh(mesh: AbstractMesh): void;
  46488. /**
  46489. * Remove a mesh from the floor meshes array using its name
  46490. * @param name the mesh name to remove
  46491. */
  46492. removeFloorMeshByName(name: string): void;
  46493. /**
  46494. * 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
  46495. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46496. * @returns was the point found and removed or not
  46497. */
  46498. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46499. /**
  46500. * This function sets a selection feature that will be disabled when
  46501. * the forward ray is shown and will be reattached when hidden.
  46502. * This is used to remove the selection rays when moving.
  46503. * @param selectionFeature the feature to disable when forward movement is enabled
  46504. */
  46505. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46506. protected _onXRFrame(_xrFrame: XRFrame): void;
  46507. private _attachController;
  46508. private _createDefaultTargetMesh;
  46509. private _detachController;
  46510. private _findClosestSnapPointWithRadius;
  46511. private _setTargetMeshPosition;
  46512. private _setTargetMeshVisibility;
  46513. private _showParabolicPath;
  46514. private _teleportForward;
  46515. }
  46516. }
  46517. declare module "babylonjs/XR/webXRDefaultExperience" {
  46518. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46519. import { Scene } from "babylonjs/scene";
  46520. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46521. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46522. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46523. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46525. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46526. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46527. /**
  46528. * Options for the default xr helper
  46529. */
  46530. export class WebXRDefaultExperienceOptions {
  46531. /**
  46532. * Enable or disable default UI to enter XR
  46533. */
  46534. disableDefaultUI?: boolean;
  46535. /**
  46536. * Should teleportation not initialize. defaults to false.
  46537. */
  46538. disableTeleportation?: boolean;
  46539. /**
  46540. * Floor meshes that will be used for teleport
  46541. */
  46542. floorMeshes?: Array<AbstractMesh>;
  46543. /**
  46544. * If set to true, the first frame will not be used to reset position
  46545. * The first frame is mainly used when copying transformation from the old camera
  46546. * Mainly used in AR
  46547. */
  46548. ignoreNativeCameraTransformation?: boolean;
  46549. /**
  46550. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46551. */
  46552. inputOptions?: IWebXRInputOptions;
  46553. /**
  46554. * optional configuration for the output canvas
  46555. */
  46556. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46557. /**
  46558. * optional UI options. This can be used among other to change session mode and reference space type
  46559. */
  46560. uiOptions?: WebXREnterExitUIOptions;
  46561. /**
  46562. * When loading teleportation and pointer select, use stable versions instead of latest.
  46563. */
  46564. useStablePlugins?: boolean;
  46565. }
  46566. /**
  46567. * Default experience which provides a similar setup to the previous webVRExperience
  46568. */
  46569. export class WebXRDefaultExperience {
  46570. /**
  46571. * Base experience
  46572. */
  46573. baseExperience: WebXRExperienceHelper;
  46574. /**
  46575. * Enables ui for entering/exiting xr
  46576. */
  46577. enterExitUI: WebXREnterExitUI;
  46578. /**
  46579. * Input experience extension
  46580. */
  46581. input: WebXRInput;
  46582. /**
  46583. * Enables laser pointer and selection
  46584. */
  46585. pointerSelection: WebXRControllerPointerSelection;
  46586. /**
  46587. * Default target xr should render to
  46588. */
  46589. renderTarget: WebXRRenderTarget;
  46590. /**
  46591. * Enables teleportation
  46592. */
  46593. teleportation: WebXRMotionControllerTeleportation;
  46594. private constructor();
  46595. /**
  46596. * Creates the default xr experience
  46597. * @param scene scene
  46598. * @param options options for basic configuration
  46599. * @returns resulting WebXRDefaultExperience
  46600. */
  46601. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46602. /**
  46603. * DIsposes of the experience helper
  46604. */
  46605. dispose(): void;
  46606. }
  46607. }
  46608. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46609. import { Observable } from "babylonjs/Misc/observable";
  46610. import { Nullable } from "babylonjs/types";
  46611. import { Camera } from "babylonjs/Cameras/camera";
  46612. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46613. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46614. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46615. import { Scene } from "babylonjs/scene";
  46616. import { Vector3 } from "babylonjs/Maths/math.vector";
  46617. import { Color3 } from "babylonjs/Maths/math.color";
  46618. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46620. import { Mesh } from "babylonjs/Meshes/mesh";
  46621. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46622. import { EasingFunction } from "babylonjs/Animations/easing";
  46623. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46624. import "babylonjs/Meshes/Builders/groundBuilder";
  46625. import "babylonjs/Meshes/Builders/torusBuilder";
  46626. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46627. import "babylonjs/Gamepads/gamepadSceneComponent";
  46628. import "babylonjs/Animations/animatable";
  46629. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46630. /**
  46631. * Options to modify the vr teleportation behavior.
  46632. */
  46633. export interface VRTeleportationOptions {
  46634. /**
  46635. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46636. */
  46637. floorMeshName?: string;
  46638. /**
  46639. * A list of meshes to be used as the teleportation floor. (default: empty)
  46640. */
  46641. floorMeshes?: Mesh[];
  46642. /**
  46643. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46644. */
  46645. teleportationMode?: number;
  46646. /**
  46647. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46648. */
  46649. teleportationTime?: number;
  46650. /**
  46651. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46652. */
  46653. teleportationSpeed?: number;
  46654. /**
  46655. * The easing function used in the animation or null for Linear. (default CircleEase)
  46656. */
  46657. easingFunction?: EasingFunction;
  46658. }
  46659. /**
  46660. * Options to modify the vr experience helper's behavior.
  46661. */
  46662. export interface VRExperienceHelperOptions extends WebVROptions {
  46663. /**
  46664. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46665. */
  46666. createDeviceOrientationCamera?: boolean;
  46667. /**
  46668. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46669. */
  46670. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46671. /**
  46672. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46673. */
  46674. laserToggle?: boolean;
  46675. /**
  46676. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46677. */
  46678. floorMeshes?: Mesh[];
  46679. /**
  46680. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46681. */
  46682. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46683. /**
  46684. * Defines if WebXR should be used instead of WebVR (if available)
  46685. */
  46686. useXR?: boolean;
  46687. }
  46688. /**
  46689. * Event containing information after VR has been entered
  46690. */
  46691. export class OnAfterEnteringVRObservableEvent {
  46692. /**
  46693. * If entering vr was successful
  46694. */
  46695. success: boolean;
  46696. }
  46697. /**
  46698. * Helps to quickly add VR support to an existing scene.
  46699. * See http://doc.babylonjs.com/how_to/webvr_helper
  46700. */
  46701. export class VRExperienceHelper {
  46702. /** Options to modify the vr experience helper's behavior. */
  46703. webVROptions: VRExperienceHelperOptions;
  46704. private _scene;
  46705. private _position;
  46706. private _btnVR;
  46707. private _btnVRDisplayed;
  46708. private _webVRsupported;
  46709. private _webVRready;
  46710. private _webVRrequesting;
  46711. private _webVRpresenting;
  46712. private _hasEnteredVR;
  46713. private _fullscreenVRpresenting;
  46714. private _inputElement;
  46715. private _webVRCamera;
  46716. private _vrDeviceOrientationCamera;
  46717. private _deviceOrientationCamera;
  46718. private _existingCamera;
  46719. private _onKeyDown;
  46720. private _onVrDisplayPresentChange;
  46721. private _onVRDisplayChanged;
  46722. private _onVRRequestPresentStart;
  46723. private _onVRRequestPresentComplete;
  46724. /**
  46725. * 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)
  46726. */
  46727. enableGazeEvenWhenNoPointerLock: boolean;
  46728. /**
  46729. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46730. */
  46731. exitVROnDoubleTap: boolean;
  46732. /**
  46733. * Observable raised right before entering VR.
  46734. */
  46735. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46736. /**
  46737. * Observable raised when entering VR has completed.
  46738. */
  46739. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46740. /**
  46741. * Observable raised when exiting VR.
  46742. */
  46743. onExitingVRObservable: Observable<VRExperienceHelper>;
  46744. /**
  46745. * Observable raised when controller mesh is loaded.
  46746. */
  46747. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46748. /** Return this.onEnteringVRObservable
  46749. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46750. */
  46751. get onEnteringVR(): Observable<VRExperienceHelper>;
  46752. /** Return this.onExitingVRObservable
  46753. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46754. */
  46755. get onExitingVR(): Observable<VRExperienceHelper>;
  46756. /** Return this.onControllerMeshLoadedObservable
  46757. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46758. */
  46759. get onControllerMeshLoaded(): Observable<WebVRController>;
  46760. private _rayLength;
  46761. private _useCustomVRButton;
  46762. private _teleportationRequested;
  46763. private _teleportActive;
  46764. private _floorMeshName;
  46765. private _floorMeshesCollection;
  46766. private _teleportationMode;
  46767. private _teleportationTime;
  46768. private _teleportationSpeed;
  46769. private _teleportationEasing;
  46770. private _rotationAllowed;
  46771. private _teleportBackwardsVector;
  46772. private _teleportationTarget;
  46773. private _isDefaultTeleportationTarget;
  46774. private _postProcessMove;
  46775. private _teleportationFillColor;
  46776. private _teleportationBorderColor;
  46777. private _rotationAngle;
  46778. private _haloCenter;
  46779. private _cameraGazer;
  46780. private _padSensibilityUp;
  46781. private _padSensibilityDown;
  46782. private _leftController;
  46783. private _rightController;
  46784. private _gazeColor;
  46785. private _laserColor;
  46786. private _pickedLaserColor;
  46787. private _pickedGazeColor;
  46788. /**
  46789. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46790. */
  46791. onNewMeshSelected: Observable<AbstractMesh>;
  46792. /**
  46793. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46794. * This observable will provide the mesh and the controller used to select the mesh
  46795. */
  46796. onMeshSelectedWithController: Observable<{
  46797. mesh: AbstractMesh;
  46798. controller: WebVRController;
  46799. }>;
  46800. /**
  46801. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46802. */
  46803. onNewMeshPicked: Observable<PickingInfo>;
  46804. private _circleEase;
  46805. /**
  46806. * Observable raised before camera teleportation
  46807. */
  46808. onBeforeCameraTeleport: Observable<Vector3>;
  46809. /**
  46810. * Observable raised after camera teleportation
  46811. */
  46812. onAfterCameraTeleport: Observable<Vector3>;
  46813. /**
  46814. * Observable raised when current selected mesh gets unselected
  46815. */
  46816. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46817. private _raySelectionPredicate;
  46818. /**
  46819. * To be optionaly changed by user to define custom ray selection
  46820. */
  46821. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46822. /**
  46823. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46824. */
  46825. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46826. /**
  46827. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46828. */
  46829. teleportationEnabled: boolean;
  46830. private _defaultHeight;
  46831. private _teleportationInitialized;
  46832. private _interactionsEnabled;
  46833. private _interactionsRequested;
  46834. private _displayGaze;
  46835. private _displayLaserPointer;
  46836. /**
  46837. * The mesh used to display where the user is going to teleport.
  46838. */
  46839. get teleportationTarget(): Mesh;
  46840. /**
  46841. * Sets the mesh to be used to display where the user is going to teleport.
  46842. */
  46843. set teleportationTarget(value: Mesh);
  46844. /**
  46845. * 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
  46846. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46847. * See http://doc.babylonjs.com/resources/baking_transformations
  46848. */
  46849. get gazeTrackerMesh(): Mesh;
  46850. set gazeTrackerMesh(value: Mesh);
  46851. /**
  46852. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46853. */
  46854. updateGazeTrackerScale: boolean;
  46855. /**
  46856. * If the gaze trackers color should be updated when selecting meshes
  46857. */
  46858. updateGazeTrackerColor: boolean;
  46859. /**
  46860. * If the controller laser color should be updated when selecting meshes
  46861. */
  46862. updateControllerLaserColor: boolean;
  46863. /**
  46864. * The gaze tracking mesh corresponding to the left controller
  46865. */
  46866. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46867. /**
  46868. * The gaze tracking mesh corresponding to the right controller
  46869. */
  46870. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46871. /**
  46872. * If the ray of the gaze should be displayed.
  46873. */
  46874. get displayGaze(): boolean;
  46875. /**
  46876. * Sets if the ray of the gaze should be displayed.
  46877. */
  46878. set displayGaze(value: boolean);
  46879. /**
  46880. * If the ray of the LaserPointer should be displayed.
  46881. */
  46882. get displayLaserPointer(): boolean;
  46883. /**
  46884. * Sets if the ray of the LaserPointer should be displayed.
  46885. */
  46886. set displayLaserPointer(value: boolean);
  46887. /**
  46888. * The deviceOrientationCamera used as the camera when not in VR.
  46889. */
  46890. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46891. /**
  46892. * Based on the current WebVR support, returns the current VR camera used.
  46893. */
  46894. get currentVRCamera(): Nullable<Camera>;
  46895. /**
  46896. * The webVRCamera which is used when in VR.
  46897. */
  46898. get webVRCamera(): WebVRFreeCamera;
  46899. /**
  46900. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46901. */
  46902. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46903. /**
  46904. * The html button that is used to trigger entering into VR.
  46905. */
  46906. get vrButton(): Nullable<HTMLButtonElement>;
  46907. private get _teleportationRequestInitiated();
  46908. /**
  46909. * Defines whether or not Pointer lock should be requested when switching to
  46910. * full screen.
  46911. */
  46912. requestPointerLockOnFullScreen: boolean;
  46913. /**
  46914. * If asking to force XR, this will be populated with the default xr experience
  46915. */
  46916. xr: WebXRDefaultExperience;
  46917. /**
  46918. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46919. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46920. */
  46921. xrTestDone: boolean;
  46922. /**
  46923. * Instantiates a VRExperienceHelper.
  46924. * Helps to quickly add VR support to an existing scene.
  46925. * @param scene The scene the VRExperienceHelper belongs to.
  46926. * @param webVROptions Options to modify the vr experience helper's behavior.
  46927. */
  46928. constructor(scene: Scene,
  46929. /** Options to modify the vr experience helper's behavior. */
  46930. webVROptions?: VRExperienceHelperOptions);
  46931. private completeVRInit;
  46932. private _onDefaultMeshLoaded;
  46933. private _onResize;
  46934. private _onFullscreenChange;
  46935. /**
  46936. * Gets a value indicating if we are currently in VR mode.
  46937. */
  46938. get isInVRMode(): boolean;
  46939. private onVrDisplayPresentChange;
  46940. private onVRDisplayChanged;
  46941. private moveButtonToBottomRight;
  46942. private displayVRButton;
  46943. private updateButtonVisibility;
  46944. private _cachedAngularSensibility;
  46945. /**
  46946. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46947. * Otherwise, will use the fullscreen API.
  46948. */
  46949. enterVR(): void;
  46950. /**
  46951. * Attempt to exit VR, or fullscreen.
  46952. */
  46953. exitVR(): void;
  46954. /**
  46955. * The position of the vr experience helper.
  46956. */
  46957. get position(): Vector3;
  46958. /**
  46959. * Sets the position of the vr experience helper.
  46960. */
  46961. set position(value: Vector3);
  46962. /**
  46963. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46964. */
  46965. enableInteractions(): void;
  46966. private get _noControllerIsActive();
  46967. private beforeRender;
  46968. private _isTeleportationFloor;
  46969. /**
  46970. * Adds a floor mesh to be used for teleportation.
  46971. * @param floorMesh the mesh to be used for teleportation.
  46972. */
  46973. addFloorMesh(floorMesh: Mesh): void;
  46974. /**
  46975. * Removes a floor mesh from being used for teleportation.
  46976. * @param floorMesh the mesh to be removed.
  46977. */
  46978. removeFloorMesh(floorMesh: Mesh): void;
  46979. /**
  46980. * Enables interactions and teleportation using the VR controllers and gaze.
  46981. * @param vrTeleportationOptions options to modify teleportation behavior.
  46982. */
  46983. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46984. private _onNewGamepadConnected;
  46985. private _tryEnableInteractionOnController;
  46986. private _onNewGamepadDisconnected;
  46987. private _enableInteractionOnController;
  46988. private _checkTeleportWithRay;
  46989. private _checkRotate;
  46990. private _checkTeleportBackwards;
  46991. private _enableTeleportationOnController;
  46992. private _createTeleportationCircles;
  46993. private _displayTeleportationTarget;
  46994. private _hideTeleportationTarget;
  46995. private _rotateCamera;
  46996. private _moveTeleportationSelectorTo;
  46997. private _workingVector;
  46998. private _workingQuaternion;
  46999. private _workingMatrix;
  47000. /**
  47001. * Time Constant Teleportation Mode
  47002. */
  47003. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47004. /**
  47005. * Speed Constant Teleportation Mode
  47006. */
  47007. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47008. /**
  47009. * Teleports the users feet to the desired location
  47010. * @param location The location where the user's feet should be placed
  47011. */
  47012. teleportCamera(location: Vector3): void;
  47013. private _convertNormalToDirectionOfRay;
  47014. private _castRayAndSelectObject;
  47015. private _notifySelectedMeshUnselected;
  47016. /**
  47017. * Permanently set new colors for the laser pointer
  47018. * @param color the new laser color
  47019. * @param pickedColor the new laser color when picked mesh detected
  47020. */
  47021. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47022. /**
  47023. * Set lighting enabled / disabled on the laser pointer of both controllers
  47024. * @param enabled should the lighting be enabled on the laser pointer
  47025. */
  47026. setLaserLightingState(enabled?: boolean): void;
  47027. /**
  47028. * Permanently set new colors for the gaze pointer
  47029. * @param color the new gaze color
  47030. * @param pickedColor the new gaze color when picked mesh detected
  47031. */
  47032. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47033. /**
  47034. * Sets the color of the laser ray from the vr controllers.
  47035. * @param color new color for the ray.
  47036. */
  47037. changeLaserColor(color: Color3): void;
  47038. /**
  47039. * Sets the color of the ray from the vr headsets gaze.
  47040. * @param color new color for the ray.
  47041. */
  47042. changeGazeColor(color: Color3): void;
  47043. /**
  47044. * Exits VR and disposes of the vr experience helper
  47045. */
  47046. dispose(): void;
  47047. /**
  47048. * Gets the name of the VRExperienceHelper class
  47049. * @returns "VRExperienceHelper"
  47050. */
  47051. getClassName(): string;
  47052. }
  47053. }
  47054. declare module "babylonjs/Cameras/VR/index" {
  47055. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47056. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47057. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47058. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47059. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47060. export * from "babylonjs/Cameras/VR/webVRCamera";
  47061. }
  47062. declare module "babylonjs/Cameras/RigModes/index" {
  47063. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47064. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47065. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47066. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47067. }
  47068. declare module "babylonjs/Cameras/index" {
  47069. export * from "babylonjs/Cameras/Inputs/index";
  47070. export * from "babylonjs/Cameras/cameraInputsManager";
  47071. export * from "babylonjs/Cameras/camera";
  47072. export * from "babylonjs/Cameras/targetCamera";
  47073. export * from "babylonjs/Cameras/freeCamera";
  47074. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47075. export * from "babylonjs/Cameras/touchCamera";
  47076. export * from "babylonjs/Cameras/arcRotateCamera";
  47077. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47078. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47079. export * from "babylonjs/Cameras/flyCamera";
  47080. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47081. export * from "babylonjs/Cameras/followCamera";
  47082. export * from "babylonjs/Cameras/followCameraInputsManager";
  47083. export * from "babylonjs/Cameras/gamepadCamera";
  47084. export * from "babylonjs/Cameras/Stereoscopic/index";
  47085. export * from "babylonjs/Cameras/universalCamera";
  47086. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47087. export * from "babylonjs/Cameras/VR/index";
  47088. export * from "babylonjs/Cameras/RigModes/index";
  47089. }
  47090. declare module "babylonjs/Collisions/index" {
  47091. export * from "babylonjs/Collisions/collider";
  47092. export * from "babylonjs/Collisions/collisionCoordinator";
  47093. export * from "babylonjs/Collisions/pickingInfo";
  47094. export * from "babylonjs/Collisions/intersectionInfo";
  47095. export * from "babylonjs/Collisions/meshCollisionData";
  47096. }
  47097. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47098. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47099. import { Vector3 } from "babylonjs/Maths/math.vector";
  47100. import { Ray } from "babylonjs/Culling/ray";
  47101. import { Plane } from "babylonjs/Maths/math.plane";
  47102. /**
  47103. * Contains an array of blocks representing the octree
  47104. */
  47105. export interface IOctreeContainer<T> {
  47106. /**
  47107. * Blocks within the octree
  47108. */
  47109. blocks: Array<OctreeBlock<T>>;
  47110. }
  47111. /**
  47112. * Class used to store a cell in an octree
  47113. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47114. */
  47115. export class OctreeBlock<T> {
  47116. /**
  47117. * Gets the content of the current block
  47118. */
  47119. entries: T[];
  47120. /**
  47121. * Gets the list of block children
  47122. */
  47123. blocks: Array<OctreeBlock<T>>;
  47124. private _depth;
  47125. private _maxDepth;
  47126. private _capacity;
  47127. private _minPoint;
  47128. private _maxPoint;
  47129. private _boundingVectors;
  47130. private _creationFunc;
  47131. /**
  47132. * Creates a new block
  47133. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47134. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47135. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47136. * @param depth defines the current depth of this block in the octree
  47137. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47138. * @param creationFunc defines a callback to call when an element is added to the block
  47139. */
  47140. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47141. /**
  47142. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47143. */
  47144. get capacity(): number;
  47145. /**
  47146. * Gets the minimum vector (in world space) of the block's bounding box
  47147. */
  47148. get minPoint(): Vector3;
  47149. /**
  47150. * Gets the maximum vector (in world space) of the block's bounding box
  47151. */
  47152. get maxPoint(): Vector3;
  47153. /**
  47154. * Add a new element to this block
  47155. * @param entry defines the element to add
  47156. */
  47157. addEntry(entry: T): void;
  47158. /**
  47159. * Remove an element from this block
  47160. * @param entry defines the element to remove
  47161. */
  47162. removeEntry(entry: T): void;
  47163. /**
  47164. * Add an array of elements to this block
  47165. * @param entries defines the array of elements to add
  47166. */
  47167. addEntries(entries: T[]): void;
  47168. /**
  47169. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47170. * @param frustumPlanes defines the frustum planes to test
  47171. * @param selection defines the array to store current content if selection is positive
  47172. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47173. */
  47174. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47175. /**
  47176. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47177. * @param sphereCenter defines the bounding sphere center
  47178. * @param sphereRadius defines the bounding sphere radius
  47179. * @param selection defines the array to store current content if selection is positive
  47180. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47181. */
  47182. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47183. /**
  47184. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47185. * @param ray defines the ray to test with
  47186. * @param selection defines the array to store current content if selection is positive
  47187. */
  47188. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47189. /**
  47190. * Subdivide the content into child blocks (this block will then be empty)
  47191. */
  47192. createInnerBlocks(): void;
  47193. /**
  47194. * @hidden
  47195. */
  47196. 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;
  47197. }
  47198. }
  47199. declare module "babylonjs/Culling/Octrees/octree" {
  47200. import { SmartArray } from "babylonjs/Misc/smartArray";
  47201. import { Vector3 } from "babylonjs/Maths/math.vector";
  47202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47204. import { Ray } from "babylonjs/Culling/ray";
  47205. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47206. import { Plane } from "babylonjs/Maths/math.plane";
  47207. /**
  47208. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47209. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47210. */
  47211. export class Octree<T> {
  47212. /** 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.) */
  47213. maxDepth: number;
  47214. /**
  47215. * Blocks within the octree containing objects
  47216. */
  47217. blocks: Array<OctreeBlock<T>>;
  47218. /**
  47219. * Content stored in the octree
  47220. */
  47221. dynamicContent: T[];
  47222. private _maxBlockCapacity;
  47223. private _selectionContent;
  47224. private _creationFunc;
  47225. /**
  47226. * Creates a octree
  47227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47228. * @param creationFunc function to be used to instatiate the octree
  47229. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47230. * @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.)
  47231. */
  47232. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47233. /** 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.) */
  47234. maxDepth?: number);
  47235. /**
  47236. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47237. * @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);
  47238. * @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);
  47239. * @param entries meshes to be added to the octree blocks
  47240. */
  47241. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47242. /**
  47243. * Adds a mesh to the octree
  47244. * @param entry Mesh to add to the octree
  47245. */
  47246. addMesh(entry: T): void;
  47247. /**
  47248. * Remove an element from the octree
  47249. * @param entry defines the element to remove
  47250. */
  47251. removeMesh(entry: T): void;
  47252. /**
  47253. * Selects an array of meshes within the frustum
  47254. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47255. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47256. * @returns array of meshes within the frustum
  47257. */
  47258. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47259. /**
  47260. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47261. * @param sphereCenter defines the bounding sphere center
  47262. * @param sphereRadius defines the bounding sphere radius
  47263. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47264. * @returns an array of objects that intersect the sphere
  47265. */
  47266. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47267. /**
  47268. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47269. * @param ray defines the ray to test with
  47270. * @returns array of intersected objects
  47271. */
  47272. intersectsRay(ray: Ray): SmartArray<T>;
  47273. /**
  47274. * Adds a mesh into the octree block if it intersects the block
  47275. */
  47276. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47277. /**
  47278. * Adds a submesh into the octree block if it intersects the block
  47279. */
  47280. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47281. }
  47282. }
  47283. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47284. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47285. import { Scene } from "babylonjs/scene";
  47286. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47288. import { Ray } from "babylonjs/Culling/ray";
  47289. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47290. import { Collider } from "babylonjs/Collisions/collider";
  47291. module "babylonjs/scene" {
  47292. interface Scene {
  47293. /**
  47294. * @hidden
  47295. * Backing Filed
  47296. */
  47297. _selectionOctree: Octree<AbstractMesh>;
  47298. /**
  47299. * Gets the octree used to boost mesh selection (picking)
  47300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47301. */
  47302. selectionOctree: Octree<AbstractMesh>;
  47303. /**
  47304. * Creates or updates the octree used to boost selection (picking)
  47305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47306. * @param maxCapacity defines the maximum capacity per leaf
  47307. * @param maxDepth defines the maximum depth of the octree
  47308. * @returns an octree of AbstractMesh
  47309. */
  47310. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47311. }
  47312. }
  47313. module "babylonjs/Meshes/abstractMesh" {
  47314. interface AbstractMesh {
  47315. /**
  47316. * @hidden
  47317. * Backing Field
  47318. */
  47319. _submeshesOctree: Octree<SubMesh>;
  47320. /**
  47321. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47322. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47323. * @param maxCapacity defines the maximum size of each block (64 by default)
  47324. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47325. * @returns the new octree
  47326. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47328. */
  47329. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47330. }
  47331. }
  47332. /**
  47333. * Defines the octree scene component responsible to manage any octrees
  47334. * in a given scene.
  47335. */
  47336. export class OctreeSceneComponent {
  47337. /**
  47338. * The component name help to identify the component in the list of scene components.
  47339. */
  47340. readonly name: string;
  47341. /**
  47342. * The scene the component belongs to.
  47343. */
  47344. scene: Scene;
  47345. /**
  47346. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47347. */
  47348. readonly checksIsEnabled: boolean;
  47349. /**
  47350. * Creates a new instance of the component for the given scene
  47351. * @param scene Defines the scene to register the component in
  47352. */
  47353. constructor(scene: Scene);
  47354. /**
  47355. * Registers the component in a given scene
  47356. */
  47357. register(): void;
  47358. /**
  47359. * Return the list of active meshes
  47360. * @returns the list of active meshes
  47361. */
  47362. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47363. /**
  47364. * Return the list of active sub meshes
  47365. * @param mesh The mesh to get the candidates sub meshes from
  47366. * @returns the list of active sub meshes
  47367. */
  47368. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47369. private _tempRay;
  47370. /**
  47371. * Return the list of sub meshes intersecting with a given local ray
  47372. * @param mesh defines the mesh to find the submesh for
  47373. * @param localRay defines the ray in local space
  47374. * @returns the list of intersecting sub meshes
  47375. */
  47376. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47377. /**
  47378. * Return the list of sub meshes colliding with a collider
  47379. * @param mesh defines the mesh to find the submesh for
  47380. * @param collider defines the collider to evaluate the collision against
  47381. * @returns the list of colliding sub meshes
  47382. */
  47383. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47384. /**
  47385. * Rebuilds the elements related to this component in case of
  47386. * context lost for instance.
  47387. */
  47388. rebuild(): void;
  47389. /**
  47390. * Disposes the component and the associated ressources.
  47391. */
  47392. dispose(): void;
  47393. }
  47394. }
  47395. declare module "babylonjs/Culling/Octrees/index" {
  47396. export * from "babylonjs/Culling/Octrees/octree";
  47397. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47398. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47399. }
  47400. declare module "babylonjs/Culling/index" {
  47401. export * from "babylonjs/Culling/boundingBox";
  47402. export * from "babylonjs/Culling/boundingInfo";
  47403. export * from "babylonjs/Culling/boundingSphere";
  47404. export * from "babylonjs/Culling/Octrees/index";
  47405. export * from "babylonjs/Culling/ray";
  47406. }
  47407. declare module "babylonjs/Gizmos/gizmo" {
  47408. import { Nullable } from "babylonjs/types";
  47409. import { IDisposable } from "babylonjs/scene";
  47410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47411. import { Mesh } from "babylonjs/Meshes/mesh";
  47412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47413. /**
  47414. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47415. */
  47416. export class Gizmo implements IDisposable {
  47417. /** The utility layer the gizmo will be added to */
  47418. gizmoLayer: UtilityLayerRenderer;
  47419. /**
  47420. * The root mesh of the gizmo
  47421. */
  47422. _rootMesh: Mesh;
  47423. private _attachedMesh;
  47424. /**
  47425. * Ratio for the scale of the gizmo (Default: 1)
  47426. */
  47427. scaleRatio: number;
  47428. /**
  47429. * If a custom mesh has been set (Default: false)
  47430. */
  47431. protected _customMeshSet: boolean;
  47432. /**
  47433. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47434. * * When set, interactions will be enabled
  47435. */
  47436. get attachedMesh(): Nullable<AbstractMesh>;
  47437. set attachedMesh(value: Nullable<AbstractMesh>);
  47438. /**
  47439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47440. * @param mesh The mesh to replace the default mesh of the gizmo
  47441. */
  47442. setCustomMesh(mesh: Mesh): void;
  47443. /**
  47444. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47445. */
  47446. updateGizmoRotationToMatchAttachedMesh: boolean;
  47447. /**
  47448. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47449. */
  47450. updateGizmoPositionToMatchAttachedMesh: boolean;
  47451. /**
  47452. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47453. */
  47454. updateScale: boolean;
  47455. protected _interactionsEnabled: boolean;
  47456. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47457. private _beforeRenderObserver;
  47458. private _tempVector;
  47459. /**
  47460. * Creates a gizmo
  47461. * @param gizmoLayer The utility layer the gizmo will be added to
  47462. */
  47463. constructor(
  47464. /** The utility layer the gizmo will be added to */
  47465. gizmoLayer?: UtilityLayerRenderer);
  47466. /**
  47467. * Updates the gizmo to match the attached mesh's position/rotation
  47468. */
  47469. protected _update(): void;
  47470. /**
  47471. * Disposes of the gizmo
  47472. */
  47473. dispose(): void;
  47474. }
  47475. }
  47476. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47477. import { Observable } from "babylonjs/Misc/observable";
  47478. import { Nullable } from "babylonjs/types";
  47479. import { Vector3 } from "babylonjs/Maths/math.vector";
  47480. import { Color3 } from "babylonjs/Maths/math.color";
  47481. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47483. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47484. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47486. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47487. import { Scene } from "babylonjs/scene";
  47488. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47489. /**
  47490. * Single plane drag gizmo
  47491. */
  47492. export class PlaneDragGizmo extends Gizmo {
  47493. /**
  47494. * Drag behavior responsible for the gizmos dragging interactions
  47495. */
  47496. dragBehavior: PointerDragBehavior;
  47497. private _pointerObserver;
  47498. /**
  47499. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47500. */
  47501. snapDistance: number;
  47502. /**
  47503. * Event that fires each time the gizmo snaps to a new location.
  47504. * * snapDistance is the the change in distance
  47505. */
  47506. onSnapObservable: Observable<{
  47507. snapDistance: number;
  47508. }>;
  47509. private _plane;
  47510. private _coloredMaterial;
  47511. private _hoverMaterial;
  47512. private _isEnabled;
  47513. private _parent;
  47514. /** @hidden */
  47515. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47516. /** @hidden */
  47517. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47518. /**
  47519. * Creates a PlaneDragGizmo
  47520. * @param gizmoLayer The utility layer the gizmo will be added to
  47521. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47522. * @param color The color of the gizmo
  47523. */
  47524. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47525. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47526. /**
  47527. * If the gizmo is enabled
  47528. */
  47529. set isEnabled(value: boolean);
  47530. get isEnabled(): boolean;
  47531. /**
  47532. * Disposes of the gizmo
  47533. */
  47534. dispose(): void;
  47535. }
  47536. }
  47537. declare module "babylonjs/Gizmos/positionGizmo" {
  47538. import { Observable } from "babylonjs/Misc/observable";
  47539. import { Nullable } from "babylonjs/types";
  47540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47541. import { Mesh } from "babylonjs/Meshes/mesh";
  47542. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47543. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47544. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47545. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47546. /**
  47547. * Gizmo that enables dragging a mesh along 3 axis
  47548. */
  47549. export class PositionGizmo extends Gizmo {
  47550. /**
  47551. * Internal gizmo used for interactions on the x axis
  47552. */
  47553. xGizmo: AxisDragGizmo;
  47554. /**
  47555. * Internal gizmo used for interactions on the y axis
  47556. */
  47557. yGizmo: AxisDragGizmo;
  47558. /**
  47559. * Internal gizmo used for interactions on the z axis
  47560. */
  47561. zGizmo: AxisDragGizmo;
  47562. /**
  47563. * Internal gizmo used for interactions on the yz plane
  47564. */
  47565. xPlaneGizmo: PlaneDragGizmo;
  47566. /**
  47567. * Internal gizmo used for interactions on the xz plane
  47568. */
  47569. yPlaneGizmo: PlaneDragGizmo;
  47570. /**
  47571. * Internal gizmo used for interactions on the xy plane
  47572. */
  47573. zPlaneGizmo: PlaneDragGizmo;
  47574. /**
  47575. * private variables
  47576. */
  47577. private _meshAttached;
  47578. private _updateGizmoRotationToMatchAttachedMesh;
  47579. private _snapDistance;
  47580. private _scaleRatio;
  47581. /** Fires an event when any of it's sub gizmos are dragged */
  47582. onDragStartObservable: Observable<unknown>;
  47583. /** Fires an event when any of it's sub gizmos are released from dragging */
  47584. onDragEndObservable: Observable<unknown>;
  47585. /**
  47586. * If set to true, planar drag is enabled
  47587. */
  47588. private _planarGizmoEnabled;
  47589. get attachedMesh(): Nullable<AbstractMesh>;
  47590. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47591. /**
  47592. * Creates a PositionGizmo
  47593. * @param gizmoLayer The utility layer the gizmo will be added to
  47594. */
  47595. constructor(gizmoLayer?: UtilityLayerRenderer);
  47596. /**
  47597. * If the planar drag gizmo is enabled
  47598. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47599. */
  47600. set planarGizmoEnabled(value: boolean);
  47601. get planarGizmoEnabled(): boolean;
  47602. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47603. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47604. /**
  47605. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47606. */
  47607. set snapDistance(value: number);
  47608. get snapDistance(): number;
  47609. /**
  47610. * Ratio for the scale of the gizmo (Default: 1)
  47611. */
  47612. set scaleRatio(value: number);
  47613. get scaleRatio(): number;
  47614. /**
  47615. * Disposes of the gizmo
  47616. */
  47617. dispose(): void;
  47618. /**
  47619. * CustomMeshes are not supported by this gizmo
  47620. * @param mesh The mesh to replace the default mesh of the gizmo
  47621. */
  47622. setCustomMesh(mesh: Mesh): void;
  47623. }
  47624. }
  47625. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47626. import { Observable } from "babylonjs/Misc/observable";
  47627. import { Nullable } from "babylonjs/types";
  47628. import { Vector3 } from "babylonjs/Maths/math.vector";
  47629. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47631. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47632. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47633. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47634. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47635. import { Scene } from "babylonjs/scene";
  47636. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47637. import { Color3 } from "babylonjs/Maths/math.color";
  47638. /**
  47639. * Single axis drag gizmo
  47640. */
  47641. export class AxisDragGizmo extends Gizmo {
  47642. /**
  47643. * Drag behavior responsible for the gizmos dragging interactions
  47644. */
  47645. dragBehavior: PointerDragBehavior;
  47646. private _pointerObserver;
  47647. /**
  47648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47649. */
  47650. snapDistance: number;
  47651. /**
  47652. * Event that fires each time the gizmo snaps to a new location.
  47653. * * snapDistance is the the change in distance
  47654. */
  47655. onSnapObservable: Observable<{
  47656. snapDistance: number;
  47657. }>;
  47658. private _isEnabled;
  47659. private _parent;
  47660. private _arrow;
  47661. private _coloredMaterial;
  47662. private _hoverMaterial;
  47663. /** @hidden */
  47664. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47665. /** @hidden */
  47666. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47667. /**
  47668. * Creates an AxisDragGizmo
  47669. * @param gizmoLayer The utility layer the gizmo will be added to
  47670. * @param dragAxis The axis which the gizmo will be able to drag on
  47671. * @param color The color of the gizmo
  47672. */
  47673. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47675. /**
  47676. * If the gizmo is enabled
  47677. */
  47678. set isEnabled(value: boolean);
  47679. get isEnabled(): boolean;
  47680. /**
  47681. * Disposes of the gizmo
  47682. */
  47683. dispose(): void;
  47684. }
  47685. }
  47686. declare module "babylonjs/Debug/axesViewer" {
  47687. import { Vector3 } from "babylonjs/Maths/math.vector";
  47688. import { Nullable } from "babylonjs/types";
  47689. import { Scene } from "babylonjs/scene";
  47690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47691. /**
  47692. * The Axes viewer will show 3 axes in a specific point in space
  47693. */
  47694. export class AxesViewer {
  47695. private _xAxis;
  47696. private _yAxis;
  47697. private _zAxis;
  47698. private _scaleLinesFactor;
  47699. private _instanced;
  47700. /**
  47701. * Gets the hosting scene
  47702. */
  47703. scene: Scene;
  47704. /**
  47705. * Gets or sets a number used to scale line length
  47706. */
  47707. scaleLines: number;
  47708. /** Gets the node hierarchy used to render x-axis */
  47709. get xAxis(): TransformNode;
  47710. /** Gets the node hierarchy used to render y-axis */
  47711. get yAxis(): TransformNode;
  47712. /** Gets the node hierarchy used to render z-axis */
  47713. get zAxis(): TransformNode;
  47714. /**
  47715. * Creates a new AxesViewer
  47716. * @param scene defines the hosting scene
  47717. * @param scaleLines defines a number used to scale line length (1 by default)
  47718. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47719. * @param xAxis defines the node hierarchy used to render the x-axis
  47720. * @param yAxis defines the node hierarchy used to render the y-axis
  47721. * @param zAxis defines the node hierarchy used to render the z-axis
  47722. */
  47723. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47724. /**
  47725. * Force the viewer to update
  47726. * @param position defines the position of the viewer
  47727. * @param xaxis defines the x axis of the viewer
  47728. * @param yaxis defines the y axis of the viewer
  47729. * @param zaxis defines the z axis of the viewer
  47730. */
  47731. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47732. /**
  47733. * Creates an instance of this axes viewer.
  47734. * @returns a new axes viewer with instanced meshes
  47735. */
  47736. createInstance(): AxesViewer;
  47737. /** Releases resources */
  47738. dispose(): void;
  47739. private static _SetRenderingGroupId;
  47740. }
  47741. }
  47742. declare module "babylonjs/Debug/boneAxesViewer" {
  47743. import { Nullable } from "babylonjs/types";
  47744. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47745. import { Vector3 } from "babylonjs/Maths/math.vector";
  47746. import { Mesh } from "babylonjs/Meshes/mesh";
  47747. import { Bone } from "babylonjs/Bones/bone";
  47748. import { Scene } from "babylonjs/scene";
  47749. /**
  47750. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47751. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47752. */
  47753. export class BoneAxesViewer extends AxesViewer {
  47754. /**
  47755. * Gets or sets the target mesh where to display the axes viewer
  47756. */
  47757. mesh: Nullable<Mesh>;
  47758. /**
  47759. * Gets or sets the target bone where to display the axes viewer
  47760. */
  47761. bone: Nullable<Bone>;
  47762. /** Gets current position */
  47763. pos: Vector3;
  47764. /** Gets direction of X axis */
  47765. xaxis: Vector3;
  47766. /** Gets direction of Y axis */
  47767. yaxis: Vector3;
  47768. /** Gets direction of Z axis */
  47769. zaxis: Vector3;
  47770. /**
  47771. * Creates a new BoneAxesViewer
  47772. * @param scene defines the hosting scene
  47773. * @param bone defines the target bone
  47774. * @param mesh defines the target mesh
  47775. * @param scaleLines defines a scaling factor for line length (1 by default)
  47776. */
  47777. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47778. /**
  47779. * Force the viewer to update
  47780. */
  47781. update(): void;
  47782. /** Releases resources */
  47783. dispose(): void;
  47784. }
  47785. }
  47786. declare module "babylonjs/Debug/debugLayer" {
  47787. import { Scene } from "babylonjs/scene";
  47788. /**
  47789. * Interface used to define scene explorer extensibility option
  47790. */
  47791. export interface IExplorerExtensibilityOption {
  47792. /**
  47793. * Define the option label
  47794. */
  47795. label: string;
  47796. /**
  47797. * Defines the action to execute on click
  47798. */
  47799. action: (entity: any) => void;
  47800. }
  47801. /**
  47802. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47803. */
  47804. export interface IExplorerExtensibilityGroup {
  47805. /**
  47806. * Defines a predicate to test if a given type mut be extended
  47807. */
  47808. predicate: (entity: any) => boolean;
  47809. /**
  47810. * Gets the list of options added to a type
  47811. */
  47812. entries: IExplorerExtensibilityOption[];
  47813. }
  47814. /**
  47815. * Interface used to define the options to use to create the Inspector
  47816. */
  47817. export interface IInspectorOptions {
  47818. /**
  47819. * Display in overlay mode (default: false)
  47820. */
  47821. overlay?: boolean;
  47822. /**
  47823. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47824. */
  47825. globalRoot?: HTMLElement;
  47826. /**
  47827. * Display the Scene explorer
  47828. */
  47829. showExplorer?: boolean;
  47830. /**
  47831. * Display the property inspector
  47832. */
  47833. showInspector?: boolean;
  47834. /**
  47835. * Display in embed mode (both panes on the right)
  47836. */
  47837. embedMode?: boolean;
  47838. /**
  47839. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47840. */
  47841. handleResize?: boolean;
  47842. /**
  47843. * Allow the panes to popup (default: true)
  47844. */
  47845. enablePopup?: boolean;
  47846. /**
  47847. * Allow the panes to be closed by users (default: true)
  47848. */
  47849. enableClose?: boolean;
  47850. /**
  47851. * Optional list of extensibility entries
  47852. */
  47853. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47854. /**
  47855. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47856. */
  47857. inspectorURL?: string;
  47858. /**
  47859. * Optional initial tab (default to DebugLayerTab.Properties)
  47860. */
  47861. initialTab?: DebugLayerTab;
  47862. }
  47863. module "babylonjs/scene" {
  47864. interface Scene {
  47865. /**
  47866. * @hidden
  47867. * Backing field
  47868. */
  47869. _debugLayer: DebugLayer;
  47870. /**
  47871. * Gets the debug layer (aka Inspector) associated with the scene
  47872. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47873. */
  47874. debugLayer: DebugLayer;
  47875. }
  47876. }
  47877. /**
  47878. * Enum of inspector action tab
  47879. */
  47880. export enum DebugLayerTab {
  47881. /**
  47882. * Properties tag (default)
  47883. */
  47884. Properties = 0,
  47885. /**
  47886. * Debug tab
  47887. */
  47888. Debug = 1,
  47889. /**
  47890. * Statistics tab
  47891. */
  47892. Statistics = 2,
  47893. /**
  47894. * Tools tab
  47895. */
  47896. Tools = 3,
  47897. /**
  47898. * Settings tab
  47899. */
  47900. Settings = 4
  47901. }
  47902. /**
  47903. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47904. * what is happening in your scene
  47905. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47906. */
  47907. export class DebugLayer {
  47908. /**
  47909. * Define the url to get the inspector script from.
  47910. * By default it uses the babylonjs CDN.
  47911. * @ignoreNaming
  47912. */
  47913. static InspectorURL: string;
  47914. private _scene;
  47915. private BJSINSPECTOR;
  47916. private _onPropertyChangedObservable?;
  47917. /**
  47918. * Observable triggered when a property is changed through the inspector.
  47919. */
  47920. get onPropertyChangedObservable(): any;
  47921. /**
  47922. * Instantiates a new debug layer.
  47923. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47924. * what is happening in your scene
  47925. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47926. * @param scene Defines the scene to inspect
  47927. */
  47928. constructor(scene: Scene);
  47929. /** Creates the inspector window. */
  47930. private _createInspector;
  47931. /**
  47932. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47933. * @param entity defines the entity to select
  47934. * @param lineContainerTitle defines the specific block to highlight
  47935. */
  47936. select(entity: any, lineContainerTitle?: string): void;
  47937. /** Get the inspector from bundle or global */
  47938. private _getGlobalInspector;
  47939. /**
  47940. * Get if the inspector is visible or not.
  47941. * @returns true if visible otherwise, false
  47942. */
  47943. isVisible(): boolean;
  47944. /**
  47945. * Hide the inspector and close its window.
  47946. */
  47947. hide(): void;
  47948. /**
  47949. * Launch the debugLayer.
  47950. * @param config Define the configuration of the inspector
  47951. * @return a promise fulfilled when the debug layer is visible
  47952. */
  47953. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47954. }
  47955. }
  47956. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47957. import { Nullable } from "babylonjs/types";
  47958. import { Scene } from "babylonjs/scene";
  47959. import { Vector4 } from "babylonjs/Maths/math.vector";
  47960. import { Color4 } from "babylonjs/Maths/math.color";
  47961. import { Mesh } from "babylonjs/Meshes/mesh";
  47962. /**
  47963. * Class containing static functions to help procedurally build meshes
  47964. */
  47965. export class BoxBuilder {
  47966. /**
  47967. * Creates a box mesh
  47968. * * The parameter `size` sets the size (float) of each box side (default 1)
  47969. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47970. * * 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)
  47971. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47975. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47976. * @param name defines the name of the mesh
  47977. * @param options defines the options used to create the mesh
  47978. * @param scene defines the hosting scene
  47979. * @returns the box mesh
  47980. */
  47981. static CreateBox(name: string, options: {
  47982. size?: number;
  47983. width?: number;
  47984. height?: number;
  47985. depth?: number;
  47986. faceUV?: Vector4[];
  47987. faceColors?: Color4[];
  47988. sideOrientation?: number;
  47989. frontUVs?: Vector4;
  47990. backUVs?: Vector4;
  47991. wrap?: boolean;
  47992. topBaseAt?: number;
  47993. bottomBaseAt?: number;
  47994. updatable?: boolean;
  47995. }, scene?: Nullable<Scene>): Mesh;
  47996. }
  47997. }
  47998. declare module "babylonjs/Debug/physicsViewer" {
  47999. import { Nullable } from "babylonjs/types";
  48000. import { Scene } from "babylonjs/scene";
  48001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48002. import { Mesh } from "babylonjs/Meshes/mesh";
  48003. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48004. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48005. /**
  48006. * Used to show the physics impostor around the specific mesh
  48007. */
  48008. export class PhysicsViewer {
  48009. /** @hidden */
  48010. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48011. /** @hidden */
  48012. protected _meshes: Array<Nullable<AbstractMesh>>;
  48013. /** @hidden */
  48014. protected _scene: Nullable<Scene>;
  48015. /** @hidden */
  48016. protected _numMeshes: number;
  48017. /** @hidden */
  48018. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48019. private _renderFunction;
  48020. private _utilityLayer;
  48021. private _debugBoxMesh;
  48022. private _debugSphereMesh;
  48023. private _debugCylinderMesh;
  48024. private _debugMaterial;
  48025. private _debugMeshMeshes;
  48026. /**
  48027. * Creates a new PhysicsViewer
  48028. * @param scene defines the hosting scene
  48029. */
  48030. constructor(scene: Scene);
  48031. /** @hidden */
  48032. protected _updateDebugMeshes(): void;
  48033. /**
  48034. * Renders a specified physic impostor
  48035. * @param impostor defines the impostor to render
  48036. * @param targetMesh defines the mesh represented by the impostor
  48037. * @returns the new debug mesh used to render the impostor
  48038. */
  48039. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48040. /**
  48041. * Hides a specified physic impostor
  48042. * @param impostor defines the impostor to hide
  48043. */
  48044. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48045. private _getDebugMaterial;
  48046. private _getDebugBoxMesh;
  48047. private _getDebugSphereMesh;
  48048. private _getDebugCylinderMesh;
  48049. private _getDebugMeshMesh;
  48050. private _getDebugMesh;
  48051. /** Releases all resources */
  48052. dispose(): void;
  48053. }
  48054. }
  48055. declare module "babylonjs/Debug/rayHelper" {
  48056. import { Nullable } from "babylonjs/types";
  48057. import { Ray } from "babylonjs/Culling/ray";
  48058. import { Vector3 } from "babylonjs/Maths/math.vector";
  48059. import { Color3 } from "babylonjs/Maths/math.color";
  48060. import { Scene } from "babylonjs/scene";
  48061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48062. import "babylonjs/Meshes/Builders/linesBuilder";
  48063. /**
  48064. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48065. * in order to better appreciate the issue one might have.
  48066. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48067. */
  48068. export class RayHelper {
  48069. /**
  48070. * Defines the ray we are currently tryin to visualize.
  48071. */
  48072. ray: Nullable<Ray>;
  48073. private _renderPoints;
  48074. private _renderLine;
  48075. private _renderFunction;
  48076. private _scene;
  48077. private _updateToMeshFunction;
  48078. private _attachedToMesh;
  48079. private _meshSpaceDirection;
  48080. private _meshSpaceOrigin;
  48081. /**
  48082. * Helper function to create a colored helper in a scene in one line.
  48083. * @param ray Defines the ray we are currently tryin to visualize
  48084. * @param scene Defines the scene the ray is used in
  48085. * @param color Defines the color we want to see the ray in
  48086. * @returns The newly created ray helper.
  48087. */
  48088. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48089. /**
  48090. * Instantiate a new ray helper.
  48091. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48092. * in order to better appreciate the issue one might have.
  48093. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48094. * @param ray Defines the ray we are currently tryin to visualize
  48095. */
  48096. constructor(ray: Ray);
  48097. /**
  48098. * Shows the ray we are willing to debug.
  48099. * @param scene Defines the scene the ray needs to be rendered in
  48100. * @param color Defines the color the ray needs to be rendered in
  48101. */
  48102. show(scene: Scene, color?: Color3): void;
  48103. /**
  48104. * Hides the ray we are debugging.
  48105. */
  48106. hide(): void;
  48107. private _render;
  48108. /**
  48109. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48110. * @param mesh Defines the mesh we want the helper attached to
  48111. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48112. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48113. * @param length Defines the length of the ray
  48114. */
  48115. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48116. /**
  48117. * Detach the ray helper from the mesh it has previously been attached to.
  48118. */
  48119. detachFromMesh(): void;
  48120. private _updateToMesh;
  48121. /**
  48122. * Dispose the helper and release its associated resources.
  48123. */
  48124. dispose(): void;
  48125. }
  48126. }
  48127. declare module "babylonjs/Debug/skeletonViewer" {
  48128. import { Color3 } from "babylonjs/Maths/math.color";
  48129. import { Scene } from "babylonjs/scene";
  48130. import { Nullable } from "babylonjs/types";
  48131. import { Skeleton } from "babylonjs/Bones/skeleton";
  48132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48133. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48134. /**
  48135. * Class used to render a debug view of a given skeleton
  48136. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48137. */
  48138. export class SkeletonViewer {
  48139. /** defines the skeleton to render */
  48140. skeleton: Skeleton;
  48141. /** defines the mesh attached to the skeleton */
  48142. mesh: AbstractMesh;
  48143. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48144. autoUpdateBonesMatrices: boolean;
  48145. /** defines the rendering group id to use with the viewer */
  48146. renderingGroupId: number;
  48147. /** Gets or sets the color used to render the skeleton */
  48148. color: Color3;
  48149. private _scene;
  48150. private _debugLines;
  48151. private _debugMesh;
  48152. private _isEnabled;
  48153. private _renderFunction;
  48154. private _utilityLayer;
  48155. /**
  48156. * Returns the mesh used to render the bones
  48157. */
  48158. get debugMesh(): Nullable<LinesMesh>;
  48159. /**
  48160. * Creates a new SkeletonViewer
  48161. * @param skeleton defines the skeleton to render
  48162. * @param mesh defines the mesh attached to the skeleton
  48163. * @param scene defines the hosting scene
  48164. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48165. * @param renderingGroupId defines the rendering group id to use with the viewer
  48166. */
  48167. constructor(
  48168. /** defines the skeleton to render */
  48169. skeleton: Skeleton,
  48170. /** defines the mesh attached to the skeleton */
  48171. mesh: AbstractMesh, scene: Scene,
  48172. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48173. autoUpdateBonesMatrices?: boolean,
  48174. /** defines the rendering group id to use with the viewer */
  48175. renderingGroupId?: number);
  48176. /** Gets or sets a boolean indicating if the viewer is enabled */
  48177. set isEnabled(value: boolean);
  48178. get isEnabled(): boolean;
  48179. private _getBonePosition;
  48180. private _getLinesForBonesWithLength;
  48181. private _getLinesForBonesNoLength;
  48182. /** Update the viewer to sync with current skeleton state */
  48183. update(): void;
  48184. /** Release associated resources */
  48185. dispose(): void;
  48186. }
  48187. }
  48188. declare module "babylonjs/Debug/index" {
  48189. export * from "babylonjs/Debug/axesViewer";
  48190. export * from "babylonjs/Debug/boneAxesViewer";
  48191. export * from "babylonjs/Debug/debugLayer";
  48192. export * from "babylonjs/Debug/physicsViewer";
  48193. export * from "babylonjs/Debug/rayHelper";
  48194. export * from "babylonjs/Debug/skeletonViewer";
  48195. }
  48196. declare module "babylonjs/Engines/nullEngine" {
  48197. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48198. import { Engine } from "babylonjs/Engines/engine";
  48199. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48200. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48202. import { Effect } from "babylonjs/Materials/effect";
  48203. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48204. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48205. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48206. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48207. /**
  48208. * Options to create the null engine
  48209. */
  48210. export class NullEngineOptions {
  48211. /**
  48212. * Render width (Default: 512)
  48213. */
  48214. renderWidth: number;
  48215. /**
  48216. * Render height (Default: 256)
  48217. */
  48218. renderHeight: number;
  48219. /**
  48220. * Texture size (Default: 512)
  48221. */
  48222. textureSize: number;
  48223. /**
  48224. * If delta time between frames should be constant
  48225. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48226. */
  48227. deterministicLockstep: boolean;
  48228. /**
  48229. * Maximum about of steps between frames (Default: 4)
  48230. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48231. */
  48232. lockstepMaxSteps: number;
  48233. }
  48234. /**
  48235. * The null engine class provides support for headless version of babylon.js.
  48236. * This can be used in server side scenario or for testing purposes
  48237. */
  48238. export class NullEngine extends Engine {
  48239. private _options;
  48240. /**
  48241. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48243. * @returns true if engine is in deterministic lock step mode
  48244. */
  48245. isDeterministicLockStep(): boolean;
  48246. /**
  48247. * Gets the max steps when engine is running in deterministic lock step
  48248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48249. * @returns the max steps
  48250. */
  48251. getLockstepMaxSteps(): number;
  48252. /**
  48253. * Gets the current hardware scaling level.
  48254. * By default the hardware scaling level is computed from the window device ratio.
  48255. * 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.
  48256. * @returns a number indicating the current hardware scaling level
  48257. */
  48258. getHardwareScalingLevel(): number;
  48259. constructor(options?: NullEngineOptions);
  48260. /**
  48261. * Creates a vertex buffer
  48262. * @param vertices the data for the vertex buffer
  48263. * @returns the new WebGL static buffer
  48264. */
  48265. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48266. /**
  48267. * Creates a new index buffer
  48268. * @param indices defines the content of the index buffer
  48269. * @param updatable defines if the index buffer must be updatable
  48270. * @returns a new webGL buffer
  48271. */
  48272. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48273. /**
  48274. * Clear the current render buffer or the current render target (if any is set up)
  48275. * @param color defines the color to use
  48276. * @param backBuffer defines if the back buffer must be cleared
  48277. * @param depth defines if the depth buffer must be cleared
  48278. * @param stencil defines if the stencil buffer must be cleared
  48279. */
  48280. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48281. /**
  48282. * Gets the current render width
  48283. * @param useScreen defines if screen size must be used (or the current render target if any)
  48284. * @returns a number defining the current render width
  48285. */
  48286. getRenderWidth(useScreen?: boolean): number;
  48287. /**
  48288. * Gets the current render height
  48289. * @param useScreen defines if screen size must be used (or the current render target if any)
  48290. * @returns a number defining the current render height
  48291. */
  48292. getRenderHeight(useScreen?: boolean): number;
  48293. /**
  48294. * Set the WebGL's viewport
  48295. * @param viewport defines the viewport element to be used
  48296. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48297. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48298. */
  48299. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48300. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48301. /**
  48302. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48303. * @param pipelineContext defines the pipeline context to use
  48304. * @param uniformsNames defines the list of uniform names
  48305. * @returns an array of webGL uniform locations
  48306. */
  48307. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48308. /**
  48309. * Gets the lsit of active attributes for a given webGL program
  48310. * @param pipelineContext defines the pipeline context to use
  48311. * @param attributesNames defines the list of attribute names to get
  48312. * @returns an array of indices indicating the offset of each attribute
  48313. */
  48314. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48315. /**
  48316. * Binds an effect to the webGL context
  48317. * @param effect defines the effect to bind
  48318. */
  48319. bindSamplers(effect: Effect): void;
  48320. /**
  48321. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48322. * @param effect defines the effect to activate
  48323. */
  48324. enableEffect(effect: Effect): void;
  48325. /**
  48326. * Set various states to the webGL context
  48327. * @param culling defines backface culling state
  48328. * @param zOffset defines the value to apply to zOffset (0 by default)
  48329. * @param force defines if states must be applied even if cache is up to date
  48330. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48331. */
  48332. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48333. /**
  48334. * Set the value of an uniform to an array of int32
  48335. * @param uniform defines the webGL uniform location where to store the value
  48336. * @param array defines the array of int32 to store
  48337. */
  48338. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48339. /**
  48340. * Set the value of an uniform to an array of int32 (stored as vec2)
  48341. * @param uniform defines the webGL uniform location where to store the value
  48342. * @param array defines the array of int32 to store
  48343. */
  48344. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48345. /**
  48346. * Set the value of an uniform to an array of int32 (stored as vec3)
  48347. * @param uniform defines the webGL uniform location where to store the value
  48348. * @param array defines the array of int32 to store
  48349. */
  48350. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48351. /**
  48352. * Set the value of an uniform to an array of int32 (stored as vec4)
  48353. * @param uniform defines the webGL uniform location where to store the value
  48354. * @param array defines the array of int32 to store
  48355. */
  48356. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48357. /**
  48358. * Set the value of an uniform to an array of float32
  48359. * @param uniform defines the webGL uniform location where to store the value
  48360. * @param array defines the array of float32 to store
  48361. */
  48362. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48363. /**
  48364. * Set the value of an uniform to an array of float32 (stored as vec2)
  48365. * @param uniform defines the webGL uniform location where to store the value
  48366. * @param array defines the array of float32 to store
  48367. */
  48368. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48369. /**
  48370. * Set the value of an uniform to an array of float32 (stored as vec3)
  48371. * @param uniform defines the webGL uniform location where to store the value
  48372. * @param array defines the array of float32 to store
  48373. */
  48374. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48375. /**
  48376. * Set the value of an uniform to an array of float32 (stored as vec4)
  48377. * @param uniform defines the webGL uniform location where to store the value
  48378. * @param array defines the array of float32 to store
  48379. */
  48380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48381. /**
  48382. * Set the value of an uniform to an array of number
  48383. * @param uniform defines the webGL uniform location where to store the value
  48384. * @param array defines the array of number to store
  48385. */
  48386. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48387. /**
  48388. * Set the value of an uniform to an array of number (stored as vec2)
  48389. * @param uniform defines the webGL uniform location where to store the value
  48390. * @param array defines the array of number to store
  48391. */
  48392. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48393. /**
  48394. * Set the value of an uniform to an array of number (stored as vec3)
  48395. * @param uniform defines the webGL uniform location where to store the value
  48396. * @param array defines the array of number to store
  48397. */
  48398. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48399. /**
  48400. * Set the value of an uniform to an array of number (stored as vec4)
  48401. * @param uniform defines the webGL uniform location where to store the value
  48402. * @param array defines the array of number to store
  48403. */
  48404. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48405. /**
  48406. * Set the value of an uniform to an array of float32 (stored as matrices)
  48407. * @param uniform defines the webGL uniform location where to store the value
  48408. * @param matrices defines the array of float32 to store
  48409. */
  48410. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48411. /**
  48412. * Set the value of an uniform to a matrix (3x3)
  48413. * @param uniform defines the webGL uniform location where to store the value
  48414. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48415. */
  48416. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48417. /**
  48418. * Set the value of an uniform to a matrix (2x2)
  48419. * @param uniform defines the webGL uniform location where to store the value
  48420. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48421. */
  48422. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48423. /**
  48424. * Set the value of an uniform to a number (float)
  48425. * @param uniform defines the webGL uniform location where to store the value
  48426. * @param value defines the float number to store
  48427. */
  48428. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48429. /**
  48430. * Set the value of an uniform to a vec2
  48431. * @param uniform defines the webGL uniform location where to store the value
  48432. * @param x defines the 1st component of the value
  48433. * @param y defines the 2nd component of the value
  48434. */
  48435. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48436. /**
  48437. * Set the value of an uniform to a vec3
  48438. * @param uniform defines the webGL uniform location where to store the value
  48439. * @param x defines the 1st component of the value
  48440. * @param y defines the 2nd component of the value
  48441. * @param z defines the 3rd component of the value
  48442. */
  48443. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48444. /**
  48445. * Set the value of an uniform to a boolean
  48446. * @param uniform defines the webGL uniform location where to store the value
  48447. * @param bool defines the boolean to store
  48448. */
  48449. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48450. /**
  48451. * Set the value of an uniform to a vec4
  48452. * @param uniform defines the webGL uniform location where to store the value
  48453. * @param x defines the 1st component of the value
  48454. * @param y defines the 2nd component of the value
  48455. * @param z defines the 3rd component of the value
  48456. * @param w defines the 4th component of the value
  48457. */
  48458. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48459. /**
  48460. * Sets the current alpha mode
  48461. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48462. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48464. */
  48465. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48466. /**
  48467. * Bind webGl buffers directly to the webGL context
  48468. * @param vertexBuffers defines the vertex buffer to bind
  48469. * @param indexBuffer defines the index buffer to bind
  48470. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48471. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48472. * @param effect defines the effect associated with the vertex buffer
  48473. */
  48474. bindBuffers(vertexBuffers: {
  48475. [key: string]: VertexBuffer;
  48476. }, indexBuffer: DataBuffer, effect: Effect): void;
  48477. /**
  48478. * Force the entire cache to be cleared
  48479. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48480. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48481. */
  48482. wipeCaches(bruteForce?: boolean): void;
  48483. /**
  48484. * Send a draw order
  48485. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48486. * @param indexStart defines the starting index
  48487. * @param indexCount defines the number of index to draw
  48488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48489. */
  48490. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48491. /**
  48492. * Draw a list of indexed primitives
  48493. * @param fillMode defines the primitive to use
  48494. * @param indexStart defines the starting index
  48495. * @param indexCount defines the number of index to draw
  48496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48497. */
  48498. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48499. /**
  48500. * Draw a list of unindexed primitives
  48501. * @param fillMode defines the primitive to use
  48502. * @param verticesStart defines the index of first vertex to draw
  48503. * @param verticesCount defines the count of vertices to draw
  48504. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48505. */
  48506. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48507. /** @hidden */
  48508. _createTexture(): WebGLTexture;
  48509. /** @hidden */
  48510. _releaseTexture(texture: InternalTexture): void;
  48511. /**
  48512. * Usually called from Texture.ts.
  48513. * Passed information to create a WebGLTexture
  48514. * @param urlArg defines a value which contains one of the following:
  48515. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48516. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48517. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48519. * @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)
  48520. * @param scene needed for loading to the correct scene
  48521. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48522. * @param onLoad optional callback to be called upon successful completion
  48523. * @param onError optional callback to be called upon failure
  48524. * @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
  48525. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48526. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48527. * @param forcedExtension defines the extension to use to pick the right loader
  48528. * @param mimeType defines an optional mime type
  48529. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48530. */
  48531. 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;
  48532. /**
  48533. * Creates a new render target texture
  48534. * @param size defines the size of the texture
  48535. * @param options defines the options used to create the texture
  48536. * @returns a new render target texture stored in an InternalTexture
  48537. */
  48538. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48539. /**
  48540. * Update the sampling mode of a given texture
  48541. * @param samplingMode defines the required sampling mode
  48542. * @param texture defines the texture to update
  48543. */
  48544. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48545. /**
  48546. * Binds the frame buffer to the specified texture.
  48547. * @param texture The texture to render to or null for the default canvas
  48548. * @param faceIndex The face of the texture to render to in case of cube texture
  48549. * @param requiredWidth The width of the target to render to
  48550. * @param requiredHeight The height of the target to render to
  48551. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48552. * @param lodLevel defines le lod level to bind to the frame buffer
  48553. */
  48554. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48555. /**
  48556. * Unbind the current render target texture from the webGL context
  48557. * @param texture defines the render target texture to unbind
  48558. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48559. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48560. */
  48561. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48562. /**
  48563. * Creates a dynamic vertex buffer
  48564. * @param vertices the data for the dynamic vertex buffer
  48565. * @returns the new WebGL dynamic buffer
  48566. */
  48567. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48568. /**
  48569. * Update the content of a dynamic texture
  48570. * @param texture defines the texture to update
  48571. * @param canvas defines the canvas containing the source
  48572. * @param invertY defines if data must be stored with Y axis inverted
  48573. * @param premulAlpha defines if alpha is stored as premultiplied
  48574. * @param format defines the format of the data
  48575. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48576. */
  48577. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48578. /**
  48579. * Gets a boolean indicating if all created effects are ready
  48580. * @returns true if all effects are ready
  48581. */
  48582. areAllEffectsReady(): boolean;
  48583. /**
  48584. * @hidden
  48585. * Get the current error code of the webGL context
  48586. * @returns the error code
  48587. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48588. */
  48589. getError(): number;
  48590. /** @hidden */
  48591. _getUnpackAlignement(): number;
  48592. /** @hidden */
  48593. _unpackFlipY(value: boolean): void;
  48594. /**
  48595. * Update a dynamic index buffer
  48596. * @param indexBuffer defines the target index buffer
  48597. * @param indices defines the data to update
  48598. * @param offset defines the offset in the target index buffer where update should start
  48599. */
  48600. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48601. /**
  48602. * Updates a dynamic vertex buffer.
  48603. * @param vertexBuffer the vertex buffer to update
  48604. * @param vertices the data used to update the vertex buffer
  48605. * @param byteOffset the byte offset of the data (optional)
  48606. * @param byteLength the byte length of the data (optional)
  48607. */
  48608. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48609. /** @hidden */
  48610. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48611. /** @hidden */
  48612. _bindTexture(channel: number, texture: InternalTexture): void;
  48613. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48614. /**
  48615. * 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
  48616. */
  48617. releaseEffects(): void;
  48618. displayLoadingUI(): void;
  48619. hideLoadingUI(): void;
  48620. /** @hidden */
  48621. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48622. /** @hidden */
  48623. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48624. /** @hidden */
  48625. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48626. /** @hidden */
  48627. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48628. }
  48629. }
  48630. declare module "babylonjs/Instrumentation/timeToken" {
  48631. import { Nullable } from "babylonjs/types";
  48632. /**
  48633. * @hidden
  48634. **/
  48635. export class _TimeToken {
  48636. _startTimeQuery: Nullable<WebGLQuery>;
  48637. _endTimeQuery: Nullable<WebGLQuery>;
  48638. _timeElapsedQuery: Nullable<WebGLQuery>;
  48639. _timeElapsedQueryEnded: boolean;
  48640. }
  48641. }
  48642. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48643. import { Nullable, int } from "babylonjs/types";
  48644. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48645. /** @hidden */
  48646. export class _OcclusionDataStorage {
  48647. /** @hidden */
  48648. occlusionInternalRetryCounter: number;
  48649. /** @hidden */
  48650. isOcclusionQueryInProgress: boolean;
  48651. /** @hidden */
  48652. isOccluded: boolean;
  48653. /** @hidden */
  48654. occlusionRetryCount: number;
  48655. /** @hidden */
  48656. occlusionType: number;
  48657. /** @hidden */
  48658. occlusionQueryAlgorithmType: number;
  48659. }
  48660. module "babylonjs/Engines/engine" {
  48661. interface Engine {
  48662. /**
  48663. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48664. * @return the new query
  48665. */
  48666. createQuery(): WebGLQuery;
  48667. /**
  48668. * Delete and release a webGL query
  48669. * @param query defines the query to delete
  48670. * @return the current engine
  48671. */
  48672. deleteQuery(query: WebGLQuery): Engine;
  48673. /**
  48674. * Check if a given query has resolved and got its value
  48675. * @param query defines the query to check
  48676. * @returns true if the query got its value
  48677. */
  48678. isQueryResultAvailable(query: WebGLQuery): boolean;
  48679. /**
  48680. * Gets the value of a given query
  48681. * @param query defines the query to check
  48682. * @returns the value of the query
  48683. */
  48684. getQueryResult(query: WebGLQuery): number;
  48685. /**
  48686. * Initiates an occlusion query
  48687. * @param algorithmType defines the algorithm to use
  48688. * @param query defines the query to use
  48689. * @returns the current engine
  48690. * @see http://doc.babylonjs.com/features/occlusionquery
  48691. */
  48692. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48693. /**
  48694. * Ends an occlusion query
  48695. * @see http://doc.babylonjs.com/features/occlusionquery
  48696. * @param algorithmType defines the algorithm to use
  48697. * @returns the current engine
  48698. */
  48699. endOcclusionQuery(algorithmType: number): Engine;
  48700. /**
  48701. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48702. * Please note that only one query can be issued at a time
  48703. * @returns a time token used to track the time span
  48704. */
  48705. startTimeQuery(): Nullable<_TimeToken>;
  48706. /**
  48707. * Ends a time query
  48708. * @param token defines the token used to measure the time span
  48709. * @returns the time spent (in ns)
  48710. */
  48711. endTimeQuery(token: _TimeToken): int;
  48712. /** @hidden */
  48713. _currentNonTimestampToken: Nullable<_TimeToken>;
  48714. /** @hidden */
  48715. _createTimeQuery(): WebGLQuery;
  48716. /** @hidden */
  48717. _deleteTimeQuery(query: WebGLQuery): void;
  48718. /** @hidden */
  48719. _getGlAlgorithmType(algorithmType: number): number;
  48720. /** @hidden */
  48721. _getTimeQueryResult(query: WebGLQuery): any;
  48722. /** @hidden */
  48723. _getTimeQueryAvailability(query: WebGLQuery): any;
  48724. }
  48725. }
  48726. module "babylonjs/Meshes/abstractMesh" {
  48727. interface AbstractMesh {
  48728. /**
  48729. * Backing filed
  48730. * @hidden
  48731. */
  48732. __occlusionDataStorage: _OcclusionDataStorage;
  48733. /**
  48734. * Access property
  48735. * @hidden
  48736. */
  48737. _occlusionDataStorage: _OcclusionDataStorage;
  48738. /**
  48739. * 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.
  48740. * The default value is -1 which means don't break the query and wait till the result
  48741. * @see http://doc.babylonjs.com/features/occlusionquery
  48742. */
  48743. occlusionRetryCount: number;
  48744. /**
  48745. * 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:
  48746. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48747. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48748. * * 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.
  48749. * @see http://doc.babylonjs.com/features/occlusionquery
  48750. */
  48751. occlusionType: number;
  48752. /**
  48753. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48754. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48755. * * 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.
  48756. * @see http://doc.babylonjs.com/features/occlusionquery
  48757. */
  48758. occlusionQueryAlgorithmType: number;
  48759. /**
  48760. * 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
  48761. * @see http://doc.babylonjs.com/features/occlusionquery
  48762. */
  48763. isOccluded: boolean;
  48764. /**
  48765. * Flag to check the progress status of the query
  48766. * @see http://doc.babylonjs.com/features/occlusionquery
  48767. */
  48768. isOcclusionQueryInProgress: boolean;
  48769. }
  48770. }
  48771. }
  48772. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48773. import { Nullable } from "babylonjs/types";
  48774. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48775. /** @hidden */
  48776. export var _forceTransformFeedbackToBundle: boolean;
  48777. module "babylonjs/Engines/engine" {
  48778. interface Engine {
  48779. /**
  48780. * Creates a webGL transform feedback object
  48781. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48782. * @returns the webGL transform feedback object
  48783. */
  48784. createTransformFeedback(): WebGLTransformFeedback;
  48785. /**
  48786. * Delete a webGL transform feedback object
  48787. * @param value defines the webGL transform feedback object to delete
  48788. */
  48789. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48790. /**
  48791. * Bind a webGL transform feedback object to the webgl context
  48792. * @param value defines the webGL transform feedback object to bind
  48793. */
  48794. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48795. /**
  48796. * Begins a transform feedback operation
  48797. * @param usePoints defines if points or triangles must be used
  48798. */
  48799. beginTransformFeedback(usePoints: boolean): void;
  48800. /**
  48801. * Ends a transform feedback operation
  48802. */
  48803. endTransformFeedback(): void;
  48804. /**
  48805. * Specify the varyings to use with transform feedback
  48806. * @param program defines the associated webGL program
  48807. * @param value defines the list of strings representing the varying names
  48808. */
  48809. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48810. /**
  48811. * Bind a webGL buffer for a transform feedback operation
  48812. * @param value defines the webGL buffer to bind
  48813. */
  48814. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48815. }
  48816. }
  48817. }
  48818. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48819. import { Scene } from "babylonjs/scene";
  48820. import { Engine } from "babylonjs/Engines/engine";
  48821. import { Texture } from "babylonjs/Materials/Textures/texture";
  48822. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48823. import "babylonjs/Engines/Extensions/engine.multiRender";
  48824. /**
  48825. * Creation options of the multi render target texture.
  48826. */
  48827. export interface IMultiRenderTargetOptions {
  48828. /**
  48829. * Define if the texture needs to create mip maps after render.
  48830. */
  48831. generateMipMaps?: boolean;
  48832. /**
  48833. * Define the types of all the draw buffers we want to create
  48834. */
  48835. types?: number[];
  48836. /**
  48837. * Define the sampling modes of all the draw buffers we want to create
  48838. */
  48839. samplingModes?: number[];
  48840. /**
  48841. * Define if a depth buffer is required
  48842. */
  48843. generateDepthBuffer?: boolean;
  48844. /**
  48845. * Define if a stencil buffer is required
  48846. */
  48847. generateStencilBuffer?: boolean;
  48848. /**
  48849. * Define if a depth texture is required instead of a depth buffer
  48850. */
  48851. generateDepthTexture?: boolean;
  48852. /**
  48853. * Define the number of desired draw buffers
  48854. */
  48855. textureCount?: number;
  48856. /**
  48857. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48858. */
  48859. doNotChangeAspectRatio?: boolean;
  48860. /**
  48861. * Define the default type of the buffers we are creating
  48862. */
  48863. defaultType?: number;
  48864. }
  48865. /**
  48866. * A multi render target, like a render target provides the ability to render to a texture.
  48867. * Unlike the render target, it can render to several draw buffers in one draw.
  48868. * This is specially interesting in deferred rendering or for any effects requiring more than
  48869. * just one color from a single pass.
  48870. */
  48871. export class MultiRenderTarget extends RenderTargetTexture {
  48872. private _internalTextures;
  48873. private _textures;
  48874. private _multiRenderTargetOptions;
  48875. /**
  48876. * Get if draw buffers are currently supported by the used hardware and browser.
  48877. */
  48878. get isSupported(): boolean;
  48879. /**
  48880. * Get the list of textures generated by the multi render target.
  48881. */
  48882. get textures(): Texture[];
  48883. /**
  48884. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48885. */
  48886. get depthTexture(): Texture;
  48887. /**
  48888. * Set the wrapping mode on U of all the textures we are rendering to.
  48889. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48890. */
  48891. set wrapU(wrap: number);
  48892. /**
  48893. * Set the wrapping mode on V of all the textures we are rendering to.
  48894. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48895. */
  48896. set wrapV(wrap: number);
  48897. /**
  48898. * Instantiate a new multi render target texture.
  48899. * A multi render target, like a render target provides the ability to render to a texture.
  48900. * Unlike the render target, it can render to several draw buffers in one draw.
  48901. * This is specially interesting in deferred rendering or for any effects requiring more than
  48902. * just one color from a single pass.
  48903. * @param name Define the name of the texture
  48904. * @param size Define the size of the buffers to render to
  48905. * @param count Define the number of target we are rendering into
  48906. * @param scene Define the scene the texture belongs to
  48907. * @param options Define the options used to create the multi render target
  48908. */
  48909. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48910. /** @hidden */
  48911. _rebuild(): void;
  48912. private _createInternalTextures;
  48913. private _createTextures;
  48914. /**
  48915. * Define the number of samples used if MSAA is enabled.
  48916. */
  48917. get samples(): number;
  48918. set samples(value: number);
  48919. /**
  48920. * Resize all the textures in the multi render target.
  48921. * Be carrefull as it will recreate all the data in the new texture.
  48922. * @param size Define the new size
  48923. */
  48924. resize(size: any): void;
  48925. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48926. /**
  48927. * Dispose the render targets and their associated resources
  48928. */
  48929. dispose(): void;
  48930. /**
  48931. * Release all the underlying texture used as draw buffers.
  48932. */
  48933. releaseInternalTextures(): void;
  48934. }
  48935. }
  48936. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48938. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48939. import { Nullable } from "babylonjs/types";
  48940. module "babylonjs/Engines/thinEngine" {
  48941. interface ThinEngine {
  48942. /**
  48943. * Unbind a list of render target textures from the webGL context
  48944. * This is used only when drawBuffer extension or webGL2 are active
  48945. * @param textures defines the render target textures to unbind
  48946. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48947. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48948. */
  48949. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48950. /**
  48951. * Create a multi render target texture
  48952. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48953. * @param size defines the size of the texture
  48954. * @param options defines the creation options
  48955. * @returns the cube texture as an InternalTexture
  48956. */
  48957. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48958. /**
  48959. * Update the sample count for a given multiple render target texture
  48960. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48961. * @param textures defines the textures to update
  48962. * @param samples defines the sample count to set
  48963. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48964. */
  48965. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48966. }
  48967. }
  48968. }
  48969. declare module "babylonjs/Engines/Extensions/engine.views" {
  48970. import { Camera } from "babylonjs/Cameras/camera";
  48971. import { Nullable } from "babylonjs/types";
  48972. /**
  48973. * Class used to define an additional view for the engine
  48974. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48975. */
  48976. export class EngineView {
  48977. /** Defines the canvas where to render the view */
  48978. target: HTMLCanvasElement;
  48979. /** Defines an optional camera used to render the view (will use active camera else) */
  48980. camera?: Camera;
  48981. }
  48982. module "babylonjs/Engines/engine" {
  48983. interface Engine {
  48984. /**
  48985. * Gets or sets the HTML element to use for attaching events
  48986. */
  48987. inputElement: Nullable<HTMLElement>;
  48988. /**
  48989. * Gets the current engine view
  48990. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48991. */
  48992. activeView: Nullable<EngineView>;
  48993. /** Gets or sets the list of views */
  48994. views: EngineView[];
  48995. /**
  48996. * Register a new child canvas
  48997. * @param canvas defines the canvas to register
  48998. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48999. * @returns the associated view
  49000. */
  49001. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49002. /**
  49003. * Remove a registered child canvas
  49004. * @param canvas defines the canvas to remove
  49005. * @returns the current engine
  49006. */
  49007. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49008. }
  49009. }
  49010. }
  49011. declare module "babylonjs/Engines/Extensions/index" {
  49012. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49013. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49014. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49015. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49016. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49017. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49018. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49019. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49020. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49021. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49022. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49023. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49024. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49025. export * from "babylonjs/Engines/Extensions/engine.views";
  49026. }
  49027. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49028. import { Nullable } from "babylonjs/types";
  49029. /**
  49030. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49031. */
  49032. export interface CubeMapInfo {
  49033. /**
  49034. * The pixel array for the front face.
  49035. * This is stored in format, left to right, up to down format.
  49036. */
  49037. front: Nullable<ArrayBufferView>;
  49038. /**
  49039. * The pixel array for the back face.
  49040. * This is stored in format, left to right, up to down format.
  49041. */
  49042. back: Nullable<ArrayBufferView>;
  49043. /**
  49044. * The pixel array for the left face.
  49045. * This is stored in format, left to right, up to down format.
  49046. */
  49047. left: Nullable<ArrayBufferView>;
  49048. /**
  49049. * The pixel array for the right face.
  49050. * This is stored in format, left to right, up to down format.
  49051. */
  49052. right: Nullable<ArrayBufferView>;
  49053. /**
  49054. * The pixel array for the up face.
  49055. * This is stored in format, left to right, up to down format.
  49056. */
  49057. up: Nullable<ArrayBufferView>;
  49058. /**
  49059. * The pixel array for the down face.
  49060. * This is stored in format, left to right, up to down format.
  49061. */
  49062. down: Nullable<ArrayBufferView>;
  49063. /**
  49064. * The size of the cubemap stored.
  49065. *
  49066. * Each faces will be size * size pixels.
  49067. */
  49068. size: number;
  49069. /**
  49070. * The format of the texture.
  49071. *
  49072. * RGBA, RGB.
  49073. */
  49074. format: number;
  49075. /**
  49076. * The type of the texture data.
  49077. *
  49078. * UNSIGNED_INT, FLOAT.
  49079. */
  49080. type: number;
  49081. /**
  49082. * Specifies whether the texture is in gamma space.
  49083. */
  49084. gammaSpace: boolean;
  49085. }
  49086. /**
  49087. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49088. */
  49089. export class PanoramaToCubeMapTools {
  49090. private static FACE_FRONT;
  49091. private static FACE_BACK;
  49092. private static FACE_RIGHT;
  49093. private static FACE_LEFT;
  49094. private static FACE_DOWN;
  49095. private static FACE_UP;
  49096. /**
  49097. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49098. *
  49099. * @param float32Array The source data.
  49100. * @param inputWidth The width of the input panorama.
  49101. * @param inputHeight The height of the input panorama.
  49102. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49103. * @return The cubemap data
  49104. */
  49105. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49106. private static CreateCubemapTexture;
  49107. private static CalcProjectionSpherical;
  49108. }
  49109. }
  49110. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49111. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49113. import { Nullable } from "babylonjs/types";
  49114. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49115. /**
  49116. * Helper class dealing with the extraction of spherical polynomial dataArray
  49117. * from a cube map.
  49118. */
  49119. export class CubeMapToSphericalPolynomialTools {
  49120. private static FileFaces;
  49121. /**
  49122. * Converts a texture to the according Spherical Polynomial data.
  49123. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49124. *
  49125. * @param texture The texture to extract the information from.
  49126. * @return The Spherical Polynomial data.
  49127. */
  49128. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49129. /**
  49130. * Converts a cubemap to the according Spherical Polynomial data.
  49131. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49132. *
  49133. * @param cubeInfo The Cube map to extract the information from.
  49134. * @return The Spherical Polynomial data.
  49135. */
  49136. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49137. }
  49138. }
  49139. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49140. import { Nullable } from "babylonjs/types";
  49141. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49142. module "babylonjs/Materials/Textures/baseTexture" {
  49143. interface BaseTexture {
  49144. /**
  49145. * Get the polynomial representation of the texture data.
  49146. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49147. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49148. */
  49149. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49150. }
  49151. }
  49152. }
  49153. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49155. /** @hidden */
  49156. export var rgbdEncodePixelShader: {
  49157. name: string;
  49158. shader: string;
  49159. };
  49160. }
  49161. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49162. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49163. /** @hidden */
  49164. export var rgbdDecodePixelShader: {
  49165. name: string;
  49166. shader: string;
  49167. };
  49168. }
  49169. declare module "babylonjs/Misc/environmentTextureTools" {
  49170. import { Nullable } from "babylonjs/types";
  49171. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49173. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49174. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49175. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49176. import "babylonjs/Shaders/rgbdEncode.fragment";
  49177. import "babylonjs/Shaders/rgbdDecode.fragment";
  49178. /**
  49179. * Raw texture data and descriptor sufficient for WebGL texture upload
  49180. */
  49181. export interface EnvironmentTextureInfo {
  49182. /**
  49183. * Version of the environment map
  49184. */
  49185. version: number;
  49186. /**
  49187. * Width of image
  49188. */
  49189. width: number;
  49190. /**
  49191. * Irradiance information stored in the file.
  49192. */
  49193. irradiance: any;
  49194. /**
  49195. * Specular information stored in the file.
  49196. */
  49197. specular: any;
  49198. }
  49199. /**
  49200. * Defines One Image in the file. It requires only the position in the file
  49201. * as well as the length.
  49202. */
  49203. interface BufferImageData {
  49204. /**
  49205. * Length of the image data.
  49206. */
  49207. length: number;
  49208. /**
  49209. * Position of the data from the null terminator delimiting the end of the JSON.
  49210. */
  49211. position: number;
  49212. }
  49213. /**
  49214. * Defines the specular data enclosed in the file.
  49215. * This corresponds to the version 1 of the data.
  49216. */
  49217. export interface EnvironmentTextureSpecularInfoV1 {
  49218. /**
  49219. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49220. */
  49221. specularDataPosition?: number;
  49222. /**
  49223. * This contains all the images data needed to reconstruct the cubemap.
  49224. */
  49225. mipmaps: Array<BufferImageData>;
  49226. /**
  49227. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49228. */
  49229. lodGenerationScale: number;
  49230. }
  49231. /**
  49232. * Sets of helpers addressing the serialization and deserialization of environment texture
  49233. * stored in a BabylonJS env file.
  49234. * Those files are usually stored as .env files.
  49235. */
  49236. export class EnvironmentTextureTools {
  49237. /**
  49238. * Magic number identifying the env file.
  49239. */
  49240. private static _MagicBytes;
  49241. /**
  49242. * Gets the environment info from an env file.
  49243. * @param data The array buffer containing the .env bytes.
  49244. * @returns the environment file info (the json header) if successfully parsed.
  49245. */
  49246. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49247. /**
  49248. * Creates an environment texture from a loaded cube texture.
  49249. * @param texture defines the cube texture to convert in env file
  49250. * @return a promise containing the environment data if succesfull.
  49251. */
  49252. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49253. /**
  49254. * Creates a JSON representation of the spherical data.
  49255. * @param texture defines the texture containing the polynomials
  49256. * @return the JSON representation of the spherical info
  49257. */
  49258. private static _CreateEnvTextureIrradiance;
  49259. /**
  49260. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49261. * @param data the image data
  49262. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49263. * @return the views described by info providing access to the underlying buffer
  49264. */
  49265. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49266. /**
  49267. * Uploads the texture info contained in the env file to the GPU.
  49268. * @param texture defines the internal texture to upload to
  49269. * @param data defines the data to load
  49270. * @param info defines the texture info retrieved through the GetEnvInfo method
  49271. * @returns a promise
  49272. */
  49273. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49274. private static _OnImageReadyAsync;
  49275. /**
  49276. * Uploads the levels of image data to the GPU.
  49277. * @param texture defines the internal texture to upload to
  49278. * @param imageData defines the array buffer views of image data [mipmap][face]
  49279. * @returns a promise
  49280. */
  49281. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49282. /**
  49283. * Uploads spherical polynomials information to the texture.
  49284. * @param texture defines the texture we are trying to upload the information to
  49285. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49286. */
  49287. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49288. /** @hidden */
  49289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49290. }
  49291. }
  49292. declare module "babylonjs/Maths/math.vertexFormat" {
  49293. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49294. /**
  49295. * Contains position and normal vectors for a vertex
  49296. */
  49297. export class PositionNormalVertex {
  49298. /** the position of the vertex (defaut: 0,0,0) */
  49299. position: Vector3;
  49300. /** the normal of the vertex (defaut: 0,1,0) */
  49301. normal: Vector3;
  49302. /**
  49303. * Creates a PositionNormalVertex
  49304. * @param position the position of the vertex (defaut: 0,0,0)
  49305. * @param normal the normal of the vertex (defaut: 0,1,0)
  49306. */
  49307. constructor(
  49308. /** the position of the vertex (defaut: 0,0,0) */
  49309. position?: Vector3,
  49310. /** the normal of the vertex (defaut: 0,1,0) */
  49311. normal?: Vector3);
  49312. /**
  49313. * Clones the PositionNormalVertex
  49314. * @returns the cloned PositionNormalVertex
  49315. */
  49316. clone(): PositionNormalVertex;
  49317. }
  49318. /**
  49319. * Contains position, normal and uv vectors for a vertex
  49320. */
  49321. export class PositionNormalTextureVertex {
  49322. /** the position of the vertex (defaut: 0,0,0) */
  49323. position: Vector3;
  49324. /** the normal of the vertex (defaut: 0,1,0) */
  49325. normal: Vector3;
  49326. /** the uv of the vertex (default: 0,0) */
  49327. uv: Vector2;
  49328. /**
  49329. * Creates a PositionNormalTextureVertex
  49330. * @param position the position of the vertex (defaut: 0,0,0)
  49331. * @param normal the normal of the vertex (defaut: 0,1,0)
  49332. * @param uv the uv of the vertex (default: 0,0)
  49333. */
  49334. constructor(
  49335. /** the position of the vertex (defaut: 0,0,0) */
  49336. position?: Vector3,
  49337. /** the normal of the vertex (defaut: 0,1,0) */
  49338. normal?: Vector3,
  49339. /** the uv of the vertex (default: 0,0) */
  49340. uv?: Vector2);
  49341. /**
  49342. * Clones the PositionNormalTextureVertex
  49343. * @returns the cloned PositionNormalTextureVertex
  49344. */
  49345. clone(): PositionNormalTextureVertex;
  49346. }
  49347. }
  49348. declare module "babylonjs/Maths/math" {
  49349. export * from "babylonjs/Maths/math.axis";
  49350. export * from "babylonjs/Maths/math.color";
  49351. export * from "babylonjs/Maths/math.constants";
  49352. export * from "babylonjs/Maths/math.frustum";
  49353. export * from "babylonjs/Maths/math.path";
  49354. export * from "babylonjs/Maths/math.plane";
  49355. export * from "babylonjs/Maths/math.size";
  49356. export * from "babylonjs/Maths/math.vector";
  49357. export * from "babylonjs/Maths/math.vertexFormat";
  49358. export * from "babylonjs/Maths/math.viewport";
  49359. }
  49360. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49361. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49362. /** @hidden */
  49363. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49364. private _genericAttributeLocation;
  49365. private _varyingLocationCount;
  49366. private _varyingLocationMap;
  49367. private _replacements;
  49368. private _textureCount;
  49369. private _uniforms;
  49370. lineProcessor(line: string): string;
  49371. attributeProcessor(attribute: string): string;
  49372. varyingProcessor(varying: string, isFragment: boolean): string;
  49373. uniformProcessor(uniform: string): string;
  49374. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49375. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49376. }
  49377. }
  49378. declare module "babylonjs/Engines/nativeEngine" {
  49379. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49380. import { Engine } from "babylonjs/Engines/engine";
  49381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49384. import { Effect } from "babylonjs/Materials/effect";
  49385. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49386. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49387. import { IColor4Like } from "babylonjs/Maths/math.like";
  49388. import { Scene } from "babylonjs/scene";
  49389. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49390. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49391. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49392. /**
  49393. * Container for accessors for natively-stored mesh data buffers.
  49394. */
  49395. class NativeDataBuffer extends DataBuffer {
  49396. /**
  49397. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49398. */
  49399. nativeIndexBuffer?: any;
  49400. /**
  49401. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49402. */
  49403. nativeVertexBuffer?: any;
  49404. }
  49405. /** @hidden */
  49406. class NativeTexture extends InternalTexture {
  49407. getInternalTexture(): InternalTexture;
  49408. getViewCount(): number;
  49409. }
  49410. /** @hidden */
  49411. export class NativeEngine extends Engine {
  49412. private readonly _native;
  49413. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49414. private readonly INVALID_HANDLE;
  49415. getHardwareScalingLevel(): number;
  49416. constructor();
  49417. /**
  49418. * Can be used to override the current requestAnimationFrame requester.
  49419. * @hidden
  49420. */
  49421. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49422. /**
  49423. * Override default engine behavior.
  49424. * @param color
  49425. * @param backBuffer
  49426. * @param depth
  49427. * @param stencil
  49428. */
  49429. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49430. /**
  49431. * Gets host document
  49432. * @returns the host document object
  49433. */
  49434. getHostDocument(): Nullable<Document>;
  49435. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49436. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49437. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49438. recordVertexArrayObject(vertexBuffers: {
  49439. [key: string]: VertexBuffer;
  49440. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49441. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49442. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49443. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49444. /**
  49445. * Draw a list of indexed primitives
  49446. * @param fillMode defines the primitive to use
  49447. * @param indexStart defines the starting index
  49448. * @param indexCount defines the number of index to draw
  49449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49450. */
  49451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49452. /**
  49453. * Draw a list of unindexed primitives
  49454. * @param fillMode defines the primitive to use
  49455. * @param verticesStart defines the index of first vertex to draw
  49456. * @param verticesCount defines the count of vertices to draw
  49457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49458. */
  49459. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49460. createPipelineContext(): IPipelineContext;
  49461. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49462. /** @hidden */
  49463. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49464. /** @hidden */
  49465. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49466. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49467. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49468. protected _setProgram(program: WebGLProgram): void;
  49469. _releaseEffect(effect: Effect): void;
  49470. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49471. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49472. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49473. bindSamplers(effect: Effect): void;
  49474. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49475. getRenderWidth(useScreen?: boolean): number;
  49476. getRenderHeight(useScreen?: boolean): number;
  49477. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49479. /**
  49480. * Set the z offset to apply to current rendering
  49481. * @param value defines the offset to apply
  49482. */
  49483. setZOffset(value: number): void;
  49484. /**
  49485. * Gets the current value of the zOffset
  49486. * @returns the current zOffset state
  49487. */
  49488. getZOffset(): number;
  49489. /**
  49490. * Enable or disable depth buffering
  49491. * @param enable defines the state to set
  49492. */
  49493. setDepthBuffer(enable: boolean): void;
  49494. /**
  49495. * Gets a boolean indicating if depth writing is enabled
  49496. * @returns the current depth writing state
  49497. */
  49498. getDepthWrite(): boolean;
  49499. /**
  49500. * Enable or disable depth writing
  49501. * @param enable defines the state to set
  49502. */
  49503. setDepthWrite(enable: boolean): void;
  49504. /**
  49505. * Enable or disable color writing
  49506. * @param enable defines the state to set
  49507. */
  49508. setColorWrite(enable: boolean): void;
  49509. /**
  49510. * Gets a boolean indicating if color writing is enabled
  49511. * @returns the current color writing state
  49512. */
  49513. getColorWrite(): boolean;
  49514. /**
  49515. * Sets alpha constants used by some alpha blending modes
  49516. * @param r defines the red component
  49517. * @param g defines the green component
  49518. * @param b defines the blue component
  49519. * @param a defines the alpha component
  49520. */
  49521. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49522. /**
  49523. * Sets the current alpha mode
  49524. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49526. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49527. */
  49528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49529. /**
  49530. * Gets the current alpha mode
  49531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49532. * @returns the current alpha mode
  49533. */
  49534. getAlphaMode(): number;
  49535. setInt(uniform: WebGLUniformLocation, int: number): void;
  49536. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49537. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49538. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49539. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49540. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49541. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49542. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49543. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49544. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49545. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49546. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49547. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49548. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49549. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49550. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49551. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49552. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49553. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49554. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49555. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49556. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49557. wipeCaches(bruteForce?: boolean): void;
  49558. _createTexture(): WebGLTexture;
  49559. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49560. /**
  49561. * Usually called from Texture.ts.
  49562. * Passed information to create a WebGLTexture
  49563. * @param urlArg defines a value which contains one of the following:
  49564. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49565. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49566. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49567. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49568. * @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)
  49569. * @param scene needed for loading to the correct scene
  49570. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49571. * @param onLoad optional callback to be called upon successful completion
  49572. * @param onError optional callback to be called upon failure
  49573. * @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
  49574. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49575. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49576. * @param forcedExtension defines the extension to use to pick the right loader
  49577. * @param mimeType defines an optional mime type
  49578. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49579. */
  49580. 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;
  49581. /**
  49582. * Creates a cube texture
  49583. * @param rootUrl defines the url where the files to load is located
  49584. * @param scene defines the current scene
  49585. * @param files defines the list of files to load (1 per face)
  49586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49587. * @param onLoad defines an optional callback raised when the texture is loaded
  49588. * @param onError defines an optional callback raised if there is an issue to load the texture
  49589. * @param format defines the format of the data
  49590. * @param forcedExtension defines the extension to use to pick the right loader
  49591. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49592. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49593. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49594. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49595. * @returns the cube texture as an InternalTexture
  49596. */
  49597. 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;
  49598. private _getSamplingFilter;
  49599. private static _GetNativeTextureFormat;
  49600. createRenderTargetTexture(size: number | {
  49601. width: number;
  49602. height: number;
  49603. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49604. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49605. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49606. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49607. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49608. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49609. /**
  49610. * Updates a dynamic vertex buffer.
  49611. * @param vertexBuffer the vertex buffer to update
  49612. * @param data the data used to update the vertex buffer
  49613. * @param byteOffset the byte offset of the data (optional)
  49614. * @param byteLength the byte length of the data (optional)
  49615. */
  49616. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49617. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49618. private _updateAnisotropicLevel;
  49619. private _getAddressMode;
  49620. /** @hidden */
  49621. _bindTexture(channel: number, texture: InternalTexture): void;
  49622. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49623. releaseEffects(): void;
  49624. /** @hidden */
  49625. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49626. /** @hidden */
  49627. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49628. /** @hidden */
  49629. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49630. /** @hidden */
  49631. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49632. }
  49633. }
  49634. declare module "babylonjs/Engines/index" {
  49635. export * from "babylonjs/Engines/constants";
  49636. export * from "babylonjs/Engines/engineCapabilities";
  49637. export * from "babylonjs/Engines/instancingAttributeInfo";
  49638. export * from "babylonjs/Engines/thinEngine";
  49639. export * from "babylonjs/Engines/engine";
  49640. export * from "babylonjs/Engines/engineStore";
  49641. export * from "babylonjs/Engines/nullEngine";
  49642. export * from "babylonjs/Engines/Extensions/index";
  49643. export * from "babylonjs/Engines/IPipelineContext";
  49644. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49645. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49646. export * from "babylonjs/Engines/nativeEngine";
  49647. }
  49648. declare module "babylonjs/Events/clipboardEvents" {
  49649. /**
  49650. * Gather the list of clipboard event types as constants.
  49651. */
  49652. export class ClipboardEventTypes {
  49653. /**
  49654. * The clipboard event is fired when a copy command is active (pressed).
  49655. */
  49656. static readonly COPY: number;
  49657. /**
  49658. * The clipboard event is fired when a cut command is active (pressed).
  49659. */
  49660. static readonly CUT: number;
  49661. /**
  49662. * The clipboard event is fired when a paste command is active (pressed).
  49663. */
  49664. static readonly PASTE: number;
  49665. }
  49666. /**
  49667. * This class is used to store clipboard related info for the onClipboardObservable event.
  49668. */
  49669. export class ClipboardInfo {
  49670. /**
  49671. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49672. */
  49673. type: number;
  49674. /**
  49675. * Defines the related dom event
  49676. */
  49677. event: ClipboardEvent;
  49678. /**
  49679. *Creates an instance of ClipboardInfo.
  49680. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49681. * @param event Defines the related dom event
  49682. */
  49683. constructor(
  49684. /**
  49685. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49686. */
  49687. type: number,
  49688. /**
  49689. * Defines the related dom event
  49690. */
  49691. event: ClipboardEvent);
  49692. /**
  49693. * Get the clipboard event's type from the keycode.
  49694. * @param keyCode Defines the keyCode for the current keyboard event.
  49695. * @return {number}
  49696. */
  49697. static GetTypeFromCharacter(keyCode: number): number;
  49698. }
  49699. }
  49700. declare module "babylonjs/Events/index" {
  49701. export * from "babylonjs/Events/keyboardEvents";
  49702. export * from "babylonjs/Events/pointerEvents";
  49703. export * from "babylonjs/Events/clipboardEvents";
  49704. }
  49705. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49706. import { Scene } from "babylonjs/scene";
  49707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49708. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49709. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49710. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49711. /**
  49712. * Google Daydream controller
  49713. */
  49714. export class DaydreamController extends WebVRController {
  49715. /**
  49716. * Base Url for the controller model.
  49717. */
  49718. static MODEL_BASE_URL: string;
  49719. /**
  49720. * File name for the controller model.
  49721. */
  49722. static MODEL_FILENAME: string;
  49723. /**
  49724. * Gamepad Id prefix used to identify Daydream Controller.
  49725. */
  49726. static readonly GAMEPAD_ID_PREFIX: string;
  49727. /**
  49728. * Creates a new DaydreamController from a gamepad
  49729. * @param vrGamepad the gamepad that the controller should be created from
  49730. */
  49731. constructor(vrGamepad: any);
  49732. /**
  49733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49734. * @param scene scene in which to add meshes
  49735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49736. */
  49737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49738. /**
  49739. * Called once for each button that changed state since the last frame
  49740. * @param buttonIdx Which button index changed
  49741. * @param state New state of the button
  49742. * @param changes Which properties on the state changed since last frame
  49743. */
  49744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49745. }
  49746. }
  49747. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49748. import { Scene } from "babylonjs/scene";
  49749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49750. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49751. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49752. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49753. /**
  49754. * Gear VR Controller
  49755. */
  49756. export class GearVRController extends WebVRController {
  49757. /**
  49758. * Base Url for the controller model.
  49759. */
  49760. static MODEL_BASE_URL: string;
  49761. /**
  49762. * File name for the controller model.
  49763. */
  49764. static MODEL_FILENAME: string;
  49765. /**
  49766. * Gamepad Id prefix used to identify this controller.
  49767. */
  49768. static readonly GAMEPAD_ID_PREFIX: string;
  49769. private readonly _buttonIndexToObservableNameMap;
  49770. /**
  49771. * Creates a new GearVRController from a gamepad
  49772. * @param vrGamepad the gamepad that the controller should be created from
  49773. */
  49774. constructor(vrGamepad: any);
  49775. /**
  49776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49777. * @param scene scene in which to add meshes
  49778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49779. */
  49780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49781. /**
  49782. * Called once for each button that changed state since the last frame
  49783. * @param buttonIdx Which button index changed
  49784. * @param state New state of the button
  49785. * @param changes Which properties on the state changed since last frame
  49786. */
  49787. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49788. }
  49789. }
  49790. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49791. import { Scene } from "babylonjs/scene";
  49792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49793. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49794. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49795. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49796. /**
  49797. * Generic Controller
  49798. */
  49799. export class GenericController extends WebVRController {
  49800. /**
  49801. * Base Url for the controller model.
  49802. */
  49803. static readonly MODEL_BASE_URL: string;
  49804. /**
  49805. * File name for the controller model.
  49806. */
  49807. static readonly MODEL_FILENAME: string;
  49808. /**
  49809. * Creates a new GenericController from a gamepad
  49810. * @param vrGamepad the gamepad that the controller should be created from
  49811. */
  49812. constructor(vrGamepad: any);
  49813. /**
  49814. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49815. * @param scene scene in which to add meshes
  49816. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49817. */
  49818. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49819. /**
  49820. * Called once for each button that changed state since the last frame
  49821. * @param buttonIdx Which button index changed
  49822. * @param state New state of the button
  49823. * @param changes Which properties on the state changed since last frame
  49824. */
  49825. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49826. }
  49827. }
  49828. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49829. import { Observable } from "babylonjs/Misc/observable";
  49830. import { Scene } from "babylonjs/scene";
  49831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49832. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49833. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49834. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49835. /**
  49836. * Oculus Touch Controller
  49837. */
  49838. export class OculusTouchController extends WebVRController {
  49839. /**
  49840. * Base Url for the controller model.
  49841. */
  49842. static MODEL_BASE_URL: string;
  49843. /**
  49844. * File name for the left controller model.
  49845. */
  49846. static MODEL_LEFT_FILENAME: string;
  49847. /**
  49848. * File name for the right controller model.
  49849. */
  49850. static MODEL_RIGHT_FILENAME: string;
  49851. /**
  49852. * Base Url for the Quest controller model.
  49853. */
  49854. static QUEST_MODEL_BASE_URL: string;
  49855. /**
  49856. * @hidden
  49857. * If the controllers are running on a device that needs the updated Quest controller models
  49858. */
  49859. static _IsQuest: boolean;
  49860. /**
  49861. * Fired when the secondary trigger on this controller is modified
  49862. */
  49863. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49864. /**
  49865. * Fired when the thumb rest on this controller is modified
  49866. */
  49867. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49868. /**
  49869. * Creates a new OculusTouchController from a gamepad
  49870. * @param vrGamepad the gamepad that the controller should be created from
  49871. */
  49872. constructor(vrGamepad: any);
  49873. /**
  49874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49875. * @param scene scene in which to add meshes
  49876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49877. */
  49878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49879. /**
  49880. * Fired when the A button on this controller is modified
  49881. */
  49882. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49883. /**
  49884. * Fired when the B button on this controller is modified
  49885. */
  49886. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49887. /**
  49888. * Fired when the X button on this controller is modified
  49889. */
  49890. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49891. /**
  49892. * Fired when the Y button on this controller is modified
  49893. */
  49894. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49895. /**
  49896. * Called once for each button that changed state since the last frame
  49897. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49898. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49899. * 2) secondary trigger (same)
  49900. * 3) A (right) X (left), touch, pressed = value
  49901. * 4) B / Y
  49902. * 5) thumb rest
  49903. * @param buttonIdx Which button index changed
  49904. * @param state New state of the button
  49905. * @param changes Which properties on the state changed since last frame
  49906. */
  49907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49908. }
  49909. }
  49910. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49911. import { Scene } from "babylonjs/scene";
  49912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49913. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49914. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49915. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49916. import { Observable } from "babylonjs/Misc/observable";
  49917. /**
  49918. * Vive Controller
  49919. */
  49920. export class ViveController extends WebVRController {
  49921. /**
  49922. * Base Url for the controller model.
  49923. */
  49924. static MODEL_BASE_URL: string;
  49925. /**
  49926. * File name for the controller model.
  49927. */
  49928. static MODEL_FILENAME: string;
  49929. /**
  49930. * Creates a new ViveController from a gamepad
  49931. * @param vrGamepad the gamepad that the controller should be created from
  49932. */
  49933. constructor(vrGamepad: any);
  49934. /**
  49935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49936. * @param scene scene in which to add meshes
  49937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49938. */
  49939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49940. /**
  49941. * Fired when the left button on this controller is modified
  49942. */
  49943. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49944. /**
  49945. * Fired when the right button on this controller is modified
  49946. */
  49947. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49948. /**
  49949. * Fired when the menu button on this controller is modified
  49950. */
  49951. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49952. /**
  49953. * Called once for each button that changed state since the last frame
  49954. * Vive mapping:
  49955. * 0: touchpad
  49956. * 1: trigger
  49957. * 2: left AND right buttons
  49958. * 3: menu button
  49959. * @param buttonIdx Which button index changed
  49960. * @param state New state of the button
  49961. * @param changes Which properties on the state changed since last frame
  49962. */
  49963. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49964. }
  49965. }
  49966. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49967. import { Observable } from "babylonjs/Misc/observable";
  49968. import { Scene } from "babylonjs/scene";
  49969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49970. import { Ray } from "babylonjs/Culling/ray";
  49971. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49972. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49973. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49974. /**
  49975. * Defines the WindowsMotionController object that the state of the windows motion controller
  49976. */
  49977. export class WindowsMotionController extends WebVRController {
  49978. /**
  49979. * The base url used to load the left and right controller models
  49980. */
  49981. static MODEL_BASE_URL: string;
  49982. /**
  49983. * The name of the left controller model file
  49984. */
  49985. static MODEL_LEFT_FILENAME: string;
  49986. /**
  49987. * The name of the right controller model file
  49988. */
  49989. static MODEL_RIGHT_FILENAME: string;
  49990. /**
  49991. * The controller name prefix for this controller type
  49992. */
  49993. static readonly GAMEPAD_ID_PREFIX: string;
  49994. /**
  49995. * The controller id pattern for this controller type
  49996. */
  49997. private static readonly GAMEPAD_ID_PATTERN;
  49998. private _loadedMeshInfo;
  49999. protected readonly _mapping: {
  50000. buttons: string[];
  50001. buttonMeshNames: {
  50002. 'trigger': string;
  50003. 'menu': string;
  50004. 'grip': string;
  50005. 'thumbstick': string;
  50006. 'trackpad': string;
  50007. };
  50008. buttonObservableNames: {
  50009. 'trigger': string;
  50010. 'menu': string;
  50011. 'grip': string;
  50012. 'thumbstick': string;
  50013. 'trackpad': string;
  50014. };
  50015. axisMeshNames: string[];
  50016. pointingPoseMeshName: string;
  50017. };
  50018. /**
  50019. * Fired when the trackpad on this controller is clicked
  50020. */
  50021. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50022. /**
  50023. * Fired when the trackpad on this controller is modified
  50024. */
  50025. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50026. /**
  50027. * The current x and y values of this controller's trackpad
  50028. */
  50029. trackpad: StickValues;
  50030. /**
  50031. * Creates a new WindowsMotionController from a gamepad
  50032. * @param vrGamepad the gamepad that the controller should be created from
  50033. */
  50034. constructor(vrGamepad: any);
  50035. /**
  50036. * Fired when the trigger on this controller is modified
  50037. */
  50038. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50039. /**
  50040. * Fired when the menu button on this controller is modified
  50041. */
  50042. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50043. /**
  50044. * Fired when the grip button on this controller is modified
  50045. */
  50046. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50047. /**
  50048. * Fired when the thumbstick button on this controller is modified
  50049. */
  50050. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50051. /**
  50052. * Fired when the touchpad button on this controller is modified
  50053. */
  50054. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50055. /**
  50056. * Fired when the touchpad values on this controller are modified
  50057. */
  50058. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50059. protected _updateTrackpad(): void;
  50060. /**
  50061. * Called once per frame by the engine.
  50062. */
  50063. update(): void;
  50064. /**
  50065. * Called once for each button that changed state since the last frame
  50066. * @param buttonIdx Which button index changed
  50067. * @param state New state of the button
  50068. * @param changes Which properties on the state changed since last frame
  50069. */
  50070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50071. /**
  50072. * Moves the buttons on the controller mesh based on their current state
  50073. * @param buttonName the name of the button to move
  50074. * @param buttonValue the value of the button which determines the buttons new position
  50075. */
  50076. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50077. /**
  50078. * Moves the axis on the controller mesh based on its current state
  50079. * @param axis the index of the axis
  50080. * @param axisValue the value of the axis which determines the meshes new position
  50081. * @hidden
  50082. */
  50083. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50084. /**
  50085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50086. * @param scene scene in which to add meshes
  50087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50088. */
  50089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50090. /**
  50091. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50092. * can be transformed by button presses and axes values, based on this._mapping.
  50093. *
  50094. * @param scene scene in which the meshes exist
  50095. * @param meshes list of meshes that make up the controller model to process
  50096. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50097. */
  50098. private processModel;
  50099. private createMeshInfo;
  50100. /**
  50101. * Gets the ray of the controller in the direction the controller is pointing
  50102. * @param length the length the resulting ray should be
  50103. * @returns a ray in the direction the controller is pointing
  50104. */
  50105. getForwardRay(length?: number): Ray;
  50106. /**
  50107. * Disposes of the controller
  50108. */
  50109. dispose(): void;
  50110. }
  50111. /**
  50112. * This class represents a new windows motion controller in XR.
  50113. */
  50114. export class XRWindowsMotionController extends WindowsMotionController {
  50115. /**
  50116. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50117. */
  50118. protected readonly _mapping: {
  50119. buttons: string[];
  50120. buttonMeshNames: {
  50121. 'trigger': string;
  50122. 'menu': string;
  50123. 'grip': string;
  50124. 'thumbstick': string;
  50125. 'trackpad': string;
  50126. };
  50127. buttonObservableNames: {
  50128. 'trigger': string;
  50129. 'menu': string;
  50130. 'grip': string;
  50131. 'thumbstick': string;
  50132. 'trackpad': string;
  50133. };
  50134. axisMeshNames: string[];
  50135. pointingPoseMeshName: string;
  50136. };
  50137. /**
  50138. * Construct a new XR-Based windows motion controller
  50139. *
  50140. * @param gamepadInfo the gamepad object from the browser
  50141. */
  50142. constructor(gamepadInfo: any);
  50143. /**
  50144. * holds the thumbstick values (X,Y)
  50145. */
  50146. thumbstickValues: StickValues;
  50147. /**
  50148. * Fired when the thumbstick on this controller is clicked
  50149. */
  50150. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50151. /**
  50152. * Fired when the thumbstick on this controller is modified
  50153. */
  50154. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50155. /**
  50156. * Fired when the touchpad button on this controller is modified
  50157. */
  50158. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50159. /**
  50160. * Fired when the touchpad values on this controller are modified
  50161. */
  50162. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50163. /**
  50164. * Fired when the thumbstick button on this controller is modified
  50165. * here to prevent breaking changes
  50166. */
  50167. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50168. /**
  50169. * updating the thumbstick(!) and not the trackpad.
  50170. * This is named this way due to the difference between WebVR and XR and to avoid
  50171. * changing the parent class.
  50172. */
  50173. protected _updateTrackpad(): void;
  50174. /**
  50175. * Disposes the class with joy
  50176. */
  50177. dispose(): void;
  50178. }
  50179. }
  50180. declare module "babylonjs/Gamepads/Controllers/index" {
  50181. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50182. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50183. export * from "babylonjs/Gamepads/Controllers/genericController";
  50184. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50185. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50186. export * from "babylonjs/Gamepads/Controllers/viveController";
  50187. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50188. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50189. }
  50190. declare module "babylonjs/Gamepads/index" {
  50191. export * from "babylonjs/Gamepads/Controllers/index";
  50192. export * from "babylonjs/Gamepads/gamepad";
  50193. export * from "babylonjs/Gamepads/gamepadManager";
  50194. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50195. export * from "babylonjs/Gamepads/xboxGamepad";
  50196. export * from "babylonjs/Gamepads/dualShockGamepad";
  50197. }
  50198. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50199. import { Scene } from "babylonjs/scene";
  50200. import { Vector4 } from "babylonjs/Maths/math.vector";
  50201. import { Color4 } from "babylonjs/Maths/math.color";
  50202. import { Mesh } from "babylonjs/Meshes/mesh";
  50203. import { Nullable } from "babylonjs/types";
  50204. /**
  50205. * Class containing static functions to help procedurally build meshes
  50206. */
  50207. export class PolyhedronBuilder {
  50208. /**
  50209. * Creates a polyhedron mesh
  50210. * * 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
  50211. * * The parameter `size` (positive float, default 1) sets the polygon size
  50212. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50213. * * 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`
  50214. * * 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
  50215. * * 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)`)
  50216. * * 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
  50217. * * 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
  50218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50221. * @param name defines the name of the mesh
  50222. * @param options defines the options used to create the mesh
  50223. * @param scene defines the hosting scene
  50224. * @returns the polyhedron mesh
  50225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50226. */
  50227. static CreatePolyhedron(name: string, options: {
  50228. type?: number;
  50229. size?: number;
  50230. sizeX?: number;
  50231. sizeY?: number;
  50232. sizeZ?: number;
  50233. custom?: any;
  50234. faceUV?: Vector4[];
  50235. faceColors?: Color4[];
  50236. flat?: boolean;
  50237. updatable?: boolean;
  50238. sideOrientation?: number;
  50239. frontUVs?: Vector4;
  50240. backUVs?: Vector4;
  50241. }, scene?: Nullable<Scene>): Mesh;
  50242. }
  50243. }
  50244. declare module "babylonjs/Gizmos/scaleGizmo" {
  50245. import { Observable } from "babylonjs/Misc/observable";
  50246. import { Nullable } from "babylonjs/types";
  50247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50248. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50249. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50251. /**
  50252. * Gizmo that enables scaling a mesh along 3 axis
  50253. */
  50254. export class ScaleGizmo extends Gizmo {
  50255. /**
  50256. * Internal gizmo used for interactions on the x axis
  50257. */
  50258. xGizmo: AxisScaleGizmo;
  50259. /**
  50260. * Internal gizmo used for interactions on the y axis
  50261. */
  50262. yGizmo: AxisScaleGizmo;
  50263. /**
  50264. * Internal gizmo used for interactions on the z axis
  50265. */
  50266. zGizmo: AxisScaleGizmo;
  50267. /**
  50268. * Internal gizmo used to scale all axis equally
  50269. */
  50270. uniformScaleGizmo: AxisScaleGizmo;
  50271. private _meshAttached;
  50272. private _updateGizmoRotationToMatchAttachedMesh;
  50273. private _snapDistance;
  50274. private _scaleRatio;
  50275. private _uniformScalingMesh;
  50276. private _octahedron;
  50277. private _sensitivity;
  50278. /** Fires an event when any of it's sub gizmos are dragged */
  50279. onDragStartObservable: Observable<unknown>;
  50280. /** Fires an event when any of it's sub gizmos are released from dragging */
  50281. onDragEndObservable: Observable<unknown>;
  50282. get attachedMesh(): Nullable<AbstractMesh>;
  50283. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50284. /**
  50285. * Creates a ScaleGizmo
  50286. * @param gizmoLayer The utility layer the gizmo will be added to
  50287. */
  50288. constructor(gizmoLayer?: UtilityLayerRenderer);
  50289. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50290. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50291. /**
  50292. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50293. */
  50294. set snapDistance(value: number);
  50295. get snapDistance(): number;
  50296. /**
  50297. * Ratio for the scale of the gizmo (Default: 1)
  50298. */
  50299. set scaleRatio(value: number);
  50300. get scaleRatio(): number;
  50301. /**
  50302. * Sensitivity factor for dragging (Default: 1)
  50303. */
  50304. set sensitivity(value: number);
  50305. get sensitivity(): number;
  50306. /**
  50307. * Disposes of the gizmo
  50308. */
  50309. dispose(): void;
  50310. }
  50311. }
  50312. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50313. import { Observable } from "babylonjs/Misc/observable";
  50314. import { Nullable } from "babylonjs/types";
  50315. import { Vector3 } from "babylonjs/Maths/math.vector";
  50316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50317. import { Mesh } from "babylonjs/Meshes/mesh";
  50318. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50319. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50321. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50322. import { Color3 } from "babylonjs/Maths/math.color";
  50323. /**
  50324. * Single axis scale gizmo
  50325. */
  50326. export class AxisScaleGizmo extends Gizmo {
  50327. /**
  50328. * Drag behavior responsible for the gizmos dragging interactions
  50329. */
  50330. dragBehavior: PointerDragBehavior;
  50331. private _pointerObserver;
  50332. /**
  50333. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50334. */
  50335. snapDistance: number;
  50336. /**
  50337. * Event that fires each time the gizmo snaps to a new location.
  50338. * * snapDistance is the the change in distance
  50339. */
  50340. onSnapObservable: Observable<{
  50341. snapDistance: number;
  50342. }>;
  50343. /**
  50344. * If the scaling operation should be done on all axis (default: false)
  50345. */
  50346. uniformScaling: boolean;
  50347. /**
  50348. * Custom sensitivity value for the drag strength
  50349. */
  50350. sensitivity: number;
  50351. private _isEnabled;
  50352. private _parent;
  50353. private _arrow;
  50354. private _coloredMaterial;
  50355. private _hoverMaterial;
  50356. /**
  50357. * Creates an AxisScaleGizmo
  50358. * @param gizmoLayer The utility layer the gizmo will be added to
  50359. * @param dragAxis The axis which the gizmo will be able to scale on
  50360. * @param color The color of the gizmo
  50361. */
  50362. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50364. /**
  50365. * If the gizmo is enabled
  50366. */
  50367. set isEnabled(value: boolean);
  50368. get isEnabled(): boolean;
  50369. /**
  50370. * Disposes of the gizmo
  50371. */
  50372. dispose(): void;
  50373. /**
  50374. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50375. * @param mesh The mesh to replace the default mesh of the gizmo
  50376. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50377. */
  50378. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50379. }
  50380. }
  50381. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50382. import { Observable } from "babylonjs/Misc/observable";
  50383. import { Nullable } from "babylonjs/types";
  50384. import { Vector3 } from "babylonjs/Maths/math.vector";
  50385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50386. import { Mesh } from "babylonjs/Meshes/mesh";
  50387. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50388. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50389. import { Color3 } from "babylonjs/Maths/math.color";
  50390. import "babylonjs/Meshes/Builders/boxBuilder";
  50391. /**
  50392. * Bounding box gizmo
  50393. */
  50394. export class BoundingBoxGizmo extends Gizmo {
  50395. private _lineBoundingBox;
  50396. private _rotateSpheresParent;
  50397. private _scaleBoxesParent;
  50398. private _boundingDimensions;
  50399. private _renderObserver;
  50400. private _pointerObserver;
  50401. private _scaleDragSpeed;
  50402. private _tmpQuaternion;
  50403. private _tmpVector;
  50404. private _tmpRotationMatrix;
  50405. /**
  50406. * 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)
  50407. */
  50408. ignoreChildren: boolean;
  50409. /**
  50410. * 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)
  50411. */
  50412. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50413. /**
  50414. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50415. */
  50416. rotationSphereSize: number;
  50417. /**
  50418. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50419. */
  50420. scaleBoxSize: number;
  50421. /**
  50422. * 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)
  50423. */
  50424. fixedDragMeshScreenSize: boolean;
  50425. /**
  50426. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50427. */
  50428. fixedDragMeshScreenSizeDistanceFactor: number;
  50429. /**
  50430. * Fired when a rotation sphere or scale box is dragged
  50431. */
  50432. onDragStartObservable: Observable<{}>;
  50433. /**
  50434. * Fired when a scale box is dragged
  50435. */
  50436. onScaleBoxDragObservable: Observable<{}>;
  50437. /**
  50438. * Fired when a scale box drag is ended
  50439. */
  50440. onScaleBoxDragEndObservable: Observable<{}>;
  50441. /**
  50442. * Fired when a rotation sphere is dragged
  50443. */
  50444. onRotationSphereDragObservable: Observable<{}>;
  50445. /**
  50446. * Fired when a rotation sphere drag is ended
  50447. */
  50448. onRotationSphereDragEndObservable: Observable<{}>;
  50449. /**
  50450. * 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)
  50451. */
  50452. scalePivot: Nullable<Vector3>;
  50453. /**
  50454. * Mesh used as a pivot to rotate the attached mesh
  50455. */
  50456. private _anchorMesh;
  50457. private _existingMeshScale;
  50458. private _dragMesh;
  50459. private pointerDragBehavior;
  50460. private coloredMaterial;
  50461. private hoverColoredMaterial;
  50462. /**
  50463. * Sets the color of the bounding box gizmo
  50464. * @param color the color to set
  50465. */
  50466. setColor(color: Color3): void;
  50467. /**
  50468. * Creates an BoundingBoxGizmo
  50469. * @param gizmoLayer The utility layer the gizmo will be added to
  50470. * @param color The color of the gizmo
  50471. */
  50472. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50473. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50474. private _selectNode;
  50475. /**
  50476. * Updates the bounding box information for the Gizmo
  50477. */
  50478. updateBoundingBox(): void;
  50479. private _updateRotationSpheres;
  50480. private _updateScaleBoxes;
  50481. /**
  50482. * Enables rotation on the specified axis and disables rotation on the others
  50483. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50484. */
  50485. setEnabledRotationAxis(axis: string): void;
  50486. /**
  50487. * Enables/disables scaling
  50488. * @param enable if scaling should be enabled
  50489. */
  50490. setEnabledScaling(enable: boolean): void;
  50491. private _updateDummy;
  50492. /**
  50493. * Enables a pointer drag behavior on the bounding box of the gizmo
  50494. */
  50495. enableDragBehavior(): void;
  50496. /**
  50497. * Disposes of the gizmo
  50498. */
  50499. dispose(): void;
  50500. /**
  50501. * 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)
  50502. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50503. * @returns the bounding box mesh with the passed in mesh as a child
  50504. */
  50505. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50506. /**
  50507. * CustomMeshes are not supported by this gizmo
  50508. * @param mesh The mesh to replace the default mesh of the gizmo
  50509. */
  50510. setCustomMesh(mesh: Mesh): void;
  50511. }
  50512. }
  50513. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50514. import { Observable } from "babylonjs/Misc/observable";
  50515. import { Nullable } from "babylonjs/types";
  50516. import { Vector3 } from "babylonjs/Maths/math.vector";
  50517. import { Color3 } from "babylonjs/Maths/math.color";
  50518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50519. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50520. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50521. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50522. import "babylonjs/Meshes/Builders/linesBuilder";
  50523. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50524. /**
  50525. * Single plane rotation gizmo
  50526. */
  50527. export class PlaneRotationGizmo extends Gizmo {
  50528. /**
  50529. * Drag behavior responsible for the gizmos dragging interactions
  50530. */
  50531. dragBehavior: PointerDragBehavior;
  50532. private _pointerObserver;
  50533. /**
  50534. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50535. */
  50536. snapDistance: number;
  50537. /**
  50538. * Event that fires each time the gizmo snaps to a new location.
  50539. * * snapDistance is the the change in distance
  50540. */
  50541. onSnapObservable: Observable<{
  50542. snapDistance: number;
  50543. }>;
  50544. private _isEnabled;
  50545. private _parent;
  50546. /**
  50547. * Creates a PlaneRotationGizmo
  50548. * @param gizmoLayer The utility layer the gizmo will be added to
  50549. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50550. * @param color The color of the gizmo
  50551. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50552. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50553. */
  50554. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50556. /**
  50557. * If the gizmo is enabled
  50558. */
  50559. set isEnabled(value: boolean);
  50560. get isEnabled(): boolean;
  50561. /**
  50562. * Disposes of the gizmo
  50563. */
  50564. dispose(): void;
  50565. }
  50566. }
  50567. declare module "babylonjs/Gizmos/rotationGizmo" {
  50568. import { Observable } from "babylonjs/Misc/observable";
  50569. import { Nullable } from "babylonjs/types";
  50570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50571. import { Mesh } from "babylonjs/Meshes/mesh";
  50572. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50573. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50575. /**
  50576. * Gizmo that enables rotating a mesh along 3 axis
  50577. */
  50578. export class RotationGizmo extends Gizmo {
  50579. /**
  50580. * Internal gizmo used for interactions on the x axis
  50581. */
  50582. xGizmo: PlaneRotationGizmo;
  50583. /**
  50584. * Internal gizmo used for interactions on the y axis
  50585. */
  50586. yGizmo: PlaneRotationGizmo;
  50587. /**
  50588. * Internal gizmo used for interactions on the z axis
  50589. */
  50590. zGizmo: PlaneRotationGizmo;
  50591. /** Fires an event when any of it's sub gizmos are dragged */
  50592. onDragStartObservable: Observable<unknown>;
  50593. /** Fires an event when any of it's sub gizmos are released from dragging */
  50594. onDragEndObservable: Observable<unknown>;
  50595. private _meshAttached;
  50596. get attachedMesh(): Nullable<AbstractMesh>;
  50597. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50598. /**
  50599. * Creates a RotationGizmo
  50600. * @param gizmoLayer The utility layer the gizmo will be added to
  50601. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50602. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50603. */
  50604. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50605. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50606. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50607. /**
  50608. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50609. */
  50610. set snapDistance(value: number);
  50611. get snapDistance(): number;
  50612. /**
  50613. * Ratio for the scale of the gizmo (Default: 1)
  50614. */
  50615. set scaleRatio(value: number);
  50616. get scaleRatio(): number;
  50617. /**
  50618. * Disposes of the gizmo
  50619. */
  50620. dispose(): void;
  50621. /**
  50622. * CustomMeshes are not supported by this gizmo
  50623. * @param mesh The mesh to replace the default mesh of the gizmo
  50624. */
  50625. setCustomMesh(mesh: Mesh): void;
  50626. }
  50627. }
  50628. declare module "babylonjs/Gizmos/gizmoManager" {
  50629. import { Observable } from "babylonjs/Misc/observable";
  50630. import { Nullable } from "babylonjs/types";
  50631. import { Scene, IDisposable } from "babylonjs/scene";
  50632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50633. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50634. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50635. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50636. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50637. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50638. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50639. /**
  50640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50641. */
  50642. export class GizmoManager implements IDisposable {
  50643. private scene;
  50644. /**
  50645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50646. */
  50647. gizmos: {
  50648. positionGizmo: Nullable<PositionGizmo>;
  50649. rotationGizmo: Nullable<RotationGizmo>;
  50650. scaleGizmo: Nullable<ScaleGizmo>;
  50651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50652. };
  50653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50654. clearGizmoOnEmptyPointerEvent: boolean;
  50655. /** Fires an event when the manager is attached to a mesh */
  50656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50657. private _gizmosEnabled;
  50658. private _pointerObserver;
  50659. private _attachedMesh;
  50660. private _boundingBoxColor;
  50661. private _defaultUtilityLayer;
  50662. private _defaultKeepDepthUtilityLayer;
  50663. /**
  50664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50665. */
  50666. boundingBoxDragBehavior: SixDofDragBehavior;
  50667. /**
  50668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50669. */
  50670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50671. /**
  50672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50673. */
  50674. usePointerToAttachGizmos: boolean;
  50675. /**
  50676. * Utility layer that the bounding box gizmo belongs to
  50677. */
  50678. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50679. /**
  50680. * Utility layer that all gizmos besides bounding box belong to
  50681. */
  50682. get utilityLayer(): UtilityLayerRenderer;
  50683. /**
  50684. * Instatiates a gizmo manager
  50685. * @param scene the scene to overlay the gizmos on top of
  50686. */
  50687. constructor(scene: Scene);
  50688. /**
  50689. * Attaches a set of gizmos to the specified mesh
  50690. * @param mesh The mesh the gizmo's should be attached to
  50691. */
  50692. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50693. /**
  50694. * If the position gizmo is enabled
  50695. */
  50696. set positionGizmoEnabled(value: boolean);
  50697. get positionGizmoEnabled(): boolean;
  50698. /**
  50699. * If the rotation gizmo is enabled
  50700. */
  50701. set rotationGizmoEnabled(value: boolean);
  50702. get rotationGizmoEnabled(): boolean;
  50703. /**
  50704. * If the scale gizmo is enabled
  50705. */
  50706. set scaleGizmoEnabled(value: boolean);
  50707. get scaleGizmoEnabled(): boolean;
  50708. /**
  50709. * If the boundingBox gizmo is enabled
  50710. */
  50711. set boundingBoxGizmoEnabled(value: boolean);
  50712. get boundingBoxGizmoEnabled(): boolean;
  50713. /**
  50714. * Disposes of the gizmo manager
  50715. */
  50716. dispose(): void;
  50717. }
  50718. }
  50719. declare module "babylonjs/Lights/directionalLight" {
  50720. import { Camera } from "babylonjs/Cameras/camera";
  50721. import { Scene } from "babylonjs/scene";
  50722. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50724. import { Light } from "babylonjs/Lights/light";
  50725. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50726. import { Effect } from "babylonjs/Materials/effect";
  50727. /**
  50728. * A directional light is defined by a direction (what a surprise!).
  50729. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50730. * 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.
  50731. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50732. */
  50733. export class DirectionalLight extends ShadowLight {
  50734. private _shadowFrustumSize;
  50735. /**
  50736. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50737. */
  50738. get shadowFrustumSize(): number;
  50739. /**
  50740. * Specifies a fix frustum size for the shadow generation.
  50741. */
  50742. set shadowFrustumSize(value: number);
  50743. private _shadowOrthoScale;
  50744. /**
  50745. * Gets the shadow projection scale against the optimal computed one.
  50746. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50747. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50748. */
  50749. get shadowOrthoScale(): number;
  50750. /**
  50751. * Sets the shadow projection scale against the optimal computed one.
  50752. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50753. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50754. */
  50755. set shadowOrthoScale(value: number);
  50756. /**
  50757. * Automatically compute the projection matrix to best fit (including all the casters)
  50758. * on each frame.
  50759. */
  50760. autoUpdateExtends: boolean;
  50761. /**
  50762. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50763. * on each frame. autoUpdateExtends must be set to true for this to work
  50764. */
  50765. autoCalcShadowZBounds: boolean;
  50766. private _orthoLeft;
  50767. private _orthoRight;
  50768. private _orthoTop;
  50769. private _orthoBottom;
  50770. /**
  50771. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50772. * The directional light is emitted from everywhere in the given direction.
  50773. * It can cast shadows.
  50774. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50775. * @param name The friendly name of the light
  50776. * @param direction The direction of the light
  50777. * @param scene The scene the light belongs to
  50778. */
  50779. constructor(name: string, direction: Vector3, scene: Scene);
  50780. /**
  50781. * Returns the string "DirectionalLight".
  50782. * @return The class name
  50783. */
  50784. getClassName(): string;
  50785. /**
  50786. * Returns the integer 1.
  50787. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50788. */
  50789. getTypeID(): number;
  50790. /**
  50791. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50792. * Returns the DirectionalLight Shadow projection matrix.
  50793. */
  50794. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50795. /**
  50796. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50797. * Returns the DirectionalLight Shadow projection matrix.
  50798. */
  50799. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50800. /**
  50801. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50802. * Returns the DirectionalLight Shadow projection matrix.
  50803. */
  50804. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50805. protected _buildUniformLayout(): void;
  50806. /**
  50807. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50808. * @param effect The effect to update
  50809. * @param lightIndex The index of the light in the effect to update
  50810. * @returns The directional light
  50811. */
  50812. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50813. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50814. /**
  50815. * Gets the minZ used for shadow according to both the scene and the light.
  50816. *
  50817. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50818. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50819. * @param activeCamera The camera we are returning the min for
  50820. * @returns the depth min z
  50821. */
  50822. getDepthMinZ(activeCamera: Camera): number;
  50823. /**
  50824. * Gets the maxZ used for shadow according to both the scene and the light.
  50825. *
  50826. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50827. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50828. * @param activeCamera The camera we are returning the max for
  50829. * @returns the depth max z
  50830. */
  50831. getDepthMaxZ(activeCamera: Camera): number;
  50832. /**
  50833. * Prepares the list of defines specific to the light type.
  50834. * @param defines the list of defines
  50835. * @param lightIndex defines the index of the light for the effect
  50836. */
  50837. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50838. }
  50839. }
  50840. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50841. import { Mesh } from "babylonjs/Meshes/mesh";
  50842. /**
  50843. * Class containing static functions to help procedurally build meshes
  50844. */
  50845. export class HemisphereBuilder {
  50846. /**
  50847. * Creates a hemisphere mesh
  50848. * @param name defines the name of the mesh
  50849. * @param options defines the options used to create the mesh
  50850. * @param scene defines the hosting scene
  50851. * @returns the hemisphere mesh
  50852. */
  50853. static CreateHemisphere(name: string, options: {
  50854. segments?: number;
  50855. diameter?: number;
  50856. sideOrientation?: number;
  50857. }, scene: any): Mesh;
  50858. }
  50859. }
  50860. declare module "babylonjs/Lights/spotLight" {
  50861. import { Nullable } from "babylonjs/types";
  50862. import { Scene } from "babylonjs/scene";
  50863. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50865. import { Effect } from "babylonjs/Materials/effect";
  50866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50867. import { Light } from "babylonjs/Lights/light";
  50868. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50869. /**
  50870. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50871. * These values define a cone of light starting from the position, emitting toward the direction.
  50872. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50873. * and the exponent defines the speed of the decay of the light with distance (reach).
  50874. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50875. */
  50876. export class SpotLight extends ShadowLight {
  50877. private _angle;
  50878. private _innerAngle;
  50879. private _cosHalfAngle;
  50880. private _lightAngleScale;
  50881. private _lightAngleOffset;
  50882. /**
  50883. * Gets the cone angle of the spot light in Radians.
  50884. */
  50885. get angle(): number;
  50886. /**
  50887. * Sets the cone angle of the spot light in Radians.
  50888. */
  50889. set angle(value: number);
  50890. /**
  50891. * Only used in gltf falloff mode, this defines the angle where
  50892. * the directional falloff will start before cutting at angle which could be seen
  50893. * as outer angle.
  50894. */
  50895. get innerAngle(): number;
  50896. /**
  50897. * Only used in gltf falloff mode, this defines the angle where
  50898. * the directional falloff will start before cutting at angle which could be seen
  50899. * as outer angle.
  50900. */
  50901. set innerAngle(value: number);
  50902. private _shadowAngleScale;
  50903. /**
  50904. * Allows scaling the angle of the light for shadow generation only.
  50905. */
  50906. get shadowAngleScale(): number;
  50907. /**
  50908. * Allows scaling the angle of the light for shadow generation only.
  50909. */
  50910. set shadowAngleScale(value: number);
  50911. /**
  50912. * The light decay speed with the distance from the emission spot.
  50913. */
  50914. exponent: number;
  50915. private _projectionTextureMatrix;
  50916. /**
  50917. * Allows reading the projecton texture
  50918. */
  50919. get projectionTextureMatrix(): Matrix;
  50920. protected _projectionTextureLightNear: number;
  50921. /**
  50922. * Gets the near clip of the Spotlight for texture projection.
  50923. */
  50924. get projectionTextureLightNear(): number;
  50925. /**
  50926. * Sets the near clip of the Spotlight for texture projection.
  50927. */
  50928. set projectionTextureLightNear(value: number);
  50929. protected _projectionTextureLightFar: number;
  50930. /**
  50931. * Gets the far clip of the Spotlight for texture projection.
  50932. */
  50933. get projectionTextureLightFar(): number;
  50934. /**
  50935. * Sets the far clip of the Spotlight for texture projection.
  50936. */
  50937. set projectionTextureLightFar(value: number);
  50938. protected _projectionTextureUpDirection: Vector3;
  50939. /**
  50940. * Gets the Up vector of the Spotlight for texture projection.
  50941. */
  50942. get projectionTextureUpDirection(): Vector3;
  50943. /**
  50944. * Sets the Up vector of the Spotlight for texture projection.
  50945. */
  50946. set projectionTextureUpDirection(value: Vector3);
  50947. private _projectionTexture;
  50948. /**
  50949. * Gets the projection texture of the light.
  50950. */
  50951. get projectionTexture(): Nullable<BaseTexture>;
  50952. /**
  50953. * Sets the projection texture of the light.
  50954. */
  50955. set projectionTexture(value: Nullable<BaseTexture>);
  50956. private _projectionTextureViewLightDirty;
  50957. private _projectionTextureProjectionLightDirty;
  50958. private _projectionTextureDirty;
  50959. private _projectionTextureViewTargetVector;
  50960. private _projectionTextureViewLightMatrix;
  50961. private _projectionTextureProjectionLightMatrix;
  50962. private _projectionTextureScalingMatrix;
  50963. /**
  50964. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50965. * It can cast shadows.
  50966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50967. * @param name The light friendly name
  50968. * @param position The position of the spot light in the scene
  50969. * @param direction The direction of the light in the scene
  50970. * @param angle The cone angle of the light in Radians
  50971. * @param exponent The light decay speed with the distance from the emission spot
  50972. * @param scene The scene the lights belongs to
  50973. */
  50974. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50975. /**
  50976. * Returns the string "SpotLight".
  50977. * @returns the class name
  50978. */
  50979. getClassName(): string;
  50980. /**
  50981. * Returns the integer 2.
  50982. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50983. */
  50984. getTypeID(): number;
  50985. /**
  50986. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50987. */
  50988. protected _setDirection(value: Vector3): void;
  50989. /**
  50990. * Overrides the position setter to recompute the projection texture view light Matrix.
  50991. */
  50992. protected _setPosition(value: Vector3): void;
  50993. /**
  50994. * 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.
  50995. * Returns the SpotLight.
  50996. */
  50997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50998. protected _computeProjectionTextureViewLightMatrix(): void;
  50999. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51000. /**
  51001. * Main function for light texture projection matrix computing.
  51002. */
  51003. protected _computeProjectionTextureMatrix(): void;
  51004. protected _buildUniformLayout(): void;
  51005. private _computeAngleValues;
  51006. /**
  51007. * Sets the passed Effect "effect" with the Light textures.
  51008. * @param effect The effect to update
  51009. * @param lightIndex The index of the light in the effect to update
  51010. * @returns The light
  51011. */
  51012. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51013. /**
  51014. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51015. * @param effect The effect to update
  51016. * @param lightIndex The index of the light in the effect to update
  51017. * @returns The spot light
  51018. */
  51019. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51021. /**
  51022. * Disposes the light and the associated resources.
  51023. */
  51024. dispose(): void;
  51025. /**
  51026. * Prepares the list of defines specific to the light type.
  51027. * @param defines the list of defines
  51028. * @param lightIndex defines the index of the light for the effect
  51029. */
  51030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51031. }
  51032. }
  51033. declare module "babylonjs/Gizmos/lightGizmo" {
  51034. import { Nullable } from "babylonjs/types";
  51035. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51036. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51037. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51038. import { Light } from "babylonjs/Lights/light";
  51039. /**
  51040. * Gizmo that enables viewing a light
  51041. */
  51042. export class LightGizmo extends Gizmo {
  51043. private _lightMesh;
  51044. private _material;
  51045. private _cachedPosition;
  51046. private _cachedForward;
  51047. private _attachedMeshParent;
  51048. /**
  51049. * Creates a LightGizmo
  51050. * @param gizmoLayer The utility layer the gizmo will be added to
  51051. */
  51052. constructor(gizmoLayer?: UtilityLayerRenderer);
  51053. private _light;
  51054. /**
  51055. * The light that the gizmo is attached to
  51056. */
  51057. set light(light: Nullable<Light>);
  51058. get light(): Nullable<Light>;
  51059. /**
  51060. * Gets the material used to render the light gizmo
  51061. */
  51062. get material(): StandardMaterial;
  51063. /**
  51064. * @hidden
  51065. * Updates the gizmo to match the attached mesh's position/rotation
  51066. */
  51067. protected _update(): void;
  51068. private static _Scale;
  51069. /**
  51070. * Creates the lines for a light mesh
  51071. */
  51072. private static _CreateLightLines;
  51073. /**
  51074. * Disposes of the light gizmo
  51075. */
  51076. dispose(): void;
  51077. private static _CreateHemisphericLightMesh;
  51078. private static _CreatePointLightMesh;
  51079. private static _CreateSpotLightMesh;
  51080. private static _CreateDirectionalLightMesh;
  51081. }
  51082. }
  51083. declare module "babylonjs/Gizmos/index" {
  51084. export * from "babylonjs/Gizmos/axisDragGizmo";
  51085. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51086. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51087. export * from "babylonjs/Gizmos/gizmo";
  51088. export * from "babylonjs/Gizmos/gizmoManager";
  51089. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51090. export * from "babylonjs/Gizmos/positionGizmo";
  51091. export * from "babylonjs/Gizmos/rotationGizmo";
  51092. export * from "babylonjs/Gizmos/scaleGizmo";
  51093. export * from "babylonjs/Gizmos/lightGizmo";
  51094. export * from "babylonjs/Gizmos/planeDragGizmo";
  51095. }
  51096. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51097. /** @hidden */
  51098. export var backgroundFragmentDeclaration: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51104. /** @hidden */
  51105. export var backgroundUboDeclaration: {
  51106. name: string;
  51107. shader: string;
  51108. };
  51109. }
  51110. declare module "babylonjs/Shaders/background.fragment" {
  51111. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51114. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51115. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51116. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51117. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51118. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51119. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51122. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51123. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51124. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51125. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51126. /** @hidden */
  51127. export var backgroundPixelShader: {
  51128. name: string;
  51129. shader: string;
  51130. };
  51131. }
  51132. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51133. /** @hidden */
  51134. export var backgroundVertexDeclaration: {
  51135. name: string;
  51136. shader: string;
  51137. };
  51138. }
  51139. declare module "babylonjs/Shaders/background.vertex" {
  51140. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51141. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51142. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51144. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51146. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51147. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51148. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51149. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51150. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51151. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51152. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51153. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51154. /** @hidden */
  51155. export var backgroundVertexShader: {
  51156. name: string;
  51157. shader: string;
  51158. };
  51159. }
  51160. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51161. import { Nullable, int, float } from "babylonjs/types";
  51162. import { Scene } from "babylonjs/scene";
  51163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51166. import { Mesh } from "babylonjs/Meshes/mesh";
  51167. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51168. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51169. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51171. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51172. import { Color3 } from "babylonjs/Maths/math.color";
  51173. import "babylonjs/Shaders/background.fragment";
  51174. import "babylonjs/Shaders/background.vertex";
  51175. /**
  51176. * Background material used to create an efficient environement around your scene.
  51177. */
  51178. export class BackgroundMaterial extends PushMaterial {
  51179. /**
  51180. * Standard reflectance value at parallel view angle.
  51181. */
  51182. static StandardReflectance0: number;
  51183. /**
  51184. * Standard reflectance value at grazing angle.
  51185. */
  51186. static StandardReflectance90: number;
  51187. protected _primaryColor: Color3;
  51188. /**
  51189. * Key light Color (multiply against the environement texture)
  51190. */
  51191. primaryColor: Color3;
  51192. protected __perceptualColor: Nullable<Color3>;
  51193. /**
  51194. * Experimental Internal Use Only.
  51195. *
  51196. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51197. * This acts as a helper to set the primary color to a more "human friendly" value.
  51198. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51199. * output color as close as possible from the chosen value.
  51200. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51201. * part of lighting setup.)
  51202. */
  51203. get _perceptualColor(): Nullable<Color3>;
  51204. set _perceptualColor(value: Nullable<Color3>);
  51205. protected _primaryColorShadowLevel: float;
  51206. /**
  51207. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51208. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51209. */
  51210. get primaryColorShadowLevel(): float;
  51211. set primaryColorShadowLevel(value: float);
  51212. protected _primaryColorHighlightLevel: float;
  51213. /**
  51214. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51215. * The primary color is used at the level chosen to define what the white area would look.
  51216. */
  51217. get primaryColorHighlightLevel(): float;
  51218. set primaryColorHighlightLevel(value: float);
  51219. protected _reflectionTexture: Nullable<BaseTexture>;
  51220. /**
  51221. * Reflection Texture used in the material.
  51222. * Should be author in a specific way for the best result (refer to the documentation).
  51223. */
  51224. reflectionTexture: Nullable<BaseTexture>;
  51225. protected _reflectionBlur: float;
  51226. /**
  51227. * Reflection Texture level of blur.
  51228. *
  51229. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51230. * texture twice.
  51231. */
  51232. reflectionBlur: float;
  51233. protected _diffuseTexture: Nullable<BaseTexture>;
  51234. /**
  51235. * Diffuse Texture used in the material.
  51236. * Should be author in a specific way for the best result (refer to the documentation).
  51237. */
  51238. diffuseTexture: Nullable<BaseTexture>;
  51239. protected _shadowLights: Nullable<IShadowLight[]>;
  51240. /**
  51241. * Specify the list of lights casting shadow on the material.
  51242. * All scene shadow lights will be included if null.
  51243. */
  51244. shadowLights: Nullable<IShadowLight[]>;
  51245. protected _shadowLevel: float;
  51246. /**
  51247. * Helps adjusting the shadow to a softer level if required.
  51248. * 0 means black shadows and 1 means no shadows.
  51249. */
  51250. shadowLevel: float;
  51251. protected _sceneCenter: Vector3;
  51252. /**
  51253. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51254. * It is usually zero but might be interesting to modify according to your setup.
  51255. */
  51256. sceneCenter: Vector3;
  51257. protected _opacityFresnel: boolean;
  51258. /**
  51259. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51260. * This helps ensuring a nice transition when the camera goes under the ground.
  51261. */
  51262. opacityFresnel: boolean;
  51263. protected _reflectionFresnel: boolean;
  51264. /**
  51265. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51266. * This helps adding a mirror texture on the ground.
  51267. */
  51268. reflectionFresnel: boolean;
  51269. protected _reflectionFalloffDistance: number;
  51270. /**
  51271. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51272. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51273. */
  51274. reflectionFalloffDistance: number;
  51275. protected _reflectionAmount: number;
  51276. /**
  51277. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51278. */
  51279. reflectionAmount: number;
  51280. protected _reflectionReflectance0: number;
  51281. /**
  51282. * This specifies the weight of the reflection at grazing angle.
  51283. */
  51284. reflectionReflectance0: number;
  51285. protected _reflectionReflectance90: number;
  51286. /**
  51287. * This specifies the weight of the reflection at a perpendicular point of view.
  51288. */
  51289. reflectionReflectance90: number;
  51290. /**
  51291. * Sets the reflection reflectance fresnel values according to the default standard
  51292. * empirically know to work well :-)
  51293. */
  51294. set reflectionStandardFresnelWeight(value: number);
  51295. protected _useRGBColor: boolean;
  51296. /**
  51297. * Helps to directly use the maps channels instead of their level.
  51298. */
  51299. useRGBColor: boolean;
  51300. protected _enableNoise: boolean;
  51301. /**
  51302. * This helps reducing the banding effect that could occur on the background.
  51303. */
  51304. enableNoise: boolean;
  51305. /**
  51306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51307. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51308. * Recommended to be keep at 1.0 except for special cases.
  51309. */
  51310. get fovMultiplier(): number;
  51311. set fovMultiplier(value: number);
  51312. private _fovMultiplier;
  51313. /**
  51314. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51315. */
  51316. useEquirectangularFOV: boolean;
  51317. private _maxSimultaneousLights;
  51318. /**
  51319. * Number of Simultaneous lights allowed on the material.
  51320. */
  51321. maxSimultaneousLights: int;
  51322. /**
  51323. * Default configuration related to image processing available in the Background Material.
  51324. */
  51325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51326. /**
  51327. * Keep track of the image processing observer to allow dispose and replace.
  51328. */
  51329. private _imageProcessingObserver;
  51330. /**
  51331. * Attaches a new image processing configuration to the PBR Material.
  51332. * @param configuration (if null the scene configuration will be use)
  51333. */
  51334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51335. /**
  51336. * Gets the image processing configuration used either in this material.
  51337. */
  51338. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51339. /**
  51340. * Sets the Default image processing configuration used either in the this material.
  51341. *
  51342. * If sets to null, the scene one is in use.
  51343. */
  51344. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51345. /**
  51346. * Gets wether the color curves effect is enabled.
  51347. */
  51348. get cameraColorCurvesEnabled(): boolean;
  51349. /**
  51350. * Sets wether the color curves effect is enabled.
  51351. */
  51352. set cameraColorCurvesEnabled(value: boolean);
  51353. /**
  51354. * Gets wether the color grading effect is enabled.
  51355. */
  51356. get cameraColorGradingEnabled(): boolean;
  51357. /**
  51358. * Gets wether the color grading effect is enabled.
  51359. */
  51360. set cameraColorGradingEnabled(value: boolean);
  51361. /**
  51362. * Gets wether tonemapping is enabled or not.
  51363. */
  51364. get cameraToneMappingEnabled(): boolean;
  51365. /**
  51366. * Sets wether tonemapping is enabled or not
  51367. */
  51368. set cameraToneMappingEnabled(value: boolean);
  51369. /**
  51370. * The camera exposure used on this material.
  51371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51372. * This corresponds to a photographic exposure.
  51373. */
  51374. get cameraExposure(): float;
  51375. /**
  51376. * The camera exposure used on this material.
  51377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51378. * This corresponds to a photographic exposure.
  51379. */
  51380. set cameraExposure(value: float);
  51381. /**
  51382. * Gets The camera contrast used on this material.
  51383. */
  51384. get cameraContrast(): float;
  51385. /**
  51386. * Sets The camera contrast used on this material.
  51387. */
  51388. set cameraContrast(value: float);
  51389. /**
  51390. * Gets the Color Grading 2D Lookup Texture.
  51391. */
  51392. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51393. /**
  51394. * Sets the Color Grading 2D Lookup Texture.
  51395. */
  51396. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51397. /**
  51398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51400. * 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;
  51401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51402. */
  51403. get cameraColorCurves(): Nullable<ColorCurves>;
  51404. /**
  51405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51407. * 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;
  51408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51409. */
  51410. set cameraColorCurves(value: Nullable<ColorCurves>);
  51411. /**
  51412. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51413. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51414. */
  51415. switchToBGR: boolean;
  51416. private _renderTargets;
  51417. private _reflectionControls;
  51418. private _white;
  51419. private _primaryShadowColor;
  51420. private _primaryHighlightColor;
  51421. /**
  51422. * Instantiates a Background Material in the given scene
  51423. * @param name The friendly name of the material
  51424. * @param scene The scene to add the material to
  51425. */
  51426. constructor(name: string, scene: Scene);
  51427. /**
  51428. * Gets a boolean indicating that current material needs to register RTT
  51429. */
  51430. get hasRenderTargetTextures(): boolean;
  51431. /**
  51432. * The entire material has been created in order to prevent overdraw.
  51433. * @returns false
  51434. */
  51435. needAlphaTesting(): boolean;
  51436. /**
  51437. * The entire material has been created in order to prevent overdraw.
  51438. * @returns true if blending is enable
  51439. */
  51440. needAlphaBlending(): boolean;
  51441. /**
  51442. * Checks wether the material is ready to be rendered for a given mesh.
  51443. * @param mesh The mesh to render
  51444. * @param subMesh The submesh to check against
  51445. * @param useInstances Specify wether or not the material is used with instances
  51446. * @returns true if all the dependencies are ready (Textures, Effects...)
  51447. */
  51448. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51449. /**
  51450. * Compute the primary color according to the chosen perceptual color.
  51451. */
  51452. private _computePrimaryColorFromPerceptualColor;
  51453. /**
  51454. * Compute the highlights and shadow colors according to their chosen levels.
  51455. */
  51456. private _computePrimaryColors;
  51457. /**
  51458. * Build the uniform buffer used in the material.
  51459. */
  51460. buildUniformLayout(): void;
  51461. /**
  51462. * Unbind the material.
  51463. */
  51464. unbind(): void;
  51465. /**
  51466. * Bind only the world matrix to the material.
  51467. * @param world The world matrix to bind.
  51468. */
  51469. bindOnlyWorldMatrix(world: Matrix): void;
  51470. /**
  51471. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51472. * @param world The world matrix to bind.
  51473. * @param subMesh The submesh to bind for.
  51474. */
  51475. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51476. /**
  51477. * Checks to see if a texture is used in the material.
  51478. * @param texture - Base texture to use.
  51479. * @returns - Boolean specifying if a texture is used in the material.
  51480. */
  51481. hasTexture(texture: BaseTexture): boolean;
  51482. /**
  51483. * Dispose the material.
  51484. * @param forceDisposeEffect Force disposal of the associated effect.
  51485. * @param forceDisposeTextures Force disposal of the associated textures.
  51486. */
  51487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51488. /**
  51489. * Clones the material.
  51490. * @param name The cloned name.
  51491. * @returns The cloned material.
  51492. */
  51493. clone(name: string): BackgroundMaterial;
  51494. /**
  51495. * Serializes the current material to its JSON representation.
  51496. * @returns The JSON representation.
  51497. */
  51498. serialize(): any;
  51499. /**
  51500. * Gets the class name of the material
  51501. * @returns "BackgroundMaterial"
  51502. */
  51503. getClassName(): string;
  51504. /**
  51505. * Parse a JSON input to create back a background material.
  51506. * @param source The JSON data to parse
  51507. * @param scene The scene to create the parsed material in
  51508. * @param rootUrl The root url of the assets the material depends upon
  51509. * @returns the instantiated BackgroundMaterial.
  51510. */
  51511. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51512. }
  51513. }
  51514. declare module "babylonjs/Helpers/environmentHelper" {
  51515. import { Observable } from "babylonjs/Misc/observable";
  51516. import { Nullable } from "babylonjs/types";
  51517. import { Scene } from "babylonjs/scene";
  51518. import { Vector3 } from "babylonjs/Maths/math.vector";
  51519. import { Color3 } from "babylonjs/Maths/math.color";
  51520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51521. import { Mesh } from "babylonjs/Meshes/mesh";
  51522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51523. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51524. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51525. import "babylonjs/Meshes/Builders/planeBuilder";
  51526. import "babylonjs/Meshes/Builders/boxBuilder";
  51527. /**
  51528. * Represents the different options available during the creation of
  51529. * a Environment helper.
  51530. *
  51531. * This can control the default ground, skybox and image processing setup of your scene.
  51532. */
  51533. export interface IEnvironmentHelperOptions {
  51534. /**
  51535. * Specifies whether or not to create a ground.
  51536. * True by default.
  51537. */
  51538. createGround: boolean;
  51539. /**
  51540. * Specifies the ground size.
  51541. * 15 by default.
  51542. */
  51543. groundSize: number;
  51544. /**
  51545. * The texture used on the ground for the main color.
  51546. * Comes from the BabylonJS CDN by default.
  51547. *
  51548. * Remarks: Can be either a texture or a url.
  51549. */
  51550. groundTexture: string | BaseTexture;
  51551. /**
  51552. * The color mixed in the ground texture by default.
  51553. * BabylonJS clearColor by default.
  51554. */
  51555. groundColor: Color3;
  51556. /**
  51557. * Specifies the ground opacity.
  51558. * 1 by default.
  51559. */
  51560. groundOpacity: number;
  51561. /**
  51562. * Enables the ground to receive shadows.
  51563. * True by default.
  51564. */
  51565. enableGroundShadow: boolean;
  51566. /**
  51567. * Helps preventing the shadow to be fully black on the ground.
  51568. * 0.5 by default.
  51569. */
  51570. groundShadowLevel: number;
  51571. /**
  51572. * Creates a mirror texture attach to the ground.
  51573. * false by default.
  51574. */
  51575. enableGroundMirror: boolean;
  51576. /**
  51577. * Specifies the ground mirror size ratio.
  51578. * 0.3 by default as the default kernel is 64.
  51579. */
  51580. groundMirrorSizeRatio: number;
  51581. /**
  51582. * Specifies the ground mirror blur kernel size.
  51583. * 64 by default.
  51584. */
  51585. groundMirrorBlurKernel: number;
  51586. /**
  51587. * Specifies the ground mirror visibility amount.
  51588. * 1 by default
  51589. */
  51590. groundMirrorAmount: number;
  51591. /**
  51592. * Specifies the ground mirror reflectance weight.
  51593. * This uses the standard weight of the background material to setup the fresnel effect
  51594. * of the mirror.
  51595. * 1 by default.
  51596. */
  51597. groundMirrorFresnelWeight: number;
  51598. /**
  51599. * Specifies the ground mirror Falloff distance.
  51600. * This can helps reducing the size of the reflection.
  51601. * 0 by Default.
  51602. */
  51603. groundMirrorFallOffDistance: number;
  51604. /**
  51605. * Specifies the ground mirror texture type.
  51606. * Unsigned Int by Default.
  51607. */
  51608. groundMirrorTextureType: number;
  51609. /**
  51610. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51611. * the shown objects.
  51612. */
  51613. groundYBias: number;
  51614. /**
  51615. * Specifies whether or not to create a skybox.
  51616. * True by default.
  51617. */
  51618. createSkybox: boolean;
  51619. /**
  51620. * Specifies the skybox size.
  51621. * 20 by default.
  51622. */
  51623. skyboxSize: number;
  51624. /**
  51625. * The texture used on the skybox for the main color.
  51626. * Comes from the BabylonJS CDN by default.
  51627. *
  51628. * Remarks: Can be either a texture or a url.
  51629. */
  51630. skyboxTexture: string | BaseTexture;
  51631. /**
  51632. * The color mixed in the skybox texture by default.
  51633. * BabylonJS clearColor by default.
  51634. */
  51635. skyboxColor: Color3;
  51636. /**
  51637. * The background rotation around the Y axis of the scene.
  51638. * This helps aligning the key lights of your scene with the background.
  51639. * 0 by default.
  51640. */
  51641. backgroundYRotation: number;
  51642. /**
  51643. * Compute automatically the size of the elements to best fit with the scene.
  51644. */
  51645. sizeAuto: boolean;
  51646. /**
  51647. * Default position of the rootMesh if autoSize is not true.
  51648. */
  51649. rootPosition: Vector3;
  51650. /**
  51651. * Sets up the image processing in the scene.
  51652. * true by default.
  51653. */
  51654. setupImageProcessing: boolean;
  51655. /**
  51656. * The texture used as your environment texture in the scene.
  51657. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51658. *
  51659. * Remarks: Can be either a texture or a url.
  51660. */
  51661. environmentTexture: string | BaseTexture;
  51662. /**
  51663. * The value of the exposure to apply to the scene.
  51664. * 0.6 by default if setupImageProcessing is true.
  51665. */
  51666. cameraExposure: number;
  51667. /**
  51668. * The value of the contrast to apply to the scene.
  51669. * 1.6 by default if setupImageProcessing is true.
  51670. */
  51671. cameraContrast: number;
  51672. /**
  51673. * Specifies whether or not tonemapping should be enabled in the scene.
  51674. * true by default if setupImageProcessing is true.
  51675. */
  51676. toneMappingEnabled: boolean;
  51677. }
  51678. /**
  51679. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51680. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51681. * It also helps with the default setup of your imageProcessing configuration.
  51682. */
  51683. export class EnvironmentHelper {
  51684. /**
  51685. * Default ground texture URL.
  51686. */
  51687. private static _groundTextureCDNUrl;
  51688. /**
  51689. * Default skybox texture URL.
  51690. */
  51691. private static _skyboxTextureCDNUrl;
  51692. /**
  51693. * Default environment texture URL.
  51694. */
  51695. private static _environmentTextureCDNUrl;
  51696. /**
  51697. * Creates the default options for the helper.
  51698. */
  51699. private static _getDefaultOptions;
  51700. private _rootMesh;
  51701. /**
  51702. * Gets the root mesh created by the helper.
  51703. */
  51704. get rootMesh(): Mesh;
  51705. private _skybox;
  51706. /**
  51707. * Gets the skybox created by the helper.
  51708. */
  51709. get skybox(): Nullable<Mesh>;
  51710. private _skyboxTexture;
  51711. /**
  51712. * Gets the skybox texture created by the helper.
  51713. */
  51714. get skyboxTexture(): Nullable<BaseTexture>;
  51715. private _skyboxMaterial;
  51716. /**
  51717. * Gets the skybox material created by the helper.
  51718. */
  51719. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51720. private _ground;
  51721. /**
  51722. * Gets the ground mesh created by the helper.
  51723. */
  51724. get ground(): Nullable<Mesh>;
  51725. private _groundTexture;
  51726. /**
  51727. * Gets the ground texture created by the helper.
  51728. */
  51729. get groundTexture(): Nullable<BaseTexture>;
  51730. private _groundMirror;
  51731. /**
  51732. * Gets the ground mirror created by the helper.
  51733. */
  51734. get groundMirror(): Nullable<MirrorTexture>;
  51735. /**
  51736. * Gets the ground mirror render list to helps pushing the meshes
  51737. * you wish in the ground reflection.
  51738. */
  51739. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51740. private _groundMaterial;
  51741. /**
  51742. * Gets the ground material created by the helper.
  51743. */
  51744. get groundMaterial(): Nullable<BackgroundMaterial>;
  51745. /**
  51746. * Stores the creation options.
  51747. */
  51748. private readonly _scene;
  51749. private _options;
  51750. /**
  51751. * This observable will be notified with any error during the creation of the environment,
  51752. * mainly texture creation errors.
  51753. */
  51754. onErrorObservable: Observable<{
  51755. message?: string;
  51756. exception?: any;
  51757. }>;
  51758. /**
  51759. * constructor
  51760. * @param options Defines the options we want to customize the helper
  51761. * @param scene The scene to add the material to
  51762. */
  51763. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51764. /**
  51765. * Updates the background according to the new options
  51766. * @param options
  51767. */
  51768. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51769. /**
  51770. * Sets the primary color of all the available elements.
  51771. * @param color the main color to affect to the ground and the background
  51772. */
  51773. setMainColor(color: Color3): void;
  51774. /**
  51775. * Setup the image processing according to the specified options.
  51776. */
  51777. private _setupImageProcessing;
  51778. /**
  51779. * Setup the environment texture according to the specified options.
  51780. */
  51781. private _setupEnvironmentTexture;
  51782. /**
  51783. * Setup the background according to the specified options.
  51784. */
  51785. private _setupBackground;
  51786. /**
  51787. * Get the scene sizes according to the setup.
  51788. */
  51789. private _getSceneSize;
  51790. /**
  51791. * Setup the ground according to the specified options.
  51792. */
  51793. private _setupGround;
  51794. /**
  51795. * Setup the ground material according to the specified options.
  51796. */
  51797. private _setupGroundMaterial;
  51798. /**
  51799. * Setup the ground diffuse texture according to the specified options.
  51800. */
  51801. private _setupGroundDiffuseTexture;
  51802. /**
  51803. * Setup the ground mirror texture according to the specified options.
  51804. */
  51805. private _setupGroundMirrorTexture;
  51806. /**
  51807. * Setup the ground to receive the mirror texture.
  51808. */
  51809. private _setupMirrorInGroundMaterial;
  51810. /**
  51811. * Setup the skybox according to the specified options.
  51812. */
  51813. private _setupSkybox;
  51814. /**
  51815. * Setup the skybox material according to the specified options.
  51816. */
  51817. private _setupSkyboxMaterial;
  51818. /**
  51819. * Setup the skybox reflection texture according to the specified options.
  51820. */
  51821. private _setupSkyboxReflectionTexture;
  51822. private _errorHandler;
  51823. /**
  51824. * Dispose all the elements created by the Helper.
  51825. */
  51826. dispose(): void;
  51827. }
  51828. }
  51829. declare module "babylonjs/Helpers/photoDome" {
  51830. import { Observable } from "babylonjs/Misc/observable";
  51831. import { Nullable } from "babylonjs/types";
  51832. import { Scene } from "babylonjs/scene";
  51833. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51834. import { Mesh } from "babylonjs/Meshes/mesh";
  51835. import { Texture } from "babylonjs/Materials/Textures/texture";
  51836. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51837. import "babylonjs/Meshes/Builders/sphereBuilder";
  51838. /**
  51839. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51840. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51841. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51842. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51843. */
  51844. export class PhotoDome extends TransformNode {
  51845. /**
  51846. * Define the image as a Monoscopic panoramic 360 image.
  51847. */
  51848. static readonly MODE_MONOSCOPIC: number;
  51849. /**
  51850. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51851. */
  51852. static readonly MODE_TOPBOTTOM: number;
  51853. /**
  51854. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51855. */
  51856. static readonly MODE_SIDEBYSIDE: number;
  51857. private _useDirectMapping;
  51858. /**
  51859. * The texture being displayed on the sphere
  51860. */
  51861. protected _photoTexture: Texture;
  51862. /**
  51863. * Gets or sets the texture being displayed on the sphere
  51864. */
  51865. get photoTexture(): Texture;
  51866. set photoTexture(value: Texture);
  51867. /**
  51868. * Observable raised when an error occured while loading the 360 image
  51869. */
  51870. onLoadErrorObservable: Observable<string>;
  51871. /**
  51872. * The skybox material
  51873. */
  51874. protected _material: BackgroundMaterial;
  51875. /**
  51876. * The surface used for the skybox
  51877. */
  51878. protected _mesh: Mesh;
  51879. /**
  51880. * Gets the mesh used for the skybox.
  51881. */
  51882. get mesh(): Mesh;
  51883. /**
  51884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51885. * Also see the options.resolution property.
  51886. */
  51887. get fovMultiplier(): number;
  51888. set fovMultiplier(value: number);
  51889. private _imageMode;
  51890. /**
  51891. * Gets or set the current video mode for the video. It can be:
  51892. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51893. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51894. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51895. */
  51896. get imageMode(): number;
  51897. set imageMode(value: number);
  51898. /**
  51899. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51900. * @param name Element's name, child elements will append suffixes for their own names.
  51901. * @param urlsOfPhoto defines the url of the photo to display
  51902. * @param options defines an object containing optional or exposed sub element properties
  51903. * @param onError defines a callback called when an error occured while loading the texture
  51904. */
  51905. constructor(name: string, urlOfPhoto: string, options: {
  51906. resolution?: number;
  51907. size?: number;
  51908. useDirectMapping?: boolean;
  51909. faceForward?: boolean;
  51910. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51911. private _onBeforeCameraRenderObserver;
  51912. private _changeImageMode;
  51913. /**
  51914. * Releases resources associated with this node.
  51915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51917. */
  51918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51919. }
  51920. }
  51921. declare module "babylonjs/Misc/rgbdTextureTools" {
  51922. import "babylonjs/Shaders/rgbdDecode.fragment";
  51923. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51924. import { Texture } from "babylonjs/Materials/Textures/texture";
  51925. /**
  51926. * Class used to host RGBD texture specific utilities
  51927. */
  51928. export class RGBDTextureTools {
  51929. /**
  51930. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51931. * @param texture the texture to expand.
  51932. */
  51933. static ExpandRGBDTexture(texture: Texture): void;
  51934. }
  51935. }
  51936. declare module "babylonjs/Misc/brdfTextureTools" {
  51937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51938. import { Scene } from "babylonjs/scene";
  51939. /**
  51940. * Class used to host texture specific utilities
  51941. */
  51942. export class BRDFTextureTools {
  51943. /**
  51944. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51945. * @param scene defines the hosting scene
  51946. * @returns the environment BRDF texture
  51947. */
  51948. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51949. private static _environmentBRDFBase64Texture;
  51950. }
  51951. }
  51952. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51953. import { Nullable } from "babylonjs/types";
  51954. import { Color3 } from "babylonjs/Maths/math.color";
  51955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51956. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51957. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51958. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51959. import { Engine } from "babylonjs/Engines/engine";
  51960. import { Scene } from "babylonjs/scene";
  51961. /**
  51962. * @hidden
  51963. */
  51964. export interface IMaterialClearCoatDefines {
  51965. CLEARCOAT: boolean;
  51966. CLEARCOAT_DEFAULTIOR: boolean;
  51967. CLEARCOAT_TEXTURE: boolean;
  51968. CLEARCOAT_TEXTUREDIRECTUV: number;
  51969. CLEARCOAT_BUMP: boolean;
  51970. CLEARCOAT_BUMPDIRECTUV: number;
  51971. CLEARCOAT_TINT: boolean;
  51972. CLEARCOAT_TINT_TEXTURE: boolean;
  51973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51974. /** @hidden */
  51975. _areTexturesDirty: boolean;
  51976. }
  51977. /**
  51978. * Define the code related to the clear coat parameters of the pbr material.
  51979. */
  51980. export class PBRClearCoatConfiguration {
  51981. /**
  51982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51983. * The default fits with a polyurethane material.
  51984. */
  51985. private static readonly _DefaultIndexOfRefraction;
  51986. private _isEnabled;
  51987. /**
  51988. * Defines if the clear coat is enabled in the material.
  51989. */
  51990. isEnabled: boolean;
  51991. /**
  51992. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51993. */
  51994. intensity: number;
  51995. /**
  51996. * Defines the clear coat layer roughness.
  51997. */
  51998. roughness: number;
  51999. private _indexOfRefraction;
  52000. /**
  52001. * Defines the index of refraction of the clear coat.
  52002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52003. * The default fits with a polyurethane material.
  52004. * Changing the default value is more performance intensive.
  52005. */
  52006. indexOfRefraction: number;
  52007. private _texture;
  52008. /**
  52009. * Stores the clear coat values in a texture.
  52010. */
  52011. texture: Nullable<BaseTexture>;
  52012. private _bumpTexture;
  52013. /**
  52014. * Define the clear coat specific bump texture.
  52015. */
  52016. bumpTexture: Nullable<BaseTexture>;
  52017. private _isTintEnabled;
  52018. /**
  52019. * Defines if the clear coat tint is enabled in the material.
  52020. */
  52021. isTintEnabled: boolean;
  52022. /**
  52023. * Defines the clear coat tint of the material.
  52024. * This is only use if tint is enabled
  52025. */
  52026. tintColor: Color3;
  52027. /**
  52028. * Defines the distance at which the tint color should be found in the
  52029. * clear coat media.
  52030. * This is only use if tint is enabled
  52031. */
  52032. tintColorAtDistance: number;
  52033. /**
  52034. * Defines the clear coat layer thickness.
  52035. * This is only use if tint is enabled
  52036. */
  52037. tintThickness: number;
  52038. private _tintTexture;
  52039. /**
  52040. * Stores the clear tint values in a texture.
  52041. * rgb is tint
  52042. * a is a thickness factor
  52043. */
  52044. tintTexture: Nullable<BaseTexture>;
  52045. /** @hidden */
  52046. private _internalMarkAllSubMeshesAsTexturesDirty;
  52047. /** @hidden */
  52048. _markAllSubMeshesAsTexturesDirty(): void;
  52049. /**
  52050. * Instantiate a new istance of clear coat configuration.
  52051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52052. */
  52053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52054. /**
  52055. * Gets wehter the submesh is ready to be used or not.
  52056. * @param defines the list of "defines" to update.
  52057. * @param scene defines the scene the material belongs to.
  52058. * @param engine defines the engine the material belongs to.
  52059. * @param disableBumpMap defines wether the material disables bump or not.
  52060. * @returns - boolean indicating that the submesh is ready or not.
  52061. */
  52062. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52063. /**
  52064. * Checks to see if a texture is used in the material.
  52065. * @param defines the list of "defines" to update.
  52066. * @param scene defines the scene to the material belongs to.
  52067. */
  52068. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52069. /**
  52070. * Binds the material data.
  52071. * @param uniformBuffer defines the Uniform buffer to fill in.
  52072. * @param scene defines the scene the material belongs to.
  52073. * @param engine defines the engine the material belongs to.
  52074. * @param disableBumpMap defines wether the material disables bump or not.
  52075. * @param isFrozen defines wether the material is frozen or not.
  52076. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52077. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52078. */
  52079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52080. /**
  52081. * Checks to see if a texture is used in the material.
  52082. * @param texture - Base texture to use.
  52083. * @returns - Boolean specifying if a texture is used in the material.
  52084. */
  52085. hasTexture(texture: BaseTexture): boolean;
  52086. /**
  52087. * Returns an array of the actively used textures.
  52088. * @param activeTextures Array of BaseTextures
  52089. */
  52090. getActiveTextures(activeTextures: BaseTexture[]): void;
  52091. /**
  52092. * Returns the animatable textures.
  52093. * @param animatables Array of animatable textures.
  52094. */
  52095. getAnimatables(animatables: IAnimatable[]): void;
  52096. /**
  52097. * Disposes the resources of the material.
  52098. * @param forceDisposeTextures - Forces the disposal of all textures.
  52099. */
  52100. dispose(forceDisposeTextures?: boolean): void;
  52101. /**
  52102. * Get the current class name of the texture useful for serialization or dynamic coding.
  52103. * @returns "PBRClearCoatConfiguration"
  52104. */
  52105. getClassName(): string;
  52106. /**
  52107. * Add fallbacks to the effect fallbacks list.
  52108. * @param defines defines the Base texture to use.
  52109. * @param fallbacks defines the current fallback list.
  52110. * @param currentRank defines the current fallback rank.
  52111. * @returns the new fallback rank.
  52112. */
  52113. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52114. /**
  52115. * Add the required uniforms to the current list.
  52116. * @param uniforms defines the current uniform list.
  52117. */
  52118. static AddUniforms(uniforms: string[]): void;
  52119. /**
  52120. * Add the required samplers to the current list.
  52121. * @param samplers defines the current sampler list.
  52122. */
  52123. static AddSamplers(samplers: string[]): void;
  52124. /**
  52125. * Add the required uniforms to the current buffer.
  52126. * @param uniformBuffer defines the current uniform buffer.
  52127. */
  52128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52129. /**
  52130. * Makes a duplicate of the current configuration into another one.
  52131. * @param clearCoatConfiguration define the config where to copy the info
  52132. */
  52133. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52134. /**
  52135. * Serializes this clear coat configuration.
  52136. * @returns - An object with the serialized config.
  52137. */
  52138. serialize(): any;
  52139. /**
  52140. * Parses a anisotropy Configuration from a serialized object.
  52141. * @param source - Serialized object.
  52142. * @param scene Defines the scene we are parsing for
  52143. * @param rootUrl Defines the rootUrl to load from
  52144. */
  52145. parse(source: any, scene: Scene, rootUrl: string): void;
  52146. }
  52147. }
  52148. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52149. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52151. import { Vector2 } from "babylonjs/Maths/math.vector";
  52152. import { Scene } from "babylonjs/scene";
  52153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52154. import { Nullable } from "babylonjs/types";
  52155. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52156. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52157. /**
  52158. * @hidden
  52159. */
  52160. export interface IMaterialAnisotropicDefines {
  52161. ANISOTROPIC: boolean;
  52162. ANISOTROPIC_TEXTURE: boolean;
  52163. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52164. MAINUV1: boolean;
  52165. _areTexturesDirty: boolean;
  52166. _needUVs: boolean;
  52167. }
  52168. /**
  52169. * Define the code related to the anisotropic parameters of the pbr material.
  52170. */
  52171. export class PBRAnisotropicConfiguration {
  52172. private _isEnabled;
  52173. /**
  52174. * Defines if the anisotropy is enabled in the material.
  52175. */
  52176. isEnabled: boolean;
  52177. /**
  52178. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52179. */
  52180. intensity: number;
  52181. /**
  52182. * Defines if the effect is along the tangents, bitangents or in between.
  52183. * By default, the effect is "strectching" the highlights along the tangents.
  52184. */
  52185. direction: Vector2;
  52186. private _texture;
  52187. /**
  52188. * Stores the anisotropy values in a texture.
  52189. * rg is direction (like normal from -1 to 1)
  52190. * b is a intensity
  52191. */
  52192. texture: Nullable<BaseTexture>;
  52193. /** @hidden */
  52194. private _internalMarkAllSubMeshesAsTexturesDirty;
  52195. /** @hidden */
  52196. _markAllSubMeshesAsTexturesDirty(): void;
  52197. /**
  52198. * Instantiate a new istance of anisotropy configuration.
  52199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52200. */
  52201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52202. /**
  52203. * Specifies that the submesh is ready to be used.
  52204. * @param defines the list of "defines" to update.
  52205. * @param scene defines the scene the material belongs to.
  52206. * @returns - boolean indicating that the submesh is ready or not.
  52207. */
  52208. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52209. /**
  52210. * Checks to see if a texture is used in the material.
  52211. * @param defines the list of "defines" to update.
  52212. * @param mesh the mesh we are preparing the defines for.
  52213. * @param scene defines the scene the material belongs to.
  52214. */
  52215. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52216. /**
  52217. * Binds the material data.
  52218. * @param uniformBuffer defines the Uniform buffer to fill in.
  52219. * @param scene defines the scene the material belongs to.
  52220. * @param isFrozen defines wether the material is frozen or not.
  52221. */
  52222. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52223. /**
  52224. * Checks to see if a texture is used in the material.
  52225. * @param texture - Base texture to use.
  52226. * @returns - Boolean specifying if a texture is used in the material.
  52227. */
  52228. hasTexture(texture: BaseTexture): boolean;
  52229. /**
  52230. * Returns an array of the actively used textures.
  52231. * @param activeTextures Array of BaseTextures
  52232. */
  52233. getActiveTextures(activeTextures: BaseTexture[]): void;
  52234. /**
  52235. * Returns the animatable textures.
  52236. * @param animatables Array of animatable textures.
  52237. */
  52238. getAnimatables(animatables: IAnimatable[]): void;
  52239. /**
  52240. * Disposes the resources of the material.
  52241. * @param forceDisposeTextures - Forces the disposal of all textures.
  52242. */
  52243. dispose(forceDisposeTextures?: boolean): void;
  52244. /**
  52245. * Get the current class name of the texture useful for serialization or dynamic coding.
  52246. * @returns "PBRAnisotropicConfiguration"
  52247. */
  52248. getClassName(): string;
  52249. /**
  52250. * Add fallbacks to the effect fallbacks list.
  52251. * @param defines defines the Base texture to use.
  52252. * @param fallbacks defines the current fallback list.
  52253. * @param currentRank defines the current fallback rank.
  52254. * @returns the new fallback rank.
  52255. */
  52256. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52257. /**
  52258. * Add the required uniforms to the current list.
  52259. * @param uniforms defines the current uniform list.
  52260. */
  52261. static AddUniforms(uniforms: string[]): void;
  52262. /**
  52263. * Add the required uniforms to the current buffer.
  52264. * @param uniformBuffer defines the current uniform buffer.
  52265. */
  52266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52267. /**
  52268. * Add the required samplers to the current list.
  52269. * @param samplers defines the current sampler list.
  52270. */
  52271. static AddSamplers(samplers: string[]): void;
  52272. /**
  52273. * Makes a duplicate of the current configuration into another one.
  52274. * @param anisotropicConfiguration define the config where to copy the info
  52275. */
  52276. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52277. /**
  52278. * Serializes this anisotropy configuration.
  52279. * @returns - An object with the serialized config.
  52280. */
  52281. serialize(): any;
  52282. /**
  52283. * Parses a anisotropy Configuration from a serialized object.
  52284. * @param source - Serialized object.
  52285. * @param scene Defines the scene we are parsing for
  52286. * @param rootUrl Defines the rootUrl to load from
  52287. */
  52288. parse(source: any, scene: Scene, rootUrl: string): void;
  52289. }
  52290. }
  52291. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52292. import { Scene } from "babylonjs/scene";
  52293. /**
  52294. * @hidden
  52295. */
  52296. export interface IMaterialBRDFDefines {
  52297. BRDF_V_HEIGHT_CORRELATED: boolean;
  52298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52299. SPHERICAL_HARMONICS: boolean;
  52300. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52301. /** @hidden */
  52302. _areMiscDirty: boolean;
  52303. }
  52304. /**
  52305. * Define the code related to the BRDF parameters of the pbr material.
  52306. */
  52307. export class PBRBRDFConfiguration {
  52308. /**
  52309. * Default value used for the energy conservation.
  52310. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52311. */
  52312. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52313. /**
  52314. * Default value used for the Smith Visibility Height Correlated mode.
  52315. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52316. */
  52317. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52318. /**
  52319. * Default value used for the IBL diffuse part.
  52320. * This can help switching back to the polynomials mode globally which is a tiny bit
  52321. * less GPU intensive at the drawback of a lower quality.
  52322. */
  52323. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52324. /**
  52325. * Default value used for activating energy conservation for the specular workflow.
  52326. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52327. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52328. */
  52329. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52330. private _useEnergyConservation;
  52331. /**
  52332. * Defines if the material uses energy conservation.
  52333. */
  52334. useEnergyConservation: boolean;
  52335. private _useSmithVisibilityHeightCorrelated;
  52336. /**
  52337. * LEGACY Mode set to false
  52338. * Defines if the material uses height smith correlated visibility term.
  52339. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52340. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52341. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52342. * Not relying on height correlated will also disable energy conservation.
  52343. */
  52344. useSmithVisibilityHeightCorrelated: boolean;
  52345. private _useSphericalHarmonics;
  52346. /**
  52347. * LEGACY Mode set to false
  52348. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52349. * diffuse part of the IBL.
  52350. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52351. * to the ground truth.
  52352. */
  52353. useSphericalHarmonics: boolean;
  52354. private _useSpecularGlossinessInputEnergyConservation;
  52355. /**
  52356. * Defines if the material uses energy conservation, when the specular workflow is active.
  52357. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52358. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52359. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52360. */
  52361. useSpecularGlossinessInputEnergyConservation: boolean;
  52362. /** @hidden */
  52363. private _internalMarkAllSubMeshesAsMiscDirty;
  52364. /** @hidden */
  52365. _markAllSubMeshesAsMiscDirty(): void;
  52366. /**
  52367. * Instantiate a new istance of clear coat configuration.
  52368. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52369. */
  52370. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52371. /**
  52372. * Checks to see if a texture is used in the material.
  52373. * @param defines the list of "defines" to update.
  52374. */
  52375. prepareDefines(defines: IMaterialBRDFDefines): void;
  52376. /**
  52377. * Get the current class name of the texture useful for serialization or dynamic coding.
  52378. * @returns "PBRClearCoatConfiguration"
  52379. */
  52380. getClassName(): string;
  52381. /**
  52382. * Makes a duplicate of the current configuration into another one.
  52383. * @param brdfConfiguration define the config where to copy the info
  52384. */
  52385. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52386. /**
  52387. * Serializes this BRDF configuration.
  52388. * @returns - An object with the serialized config.
  52389. */
  52390. serialize(): any;
  52391. /**
  52392. * Parses a anisotropy Configuration from a serialized object.
  52393. * @param source - Serialized object.
  52394. * @param scene Defines the scene we are parsing for
  52395. * @param rootUrl Defines the rootUrl to load from
  52396. */
  52397. parse(source: any, scene: Scene, rootUrl: string): void;
  52398. }
  52399. }
  52400. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52402. import { Color3 } from "babylonjs/Maths/math.color";
  52403. import { Scene } from "babylonjs/scene";
  52404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52405. import { Nullable } from "babylonjs/types";
  52406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52407. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52408. /**
  52409. * @hidden
  52410. */
  52411. export interface IMaterialSheenDefines {
  52412. SHEEN: boolean;
  52413. SHEEN_TEXTURE: boolean;
  52414. SHEEN_TEXTUREDIRECTUV: number;
  52415. SHEEN_LINKWITHALBEDO: boolean;
  52416. /** @hidden */
  52417. _areTexturesDirty: boolean;
  52418. }
  52419. /**
  52420. * Define the code related to the Sheen parameters of the pbr material.
  52421. */
  52422. export class PBRSheenConfiguration {
  52423. private _isEnabled;
  52424. /**
  52425. * Defines if the material uses sheen.
  52426. */
  52427. isEnabled: boolean;
  52428. private _linkSheenWithAlbedo;
  52429. /**
  52430. * Defines if the sheen is linked to the sheen color.
  52431. */
  52432. linkSheenWithAlbedo: boolean;
  52433. /**
  52434. * Defines the sheen intensity.
  52435. */
  52436. intensity: number;
  52437. /**
  52438. * Defines the sheen color.
  52439. */
  52440. color: Color3;
  52441. private _texture;
  52442. /**
  52443. * Stores the sheen tint values in a texture.
  52444. * rgb is tint
  52445. * a is a intensity
  52446. */
  52447. texture: Nullable<BaseTexture>;
  52448. /** @hidden */
  52449. private _internalMarkAllSubMeshesAsTexturesDirty;
  52450. /** @hidden */
  52451. _markAllSubMeshesAsTexturesDirty(): void;
  52452. /**
  52453. * Instantiate a new istance of clear coat configuration.
  52454. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52455. */
  52456. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52457. /**
  52458. * Specifies that the submesh is ready to be used.
  52459. * @param defines the list of "defines" to update.
  52460. * @param scene defines the scene the material belongs to.
  52461. * @returns - boolean indicating that the submesh is ready or not.
  52462. */
  52463. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52464. /**
  52465. * Checks to see if a texture is used in the material.
  52466. * @param defines the list of "defines" to update.
  52467. * @param scene defines the scene the material belongs to.
  52468. */
  52469. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52470. /**
  52471. * Binds the material data.
  52472. * @param uniformBuffer defines the Uniform buffer to fill in.
  52473. * @param scene defines the scene the material belongs to.
  52474. * @param isFrozen defines wether the material is frozen or not.
  52475. */
  52476. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52477. /**
  52478. * Checks to see if a texture is used in the material.
  52479. * @param texture - Base texture to use.
  52480. * @returns - Boolean specifying if a texture is used in the material.
  52481. */
  52482. hasTexture(texture: BaseTexture): boolean;
  52483. /**
  52484. * Returns an array of the actively used textures.
  52485. * @param activeTextures Array of BaseTextures
  52486. */
  52487. getActiveTextures(activeTextures: BaseTexture[]): void;
  52488. /**
  52489. * Returns the animatable textures.
  52490. * @param animatables Array of animatable textures.
  52491. */
  52492. getAnimatables(animatables: IAnimatable[]): void;
  52493. /**
  52494. * Disposes the resources of the material.
  52495. * @param forceDisposeTextures - Forces the disposal of all textures.
  52496. */
  52497. dispose(forceDisposeTextures?: boolean): void;
  52498. /**
  52499. * Get the current class name of the texture useful for serialization or dynamic coding.
  52500. * @returns "PBRSheenConfiguration"
  52501. */
  52502. getClassName(): string;
  52503. /**
  52504. * Add fallbacks to the effect fallbacks list.
  52505. * @param defines defines the Base texture to use.
  52506. * @param fallbacks defines the current fallback list.
  52507. * @param currentRank defines the current fallback rank.
  52508. * @returns the new fallback rank.
  52509. */
  52510. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52511. /**
  52512. * Add the required uniforms to the current list.
  52513. * @param uniforms defines the current uniform list.
  52514. */
  52515. static AddUniforms(uniforms: string[]): void;
  52516. /**
  52517. * Add the required uniforms to the current buffer.
  52518. * @param uniformBuffer defines the current uniform buffer.
  52519. */
  52520. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52521. /**
  52522. * Add the required samplers to the current list.
  52523. * @param samplers defines the current sampler list.
  52524. */
  52525. static AddSamplers(samplers: string[]): void;
  52526. /**
  52527. * Makes a duplicate of the current configuration into another one.
  52528. * @param sheenConfiguration define the config where to copy the info
  52529. */
  52530. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52531. /**
  52532. * Serializes this BRDF configuration.
  52533. * @returns - An object with the serialized config.
  52534. */
  52535. serialize(): any;
  52536. /**
  52537. * Parses a anisotropy Configuration from a serialized object.
  52538. * @param source - Serialized object.
  52539. * @param scene Defines the scene we are parsing for
  52540. * @param rootUrl Defines the rootUrl to load from
  52541. */
  52542. parse(source: any, scene: Scene, rootUrl: string): void;
  52543. }
  52544. }
  52545. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52546. import { Nullable } from "babylonjs/types";
  52547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52548. import { Color3 } from "babylonjs/Maths/math.color";
  52549. import { SmartArray } from "babylonjs/Misc/smartArray";
  52550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52552. import { Effect } from "babylonjs/Materials/effect";
  52553. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52554. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52555. import { Engine } from "babylonjs/Engines/engine";
  52556. import { Scene } from "babylonjs/scene";
  52557. /**
  52558. * @hidden
  52559. */
  52560. export interface IMaterialSubSurfaceDefines {
  52561. SUBSURFACE: boolean;
  52562. SS_REFRACTION: boolean;
  52563. SS_TRANSLUCENCY: boolean;
  52564. SS_SCATERRING: boolean;
  52565. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52566. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52567. SS_REFRACTIONMAP_3D: boolean;
  52568. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52569. SS_LODINREFRACTIONALPHA: boolean;
  52570. SS_GAMMAREFRACTION: boolean;
  52571. SS_RGBDREFRACTION: boolean;
  52572. SS_LINEARSPECULARREFRACTION: boolean;
  52573. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52574. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52575. /** @hidden */
  52576. _areTexturesDirty: boolean;
  52577. }
  52578. /**
  52579. * Define the code related to the sub surface parameters of the pbr material.
  52580. */
  52581. export class PBRSubSurfaceConfiguration {
  52582. private _isRefractionEnabled;
  52583. /**
  52584. * Defines if the refraction is enabled in the material.
  52585. */
  52586. isRefractionEnabled: boolean;
  52587. private _isTranslucencyEnabled;
  52588. /**
  52589. * Defines if the translucency is enabled in the material.
  52590. */
  52591. isTranslucencyEnabled: boolean;
  52592. private _isScatteringEnabled;
  52593. /**
  52594. * Defines the refraction intensity of the material.
  52595. * The refraction when enabled replaces the Diffuse part of the material.
  52596. * The intensity helps transitionning between diffuse and refraction.
  52597. */
  52598. refractionIntensity: number;
  52599. /**
  52600. * Defines the translucency intensity of the material.
  52601. * When translucency has been enabled, this defines how much of the "translucency"
  52602. * is addded to the diffuse part of the material.
  52603. */
  52604. translucencyIntensity: number;
  52605. /**
  52606. * Defines the scattering intensity of the material.
  52607. * When scattering has been enabled, this defines how much of the "scattered light"
  52608. * is addded to the diffuse part of the material.
  52609. */
  52610. scatteringIntensity: number;
  52611. private _thicknessTexture;
  52612. /**
  52613. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52614. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52615. * 0 would mean minimumThickness
  52616. * 1 would mean maximumThickness
  52617. * The other channels might be use as a mask to vary the different effects intensity.
  52618. */
  52619. thicknessTexture: Nullable<BaseTexture>;
  52620. private _refractionTexture;
  52621. /**
  52622. * Defines the texture to use for refraction.
  52623. */
  52624. refractionTexture: Nullable<BaseTexture>;
  52625. private _indexOfRefraction;
  52626. /**
  52627. * Defines the index of refraction used in the material.
  52628. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52629. */
  52630. indexOfRefraction: number;
  52631. private _invertRefractionY;
  52632. /**
  52633. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52634. */
  52635. invertRefractionY: boolean;
  52636. private _linkRefractionWithTransparency;
  52637. /**
  52638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52639. * Materials half opaque for instance using refraction could benefit from this control.
  52640. */
  52641. linkRefractionWithTransparency: boolean;
  52642. /**
  52643. * Defines the minimum thickness stored in the thickness map.
  52644. * If no thickness map is defined, this value will be used to simulate thickness.
  52645. */
  52646. minimumThickness: number;
  52647. /**
  52648. * Defines the maximum thickness stored in the thickness map.
  52649. */
  52650. maximumThickness: number;
  52651. /**
  52652. * Defines the volume tint of the material.
  52653. * This is used for both translucency and scattering.
  52654. */
  52655. tintColor: Color3;
  52656. /**
  52657. * Defines the distance at which the tint color should be found in the media.
  52658. * This is used for refraction only.
  52659. */
  52660. tintColorAtDistance: number;
  52661. /**
  52662. * Defines how far each channel transmit through the media.
  52663. * It is defined as a color to simplify it selection.
  52664. */
  52665. diffusionDistance: Color3;
  52666. private _useMaskFromThicknessTexture;
  52667. /**
  52668. * Stores the intensity of the different subsurface effects in the thickness texture.
  52669. * * the green channel is the translucency intensity.
  52670. * * the blue channel is the scattering intensity.
  52671. * * the alpha channel is the refraction intensity.
  52672. */
  52673. useMaskFromThicknessTexture: boolean;
  52674. /** @hidden */
  52675. private _internalMarkAllSubMeshesAsTexturesDirty;
  52676. /** @hidden */
  52677. _markAllSubMeshesAsTexturesDirty(): void;
  52678. /**
  52679. * Instantiate a new istance of sub surface configuration.
  52680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52681. */
  52682. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52683. /**
  52684. * Gets wehter the submesh is ready to be used or not.
  52685. * @param defines the list of "defines" to update.
  52686. * @param scene defines the scene the material belongs to.
  52687. * @returns - boolean indicating that the submesh is ready or not.
  52688. */
  52689. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52690. /**
  52691. * Checks to see if a texture is used in the material.
  52692. * @param defines the list of "defines" to update.
  52693. * @param scene defines the scene to the material belongs to.
  52694. */
  52695. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52696. /**
  52697. * Binds the material data.
  52698. * @param uniformBuffer defines the Uniform buffer to fill in.
  52699. * @param scene defines the scene the material belongs to.
  52700. * @param engine defines the engine the material belongs to.
  52701. * @param isFrozen defines wether the material is frozen or not.
  52702. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52703. */
  52704. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52705. /**
  52706. * Unbinds the material from the mesh.
  52707. * @param activeEffect defines the effect that should be unbound from.
  52708. * @returns true if unbound, otherwise false
  52709. */
  52710. unbind(activeEffect: Effect): boolean;
  52711. /**
  52712. * Returns the texture used for refraction or null if none is used.
  52713. * @param scene defines the scene the material belongs to.
  52714. * @returns - Refraction texture if present. If no refraction texture and refraction
  52715. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52716. */
  52717. private _getRefractionTexture;
  52718. /**
  52719. * Returns true if alpha blending should be disabled.
  52720. */
  52721. get disableAlphaBlending(): boolean;
  52722. /**
  52723. * Fills the list of render target textures.
  52724. * @param renderTargets the list of render targets to update
  52725. */
  52726. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52727. /**
  52728. * Checks to see if a texture is used in the material.
  52729. * @param texture - Base texture to use.
  52730. * @returns - Boolean specifying if a texture is used in the material.
  52731. */
  52732. hasTexture(texture: BaseTexture): boolean;
  52733. /**
  52734. * Gets a boolean indicating that current material needs to register RTT
  52735. * @returns true if this uses a render target otherwise false.
  52736. */
  52737. hasRenderTargetTextures(): boolean;
  52738. /**
  52739. * Returns an array of the actively used textures.
  52740. * @param activeTextures Array of BaseTextures
  52741. */
  52742. getActiveTextures(activeTextures: BaseTexture[]): void;
  52743. /**
  52744. * Returns the animatable textures.
  52745. * @param animatables Array of animatable textures.
  52746. */
  52747. getAnimatables(animatables: IAnimatable[]): void;
  52748. /**
  52749. * Disposes the resources of the material.
  52750. * @param forceDisposeTextures - Forces the disposal of all textures.
  52751. */
  52752. dispose(forceDisposeTextures?: boolean): void;
  52753. /**
  52754. * Get the current class name of the texture useful for serialization or dynamic coding.
  52755. * @returns "PBRSubSurfaceConfiguration"
  52756. */
  52757. getClassName(): string;
  52758. /**
  52759. * Add fallbacks to the effect fallbacks list.
  52760. * @param defines defines the Base texture to use.
  52761. * @param fallbacks defines the current fallback list.
  52762. * @param currentRank defines the current fallback rank.
  52763. * @returns the new fallback rank.
  52764. */
  52765. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52766. /**
  52767. * Add the required uniforms to the current list.
  52768. * @param uniforms defines the current uniform list.
  52769. */
  52770. static AddUniforms(uniforms: string[]): void;
  52771. /**
  52772. * Add the required samplers to the current list.
  52773. * @param samplers defines the current sampler list.
  52774. */
  52775. static AddSamplers(samplers: string[]): void;
  52776. /**
  52777. * Add the required uniforms to the current buffer.
  52778. * @param uniformBuffer defines the current uniform buffer.
  52779. */
  52780. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52781. /**
  52782. * Makes a duplicate of the current configuration into another one.
  52783. * @param configuration define the config where to copy the info
  52784. */
  52785. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52786. /**
  52787. * Serializes this Sub Surface configuration.
  52788. * @returns - An object with the serialized config.
  52789. */
  52790. serialize(): any;
  52791. /**
  52792. * Parses a anisotropy Configuration from a serialized object.
  52793. * @param source - Serialized object.
  52794. * @param scene Defines the scene we are parsing for
  52795. * @param rootUrl Defines the rootUrl to load from
  52796. */
  52797. parse(source: any, scene: Scene, rootUrl: string): void;
  52798. }
  52799. }
  52800. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52801. /** @hidden */
  52802. export var pbrFragmentDeclaration: {
  52803. name: string;
  52804. shader: string;
  52805. };
  52806. }
  52807. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52808. /** @hidden */
  52809. export var pbrUboDeclaration: {
  52810. name: string;
  52811. shader: string;
  52812. };
  52813. }
  52814. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52815. /** @hidden */
  52816. export var pbrFragmentExtraDeclaration: {
  52817. name: string;
  52818. shader: string;
  52819. };
  52820. }
  52821. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52822. /** @hidden */
  52823. export var pbrFragmentSamplersDeclaration: {
  52824. name: string;
  52825. shader: string;
  52826. };
  52827. }
  52828. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52829. /** @hidden */
  52830. export var pbrHelperFunctions: {
  52831. name: string;
  52832. shader: string;
  52833. };
  52834. }
  52835. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52836. /** @hidden */
  52837. export var harmonicsFunctions: {
  52838. name: string;
  52839. shader: string;
  52840. };
  52841. }
  52842. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52843. /** @hidden */
  52844. export var pbrDirectLightingSetupFunctions: {
  52845. name: string;
  52846. shader: string;
  52847. };
  52848. }
  52849. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52850. /** @hidden */
  52851. export var pbrDirectLightingFalloffFunctions: {
  52852. name: string;
  52853. shader: string;
  52854. };
  52855. }
  52856. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52857. /** @hidden */
  52858. export var pbrBRDFFunctions: {
  52859. name: string;
  52860. shader: string;
  52861. };
  52862. }
  52863. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52864. /** @hidden */
  52865. export var pbrDirectLightingFunctions: {
  52866. name: string;
  52867. shader: string;
  52868. };
  52869. }
  52870. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52871. /** @hidden */
  52872. export var pbrIBLFunctions: {
  52873. name: string;
  52874. shader: string;
  52875. };
  52876. }
  52877. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52878. /** @hidden */
  52879. export var pbrDebug: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module "babylonjs/Shaders/pbr.fragment" {
  52885. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52886. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52887. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52888. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52889. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52892. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52893. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52896. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52897. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52900. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52901. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52902. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52903. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52904. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52905. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52906. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52907. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52908. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52909. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52910. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52911. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52912. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52913. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52914. /** @hidden */
  52915. export var pbrPixelShader: {
  52916. name: string;
  52917. shader: string;
  52918. };
  52919. }
  52920. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52921. /** @hidden */
  52922. export var pbrVertexDeclaration: {
  52923. name: string;
  52924. shader: string;
  52925. };
  52926. }
  52927. declare module "babylonjs/Shaders/pbr.vertex" {
  52928. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52929. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52930. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52931. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52932. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52933. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52934. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52935. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52936. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52941. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52945. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52946. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52947. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52948. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52949. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52950. /** @hidden */
  52951. export var pbrVertexShader: {
  52952. name: string;
  52953. shader: string;
  52954. };
  52955. }
  52956. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52957. import { Nullable } from "babylonjs/types";
  52958. import { Scene } from "babylonjs/scene";
  52959. import { Matrix } from "babylonjs/Maths/math.vector";
  52960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52962. import { Mesh } from "babylonjs/Meshes/mesh";
  52963. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52964. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52965. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52966. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52967. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52968. import { Color3 } from "babylonjs/Maths/math.color";
  52969. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52970. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52971. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52972. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52975. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52976. import "babylonjs/Shaders/pbr.fragment";
  52977. import "babylonjs/Shaders/pbr.vertex";
  52978. /**
  52979. * Manages the defines for the PBR Material.
  52980. * @hidden
  52981. */
  52982. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52983. PBR: boolean;
  52984. MAINUV1: boolean;
  52985. MAINUV2: boolean;
  52986. UV1: boolean;
  52987. UV2: boolean;
  52988. ALBEDO: boolean;
  52989. GAMMAALBEDO: boolean;
  52990. ALBEDODIRECTUV: number;
  52991. VERTEXCOLOR: boolean;
  52992. AMBIENT: boolean;
  52993. AMBIENTDIRECTUV: number;
  52994. AMBIENTINGRAYSCALE: boolean;
  52995. OPACITY: boolean;
  52996. VERTEXALPHA: boolean;
  52997. OPACITYDIRECTUV: number;
  52998. OPACITYRGB: boolean;
  52999. ALPHATEST: boolean;
  53000. DEPTHPREPASS: boolean;
  53001. ALPHABLEND: boolean;
  53002. ALPHAFROMALBEDO: boolean;
  53003. ALPHATESTVALUE: string;
  53004. SPECULAROVERALPHA: boolean;
  53005. RADIANCEOVERALPHA: boolean;
  53006. ALPHAFRESNEL: boolean;
  53007. LINEARALPHAFRESNEL: boolean;
  53008. PREMULTIPLYALPHA: boolean;
  53009. EMISSIVE: boolean;
  53010. EMISSIVEDIRECTUV: number;
  53011. REFLECTIVITY: boolean;
  53012. REFLECTIVITYDIRECTUV: number;
  53013. SPECULARTERM: boolean;
  53014. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53015. MICROSURFACEAUTOMATIC: boolean;
  53016. LODBASEDMICROSFURACE: boolean;
  53017. MICROSURFACEMAP: boolean;
  53018. MICROSURFACEMAPDIRECTUV: number;
  53019. METALLICWORKFLOW: boolean;
  53020. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53021. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53022. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53023. AOSTOREINMETALMAPRED: boolean;
  53024. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53025. ENVIRONMENTBRDF: boolean;
  53026. ENVIRONMENTBRDF_RGBD: boolean;
  53027. NORMAL: boolean;
  53028. TANGENT: boolean;
  53029. BUMP: boolean;
  53030. BUMPDIRECTUV: number;
  53031. OBJECTSPACE_NORMALMAP: boolean;
  53032. PARALLAX: boolean;
  53033. PARALLAXOCCLUSION: boolean;
  53034. NORMALXYSCALE: boolean;
  53035. LIGHTMAP: boolean;
  53036. LIGHTMAPDIRECTUV: number;
  53037. USELIGHTMAPASSHADOWMAP: boolean;
  53038. GAMMALIGHTMAP: boolean;
  53039. RGBDLIGHTMAP: boolean;
  53040. REFLECTION: boolean;
  53041. REFLECTIONMAP_3D: boolean;
  53042. REFLECTIONMAP_SPHERICAL: boolean;
  53043. REFLECTIONMAP_PLANAR: boolean;
  53044. REFLECTIONMAP_CUBIC: boolean;
  53045. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53046. REFLECTIONMAP_PROJECTION: boolean;
  53047. REFLECTIONMAP_SKYBOX: boolean;
  53048. REFLECTIONMAP_EXPLICIT: boolean;
  53049. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53050. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53051. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53052. INVERTCUBICMAP: boolean;
  53053. USESPHERICALFROMREFLECTIONMAP: boolean;
  53054. USEIRRADIANCEMAP: boolean;
  53055. SPHERICAL_HARMONICS: boolean;
  53056. USESPHERICALINVERTEX: boolean;
  53057. REFLECTIONMAP_OPPOSITEZ: boolean;
  53058. LODINREFLECTIONALPHA: boolean;
  53059. GAMMAREFLECTION: boolean;
  53060. RGBDREFLECTION: boolean;
  53061. LINEARSPECULARREFLECTION: boolean;
  53062. RADIANCEOCCLUSION: boolean;
  53063. HORIZONOCCLUSION: boolean;
  53064. INSTANCES: boolean;
  53065. NUM_BONE_INFLUENCERS: number;
  53066. BonesPerMesh: number;
  53067. BONETEXTURE: boolean;
  53068. NONUNIFORMSCALING: boolean;
  53069. MORPHTARGETS: boolean;
  53070. MORPHTARGETS_NORMAL: boolean;
  53071. MORPHTARGETS_TANGENT: boolean;
  53072. MORPHTARGETS_UV: boolean;
  53073. NUM_MORPH_INFLUENCERS: number;
  53074. IMAGEPROCESSING: boolean;
  53075. VIGNETTE: boolean;
  53076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53077. VIGNETTEBLENDMODEOPAQUE: boolean;
  53078. TONEMAPPING: boolean;
  53079. TONEMAPPING_ACES: boolean;
  53080. CONTRAST: boolean;
  53081. COLORCURVES: boolean;
  53082. COLORGRADING: boolean;
  53083. COLORGRADING3D: boolean;
  53084. SAMPLER3DGREENDEPTH: boolean;
  53085. SAMPLER3DBGRMAP: boolean;
  53086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53087. EXPOSURE: boolean;
  53088. MULTIVIEW: boolean;
  53089. USEPHYSICALLIGHTFALLOFF: boolean;
  53090. USEGLTFLIGHTFALLOFF: boolean;
  53091. TWOSIDEDLIGHTING: boolean;
  53092. SHADOWFLOAT: boolean;
  53093. CLIPPLANE: boolean;
  53094. CLIPPLANE2: boolean;
  53095. CLIPPLANE3: boolean;
  53096. CLIPPLANE4: boolean;
  53097. CLIPPLANE5: boolean;
  53098. CLIPPLANE6: boolean;
  53099. POINTSIZE: boolean;
  53100. FOG: boolean;
  53101. LOGARITHMICDEPTH: boolean;
  53102. FORCENORMALFORWARD: boolean;
  53103. SPECULARAA: boolean;
  53104. CLEARCOAT: boolean;
  53105. CLEARCOAT_DEFAULTIOR: boolean;
  53106. CLEARCOAT_TEXTURE: boolean;
  53107. CLEARCOAT_TEXTUREDIRECTUV: number;
  53108. CLEARCOAT_BUMP: boolean;
  53109. CLEARCOAT_BUMPDIRECTUV: number;
  53110. CLEARCOAT_TINT: boolean;
  53111. CLEARCOAT_TINT_TEXTURE: boolean;
  53112. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53113. ANISOTROPIC: boolean;
  53114. ANISOTROPIC_TEXTURE: boolean;
  53115. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53116. BRDF_V_HEIGHT_CORRELATED: boolean;
  53117. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53118. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53119. SHEEN: boolean;
  53120. SHEEN_TEXTURE: boolean;
  53121. SHEEN_TEXTUREDIRECTUV: number;
  53122. SHEEN_LINKWITHALBEDO: boolean;
  53123. SUBSURFACE: boolean;
  53124. SS_REFRACTION: boolean;
  53125. SS_TRANSLUCENCY: boolean;
  53126. SS_SCATERRING: boolean;
  53127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53129. SS_REFRACTIONMAP_3D: boolean;
  53130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53131. SS_LODINREFRACTIONALPHA: boolean;
  53132. SS_GAMMAREFRACTION: boolean;
  53133. SS_RGBDREFRACTION: boolean;
  53134. SS_LINEARSPECULARREFRACTION: boolean;
  53135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53136. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53137. UNLIT: boolean;
  53138. DEBUGMODE: number;
  53139. /**
  53140. * Initializes the PBR Material defines.
  53141. */
  53142. constructor();
  53143. /**
  53144. * Resets the PBR Material defines.
  53145. */
  53146. reset(): void;
  53147. }
  53148. /**
  53149. * The Physically based material base class of BJS.
  53150. *
  53151. * This offers the main features of a standard PBR material.
  53152. * For more information, please refer to the documentation :
  53153. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53154. */
  53155. export abstract class PBRBaseMaterial extends PushMaterial {
  53156. /**
  53157. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53158. */
  53159. static readonly PBRMATERIAL_OPAQUE: number;
  53160. /**
  53161. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53162. */
  53163. static readonly PBRMATERIAL_ALPHATEST: number;
  53164. /**
  53165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53166. */
  53167. static readonly PBRMATERIAL_ALPHABLEND: number;
  53168. /**
  53169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53170. * They are also discarded below the alpha cutoff threshold to improve performances.
  53171. */
  53172. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53173. /**
  53174. * Defines the default value of how much AO map is occluding the analytical lights
  53175. * (point spot...).
  53176. */
  53177. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53178. /**
  53179. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53180. */
  53181. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53182. /**
  53183. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53184. * to enhance interoperability with other engines.
  53185. */
  53186. static readonly LIGHTFALLOFF_GLTF: number;
  53187. /**
  53188. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53189. * to enhance interoperability with other materials.
  53190. */
  53191. static readonly LIGHTFALLOFF_STANDARD: number;
  53192. /**
  53193. * Intensity of the direct lights e.g. the four lights available in your scene.
  53194. * This impacts both the direct diffuse and specular highlights.
  53195. */
  53196. protected _directIntensity: number;
  53197. /**
  53198. * Intensity of the emissive part of the material.
  53199. * This helps controlling the emissive effect without modifying the emissive color.
  53200. */
  53201. protected _emissiveIntensity: number;
  53202. /**
  53203. * Intensity of the environment e.g. how much the environment will light the object
  53204. * either through harmonics for rough material or through the refelction for shiny ones.
  53205. */
  53206. protected _environmentIntensity: number;
  53207. /**
  53208. * This is a special control allowing the reduction of the specular highlights coming from the
  53209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53210. */
  53211. protected _specularIntensity: number;
  53212. /**
  53213. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53214. */
  53215. private _lightingInfos;
  53216. /**
  53217. * Debug Control allowing disabling the bump map on this material.
  53218. */
  53219. protected _disableBumpMap: boolean;
  53220. /**
  53221. * AKA Diffuse Texture in standard nomenclature.
  53222. */
  53223. protected _albedoTexture: Nullable<BaseTexture>;
  53224. /**
  53225. * AKA Occlusion Texture in other nomenclature.
  53226. */
  53227. protected _ambientTexture: Nullable<BaseTexture>;
  53228. /**
  53229. * AKA Occlusion Texture Intensity in other nomenclature.
  53230. */
  53231. protected _ambientTextureStrength: number;
  53232. /**
  53233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53234. * 1 means it completely occludes it
  53235. * 0 mean it has no impact
  53236. */
  53237. protected _ambientTextureImpactOnAnalyticalLights: number;
  53238. /**
  53239. * Stores the alpha values in a texture.
  53240. */
  53241. protected _opacityTexture: Nullable<BaseTexture>;
  53242. /**
  53243. * Stores the reflection values in a texture.
  53244. */
  53245. protected _reflectionTexture: Nullable<BaseTexture>;
  53246. /**
  53247. * Stores the emissive values in a texture.
  53248. */
  53249. protected _emissiveTexture: Nullable<BaseTexture>;
  53250. /**
  53251. * AKA Specular texture in other nomenclature.
  53252. */
  53253. protected _reflectivityTexture: Nullable<BaseTexture>;
  53254. /**
  53255. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53256. */
  53257. protected _metallicTexture: Nullable<BaseTexture>;
  53258. /**
  53259. * Specifies the metallic scalar of the metallic/roughness workflow.
  53260. * Can also be used to scale the metalness values of the metallic texture.
  53261. */
  53262. protected _metallic: Nullable<number>;
  53263. /**
  53264. * Specifies the roughness scalar of the metallic/roughness workflow.
  53265. * Can also be used to scale the roughness values of the metallic texture.
  53266. */
  53267. protected _roughness: Nullable<number>;
  53268. /**
  53269. * Specifies the an F0 factor to help configuring the material F0.
  53270. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53271. * to 0.5 the previously hard coded value stays the same.
  53272. * Can also be used to scale the F0 values of the metallic texture.
  53273. */
  53274. protected _metallicF0Factor: number;
  53275. /**
  53276. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53277. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53278. * your expectation as it multiplies with the texture data.
  53279. */
  53280. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53281. /**
  53282. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53283. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53284. */
  53285. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53286. /**
  53287. * Stores surface normal data used to displace a mesh in a texture.
  53288. */
  53289. protected _bumpTexture: Nullable<BaseTexture>;
  53290. /**
  53291. * Stores the pre-calculated light information of a mesh in a texture.
  53292. */
  53293. protected _lightmapTexture: Nullable<BaseTexture>;
  53294. /**
  53295. * The color of a material in ambient lighting.
  53296. */
  53297. protected _ambientColor: Color3;
  53298. /**
  53299. * AKA Diffuse Color in other nomenclature.
  53300. */
  53301. protected _albedoColor: Color3;
  53302. /**
  53303. * AKA Specular Color in other nomenclature.
  53304. */
  53305. protected _reflectivityColor: Color3;
  53306. /**
  53307. * The color applied when light is reflected from a material.
  53308. */
  53309. protected _reflectionColor: Color3;
  53310. /**
  53311. * The color applied when light is emitted from a material.
  53312. */
  53313. protected _emissiveColor: Color3;
  53314. /**
  53315. * AKA Glossiness in other nomenclature.
  53316. */
  53317. protected _microSurface: number;
  53318. /**
  53319. * Specifies that the material will use the light map as a show map.
  53320. */
  53321. protected _useLightmapAsShadowmap: boolean;
  53322. /**
  53323. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53324. * makes the reflect vector face the model (under horizon).
  53325. */
  53326. protected _useHorizonOcclusion: boolean;
  53327. /**
  53328. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53329. * too much the area relying on ambient texture to define their ambient occlusion.
  53330. */
  53331. protected _useRadianceOcclusion: boolean;
  53332. /**
  53333. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53334. */
  53335. protected _useAlphaFromAlbedoTexture: boolean;
  53336. /**
  53337. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53338. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53339. */
  53340. protected _useSpecularOverAlpha: boolean;
  53341. /**
  53342. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53343. */
  53344. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53345. /**
  53346. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53347. */
  53348. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53349. /**
  53350. * Specifies if the metallic texture contains the roughness information in its green channel.
  53351. */
  53352. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53353. /**
  53354. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53355. */
  53356. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53357. /**
  53358. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53359. */
  53360. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53361. /**
  53362. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53363. */
  53364. protected _useAmbientInGrayScale: boolean;
  53365. /**
  53366. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53367. * The material will try to infer what glossiness each pixel should be.
  53368. */
  53369. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53370. /**
  53371. * Defines the falloff type used in this material.
  53372. * It by default is Physical.
  53373. */
  53374. protected _lightFalloff: number;
  53375. /**
  53376. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53377. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53378. */
  53379. protected _useRadianceOverAlpha: boolean;
  53380. /**
  53381. * Allows using an object space normal map (instead of tangent space).
  53382. */
  53383. protected _useObjectSpaceNormalMap: boolean;
  53384. /**
  53385. * Allows using the bump map in parallax mode.
  53386. */
  53387. protected _useParallax: boolean;
  53388. /**
  53389. * Allows using the bump map in parallax occlusion mode.
  53390. */
  53391. protected _useParallaxOcclusion: boolean;
  53392. /**
  53393. * Controls the scale bias of the parallax mode.
  53394. */
  53395. protected _parallaxScaleBias: number;
  53396. /**
  53397. * If sets to true, disables all the lights affecting the material.
  53398. */
  53399. protected _disableLighting: boolean;
  53400. /**
  53401. * Number of Simultaneous lights allowed on the material.
  53402. */
  53403. protected _maxSimultaneousLights: number;
  53404. /**
  53405. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53406. */
  53407. protected _invertNormalMapX: boolean;
  53408. /**
  53409. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53410. */
  53411. protected _invertNormalMapY: boolean;
  53412. /**
  53413. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53414. */
  53415. protected _twoSidedLighting: boolean;
  53416. /**
  53417. * Defines the alpha limits in alpha test mode.
  53418. */
  53419. protected _alphaCutOff: number;
  53420. /**
  53421. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53422. */
  53423. protected _forceAlphaTest: boolean;
  53424. /**
  53425. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53426. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53427. */
  53428. protected _useAlphaFresnel: boolean;
  53429. /**
  53430. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53431. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53432. */
  53433. protected _useLinearAlphaFresnel: boolean;
  53434. /**
  53435. * The transparency mode of the material.
  53436. */
  53437. protected _transparencyMode: Nullable<number>;
  53438. /**
  53439. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53440. * from cos thetav and roughness:
  53441. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53442. */
  53443. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53444. /**
  53445. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53446. */
  53447. protected _forceIrradianceInFragment: boolean;
  53448. /**
  53449. * Force normal to face away from face.
  53450. */
  53451. protected _forceNormalForward: boolean;
  53452. /**
  53453. * Enables specular anti aliasing in the PBR shader.
  53454. * It will both interacts on the Geometry for analytical and IBL lighting.
  53455. * It also prefilter the roughness map based on the bump values.
  53456. */
  53457. protected _enableSpecularAntiAliasing: boolean;
  53458. /**
  53459. * Default configuration related to image processing available in the PBR Material.
  53460. */
  53461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53462. /**
  53463. * Keep track of the image processing observer to allow dispose and replace.
  53464. */
  53465. private _imageProcessingObserver;
  53466. /**
  53467. * Attaches a new image processing configuration to the PBR Material.
  53468. * @param configuration
  53469. */
  53470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53471. /**
  53472. * Stores the available render targets.
  53473. */
  53474. private _renderTargets;
  53475. /**
  53476. * Sets the global ambient color for the material used in lighting calculations.
  53477. */
  53478. private _globalAmbientColor;
  53479. /**
  53480. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53481. */
  53482. private _useLogarithmicDepth;
  53483. /**
  53484. * If set to true, no lighting calculations will be applied.
  53485. */
  53486. private _unlit;
  53487. private _debugMode;
  53488. /**
  53489. * @hidden
  53490. * This is reserved for the inspector.
  53491. * Defines the material debug mode.
  53492. * It helps seeing only some components of the material while troubleshooting.
  53493. */
  53494. debugMode: number;
  53495. /**
  53496. * @hidden
  53497. * This is reserved for the inspector.
  53498. * Specify from where on screen the debug mode should start.
  53499. * The value goes from -1 (full screen) to 1 (not visible)
  53500. * It helps with side by side comparison against the final render
  53501. * This defaults to -1
  53502. */
  53503. private debugLimit;
  53504. /**
  53505. * @hidden
  53506. * This is reserved for the inspector.
  53507. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53508. * You can use the factor to better multiply the final value.
  53509. */
  53510. private debugFactor;
  53511. /**
  53512. * Defines the clear coat layer parameters for the material.
  53513. */
  53514. readonly clearCoat: PBRClearCoatConfiguration;
  53515. /**
  53516. * Defines the anisotropic parameters for the material.
  53517. */
  53518. readonly anisotropy: PBRAnisotropicConfiguration;
  53519. /**
  53520. * Defines the BRDF parameters for the material.
  53521. */
  53522. readonly brdf: PBRBRDFConfiguration;
  53523. /**
  53524. * Defines the Sheen parameters for the material.
  53525. */
  53526. readonly sheen: PBRSheenConfiguration;
  53527. /**
  53528. * Defines the SubSurface parameters for the material.
  53529. */
  53530. readonly subSurface: PBRSubSurfaceConfiguration;
  53531. /**
  53532. * Custom callback helping to override the default shader used in the material.
  53533. */
  53534. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53535. protected _rebuildInParallel: boolean;
  53536. /**
  53537. * Instantiates a new PBRMaterial instance.
  53538. *
  53539. * @param name The material name
  53540. * @param scene The scene the material will be use in.
  53541. */
  53542. constructor(name: string, scene: Scene);
  53543. /**
  53544. * Gets a boolean indicating that current material needs to register RTT
  53545. */
  53546. get hasRenderTargetTextures(): boolean;
  53547. /**
  53548. * Gets the name of the material class.
  53549. */
  53550. getClassName(): string;
  53551. /**
  53552. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53553. */
  53554. get useLogarithmicDepth(): boolean;
  53555. /**
  53556. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53557. */
  53558. set useLogarithmicDepth(value: boolean);
  53559. /**
  53560. * Gets the current transparency mode.
  53561. */
  53562. get transparencyMode(): Nullable<number>;
  53563. /**
  53564. * Sets the transparency mode of the material.
  53565. *
  53566. * | Value | Type | Description |
  53567. * | ----- | ----------------------------------- | ----------- |
  53568. * | 0 | OPAQUE | |
  53569. * | 1 | ALPHATEST | |
  53570. * | 2 | ALPHABLEND | |
  53571. * | 3 | ALPHATESTANDBLEND | |
  53572. *
  53573. */
  53574. set transparencyMode(value: Nullable<number>);
  53575. /**
  53576. * Returns true if alpha blending should be disabled.
  53577. */
  53578. private get _disableAlphaBlending();
  53579. /**
  53580. * Specifies whether or not this material should be rendered in alpha blend mode.
  53581. */
  53582. needAlphaBlending(): boolean;
  53583. /**
  53584. * Specifies if the mesh will require alpha blending.
  53585. * @param mesh - BJS mesh.
  53586. */
  53587. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53588. /**
  53589. * Specifies whether or not this material should be rendered in alpha test mode.
  53590. */
  53591. needAlphaTesting(): boolean;
  53592. /**
  53593. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53594. */
  53595. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53596. /**
  53597. * Gets the texture used for the alpha test.
  53598. */
  53599. getAlphaTestTexture(): Nullable<BaseTexture>;
  53600. /**
  53601. * Specifies that the submesh is ready to be used.
  53602. * @param mesh - BJS mesh.
  53603. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53604. * @param useInstances - Specifies that instances should be used.
  53605. * @returns - boolean indicating that the submesh is ready or not.
  53606. */
  53607. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53608. /**
  53609. * Specifies if the material uses metallic roughness workflow.
  53610. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53611. */
  53612. isMetallicWorkflow(): boolean;
  53613. private _prepareEffect;
  53614. private _prepareDefines;
  53615. /**
  53616. * Force shader compilation
  53617. */
  53618. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53619. /**
  53620. * Initializes the uniform buffer layout for the shader.
  53621. */
  53622. buildUniformLayout(): void;
  53623. /**
  53624. * Unbinds the material from the mesh
  53625. */
  53626. unbind(): void;
  53627. /**
  53628. * Binds the submesh data.
  53629. * @param world - The world matrix.
  53630. * @param mesh - The BJS mesh.
  53631. * @param subMesh - A submesh of the BJS mesh.
  53632. */
  53633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53634. /**
  53635. * Returns the animatable textures.
  53636. * @returns - Array of animatable textures.
  53637. */
  53638. getAnimatables(): IAnimatable[];
  53639. /**
  53640. * Returns the texture used for reflections.
  53641. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53642. */
  53643. private _getReflectionTexture;
  53644. /**
  53645. * Returns an array of the actively used textures.
  53646. * @returns - Array of BaseTextures
  53647. */
  53648. getActiveTextures(): BaseTexture[];
  53649. /**
  53650. * Checks to see if a texture is used in the material.
  53651. * @param texture - Base texture to use.
  53652. * @returns - Boolean specifying if a texture is used in the material.
  53653. */
  53654. hasTexture(texture: BaseTexture): boolean;
  53655. /**
  53656. * Disposes the resources of the material.
  53657. * @param forceDisposeEffect - Forces the disposal of effects.
  53658. * @param forceDisposeTextures - Forces the disposal of all textures.
  53659. */
  53660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53661. }
  53662. }
  53663. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53664. import { Nullable } from "babylonjs/types";
  53665. import { Scene } from "babylonjs/scene";
  53666. import { Color3 } from "babylonjs/Maths/math.color";
  53667. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53668. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53670. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53671. /**
  53672. * The Physically based material of BJS.
  53673. *
  53674. * This offers the main features of a standard PBR material.
  53675. * For more information, please refer to the documentation :
  53676. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53677. */
  53678. export class PBRMaterial extends PBRBaseMaterial {
  53679. /**
  53680. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53681. */
  53682. static readonly PBRMATERIAL_OPAQUE: number;
  53683. /**
  53684. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53685. */
  53686. static readonly PBRMATERIAL_ALPHATEST: number;
  53687. /**
  53688. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53689. */
  53690. static readonly PBRMATERIAL_ALPHABLEND: number;
  53691. /**
  53692. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53693. * They are also discarded below the alpha cutoff threshold to improve performances.
  53694. */
  53695. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53696. /**
  53697. * Defines the default value of how much AO map is occluding the analytical lights
  53698. * (point spot...).
  53699. */
  53700. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53701. /**
  53702. * Intensity of the direct lights e.g. the four lights available in your scene.
  53703. * This impacts both the direct diffuse and specular highlights.
  53704. */
  53705. directIntensity: number;
  53706. /**
  53707. * Intensity of the emissive part of the material.
  53708. * This helps controlling the emissive effect without modifying the emissive color.
  53709. */
  53710. emissiveIntensity: number;
  53711. /**
  53712. * Intensity of the environment e.g. how much the environment will light the object
  53713. * either through harmonics for rough material or through the refelction for shiny ones.
  53714. */
  53715. environmentIntensity: number;
  53716. /**
  53717. * This is a special control allowing the reduction of the specular highlights coming from the
  53718. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53719. */
  53720. specularIntensity: number;
  53721. /**
  53722. * Debug Control allowing disabling the bump map on this material.
  53723. */
  53724. disableBumpMap: boolean;
  53725. /**
  53726. * AKA Diffuse Texture in standard nomenclature.
  53727. */
  53728. albedoTexture: BaseTexture;
  53729. /**
  53730. * AKA Occlusion Texture in other nomenclature.
  53731. */
  53732. ambientTexture: BaseTexture;
  53733. /**
  53734. * AKA Occlusion Texture Intensity in other nomenclature.
  53735. */
  53736. ambientTextureStrength: number;
  53737. /**
  53738. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53739. * 1 means it completely occludes it
  53740. * 0 mean it has no impact
  53741. */
  53742. ambientTextureImpactOnAnalyticalLights: number;
  53743. /**
  53744. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53745. */
  53746. opacityTexture: BaseTexture;
  53747. /**
  53748. * Stores the reflection values in a texture.
  53749. */
  53750. reflectionTexture: Nullable<BaseTexture>;
  53751. /**
  53752. * Stores the emissive values in a texture.
  53753. */
  53754. emissiveTexture: BaseTexture;
  53755. /**
  53756. * AKA Specular texture in other nomenclature.
  53757. */
  53758. reflectivityTexture: BaseTexture;
  53759. /**
  53760. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53761. */
  53762. metallicTexture: BaseTexture;
  53763. /**
  53764. * Specifies the metallic scalar of the metallic/roughness workflow.
  53765. * Can also be used to scale the metalness values of the metallic texture.
  53766. */
  53767. metallic: Nullable<number>;
  53768. /**
  53769. * Specifies the roughness scalar of the metallic/roughness workflow.
  53770. * Can also be used to scale the roughness values of the metallic texture.
  53771. */
  53772. roughness: Nullable<number>;
  53773. /**
  53774. * Specifies the an F0 factor to help configuring the material F0.
  53775. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53776. * to 0.5 the previously hard coded value stays the same.
  53777. * Can also be used to scale the F0 values of the metallic texture.
  53778. */
  53779. metallicF0Factor: number;
  53780. /**
  53781. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53782. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53783. * your expectation as it multiplies with the texture data.
  53784. */
  53785. useMetallicF0FactorFromMetallicTexture: boolean;
  53786. /**
  53787. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53788. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53789. */
  53790. microSurfaceTexture: BaseTexture;
  53791. /**
  53792. * Stores surface normal data used to displace a mesh in a texture.
  53793. */
  53794. bumpTexture: BaseTexture;
  53795. /**
  53796. * Stores the pre-calculated light information of a mesh in a texture.
  53797. */
  53798. lightmapTexture: BaseTexture;
  53799. /**
  53800. * Stores the refracted light information in a texture.
  53801. */
  53802. get refractionTexture(): Nullable<BaseTexture>;
  53803. set refractionTexture(value: Nullable<BaseTexture>);
  53804. /**
  53805. * The color of a material in ambient lighting.
  53806. */
  53807. ambientColor: Color3;
  53808. /**
  53809. * AKA Diffuse Color in other nomenclature.
  53810. */
  53811. albedoColor: Color3;
  53812. /**
  53813. * AKA Specular Color in other nomenclature.
  53814. */
  53815. reflectivityColor: Color3;
  53816. /**
  53817. * The color reflected from the material.
  53818. */
  53819. reflectionColor: Color3;
  53820. /**
  53821. * The color emitted from the material.
  53822. */
  53823. emissiveColor: Color3;
  53824. /**
  53825. * AKA Glossiness in other nomenclature.
  53826. */
  53827. microSurface: number;
  53828. /**
  53829. * source material index of refraction (IOR)' / 'destination material IOR.
  53830. */
  53831. get indexOfRefraction(): number;
  53832. set indexOfRefraction(value: number);
  53833. /**
  53834. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53835. */
  53836. get invertRefractionY(): boolean;
  53837. set invertRefractionY(value: boolean);
  53838. /**
  53839. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53840. * Materials half opaque for instance using refraction could benefit from this control.
  53841. */
  53842. get linkRefractionWithTransparency(): boolean;
  53843. set linkRefractionWithTransparency(value: boolean);
  53844. /**
  53845. * If true, the light map contains occlusion information instead of lighting info.
  53846. */
  53847. useLightmapAsShadowmap: boolean;
  53848. /**
  53849. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53850. */
  53851. useAlphaFromAlbedoTexture: boolean;
  53852. /**
  53853. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53854. */
  53855. forceAlphaTest: boolean;
  53856. /**
  53857. * Defines the alpha limits in alpha test mode.
  53858. */
  53859. alphaCutOff: number;
  53860. /**
  53861. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53862. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53863. */
  53864. useSpecularOverAlpha: boolean;
  53865. /**
  53866. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53867. */
  53868. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53869. /**
  53870. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53871. */
  53872. useRoughnessFromMetallicTextureAlpha: boolean;
  53873. /**
  53874. * Specifies if the metallic texture contains the roughness information in its green channel.
  53875. */
  53876. useRoughnessFromMetallicTextureGreen: boolean;
  53877. /**
  53878. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53879. */
  53880. useMetallnessFromMetallicTextureBlue: boolean;
  53881. /**
  53882. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53883. */
  53884. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53885. /**
  53886. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53887. */
  53888. useAmbientInGrayScale: boolean;
  53889. /**
  53890. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53891. * The material will try to infer what glossiness each pixel should be.
  53892. */
  53893. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53894. /**
  53895. * BJS is using an harcoded light falloff based on a manually sets up range.
  53896. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53897. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53898. */
  53899. get usePhysicalLightFalloff(): boolean;
  53900. /**
  53901. * BJS is using an harcoded light falloff based on a manually sets up range.
  53902. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53903. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53904. */
  53905. set usePhysicalLightFalloff(value: boolean);
  53906. /**
  53907. * In order to support the falloff compatibility with gltf, a special mode has been added
  53908. * to reproduce the gltf light falloff.
  53909. */
  53910. get useGLTFLightFalloff(): boolean;
  53911. /**
  53912. * In order to support the falloff compatibility with gltf, a special mode has been added
  53913. * to reproduce the gltf light falloff.
  53914. */
  53915. set useGLTFLightFalloff(value: boolean);
  53916. /**
  53917. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53918. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53919. */
  53920. useRadianceOverAlpha: boolean;
  53921. /**
  53922. * Allows using an object space normal map (instead of tangent space).
  53923. */
  53924. useObjectSpaceNormalMap: boolean;
  53925. /**
  53926. * Allows using the bump map in parallax mode.
  53927. */
  53928. useParallax: boolean;
  53929. /**
  53930. * Allows using the bump map in parallax occlusion mode.
  53931. */
  53932. useParallaxOcclusion: boolean;
  53933. /**
  53934. * Controls the scale bias of the parallax mode.
  53935. */
  53936. parallaxScaleBias: number;
  53937. /**
  53938. * If sets to true, disables all the lights affecting the material.
  53939. */
  53940. disableLighting: boolean;
  53941. /**
  53942. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53943. */
  53944. forceIrradianceInFragment: boolean;
  53945. /**
  53946. * Number of Simultaneous lights allowed on the material.
  53947. */
  53948. maxSimultaneousLights: number;
  53949. /**
  53950. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53951. */
  53952. invertNormalMapX: boolean;
  53953. /**
  53954. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53955. */
  53956. invertNormalMapY: boolean;
  53957. /**
  53958. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53959. */
  53960. twoSidedLighting: boolean;
  53961. /**
  53962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53963. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53964. */
  53965. useAlphaFresnel: boolean;
  53966. /**
  53967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53968. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53969. */
  53970. useLinearAlphaFresnel: boolean;
  53971. /**
  53972. * Let user defines the brdf lookup texture used for IBL.
  53973. * A default 8bit version is embedded but you could point at :
  53974. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53975. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53976. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53977. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53978. */
  53979. environmentBRDFTexture: Nullable<BaseTexture>;
  53980. /**
  53981. * Force normal to face away from face.
  53982. */
  53983. forceNormalForward: boolean;
  53984. /**
  53985. * Enables specular anti aliasing in the PBR shader.
  53986. * It will both interacts on the Geometry for analytical and IBL lighting.
  53987. * It also prefilter the roughness map based on the bump values.
  53988. */
  53989. enableSpecularAntiAliasing: boolean;
  53990. /**
  53991. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53992. * makes the reflect vector face the model (under horizon).
  53993. */
  53994. useHorizonOcclusion: boolean;
  53995. /**
  53996. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53997. * too much the area relying on ambient texture to define their ambient occlusion.
  53998. */
  53999. useRadianceOcclusion: boolean;
  54000. /**
  54001. * If set to true, no lighting calculations will be applied.
  54002. */
  54003. unlit: boolean;
  54004. /**
  54005. * Gets the image processing configuration used either in this material.
  54006. */
  54007. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54008. /**
  54009. * Sets the Default image processing configuration used either in the this material.
  54010. *
  54011. * If sets to null, the scene one is in use.
  54012. */
  54013. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54014. /**
  54015. * Gets wether the color curves effect is enabled.
  54016. */
  54017. get cameraColorCurvesEnabled(): boolean;
  54018. /**
  54019. * Sets wether the color curves effect is enabled.
  54020. */
  54021. set cameraColorCurvesEnabled(value: boolean);
  54022. /**
  54023. * Gets wether the color grading effect is enabled.
  54024. */
  54025. get cameraColorGradingEnabled(): boolean;
  54026. /**
  54027. * Gets wether the color grading effect is enabled.
  54028. */
  54029. set cameraColorGradingEnabled(value: boolean);
  54030. /**
  54031. * Gets wether tonemapping is enabled or not.
  54032. */
  54033. get cameraToneMappingEnabled(): boolean;
  54034. /**
  54035. * Sets wether tonemapping is enabled or not
  54036. */
  54037. set cameraToneMappingEnabled(value: boolean);
  54038. /**
  54039. * The camera exposure used on this material.
  54040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54041. * This corresponds to a photographic exposure.
  54042. */
  54043. get cameraExposure(): number;
  54044. /**
  54045. * The camera exposure used on this material.
  54046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54047. * This corresponds to a photographic exposure.
  54048. */
  54049. set cameraExposure(value: number);
  54050. /**
  54051. * Gets The camera contrast used on this material.
  54052. */
  54053. get cameraContrast(): number;
  54054. /**
  54055. * Sets The camera contrast used on this material.
  54056. */
  54057. set cameraContrast(value: number);
  54058. /**
  54059. * Gets the Color Grading 2D Lookup Texture.
  54060. */
  54061. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54062. /**
  54063. * Sets the Color Grading 2D Lookup Texture.
  54064. */
  54065. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54066. /**
  54067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54069. * 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;
  54070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54071. */
  54072. get cameraColorCurves(): Nullable<ColorCurves>;
  54073. /**
  54074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54076. * 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;
  54077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54078. */
  54079. set cameraColorCurves(value: Nullable<ColorCurves>);
  54080. /**
  54081. * Instantiates a new PBRMaterial instance.
  54082. *
  54083. * @param name The material name
  54084. * @param scene The scene the material will be use in.
  54085. */
  54086. constructor(name: string, scene: Scene);
  54087. /**
  54088. * Returns the name of this material class.
  54089. */
  54090. getClassName(): string;
  54091. /**
  54092. * Makes a duplicate of the current material.
  54093. * @param name - name to use for the new material.
  54094. */
  54095. clone(name: string): PBRMaterial;
  54096. /**
  54097. * Serializes this PBR Material.
  54098. * @returns - An object with the serialized material.
  54099. */
  54100. serialize(): any;
  54101. /**
  54102. * Parses a PBR Material from a serialized object.
  54103. * @param source - Serialized object.
  54104. * @param scene - BJS scene instance.
  54105. * @param rootUrl - url for the scene object
  54106. * @returns - PBRMaterial
  54107. */
  54108. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54109. }
  54110. }
  54111. declare module "babylonjs/Misc/dds" {
  54112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54114. import { Nullable } from "babylonjs/types";
  54115. import { Scene } from "babylonjs/scene";
  54116. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54117. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54118. /**
  54119. * Direct draw surface info
  54120. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54121. */
  54122. export interface DDSInfo {
  54123. /**
  54124. * Width of the texture
  54125. */
  54126. width: number;
  54127. /**
  54128. * Width of the texture
  54129. */
  54130. height: number;
  54131. /**
  54132. * Number of Mipmaps for the texture
  54133. * @see https://en.wikipedia.org/wiki/Mipmap
  54134. */
  54135. mipmapCount: number;
  54136. /**
  54137. * If the textures format is a known fourCC format
  54138. * @see https://www.fourcc.org/
  54139. */
  54140. isFourCC: boolean;
  54141. /**
  54142. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54143. */
  54144. isRGB: boolean;
  54145. /**
  54146. * If the texture is a lumincance format
  54147. */
  54148. isLuminance: boolean;
  54149. /**
  54150. * If this is a cube texture
  54151. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54152. */
  54153. isCube: boolean;
  54154. /**
  54155. * If the texture is a compressed format eg. FOURCC_DXT1
  54156. */
  54157. isCompressed: boolean;
  54158. /**
  54159. * The dxgiFormat of the texture
  54160. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54161. */
  54162. dxgiFormat: number;
  54163. /**
  54164. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54165. */
  54166. textureType: number;
  54167. /**
  54168. * Sphericle polynomial created for the dds texture
  54169. */
  54170. sphericalPolynomial?: SphericalPolynomial;
  54171. }
  54172. /**
  54173. * Class used to provide DDS decompression tools
  54174. */
  54175. export class DDSTools {
  54176. /**
  54177. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54178. */
  54179. static StoreLODInAlphaChannel: boolean;
  54180. /**
  54181. * Gets DDS information from an array buffer
  54182. * @param data defines the array buffer view to read data from
  54183. * @returns the DDS information
  54184. */
  54185. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54186. private static _FloatView;
  54187. private static _Int32View;
  54188. private static _ToHalfFloat;
  54189. private static _FromHalfFloat;
  54190. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54191. private static _GetHalfFloatRGBAArrayBuffer;
  54192. private static _GetFloatRGBAArrayBuffer;
  54193. private static _GetFloatAsUIntRGBAArrayBuffer;
  54194. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54195. private static _GetRGBAArrayBuffer;
  54196. private static _ExtractLongWordOrder;
  54197. private static _GetRGBArrayBuffer;
  54198. private static _GetLuminanceArrayBuffer;
  54199. /**
  54200. * Uploads DDS Levels to a Babylon Texture
  54201. * @hidden
  54202. */
  54203. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54204. }
  54205. module "babylonjs/Engines/thinEngine" {
  54206. interface ThinEngine {
  54207. /**
  54208. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54209. * @param rootUrl defines the url where the file to load is located
  54210. * @param scene defines the current scene
  54211. * @param lodScale defines scale to apply to the mip map selection
  54212. * @param lodOffset defines offset to apply to the mip map selection
  54213. * @param onLoad defines an optional callback raised when the texture is loaded
  54214. * @param onError defines an optional callback raised if there is an issue to load the texture
  54215. * @param format defines the format of the data
  54216. * @param forcedExtension defines the extension to use to pick the right loader
  54217. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54218. * @returns the cube texture as an InternalTexture
  54219. */
  54220. 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;
  54221. }
  54222. }
  54223. }
  54224. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54225. import { Nullable } from "babylonjs/types";
  54226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54227. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54228. /**
  54229. * Implementation of the DDS Texture Loader.
  54230. * @hidden
  54231. */
  54232. export class _DDSTextureLoader implements IInternalTextureLoader {
  54233. /**
  54234. * Defines wether the loader supports cascade loading the different faces.
  54235. */
  54236. readonly supportCascades: boolean;
  54237. /**
  54238. * This returns if the loader support the current file information.
  54239. * @param extension defines the file extension of the file being loaded
  54240. * @returns true if the loader can load the specified file
  54241. */
  54242. canLoad(extension: string): boolean;
  54243. /**
  54244. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54245. * @param data contains the texture data
  54246. * @param texture defines the BabylonJS internal texture
  54247. * @param createPolynomials will be true if polynomials have been requested
  54248. * @param onLoad defines the callback to trigger once the texture is ready
  54249. * @param onError defines the callback to trigger in case of error
  54250. */
  54251. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54252. /**
  54253. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54254. * @param data contains the texture data
  54255. * @param texture defines the BabylonJS internal texture
  54256. * @param callback defines the method to call once ready to upload
  54257. */
  54258. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54262. import { Nullable } from "babylonjs/types";
  54263. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54264. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54265. /**
  54266. * Implementation of the ENV Texture Loader.
  54267. * @hidden
  54268. */
  54269. export class _ENVTextureLoader implements IInternalTextureLoader {
  54270. /**
  54271. * Defines wether the loader supports cascade loading the different faces.
  54272. */
  54273. readonly supportCascades: boolean;
  54274. /**
  54275. * This returns if the loader support the current file information.
  54276. * @param extension defines the file extension of the file being loaded
  54277. * @returns true if the loader can load the specified file
  54278. */
  54279. canLoad(extension: string): boolean;
  54280. /**
  54281. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54282. * @param data contains the texture data
  54283. * @param texture defines the BabylonJS internal texture
  54284. * @param createPolynomials will be true if polynomials have been requested
  54285. * @param onLoad defines the callback to trigger once the texture is ready
  54286. * @param onError defines the callback to trigger in case of error
  54287. */
  54288. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54289. /**
  54290. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54291. * @param data contains the texture data
  54292. * @param texture defines the BabylonJS internal texture
  54293. * @param callback defines the method to call once ready to upload
  54294. */
  54295. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54296. }
  54297. }
  54298. declare module "babylonjs/Misc/khronosTextureContainer" {
  54299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54300. /**
  54301. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54302. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54303. */
  54304. export class KhronosTextureContainer {
  54305. /** contents of the KTX container file */
  54306. data: ArrayBufferView;
  54307. private static HEADER_LEN;
  54308. private static COMPRESSED_2D;
  54309. private static COMPRESSED_3D;
  54310. private static TEX_2D;
  54311. private static TEX_3D;
  54312. /**
  54313. * Gets the openGL type
  54314. */
  54315. glType: number;
  54316. /**
  54317. * Gets the openGL type size
  54318. */
  54319. glTypeSize: number;
  54320. /**
  54321. * Gets the openGL format
  54322. */
  54323. glFormat: number;
  54324. /**
  54325. * Gets the openGL internal format
  54326. */
  54327. glInternalFormat: number;
  54328. /**
  54329. * Gets the base internal format
  54330. */
  54331. glBaseInternalFormat: number;
  54332. /**
  54333. * Gets image width in pixel
  54334. */
  54335. pixelWidth: number;
  54336. /**
  54337. * Gets image height in pixel
  54338. */
  54339. pixelHeight: number;
  54340. /**
  54341. * Gets image depth in pixels
  54342. */
  54343. pixelDepth: number;
  54344. /**
  54345. * Gets the number of array elements
  54346. */
  54347. numberOfArrayElements: number;
  54348. /**
  54349. * Gets the number of faces
  54350. */
  54351. numberOfFaces: number;
  54352. /**
  54353. * Gets the number of mipmap levels
  54354. */
  54355. numberOfMipmapLevels: number;
  54356. /**
  54357. * Gets the bytes of key value data
  54358. */
  54359. bytesOfKeyValueData: number;
  54360. /**
  54361. * Gets the load type
  54362. */
  54363. loadType: number;
  54364. /**
  54365. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54366. */
  54367. isInvalid: boolean;
  54368. /**
  54369. * Creates a new KhronosTextureContainer
  54370. * @param data contents of the KTX container file
  54371. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54372. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54373. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54374. */
  54375. constructor(
  54376. /** contents of the KTX container file */
  54377. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54378. /**
  54379. * Uploads KTX content to a Babylon Texture.
  54380. * It is assumed that the texture has already been created & is currently bound
  54381. * @hidden
  54382. */
  54383. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54384. private _upload2DCompressedLevels;
  54385. /**
  54386. * Checks if the given data starts with a KTX file identifier.
  54387. * @param data the data to check
  54388. * @returns true if the data is a KTX file or false otherwise
  54389. */
  54390. static IsValid(data: ArrayBufferView): boolean;
  54391. }
  54392. }
  54393. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54395. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54396. /**
  54397. * Class for loading KTX2 files
  54398. * !!! Experimental Extension Subject to Changes !!!
  54399. * @hidden
  54400. */
  54401. export class KhronosTextureContainer2 {
  54402. private static _ModulePromise;
  54403. private static _TranscodeFormat;
  54404. constructor(engine: ThinEngine);
  54405. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54406. private _determineTranscodeFormat;
  54407. /**
  54408. * Checks if the given data starts with a KTX2 file identifier.
  54409. * @param data the data to check
  54410. * @returns true if the data is a KTX2 file or false otherwise
  54411. */
  54412. static IsValid(data: ArrayBufferView): boolean;
  54413. }
  54414. }
  54415. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54416. import { Nullable } from "babylonjs/types";
  54417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54418. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54419. /**
  54420. * Implementation of the KTX Texture Loader.
  54421. * @hidden
  54422. */
  54423. export class _KTXTextureLoader implements IInternalTextureLoader {
  54424. /**
  54425. * Defines wether the loader supports cascade loading the different faces.
  54426. */
  54427. readonly supportCascades: boolean;
  54428. /**
  54429. * This returns if the loader support the current file information.
  54430. * @param extension defines the file extension of the file being loaded
  54431. * @returns true if the loader can load the specified file
  54432. */
  54433. canLoad(extension: string): boolean;
  54434. /**
  54435. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54436. * @param data contains the texture data
  54437. * @param texture defines the BabylonJS internal texture
  54438. * @param createPolynomials will be true if polynomials have been requested
  54439. * @param onLoad defines the callback to trigger once the texture is ready
  54440. * @param onError defines the callback to trigger in case of error
  54441. */
  54442. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54443. /**
  54444. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54445. * @param data contains the texture data
  54446. * @param texture defines the BabylonJS internal texture
  54447. * @param callback defines the method to call once ready to upload
  54448. */
  54449. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54450. }
  54451. }
  54452. declare module "babylonjs/Helpers/sceneHelpers" {
  54453. import { Nullable } from "babylonjs/types";
  54454. import { Mesh } from "babylonjs/Meshes/mesh";
  54455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54456. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54457. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54458. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54459. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54460. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54461. import "babylonjs/Meshes/Builders/boxBuilder";
  54462. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54463. /** @hidden */
  54464. export var _forceSceneHelpersToBundle: boolean;
  54465. module "babylonjs/scene" {
  54466. interface Scene {
  54467. /**
  54468. * Creates a default light for the scene.
  54469. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54470. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54471. */
  54472. createDefaultLight(replace?: boolean): void;
  54473. /**
  54474. * Creates a default camera for the scene.
  54475. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54476. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54477. * @param replace has default false, when true replaces the active camera in the scene
  54478. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54479. */
  54480. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54481. /**
  54482. * Creates a default camera and a default light.
  54483. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54484. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54485. * @param replace has the default false, when true replaces the active camera/light in the scene
  54486. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54487. */
  54488. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54489. /**
  54490. * Creates a new sky box
  54491. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54492. * @param environmentTexture defines the texture to use as environment texture
  54493. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54494. * @param scale defines the overall scale of the skybox
  54495. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54496. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54497. * @returns a new mesh holding the sky box
  54498. */
  54499. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54500. /**
  54501. * Creates a new environment
  54502. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54503. * @param options defines the options you can use to configure the environment
  54504. * @returns the new EnvironmentHelper
  54505. */
  54506. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54507. /**
  54508. * Creates a new VREXperienceHelper
  54509. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54510. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54511. * @returns a new VREXperienceHelper
  54512. */
  54513. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54514. /**
  54515. * Creates a new WebXRDefaultExperience
  54516. * @see http://doc.babylonjs.com/how_to/webxr
  54517. * @param options experience options
  54518. * @returns a promise for a new WebXRDefaultExperience
  54519. */
  54520. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54521. }
  54522. }
  54523. }
  54524. declare module "babylonjs/Helpers/videoDome" {
  54525. import { Scene } from "babylonjs/scene";
  54526. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54527. import { Mesh } from "babylonjs/Meshes/mesh";
  54528. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54529. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54530. import "babylonjs/Meshes/Builders/sphereBuilder";
  54531. /**
  54532. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54533. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54534. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54535. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54536. */
  54537. export class VideoDome extends TransformNode {
  54538. /**
  54539. * Define the video source as a Monoscopic panoramic 360 video.
  54540. */
  54541. static readonly MODE_MONOSCOPIC: number;
  54542. /**
  54543. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54544. */
  54545. static readonly MODE_TOPBOTTOM: number;
  54546. /**
  54547. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54548. */
  54549. static readonly MODE_SIDEBYSIDE: number;
  54550. private _halfDome;
  54551. private _useDirectMapping;
  54552. /**
  54553. * The video texture being displayed on the sphere
  54554. */
  54555. protected _videoTexture: VideoTexture;
  54556. /**
  54557. * Gets the video texture being displayed on the sphere
  54558. */
  54559. get videoTexture(): VideoTexture;
  54560. /**
  54561. * The skybox material
  54562. */
  54563. protected _material: BackgroundMaterial;
  54564. /**
  54565. * The surface used for the skybox
  54566. */
  54567. protected _mesh: Mesh;
  54568. /**
  54569. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54570. */
  54571. private _halfDomeMask;
  54572. /**
  54573. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54574. * Also see the options.resolution property.
  54575. */
  54576. get fovMultiplier(): number;
  54577. set fovMultiplier(value: number);
  54578. private _videoMode;
  54579. /**
  54580. * Gets or set the current video mode for the video. It can be:
  54581. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54582. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54583. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54584. */
  54585. get videoMode(): number;
  54586. set videoMode(value: number);
  54587. /**
  54588. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54589. *
  54590. */
  54591. get halfDome(): boolean;
  54592. /**
  54593. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54594. */
  54595. set halfDome(enabled: boolean);
  54596. /**
  54597. * Oberserver used in Stereoscopic VR Mode.
  54598. */
  54599. private _onBeforeCameraRenderObserver;
  54600. /**
  54601. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54602. * @param name Element's name, child elements will append suffixes for their own names.
  54603. * @param urlsOrVideo defines the url(s) or the video element to use
  54604. * @param options An object containing optional or exposed sub element properties
  54605. */
  54606. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54607. resolution?: number;
  54608. clickToPlay?: boolean;
  54609. autoPlay?: boolean;
  54610. loop?: boolean;
  54611. size?: number;
  54612. poster?: string;
  54613. faceForward?: boolean;
  54614. useDirectMapping?: boolean;
  54615. halfDomeMode?: boolean;
  54616. }, scene: Scene);
  54617. private _changeVideoMode;
  54618. /**
  54619. * Releases resources associated with this node.
  54620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54622. */
  54623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54624. }
  54625. }
  54626. declare module "babylonjs/Helpers/index" {
  54627. export * from "babylonjs/Helpers/environmentHelper";
  54628. export * from "babylonjs/Helpers/photoDome";
  54629. export * from "babylonjs/Helpers/sceneHelpers";
  54630. export * from "babylonjs/Helpers/videoDome";
  54631. }
  54632. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54633. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54634. import { IDisposable } from "babylonjs/scene";
  54635. import { Engine } from "babylonjs/Engines/engine";
  54636. /**
  54637. * This class can be used to get instrumentation data from a Babylon engine
  54638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54639. */
  54640. export class EngineInstrumentation implements IDisposable {
  54641. /**
  54642. * Define the instrumented engine.
  54643. */
  54644. engine: Engine;
  54645. private _captureGPUFrameTime;
  54646. private _gpuFrameTimeToken;
  54647. private _gpuFrameTime;
  54648. private _captureShaderCompilationTime;
  54649. private _shaderCompilationTime;
  54650. private _onBeginFrameObserver;
  54651. private _onEndFrameObserver;
  54652. private _onBeforeShaderCompilationObserver;
  54653. private _onAfterShaderCompilationObserver;
  54654. /**
  54655. * Gets the perf counter used for GPU frame time
  54656. */
  54657. get gpuFrameTimeCounter(): PerfCounter;
  54658. /**
  54659. * Gets the GPU frame time capture status
  54660. */
  54661. get captureGPUFrameTime(): boolean;
  54662. /**
  54663. * Enable or disable the GPU frame time capture
  54664. */
  54665. set captureGPUFrameTime(value: boolean);
  54666. /**
  54667. * Gets the perf counter used for shader compilation time
  54668. */
  54669. get shaderCompilationTimeCounter(): PerfCounter;
  54670. /**
  54671. * Gets the shader compilation time capture status
  54672. */
  54673. get captureShaderCompilationTime(): boolean;
  54674. /**
  54675. * Enable or disable the shader compilation time capture
  54676. */
  54677. set captureShaderCompilationTime(value: boolean);
  54678. /**
  54679. * Instantiates a new engine instrumentation.
  54680. * This class can be used to get instrumentation data from a Babylon engine
  54681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54682. * @param engine Defines the engine to instrument
  54683. */
  54684. constructor(
  54685. /**
  54686. * Define the instrumented engine.
  54687. */
  54688. engine: Engine);
  54689. /**
  54690. * Dispose and release associated resources.
  54691. */
  54692. dispose(): void;
  54693. }
  54694. }
  54695. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54696. import { Scene, IDisposable } from "babylonjs/scene";
  54697. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54698. /**
  54699. * This class can be used to get instrumentation data from a Babylon engine
  54700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54701. */
  54702. export class SceneInstrumentation implements IDisposable {
  54703. /**
  54704. * Defines the scene to instrument
  54705. */
  54706. scene: Scene;
  54707. private _captureActiveMeshesEvaluationTime;
  54708. private _activeMeshesEvaluationTime;
  54709. private _captureRenderTargetsRenderTime;
  54710. private _renderTargetsRenderTime;
  54711. private _captureFrameTime;
  54712. private _frameTime;
  54713. private _captureRenderTime;
  54714. private _renderTime;
  54715. private _captureInterFrameTime;
  54716. private _interFrameTime;
  54717. private _captureParticlesRenderTime;
  54718. private _particlesRenderTime;
  54719. private _captureSpritesRenderTime;
  54720. private _spritesRenderTime;
  54721. private _capturePhysicsTime;
  54722. private _physicsTime;
  54723. private _captureAnimationsTime;
  54724. private _animationsTime;
  54725. private _captureCameraRenderTime;
  54726. private _cameraRenderTime;
  54727. private _onBeforeActiveMeshesEvaluationObserver;
  54728. private _onAfterActiveMeshesEvaluationObserver;
  54729. private _onBeforeRenderTargetsRenderObserver;
  54730. private _onAfterRenderTargetsRenderObserver;
  54731. private _onAfterRenderObserver;
  54732. private _onBeforeDrawPhaseObserver;
  54733. private _onAfterDrawPhaseObserver;
  54734. private _onBeforeAnimationsObserver;
  54735. private _onBeforeParticlesRenderingObserver;
  54736. private _onAfterParticlesRenderingObserver;
  54737. private _onBeforeSpritesRenderingObserver;
  54738. private _onAfterSpritesRenderingObserver;
  54739. private _onBeforePhysicsObserver;
  54740. private _onAfterPhysicsObserver;
  54741. private _onAfterAnimationsObserver;
  54742. private _onBeforeCameraRenderObserver;
  54743. private _onAfterCameraRenderObserver;
  54744. /**
  54745. * Gets the perf counter used for active meshes evaluation time
  54746. */
  54747. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54748. /**
  54749. * Gets the active meshes evaluation time capture status
  54750. */
  54751. get captureActiveMeshesEvaluationTime(): boolean;
  54752. /**
  54753. * Enable or disable the active meshes evaluation time capture
  54754. */
  54755. set captureActiveMeshesEvaluationTime(value: boolean);
  54756. /**
  54757. * Gets the perf counter used for render targets render time
  54758. */
  54759. get renderTargetsRenderTimeCounter(): PerfCounter;
  54760. /**
  54761. * Gets the render targets render time capture status
  54762. */
  54763. get captureRenderTargetsRenderTime(): boolean;
  54764. /**
  54765. * Enable or disable the render targets render time capture
  54766. */
  54767. set captureRenderTargetsRenderTime(value: boolean);
  54768. /**
  54769. * Gets the perf counter used for particles render time
  54770. */
  54771. get particlesRenderTimeCounter(): PerfCounter;
  54772. /**
  54773. * Gets the particles render time capture status
  54774. */
  54775. get captureParticlesRenderTime(): boolean;
  54776. /**
  54777. * Enable or disable the particles render time capture
  54778. */
  54779. set captureParticlesRenderTime(value: boolean);
  54780. /**
  54781. * Gets the perf counter used for sprites render time
  54782. */
  54783. get spritesRenderTimeCounter(): PerfCounter;
  54784. /**
  54785. * Gets the sprites render time capture status
  54786. */
  54787. get captureSpritesRenderTime(): boolean;
  54788. /**
  54789. * Enable or disable the sprites render time capture
  54790. */
  54791. set captureSpritesRenderTime(value: boolean);
  54792. /**
  54793. * Gets the perf counter used for physics time
  54794. */
  54795. get physicsTimeCounter(): PerfCounter;
  54796. /**
  54797. * Gets the physics time capture status
  54798. */
  54799. get capturePhysicsTime(): boolean;
  54800. /**
  54801. * Enable or disable the physics time capture
  54802. */
  54803. set capturePhysicsTime(value: boolean);
  54804. /**
  54805. * Gets the perf counter used for animations time
  54806. */
  54807. get animationsTimeCounter(): PerfCounter;
  54808. /**
  54809. * Gets the animations time capture status
  54810. */
  54811. get captureAnimationsTime(): boolean;
  54812. /**
  54813. * Enable or disable the animations time capture
  54814. */
  54815. set captureAnimationsTime(value: boolean);
  54816. /**
  54817. * Gets the perf counter used for frame time capture
  54818. */
  54819. get frameTimeCounter(): PerfCounter;
  54820. /**
  54821. * Gets the frame time capture status
  54822. */
  54823. get captureFrameTime(): boolean;
  54824. /**
  54825. * Enable or disable the frame time capture
  54826. */
  54827. set captureFrameTime(value: boolean);
  54828. /**
  54829. * Gets the perf counter used for inter-frames time capture
  54830. */
  54831. get interFrameTimeCounter(): PerfCounter;
  54832. /**
  54833. * Gets the inter-frames time capture status
  54834. */
  54835. get captureInterFrameTime(): boolean;
  54836. /**
  54837. * Enable or disable the inter-frames time capture
  54838. */
  54839. set captureInterFrameTime(value: boolean);
  54840. /**
  54841. * Gets the perf counter used for render time capture
  54842. */
  54843. get renderTimeCounter(): PerfCounter;
  54844. /**
  54845. * Gets the render time capture status
  54846. */
  54847. get captureRenderTime(): boolean;
  54848. /**
  54849. * Enable or disable the render time capture
  54850. */
  54851. set captureRenderTime(value: boolean);
  54852. /**
  54853. * Gets the perf counter used for camera render time capture
  54854. */
  54855. get cameraRenderTimeCounter(): PerfCounter;
  54856. /**
  54857. * Gets the camera render time capture status
  54858. */
  54859. get captureCameraRenderTime(): boolean;
  54860. /**
  54861. * Enable or disable the camera render time capture
  54862. */
  54863. set captureCameraRenderTime(value: boolean);
  54864. /**
  54865. * Gets the perf counter used for draw calls
  54866. */
  54867. get drawCallsCounter(): PerfCounter;
  54868. /**
  54869. * Instantiates a new scene instrumentation.
  54870. * This class can be used to get instrumentation data from a Babylon engine
  54871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54872. * @param scene Defines the scene to instrument
  54873. */
  54874. constructor(
  54875. /**
  54876. * Defines the scene to instrument
  54877. */
  54878. scene: Scene);
  54879. /**
  54880. * Dispose and release associated resources.
  54881. */
  54882. dispose(): void;
  54883. }
  54884. }
  54885. declare module "babylonjs/Instrumentation/index" {
  54886. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54887. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54888. export * from "babylonjs/Instrumentation/timeToken";
  54889. }
  54890. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54891. /** @hidden */
  54892. export var glowMapGenerationPixelShader: {
  54893. name: string;
  54894. shader: string;
  54895. };
  54896. }
  54897. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54898. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54900. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54901. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54903. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54904. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54905. /** @hidden */
  54906. export var glowMapGenerationVertexShader: {
  54907. name: string;
  54908. shader: string;
  54909. };
  54910. }
  54911. declare module "babylonjs/Layers/effectLayer" {
  54912. import { Observable } from "babylonjs/Misc/observable";
  54913. import { Nullable } from "babylonjs/types";
  54914. import { Camera } from "babylonjs/Cameras/camera";
  54915. import { Scene } from "babylonjs/scene";
  54916. import { ISize } from "babylonjs/Maths/math.size";
  54917. import { Color4 } from "babylonjs/Maths/math.color";
  54918. import { Engine } from "babylonjs/Engines/engine";
  54919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54921. import { Mesh } from "babylonjs/Meshes/mesh";
  54922. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54925. import { Effect } from "babylonjs/Materials/effect";
  54926. import { Material } from "babylonjs/Materials/material";
  54927. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54928. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54929. /**
  54930. * Effect layer options. This helps customizing the behaviour
  54931. * of the effect layer.
  54932. */
  54933. export interface IEffectLayerOptions {
  54934. /**
  54935. * Multiplication factor apply to the canvas size to compute the render target size
  54936. * used to generated the objects (the smaller the faster).
  54937. */
  54938. mainTextureRatio: number;
  54939. /**
  54940. * Enforces a fixed size texture to ensure effect stability across devices.
  54941. */
  54942. mainTextureFixedSize?: number;
  54943. /**
  54944. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54945. */
  54946. alphaBlendingMode: number;
  54947. /**
  54948. * The camera attached to the layer.
  54949. */
  54950. camera: Nullable<Camera>;
  54951. /**
  54952. * The rendering group to draw the layer in.
  54953. */
  54954. renderingGroupId: number;
  54955. }
  54956. /**
  54957. * The effect layer Helps adding post process effect blended with the main pass.
  54958. *
  54959. * This can be for instance use to generate glow or higlight effects on the scene.
  54960. *
  54961. * The effect layer class can not be used directly and is intented to inherited from to be
  54962. * customized per effects.
  54963. */
  54964. export abstract class EffectLayer {
  54965. private _vertexBuffers;
  54966. private _indexBuffer;
  54967. private _cachedDefines;
  54968. private _effectLayerMapGenerationEffect;
  54969. private _effectLayerOptions;
  54970. private _mergeEffect;
  54971. protected _scene: Scene;
  54972. protected _engine: Engine;
  54973. protected _maxSize: number;
  54974. protected _mainTextureDesiredSize: ISize;
  54975. protected _mainTexture: RenderTargetTexture;
  54976. protected _shouldRender: boolean;
  54977. protected _postProcesses: PostProcess[];
  54978. protected _textures: BaseTexture[];
  54979. protected _emissiveTextureAndColor: {
  54980. texture: Nullable<BaseTexture>;
  54981. color: Color4;
  54982. };
  54983. /**
  54984. * The name of the layer
  54985. */
  54986. name: string;
  54987. /**
  54988. * The clear color of the texture used to generate the glow map.
  54989. */
  54990. neutralColor: Color4;
  54991. /**
  54992. * Specifies whether the highlight layer is enabled or not.
  54993. */
  54994. isEnabled: boolean;
  54995. /**
  54996. * Gets the camera attached to the layer.
  54997. */
  54998. get camera(): Nullable<Camera>;
  54999. /**
  55000. * Gets the rendering group id the layer should render in.
  55001. */
  55002. get renderingGroupId(): number;
  55003. set renderingGroupId(renderingGroupId: number);
  55004. /**
  55005. * An event triggered when the effect layer has been disposed.
  55006. */
  55007. onDisposeObservable: Observable<EffectLayer>;
  55008. /**
  55009. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55010. */
  55011. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55012. /**
  55013. * An event triggered when the generated texture is being merged in the scene.
  55014. */
  55015. onBeforeComposeObservable: Observable<EffectLayer>;
  55016. /**
  55017. * An event triggered when the mesh is rendered into the effect render target.
  55018. */
  55019. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55020. /**
  55021. * An event triggered after the mesh has been rendered into the effect render target.
  55022. */
  55023. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55024. /**
  55025. * An event triggered when the generated texture has been merged in the scene.
  55026. */
  55027. onAfterComposeObservable: Observable<EffectLayer>;
  55028. /**
  55029. * An event triggered when the efffect layer changes its size.
  55030. */
  55031. onSizeChangedObservable: Observable<EffectLayer>;
  55032. /** @hidden */
  55033. static _SceneComponentInitialization: (scene: Scene) => void;
  55034. /**
  55035. * Instantiates a new effect Layer and references it in the scene.
  55036. * @param name The name of the layer
  55037. * @param scene The scene to use the layer in
  55038. */
  55039. constructor(
  55040. /** The Friendly of the effect in the scene */
  55041. name: string, scene: Scene);
  55042. /**
  55043. * Get the effect name of the layer.
  55044. * @return The effect name
  55045. */
  55046. abstract getEffectName(): string;
  55047. /**
  55048. * Checks for the readiness of the element composing the layer.
  55049. * @param subMesh the mesh to check for
  55050. * @param useInstances specify whether or not to use instances to render the mesh
  55051. * @return true if ready otherwise, false
  55052. */
  55053. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55054. /**
  55055. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55056. * @returns true if the effect requires stencil during the main canvas render pass.
  55057. */
  55058. abstract needStencil(): boolean;
  55059. /**
  55060. * Create the merge effect. This is the shader use to blit the information back
  55061. * to the main canvas at the end of the scene rendering.
  55062. * @returns The effect containing the shader used to merge the effect on the main canvas
  55063. */
  55064. protected abstract _createMergeEffect(): Effect;
  55065. /**
  55066. * Creates the render target textures and post processes used in the effect layer.
  55067. */
  55068. protected abstract _createTextureAndPostProcesses(): void;
  55069. /**
  55070. * Implementation specific of rendering the generating effect on the main canvas.
  55071. * @param effect The effect used to render through
  55072. */
  55073. protected abstract _internalRender(effect: Effect): void;
  55074. /**
  55075. * Sets the required values for both the emissive texture and and the main color.
  55076. */
  55077. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55078. /**
  55079. * Free any resources and references associated to a mesh.
  55080. * Internal use
  55081. * @param mesh The mesh to free.
  55082. */
  55083. abstract _disposeMesh(mesh: Mesh): void;
  55084. /**
  55085. * Serializes this layer (Glow or Highlight for example)
  55086. * @returns a serialized layer object
  55087. */
  55088. abstract serialize?(): any;
  55089. /**
  55090. * Initializes the effect layer with the required options.
  55091. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55092. */
  55093. protected _init(options: Partial<IEffectLayerOptions>): void;
  55094. /**
  55095. * Generates the index buffer of the full screen quad blending to the main canvas.
  55096. */
  55097. private _generateIndexBuffer;
  55098. /**
  55099. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55100. */
  55101. private _generateVertexBuffer;
  55102. /**
  55103. * Sets the main texture desired size which is the closest power of two
  55104. * of the engine canvas size.
  55105. */
  55106. private _setMainTextureSize;
  55107. /**
  55108. * Creates the main texture for the effect layer.
  55109. */
  55110. protected _createMainTexture(): void;
  55111. /**
  55112. * Adds specific effects defines.
  55113. * @param defines The defines to add specifics to.
  55114. */
  55115. protected _addCustomEffectDefines(defines: string[]): void;
  55116. /**
  55117. * Checks for the readiness of the element composing the layer.
  55118. * @param subMesh the mesh to check for
  55119. * @param useInstances specify whether or not to use instances to render the mesh
  55120. * @param emissiveTexture the associated emissive texture used to generate the glow
  55121. * @return true if ready otherwise, false
  55122. */
  55123. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55124. /**
  55125. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55126. */
  55127. render(): void;
  55128. /**
  55129. * Determine if a given mesh will be used in the current effect.
  55130. * @param mesh mesh to test
  55131. * @returns true if the mesh will be used
  55132. */
  55133. hasMesh(mesh: AbstractMesh): boolean;
  55134. /**
  55135. * Returns true if the layer contains information to display, otherwise false.
  55136. * @returns true if the glow layer should be rendered
  55137. */
  55138. shouldRender(): boolean;
  55139. /**
  55140. * Returns true if the mesh should render, otherwise false.
  55141. * @param mesh The mesh to render
  55142. * @returns true if it should render otherwise false
  55143. */
  55144. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55145. /**
  55146. * Returns true if the mesh can be rendered, otherwise false.
  55147. * @param mesh The mesh to render
  55148. * @param material The material used on the mesh
  55149. * @returns true if it can be rendered otherwise false
  55150. */
  55151. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55152. /**
  55153. * Returns true if the mesh should render, otherwise false.
  55154. * @param mesh The mesh to render
  55155. * @returns true if it should render otherwise false
  55156. */
  55157. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55158. /**
  55159. * Renders the submesh passed in parameter to the generation map.
  55160. */
  55161. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55162. /**
  55163. * Defines whether the current material of the mesh should be use to render the effect.
  55164. * @param mesh defines the current mesh to render
  55165. */
  55166. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55167. /**
  55168. * Rebuild the required buffers.
  55169. * @hidden Internal use only.
  55170. */
  55171. _rebuild(): void;
  55172. /**
  55173. * Dispose only the render target textures and post process.
  55174. */
  55175. private _disposeTextureAndPostProcesses;
  55176. /**
  55177. * Dispose the highlight layer and free resources.
  55178. */
  55179. dispose(): void;
  55180. /**
  55181. * Gets the class name of the effect layer
  55182. * @returns the string with the class name of the effect layer
  55183. */
  55184. getClassName(): string;
  55185. /**
  55186. * Creates an effect layer from parsed effect layer data
  55187. * @param parsedEffectLayer defines effect layer data
  55188. * @param scene defines the current scene
  55189. * @param rootUrl defines the root URL containing the effect layer information
  55190. * @returns a parsed effect Layer
  55191. */
  55192. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55193. }
  55194. }
  55195. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55196. import { Scene } from "babylonjs/scene";
  55197. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55198. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55199. import { AbstractScene } from "babylonjs/abstractScene";
  55200. module "babylonjs/abstractScene" {
  55201. interface AbstractScene {
  55202. /**
  55203. * The list of effect layers (highlights/glow) added to the scene
  55204. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55205. * @see http://doc.babylonjs.com/how_to/glow_layer
  55206. */
  55207. effectLayers: Array<EffectLayer>;
  55208. /**
  55209. * Removes the given effect layer from this scene.
  55210. * @param toRemove defines the effect layer to remove
  55211. * @returns the index of the removed effect layer
  55212. */
  55213. removeEffectLayer(toRemove: EffectLayer): number;
  55214. /**
  55215. * Adds the given effect layer to this scene
  55216. * @param newEffectLayer defines the effect layer to add
  55217. */
  55218. addEffectLayer(newEffectLayer: EffectLayer): void;
  55219. }
  55220. }
  55221. /**
  55222. * Defines the layer scene component responsible to manage any effect layers
  55223. * in a given scene.
  55224. */
  55225. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55226. /**
  55227. * The component name helpfull to identify the component in the list of scene components.
  55228. */
  55229. readonly name: string;
  55230. /**
  55231. * The scene the component belongs to.
  55232. */
  55233. scene: Scene;
  55234. private _engine;
  55235. private _renderEffects;
  55236. private _needStencil;
  55237. private _previousStencilState;
  55238. /**
  55239. * Creates a new instance of the component for the given scene
  55240. * @param scene Defines the scene to register the component in
  55241. */
  55242. constructor(scene: Scene);
  55243. /**
  55244. * Registers the component in a given scene
  55245. */
  55246. register(): void;
  55247. /**
  55248. * Rebuilds the elements related to this component in case of
  55249. * context lost for instance.
  55250. */
  55251. rebuild(): void;
  55252. /**
  55253. * Serializes the component data to the specified json object
  55254. * @param serializationObject The object to serialize to
  55255. */
  55256. serialize(serializationObject: any): void;
  55257. /**
  55258. * Adds all the elements from the container to the scene
  55259. * @param container the container holding the elements
  55260. */
  55261. addFromContainer(container: AbstractScene): void;
  55262. /**
  55263. * Removes all the elements in the container from the scene
  55264. * @param container contains the elements to remove
  55265. * @param dispose if the removed element should be disposed (default: false)
  55266. */
  55267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55268. /**
  55269. * Disposes the component and the associated ressources.
  55270. */
  55271. dispose(): void;
  55272. private _isReadyForMesh;
  55273. private _renderMainTexture;
  55274. private _setStencil;
  55275. private _setStencilBack;
  55276. private _draw;
  55277. private _drawCamera;
  55278. private _drawRenderingGroup;
  55279. }
  55280. }
  55281. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55282. /** @hidden */
  55283. export var glowMapMergePixelShader: {
  55284. name: string;
  55285. shader: string;
  55286. };
  55287. }
  55288. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55289. /** @hidden */
  55290. export var glowMapMergeVertexShader: {
  55291. name: string;
  55292. shader: string;
  55293. };
  55294. }
  55295. declare module "babylonjs/Layers/glowLayer" {
  55296. import { Nullable } from "babylonjs/types";
  55297. import { Camera } from "babylonjs/Cameras/camera";
  55298. import { Scene } from "babylonjs/scene";
  55299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55301. import { Mesh } from "babylonjs/Meshes/mesh";
  55302. import { Texture } from "babylonjs/Materials/Textures/texture";
  55303. import { Effect } from "babylonjs/Materials/effect";
  55304. import { Material } from "babylonjs/Materials/material";
  55305. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55306. import { Color4 } from "babylonjs/Maths/math.color";
  55307. import "babylonjs/Shaders/glowMapMerge.fragment";
  55308. import "babylonjs/Shaders/glowMapMerge.vertex";
  55309. import "babylonjs/Layers/effectLayerSceneComponent";
  55310. module "babylonjs/abstractScene" {
  55311. interface AbstractScene {
  55312. /**
  55313. * Return a the first highlight layer of the scene with a given name.
  55314. * @param name The name of the highlight layer to look for.
  55315. * @return The highlight layer if found otherwise null.
  55316. */
  55317. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55318. }
  55319. }
  55320. /**
  55321. * Glow layer options. This helps customizing the behaviour
  55322. * of the glow layer.
  55323. */
  55324. export interface IGlowLayerOptions {
  55325. /**
  55326. * Multiplication factor apply to the canvas size to compute the render target size
  55327. * used to generated the glowing objects (the smaller the faster).
  55328. */
  55329. mainTextureRatio: number;
  55330. /**
  55331. * Enforces a fixed size texture to ensure resize independant blur.
  55332. */
  55333. mainTextureFixedSize?: number;
  55334. /**
  55335. * How big is the kernel of the blur texture.
  55336. */
  55337. blurKernelSize: number;
  55338. /**
  55339. * The camera attached to the layer.
  55340. */
  55341. camera: Nullable<Camera>;
  55342. /**
  55343. * Enable MSAA by chosing the number of samples.
  55344. */
  55345. mainTextureSamples?: number;
  55346. /**
  55347. * The rendering group to draw the layer in.
  55348. */
  55349. renderingGroupId: number;
  55350. }
  55351. /**
  55352. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55353. *
  55354. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55355. *
  55356. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55357. */
  55358. export class GlowLayer extends EffectLayer {
  55359. /**
  55360. * Effect Name of the layer.
  55361. */
  55362. static readonly EffectName: string;
  55363. /**
  55364. * The default blur kernel size used for the glow.
  55365. */
  55366. static DefaultBlurKernelSize: number;
  55367. /**
  55368. * The default texture size ratio used for the glow.
  55369. */
  55370. static DefaultTextureRatio: number;
  55371. /**
  55372. * Sets the kernel size of the blur.
  55373. */
  55374. set blurKernelSize(value: number);
  55375. /**
  55376. * Gets the kernel size of the blur.
  55377. */
  55378. get blurKernelSize(): number;
  55379. /**
  55380. * Sets the glow intensity.
  55381. */
  55382. set intensity(value: number);
  55383. /**
  55384. * Gets the glow intensity.
  55385. */
  55386. get intensity(): number;
  55387. private _options;
  55388. private _intensity;
  55389. private _horizontalBlurPostprocess1;
  55390. private _verticalBlurPostprocess1;
  55391. private _horizontalBlurPostprocess2;
  55392. private _verticalBlurPostprocess2;
  55393. private _blurTexture1;
  55394. private _blurTexture2;
  55395. private _postProcesses1;
  55396. private _postProcesses2;
  55397. private _includedOnlyMeshes;
  55398. private _excludedMeshes;
  55399. private _meshesUsingTheirOwnMaterials;
  55400. /**
  55401. * Callback used to let the user override the color selection on a per mesh basis
  55402. */
  55403. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55404. /**
  55405. * Callback used to let the user override the texture selection on a per mesh basis
  55406. */
  55407. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55408. /**
  55409. * Instantiates a new glow Layer and references it to the scene.
  55410. * @param name The name of the layer
  55411. * @param scene The scene to use the layer in
  55412. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55413. */
  55414. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55415. /**
  55416. * Get the effect name of the layer.
  55417. * @return The effect name
  55418. */
  55419. getEffectName(): string;
  55420. /**
  55421. * Create the merge effect. This is the shader use to blit the information back
  55422. * to the main canvas at the end of the scene rendering.
  55423. */
  55424. protected _createMergeEffect(): Effect;
  55425. /**
  55426. * Creates the render target textures and post processes used in the glow layer.
  55427. */
  55428. protected _createTextureAndPostProcesses(): void;
  55429. /**
  55430. * Checks for the readiness of the element composing the layer.
  55431. * @param subMesh the mesh to check for
  55432. * @param useInstances specify wether or not to use instances to render the mesh
  55433. * @param emissiveTexture the associated emissive texture used to generate the glow
  55434. * @return true if ready otherwise, false
  55435. */
  55436. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55437. /**
  55438. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55439. */
  55440. needStencil(): boolean;
  55441. /**
  55442. * Returns true if the mesh can be rendered, otherwise false.
  55443. * @param mesh The mesh to render
  55444. * @param material The material used on the mesh
  55445. * @returns true if it can be rendered otherwise false
  55446. */
  55447. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55448. /**
  55449. * Implementation specific of rendering the generating effect on the main canvas.
  55450. * @param effect The effect used to render through
  55451. */
  55452. protected _internalRender(effect: Effect): void;
  55453. /**
  55454. * Sets the required values for both the emissive texture and and the main color.
  55455. */
  55456. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55457. /**
  55458. * Returns true if the mesh should render, otherwise false.
  55459. * @param mesh The mesh to render
  55460. * @returns true if it should render otherwise false
  55461. */
  55462. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55463. /**
  55464. * Adds specific effects defines.
  55465. * @param defines The defines to add specifics to.
  55466. */
  55467. protected _addCustomEffectDefines(defines: string[]): void;
  55468. /**
  55469. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55470. * @param mesh The mesh to exclude from the glow layer
  55471. */
  55472. addExcludedMesh(mesh: Mesh): void;
  55473. /**
  55474. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55475. * @param mesh The mesh to remove
  55476. */
  55477. removeExcludedMesh(mesh: Mesh): void;
  55478. /**
  55479. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55480. * @param mesh The mesh to include in the glow layer
  55481. */
  55482. addIncludedOnlyMesh(mesh: Mesh): void;
  55483. /**
  55484. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55485. * @param mesh The mesh to remove
  55486. */
  55487. removeIncludedOnlyMesh(mesh: Mesh): void;
  55488. /**
  55489. * Determine if a given mesh will be used in the glow layer
  55490. * @param mesh The mesh to test
  55491. * @returns true if the mesh will be highlighted by the current glow layer
  55492. */
  55493. hasMesh(mesh: AbstractMesh): boolean;
  55494. /**
  55495. * Defines whether the current material of the mesh should be use to render the effect.
  55496. * @param mesh defines the current mesh to render
  55497. */
  55498. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55499. /**
  55500. * Add a mesh to be rendered through its own material and not with emissive only.
  55501. * @param mesh The mesh for which we need to use its material
  55502. */
  55503. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55504. /**
  55505. * Remove a mesh from being rendered through its own material and not with emissive only.
  55506. * @param mesh The mesh for which we need to not use its material
  55507. */
  55508. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55509. /**
  55510. * Free any resources and references associated to a mesh.
  55511. * Internal use
  55512. * @param mesh The mesh to free.
  55513. * @hidden
  55514. */
  55515. _disposeMesh(mesh: Mesh): void;
  55516. /**
  55517. * Gets the class name of the effect layer
  55518. * @returns the string with the class name of the effect layer
  55519. */
  55520. getClassName(): string;
  55521. /**
  55522. * Serializes this glow layer
  55523. * @returns a serialized glow layer object
  55524. */
  55525. serialize(): any;
  55526. /**
  55527. * Creates a Glow Layer from parsed glow layer data
  55528. * @param parsedGlowLayer defines glow layer data
  55529. * @param scene defines the current scene
  55530. * @param rootUrl defines the root URL containing the glow layer information
  55531. * @returns a parsed Glow Layer
  55532. */
  55533. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55534. }
  55535. }
  55536. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55537. /** @hidden */
  55538. export var glowBlurPostProcessPixelShader: {
  55539. name: string;
  55540. shader: string;
  55541. };
  55542. }
  55543. declare module "babylonjs/Layers/highlightLayer" {
  55544. import { Observable } from "babylonjs/Misc/observable";
  55545. import { Nullable } from "babylonjs/types";
  55546. import { Camera } from "babylonjs/Cameras/camera";
  55547. import { Scene } from "babylonjs/scene";
  55548. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55550. import { Mesh } from "babylonjs/Meshes/mesh";
  55551. import { Effect } from "babylonjs/Materials/effect";
  55552. import { Material } from "babylonjs/Materials/material";
  55553. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55554. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55555. import "babylonjs/Shaders/glowMapMerge.fragment";
  55556. import "babylonjs/Shaders/glowMapMerge.vertex";
  55557. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55558. module "babylonjs/abstractScene" {
  55559. interface AbstractScene {
  55560. /**
  55561. * Return a the first highlight layer of the scene with a given name.
  55562. * @param name The name of the highlight layer to look for.
  55563. * @return The highlight layer if found otherwise null.
  55564. */
  55565. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55566. }
  55567. }
  55568. /**
  55569. * Highlight layer options. This helps customizing the behaviour
  55570. * of the highlight layer.
  55571. */
  55572. export interface IHighlightLayerOptions {
  55573. /**
  55574. * Multiplication factor apply to the canvas size to compute the render target size
  55575. * used to generated the glowing objects (the smaller the faster).
  55576. */
  55577. mainTextureRatio: number;
  55578. /**
  55579. * Enforces a fixed size texture to ensure resize independant blur.
  55580. */
  55581. mainTextureFixedSize?: number;
  55582. /**
  55583. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55584. * of the picture to blur (the smaller the faster).
  55585. */
  55586. blurTextureSizeRatio: number;
  55587. /**
  55588. * How big in texel of the blur texture is the vertical blur.
  55589. */
  55590. blurVerticalSize: number;
  55591. /**
  55592. * How big in texel of the blur texture is the horizontal blur.
  55593. */
  55594. blurHorizontalSize: number;
  55595. /**
  55596. * Alpha blending mode used to apply the blur. Default is combine.
  55597. */
  55598. alphaBlendingMode: number;
  55599. /**
  55600. * The camera attached to the layer.
  55601. */
  55602. camera: Nullable<Camera>;
  55603. /**
  55604. * Should we display highlight as a solid stroke?
  55605. */
  55606. isStroke?: boolean;
  55607. /**
  55608. * The rendering group to draw the layer in.
  55609. */
  55610. renderingGroupId: number;
  55611. }
  55612. /**
  55613. * The highlight layer Helps adding a glow effect around a mesh.
  55614. *
  55615. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55616. * glowy meshes to your scene.
  55617. *
  55618. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55619. */
  55620. export class HighlightLayer extends EffectLayer {
  55621. name: string;
  55622. /**
  55623. * Effect Name of the highlight layer.
  55624. */
  55625. static readonly EffectName: string;
  55626. /**
  55627. * The neutral color used during the preparation of the glow effect.
  55628. * This is black by default as the blend operation is a blend operation.
  55629. */
  55630. static NeutralColor: Color4;
  55631. /**
  55632. * Stencil value used for glowing meshes.
  55633. */
  55634. static GlowingMeshStencilReference: number;
  55635. /**
  55636. * Stencil value used for the other meshes in the scene.
  55637. */
  55638. static NormalMeshStencilReference: number;
  55639. /**
  55640. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55641. */
  55642. innerGlow: boolean;
  55643. /**
  55644. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55645. */
  55646. outerGlow: boolean;
  55647. /**
  55648. * Specifies the horizontal size of the blur.
  55649. */
  55650. set blurHorizontalSize(value: number);
  55651. /**
  55652. * Specifies the vertical size of the blur.
  55653. */
  55654. set blurVerticalSize(value: number);
  55655. /**
  55656. * Gets the horizontal size of the blur.
  55657. */
  55658. get blurHorizontalSize(): number;
  55659. /**
  55660. * Gets the vertical size of the blur.
  55661. */
  55662. get blurVerticalSize(): number;
  55663. /**
  55664. * An event triggered when the highlight layer is being blurred.
  55665. */
  55666. onBeforeBlurObservable: Observable<HighlightLayer>;
  55667. /**
  55668. * An event triggered when the highlight layer has been blurred.
  55669. */
  55670. onAfterBlurObservable: Observable<HighlightLayer>;
  55671. private _instanceGlowingMeshStencilReference;
  55672. private _options;
  55673. private _downSamplePostprocess;
  55674. private _horizontalBlurPostprocess;
  55675. private _verticalBlurPostprocess;
  55676. private _blurTexture;
  55677. private _meshes;
  55678. private _excludedMeshes;
  55679. /**
  55680. * Instantiates a new highlight Layer and references it to the scene..
  55681. * @param name The name of the layer
  55682. * @param scene The scene to use the layer in
  55683. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55684. */
  55685. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55686. /**
  55687. * Get the effect name of the layer.
  55688. * @return The effect name
  55689. */
  55690. getEffectName(): string;
  55691. /**
  55692. * Create the merge effect. This is the shader use to blit the information back
  55693. * to the main canvas at the end of the scene rendering.
  55694. */
  55695. protected _createMergeEffect(): Effect;
  55696. /**
  55697. * Creates the render target textures and post processes used in the highlight layer.
  55698. */
  55699. protected _createTextureAndPostProcesses(): void;
  55700. /**
  55701. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55702. */
  55703. needStencil(): boolean;
  55704. /**
  55705. * Checks for the readiness of the element composing the layer.
  55706. * @param subMesh the mesh to check for
  55707. * @param useInstances specify wether or not to use instances to render the mesh
  55708. * @param emissiveTexture the associated emissive texture used to generate the glow
  55709. * @return true if ready otherwise, false
  55710. */
  55711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55712. /**
  55713. * Implementation specific of rendering the generating effect on the main canvas.
  55714. * @param effect The effect used to render through
  55715. */
  55716. protected _internalRender(effect: Effect): void;
  55717. /**
  55718. * Returns true if the layer contains information to display, otherwise false.
  55719. */
  55720. shouldRender(): boolean;
  55721. /**
  55722. * Returns true if the mesh should render, otherwise false.
  55723. * @param mesh The mesh to render
  55724. * @returns true if it should render otherwise false
  55725. */
  55726. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55727. /**
  55728. * Sets the required values for both the emissive texture and and the main color.
  55729. */
  55730. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55731. /**
  55732. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55733. * @param mesh The mesh to exclude from the highlight layer
  55734. */
  55735. addExcludedMesh(mesh: Mesh): void;
  55736. /**
  55737. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55738. * @param mesh The mesh to highlight
  55739. */
  55740. removeExcludedMesh(mesh: Mesh): void;
  55741. /**
  55742. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55743. * @param mesh mesh to test
  55744. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55745. */
  55746. hasMesh(mesh: AbstractMesh): boolean;
  55747. /**
  55748. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55749. * @param mesh The mesh to highlight
  55750. * @param color The color of the highlight
  55751. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55752. */
  55753. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55754. /**
  55755. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55756. * @param mesh The mesh to highlight
  55757. */
  55758. removeMesh(mesh: Mesh): void;
  55759. /**
  55760. * Remove all the meshes currently referenced in the highlight layer
  55761. */
  55762. removeAllMeshes(): void;
  55763. /**
  55764. * Force the stencil to the normal expected value for none glowing parts
  55765. */
  55766. private _defaultStencilReference;
  55767. /**
  55768. * Free any resources and references associated to a mesh.
  55769. * Internal use
  55770. * @param mesh The mesh to free.
  55771. * @hidden
  55772. */
  55773. _disposeMesh(mesh: Mesh): void;
  55774. /**
  55775. * Dispose the highlight layer and free resources.
  55776. */
  55777. dispose(): void;
  55778. /**
  55779. * Gets the class name of the effect layer
  55780. * @returns the string with the class name of the effect layer
  55781. */
  55782. getClassName(): string;
  55783. /**
  55784. * Serializes this Highlight layer
  55785. * @returns a serialized Highlight layer object
  55786. */
  55787. serialize(): any;
  55788. /**
  55789. * Creates a Highlight layer from parsed Highlight layer data
  55790. * @param parsedHightlightLayer defines the Highlight layer data
  55791. * @param scene defines the current scene
  55792. * @param rootUrl defines the root URL containing the Highlight layer information
  55793. * @returns a parsed Highlight layer
  55794. */
  55795. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55796. }
  55797. }
  55798. declare module "babylonjs/Layers/layerSceneComponent" {
  55799. import { Scene } from "babylonjs/scene";
  55800. import { ISceneComponent } from "babylonjs/sceneComponent";
  55801. import { Layer } from "babylonjs/Layers/layer";
  55802. import { AbstractScene } from "babylonjs/abstractScene";
  55803. module "babylonjs/abstractScene" {
  55804. interface AbstractScene {
  55805. /**
  55806. * The list of layers (background and foreground) of the scene
  55807. */
  55808. layers: Array<Layer>;
  55809. }
  55810. }
  55811. /**
  55812. * Defines the layer scene component responsible to manage any layers
  55813. * in a given scene.
  55814. */
  55815. export class LayerSceneComponent implements ISceneComponent {
  55816. /**
  55817. * The component name helpfull to identify the component in the list of scene components.
  55818. */
  55819. readonly name: string;
  55820. /**
  55821. * The scene the component belongs to.
  55822. */
  55823. scene: Scene;
  55824. private _engine;
  55825. /**
  55826. * Creates a new instance of the component for the given scene
  55827. * @param scene Defines the scene to register the component in
  55828. */
  55829. constructor(scene: Scene);
  55830. /**
  55831. * Registers the component in a given scene
  55832. */
  55833. register(): void;
  55834. /**
  55835. * Rebuilds the elements related to this component in case of
  55836. * context lost for instance.
  55837. */
  55838. rebuild(): void;
  55839. /**
  55840. * Disposes the component and the associated ressources.
  55841. */
  55842. dispose(): void;
  55843. private _draw;
  55844. private _drawCameraPredicate;
  55845. private _drawCameraBackground;
  55846. private _drawCameraForeground;
  55847. private _drawRenderTargetPredicate;
  55848. private _drawRenderTargetBackground;
  55849. private _drawRenderTargetForeground;
  55850. /**
  55851. * Adds all the elements from the container to the scene
  55852. * @param container the container holding the elements
  55853. */
  55854. addFromContainer(container: AbstractScene): void;
  55855. /**
  55856. * Removes all the elements in the container from the scene
  55857. * @param container contains the elements to remove
  55858. * @param dispose if the removed element should be disposed (default: false)
  55859. */
  55860. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55861. }
  55862. }
  55863. declare module "babylonjs/Shaders/layer.fragment" {
  55864. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55865. /** @hidden */
  55866. export var layerPixelShader: {
  55867. name: string;
  55868. shader: string;
  55869. };
  55870. }
  55871. declare module "babylonjs/Shaders/layer.vertex" {
  55872. /** @hidden */
  55873. export var layerVertexShader: {
  55874. name: string;
  55875. shader: string;
  55876. };
  55877. }
  55878. declare module "babylonjs/Layers/layer" {
  55879. import { Observable } from "babylonjs/Misc/observable";
  55880. import { Nullable } from "babylonjs/types";
  55881. import { Scene } from "babylonjs/scene";
  55882. import { Vector2 } from "babylonjs/Maths/math.vector";
  55883. import { Color4 } from "babylonjs/Maths/math.color";
  55884. import { Texture } from "babylonjs/Materials/Textures/texture";
  55885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55886. import "babylonjs/Shaders/layer.fragment";
  55887. import "babylonjs/Shaders/layer.vertex";
  55888. /**
  55889. * This represents a full screen 2d layer.
  55890. * This can be useful to display a picture in the background of your scene for instance.
  55891. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55892. */
  55893. export class Layer {
  55894. /**
  55895. * Define the name of the layer.
  55896. */
  55897. name: string;
  55898. /**
  55899. * Define the texture the layer should display.
  55900. */
  55901. texture: Nullable<Texture>;
  55902. /**
  55903. * Is the layer in background or foreground.
  55904. */
  55905. isBackground: boolean;
  55906. /**
  55907. * Define the color of the layer (instead of texture).
  55908. */
  55909. color: Color4;
  55910. /**
  55911. * Define the scale of the layer in order to zoom in out of the texture.
  55912. */
  55913. scale: Vector2;
  55914. /**
  55915. * Define an offset for the layer in order to shift the texture.
  55916. */
  55917. offset: Vector2;
  55918. /**
  55919. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55920. */
  55921. alphaBlendingMode: number;
  55922. /**
  55923. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55924. * Alpha test will not mix with the background color in case of transparency.
  55925. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55926. */
  55927. alphaTest: boolean;
  55928. /**
  55929. * Define a mask to restrict the layer to only some of the scene cameras.
  55930. */
  55931. layerMask: number;
  55932. /**
  55933. * Define the list of render target the layer is visible into.
  55934. */
  55935. renderTargetTextures: RenderTargetTexture[];
  55936. /**
  55937. * Define if the layer is only used in renderTarget or if it also
  55938. * renders in the main frame buffer of the canvas.
  55939. */
  55940. renderOnlyInRenderTargetTextures: boolean;
  55941. private _scene;
  55942. private _vertexBuffers;
  55943. private _indexBuffer;
  55944. private _effect;
  55945. private _previousDefines;
  55946. /**
  55947. * An event triggered when the layer is disposed.
  55948. */
  55949. onDisposeObservable: Observable<Layer>;
  55950. private _onDisposeObserver;
  55951. /**
  55952. * Back compatibility with callback before the onDisposeObservable existed.
  55953. * The set callback will be triggered when the layer has been disposed.
  55954. */
  55955. set onDispose(callback: () => void);
  55956. /**
  55957. * An event triggered before rendering the scene
  55958. */
  55959. onBeforeRenderObservable: Observable<Layer>;
  55960. private _onBeforeRenderObserver;
  55961. /**
  55962. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55963. * The set callback will be triggered just before rendering the layer.
  55964. */
  55965. set onBeforeRender(callback: () => void);
  55966. /**
  55967. * An event triggered after rendering the scene
  55968. */
  55969. onAfterRenderObservable: Observable<Layer>;
  55970. private _onAfterRenderObserver;
  55971. /**
  55972. * Back compatibility with callback before the onAfterRenderObservable existed.
  55973. * The set callback will be triggered just after rendering the layer.
  55974. */
  55975. set onAfterRender(callback: () => void);
  55976. /**
  55977. * Instantiates a new layer.
  55978. * This represents a full screen 2d layer.
  55979. * This can be useful to display a picture in the background of your scene for instance.
  55980. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55981. * @param name Define the name of the layer in the scene
  55982. * @param imgUrl Define the url of the texture to display in the layer
  55983. * @param scene Define the scene the layer belongs to
  55984. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55985. * @param color Defines a color for the layer
  55986. */
  55987. constructor(
  55988. /**
  55989. * Define the name of the layer.
  55990. */
  55991. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55992. private _createIndexBuffer;
  55993. /** @hidden */
  55994. _rebuild(): void;
  55995. /**
  55996. * Renders the layer in the scene.
  55997. */
  55998. render(): void;
  55999. /**
  56000. * Disposes and releases the associated ressources.
  56001. */
  56002. dispose(): void;
  56003. }
  56004. }
  56005. declare module "babylonjs/Layers/index" {
  56006. export * from "babylonjs/Layers/effectLayer";
  56007. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56008. export * from "babylonjs/Layers/glowLayer";
  56009. export * from "babylonjs/Layers/highlightLayer";
  56010. export * from "babylonjs/Layers/layer";
  56011. export * from "babylonjs/Layers/layerSceneComponent";
  56012. }
  56013. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56014. /** @hidden */
  56015. export var lensFlarePixelShader: {
  56016. name: string;
  56017. shader: string;
  56018. };
  56019. }
  56020. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56021. /** @hidden */
  56022. export var lensFlareVertexShader: {
  56023. name: string;
  56024. shader: string;
  56025. };
  56026. }
  56027. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56028. import { Scene } from "babylonjs/scene";
  56029. import { Vector3 } from "babylonjs/Maths/math.vector";
  56030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56031. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56032. import "babylonjs/Shaders/lensFlare.fragment";
  56033. import "babylonjs/Shaders/lensFlare.vertex";
  56034. import { Viewport } from "babylonjs/Maths/math.viewport";
  56035. /**
  56036. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56037. * It is usually composed of several `lensFlare`.
  56038. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56039. */
  56040. export class LensFlareSystem {
  56041. /**
  56042. * Define the name of the lens flare system
  56043. */
  56044. name: string;
  56045. /**
  56046. * List of lens flares used in this system.
  56047. */
  56048. lensFlares: LensFlare[];
  56049. /**
  56050. * Define a limit from the border the lens flare can be visible.
  56051. */
  56052. borderLimit: number;
  56053. /**
  56054. * Define a viewport border we do not want to see the lens flare in.
  56055. */
  56056. viewportBorder: number;
  56057. /**
  56058. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56059. */
  56060. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56061. /**
  56062. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56063. */
  56064. layerMask: number;
  56065. /**
  56066. * Define the id of the lens flare system in the scene.
  56067. * (equal to name by default)
  56068. */
  56069. id: string;
  56070. private _scene;
  56071. private _emitter;
  56072. private _vertexBuffers;
  56073. private _indexBuffer;
  56074. private _effect;
  56075. private _positionX;
  56076. private _positionY;
  56077. private _isEnabled;
  56078. /** @hidden */
  56079. static _SceneComponentInitialization: (scene: Scene) => void;
  56080. /**
  56081. * Instantiates a lens flare system.
  56082. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56083. * It is usually composed of several `lensFlare`.
  56084. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56085. * @param name Define the name of the lens flare system in the scene
  56086. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56087. * @param scene Define the scene the lens flare system belongs to
  56088. */
  56089. constructor(
  56090. /**
  56091. * Define the name of the lens flare system
  56092. */
  56093. name: string, emitter: any, scene: Scene);
  56094. /**
  56095. * Define if the lens flare system is enabled.
  56096. */
  56097. get isEnabled(): boolean;
  56098. set isEnabled(value: boolean);
  56099. /**
  56100. * Get the scene the effects belongs to.
  56101. * @returns the scene holding the lens flare system
  56102. */
  56103. getScene(): Scene;
  56104. /**
  56105. * Get the emitter of the lens flare system.
  56106. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56107. * @returns the emitter of the lens flare system
  56108. */
  56109. getEmitter(): any;
  56110. /**
  56111. * Set the emitter of the lens flare system.
  56112. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56113. * @param newEmitter Define the new emitter of the system
  56114. */
  56115. setEmitter(newEmitter: any): void;
  56116. /**
  56117. * Get the lens flare system emitter position.
  56118. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56119. * @returns the position
  56120. */
  56121. getEmitterPosition(): Vector3;
  56122. /**
  56123. * @hidden
  56124. */
  56125. computeEffectivePosition(globalViewport: Viewport): boolean;
  56126. /** @hidden */
  56127. _isVisible(): boolean;
  56128. /**
  56129. * @hidden
  56130. */
  56131. render(): boolean;
  56132. /**
  56133. * Dispose and release the lens flare with its associated resources.
  56134. */
  56135. dispose(): void;
  56136. /**
  56137. * Parse a lens flare system from a JSON repressentation
  56138. * @param parsedLensFlareSystem Define the JSON to parse
  56139. * @param scene Define the scene the parsed system should be instantiated in
  56140. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56141. * @returns the parsed system
  56142. */
  56143. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56144. /**
  56145. * Serialize the current Lens Flare System into a JSON representation.
  56146. * @returns the serialized JSON
  56147. */
  56148. serialize(): any;
  56149. }
  56150. }
  56151. declare module "babylonjs/LensFlares/lensFlare" {
  56152. import { Nullable } from "babylonjs/types";
  56153. import { Color3 } from "babylonjs/Maths/math.color";
  56154. import { Texture } from "babylonjs/Materials/Textures/texture";
  56155. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56156. /**
  56157. * This represents one of the lens effect in a `lensFlareSystem`.
  56158. * It controls one of the indiviual texture used in the effect.
  56159. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56160. */
  56161. export class LensFlare {
  56162. /**
  56163. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56164. */
  56165. size: number;
  56166. /**
  56167. * 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.
  56168. */
  56169. position: number;
  56170. /**
  56171. * Define the lens color.
  56172. */
  56173. color: Color3;
  56174. /**
  56175. * Define the lens texture.
  56176. */
  56177. texture: Nullable<Texture>;
  56178. /**
  56179. * Define the alpha mode to render this particular lens.
  56180. */
  56181. alphaMode: number;
  56182. private _system;
  56183. /**
  56184. * Creates a new Lens Flare.
  56185. * This represents one of the lens effect in a `lensFlareSystem`.
  56186. * It controls one of the indiviual texture used in the effect.
  56187. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56188. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56189. * @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.
  56190. * @param color Define the lens color
  56191. * @param imgUrl Define the lens texture url
  56192. * @param system Define the `lensFlareSystem` this flare is part of
  56193. * @returns The newly created Lens Flare
  56194. */
  56195. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56196. /**
  56197. * Instantiates a new Lens Flare.
  56198. * This represents one of the lens effect in a `lensFlareSystem`.
  56199. * It controls one of the indiviual texture used in the effect.
  56200. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56201. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56202. * @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.
  56203. * @param color Define the lens color
  56204. * @param imgUrl Define the lens texture url
  56205. * @param system Define the `lensFlareSystem` this flare is part of
  56206. */
  56207. constructor(
  56208. /**
  56209. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56210. */
  56211. size: number,
  56212. /**
  56213. * 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.
  56214. */
  56215. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56216. /**
  56217. * Dispose and release the lens flare with its associated resources.
  56218. */
  56219. dispose(): void;
  56220. }
  56221. }
  56222. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56223. import { Nullable } from "babylonjs/types";
  56224. import { Scene } from "babylonjs/scene";
  56225. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56226. import { AbstractScene } from "babylonjs/abstractScene";
  56227. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56228. module "babylonjs/abstractScene" {
  56229. interface AbstractScene {
  56230. /**
  56231. * The list of lens flare system added to the scene
  56232. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56233. */
  56234. lensFlareSystems: Array<LensFlareSystem>;
  56235. /**
  56236. * Removes the given lens flare system from this scene.
  56237. * @param toRemove The lens flare system to remove
  56238. * @returns The index of the removed lens flare system
  56239. */
  56240. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56241. /**
  56242. * Adds the given lens flare system to this scene
  56243. * @param newLensFlareSystem The lens flare system to add
  56244. */
  56245. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56246. /**
  56247. * Gets a lens flare system using its name
  56248. * @param name defines the name to look for
  56249. * @returns the lens flare system or null if not found
  56250. */
  56251. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56252. /**
  56253. * Gets a lens flare system using its id
  56254. * @param id defines the id to look for
  56255. * @returns the lens flare system or null if not found
  56256. */
  56257. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56258. }
  56259. }
  56260. /**
  56261. * Defines the lens flare scene component responsible to manage any lens flares
  56262. * in a given scene.
  56263. */
  56264. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56265. /**
  56266. * The component name helpfull to identify the component in the list of scene components.
  56267. */
  56268. readonly name: string;
  56269. /**
  56270. * The scene the component belongs to.
  56271. */
  56272. scene: Scene;
  56273. /**
  56274. * Creates a new instance of the component for the given scene
  56275. * @param scene Defines the scene to register the component in
  56276. */
  56277. constructor(scene: Scene);
  56278. /**
  56279. * Registers the component in a given scene
  56280. */
  56281. register(): void;
  56282. /**
  56283. * Rebuilds the elements related to this component in case of
  56284. * context lost for instance.
  56285. */
  56286. rebuild(): void;
  56287. /**
  56288. * Adds all the elements from the container to the scene
  56289. * @param container the container holding the elements
  56290. */
  56291. addFromContainer(container: AbstractScene): void;
  56292. /**
  56293. * Removes all the elements in the container from the scene
  56294. * @param container contains the elements to remove
  56295. * @param dispose if the removed element should be disposed (default: false)
  56296. */
  56297. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56298. /**
  56299. * Serializes the component data to the specified json object
  56300. * @param serializationObject The object to serialize to
  56301. */
  56302. serialize(serializationObject: any): void;
  56303. /**
  56304. * Disposes the component and the associated ressources.
  56305. */
  56306. dispose(): void;
  56307. private _draw;
  56308. }
  56309. }
  56310. declare module "babylonjs/LensFlares/index" {
  56311. export * from "babylonjs/LensFlares/lensFlare";
  56312. export * from "babylonjs/LensFlares/lensFlareSystem";
  56313. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56314. }
  56315. declare module "babylonjs/Shaders/depth.fragment" {
  56316. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56317. /** @hidden */
  56318. export var depthPixelShader: {
  56319. name: string;
  56320. shader: string;
  56321. };
  56322. }
  56323. declare module "babylonjs/Shaders/depth.vertex" {
  56324. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56331. /** @hidden */
  56332. export var depthVertexShader: {
  56333. name: string;
  56334. shader: string;
  56335. };
  56336. }
  56337. declare module "babylonjs/Rendering/depthRenderer" {
  56338. import { Nullable } from "babylonjs/types";
  56339. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56340. import { Scene } from "babylonjs/scene";
  56341. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56342. import { Camera } from "babylonjs/Cameras/camera";
  56343. import "babylonjs/Shaders/depth.fragment";
  56344. import "babylonjs/Shaders/depth.vertex";
  56345. /**
  56346. * This represents a depth renderer in Babylon.
  56347. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56348. */
  56349. export class DepthRenderer {
  56350. private _scene;
  56351. private _depthMap;
  56352. private _effect;
  56353. private readonly _storeNonLinearDepth;
  56354. private readonly _clearColor;
  56355. /** Get if the depth renderer is using packed depth or not */
  56356. readonly isPacked: boolean;
  56357. private _cachedDefines;
  56358. private _camera;
  56359. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56360. enabled: boolean;
  56361. /**
  56362. * Specifiess that the depth renderer will only be used within
  56363. * the camera it is created for.
  56364. * This can help forcing its rendering during the camera processing.
  56365. */
  56366. useOnlyInActiveCamera: boolean;
  56367. /** @hidden */
  56368. static _SceneComponentInitialization: (scene: Scene) => void;
  56369. /**
  56370. * Instantiates a depth renderer
  56371. * @param scene The scene the renderer belongs to
  56372. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56373. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56374. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56375. */
  56376. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56377. /**
  56378. * Creates the depth rendering effect and checks if the effect is ready.
  56379. * @param subMesh The submesh to be used to render the depth map of
  56380. * @param useInstances If multiple world instances should be used
  56381. * @returns if the depth renderer is ready to render the depth map
  56382. */
  56383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56384. /**
  56385. * Gets the texture which the depth map will be written to.
  56386. * @returns The depth map texture
  56387. */
  56388. getDepthMap(): RenderTargetTexture;
  56389. /**
  56390. * Disposes of the depth renderer.
  56391. */
  56392. dispose(): void;
  56393. }
  56394. }
  56395. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56396. /** @hidden */
  56397. export var minmaxReduxPixelShader: {
  56398. name: string;
  56399. shader: string;
  56400. };
  56401. }
  56402. declare module "babylonjs/Misc/minMaxReducer" {
  56403. import { Nullable } from "babylonjs/types";
  56404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56405. import { Camera } from "babylonjs/Cameras/camera";
  56406. import { Observer } from "babylonjs/Misc/observable";
  56407. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56408. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56409. import { Observable } from "babylonjs/Misc/observable";
  56410. import "babylonjs/Shaders/minmaxRedux.fragment";
  56411. /**
  56412. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56413. * and maximum values from all values of the texture.
  56414. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56415. * The source values are read from the red channel of the texture.
  56416. */
  56417. export class MinMaxReducer {
  56418. /**
  56419. * Observable triggered when the computation has been performed
  56420. */
  56421. onAfterReductionPerformed: Observable<{
  56422. min: number;
  56423. max: number;
  56424. }>;
  56425. protected _camera: Camera;
  56426. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56427. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56428. protected _postProcessManager: PostProcessManager;
  56429. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56430. protected _forceFullscreenViewport: boolean;
  56431. /**
  56432. * Creates a min/max reducer
  56433. * @param camera The camera to use for the post processes
  56434. */
  56435. constructor(camera: Camera);
  56436. /**
  56437. * Gets the texture used to read the values from.
  56438. */
  56439. get sourceTexture(): Nullable<RenderTargetTexture>;
  56440. /**
  56441. * Sets the source texture to read the values from.
  56442. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56443. * because in such textures '1' value must not be taken into account to compute the maximum
  56444. * as this value is used to clear the texture.
  56445. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56446. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56447. * @param depthRedux Indicates if the texture is a depth texture or not
  56448. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56449. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56450. */
  56451. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56452. /**
  56453. * Defines the refresh rate of the computation.
  56454. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56455. */
  56456. get refreshRate(): number;
  56457. set refreshRate(value: number);
  56458. protected _activated: boolean;
  56459. /**
  56460. * Gets the activation status of the reducer
  56461. */
  56462. get activated(): boolean;
  56463. /**
  56464. * Activates the reduction computation.
  56465. * When activated, the observers registered in onAfterReductionPerformed are
  56466. * called after the compuation is performed
  56467. */
  56468. activate(): void;
  56469. /**
  56470. * Deactivates the reduction computation.
  56471. */
  56472. deactivate(): void;
  56473. /**
  56474. * Disposes the min/max reducer
  56475. * @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.
  56476. */
  56477. dispose(disposeAll?: boolean): void;
  56478. }
  56479. }
  56480. declare module "babylonjs/Misc/depthReducer" {
  56481. import { Nullable } from "babylonjs/types";
  56482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56483. import { Camera } from "babylonjs/Cameras/camera";
  56484. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56485. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56486. /**
  56487. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56488. */
  56489. export class DepthReducer extends MinMaxReducer {
  56490. private _depthRenderer;
  56491. private _depthRendererId;
  56492. /**
  56493. * Gets the depth renderer used for the computation.
  56494. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56495. */
  56496. get depthRenderer(): Nullable<DepthRenderer>;
  56497. /**
  56498. * Creates a depth reducer
  56499. * @param camera The camera used to render the depth texture
  56500. */
  56501. constructor(camera: Camera);
  56502. /**
  56503. * Sets the depth renderer to use to generate the depth map
  56504. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56505. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56506. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56507. */
  56508. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56509. /** @hidden */
  56510. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56511. /**
  56512. * Activates the reduction computation.
  56513. * When activated, the observers registered in onAfterReductionPerformed are
  56514. * called after the compuation is performed
  56515. */
  56516. activate(): void;
  56517. /**
  56518. * Deactivates the reduction computation.
  56519. */
  56520. deactivate(): void;
  56521. /**
  56522. * Disposes the depth reducer
  56523. * @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.
  56524. */
  56525. dispose(disposeAll?: boolean): void;
  56526. }
  56527. }
  56528. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56529. import { Nullable } from "babylonjs/types";
  56530. import { Scene } from "babylonjs/scene";
  56531. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56533. import { Effect } from "babylonjs/Materials/effect";
  56534. import "babylonjs/Shaders/shadowMap.fragment";
  56535. import "babylonjs/Shaders/shadowMap.vertex";
  56536. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56537. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56538. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56539. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56540. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56541. /**
  56542. * A CSM implementation allowing casting shadows on large scenes.
  56543. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56544. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56545. */
  56546. export class CascadedShadowGenerator extends ShadowGenerator {
  56547. private static readonly frustumCornersNDCSpace;
  56548. /**
  56549. * Name of the CSM class
  56550. */
  56551. static CLASSNAME: string;
  56552. /**
  56553. * Defines the default number of cascades used by the CSM.
  56554. */
  56555. static readonly DEFAULT_CASCADES_COUNT: number;
  56556. /**
  56557. * Defines the minimum number of cascades used by the CSM.
  56558. */
  56559. static readonly MIN_CASCADES_COUNT: number;
  56560. /**
  56561. * Defines the maximum number of cascades used by the CSM.
  56562. */
  56563. static readonly MAX_CASCADES_COUNT: number;
  56564. protected _validateFilter(filter: number): number;
  56565. /**
  56566. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56567. */
  56568. penumbraDarkness: number;
  56569. private _numCascades;
  56570. /**
  56571. * Gets or set the number of cascades used by the CSM.
  56572. */
  56573. get numCascades(): number;
  56574. set numCascades(value: number);
  56575. /**
  56576. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56577. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56578. */
  56579. stabilizeCascades: boolean;
  56580. private _freezeShadowCastersBoundingInfo;
  56581. private _freezeShadowCastersBoundingInfoObservable;
  56582. /**
  56583. * Enables or disables the shadow casters bounding info computation.
  56584. * If your shadow casters don't move, you can disable this feature.
  56585. * If it is enabled, the bounding box computation is done every frame.
  56586. */
  56587. get freezeShadowCastersBoundingInfo(): boolean;
  56588. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56589. private _scbiMin;
  56590. private _scbiMax;
  56591. protected _computeShadowCastersBoundingInfo(): void;
  56592. protected _shadowCastersBoundingInfo: BoundingInfo;
  56593. /**
  56594. * Gets or sets the shadow casters bounding info.
  56595. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56596. * so that the system won't overwrite the bounds you provide
  56597. */
  56598. get shadowCastersBoundingInfo(): BoundingInfo;
  56599. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56600. protected _breaksAreDirty: boolean;
  56601. protected _minDistance: number;
  56602. protected _maxDistance: number;
  56603. /**
  56604. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56605. *
  56606. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56607. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56608. * @param min minimal distance for the breaks (default to 0.)
  56609. * @param max maximal distance for the breaks (default to 1.)
  56610. */
  56611. setMinMaxDistance(min: number, max: number): void;
  56612. /** Gets the minimal distance used in the cascade break computation */
  56613. get minDistance(): number;
  56614. /** Gets the maximal distance used in the cascade break computation */
  56615. get maxDistance(): number;
  56616. /**
  56617. * Gets the class name of that object
  56618. * @returns "CascadedShadowGenerator"
  56619. */
  56620. getClassName(): string;
  56621. private _cascadeMinExtents;
  56622. private _cascadeMaxExtents;
  56623. /**
  56624. * Gets a cascade minimum extents
  56625. * @param cascadeIndex index of the cascade
  56626. * @returns the minimum cascade extents
  56627. */
  56628. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56629. /**
  56630. * Gets a cascade maximum extents
  56631. * @param cascadeIndex index of the cascade
  56632. * @returns the maximum cascade extents
  56633. */
  56634. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56635. private _cascades;
  56636. private _currentLayer;
  56637. private _viewSpaceFrustumsZ;
  56638. private _viewMatrices;
  56639. private _projectionMatrices;
  56640. private _transformMatrices;
  56641. private _transformMatricesAsArray;
  56642. private _frustumLengths;
  56643. private _lightSizeUVCorrection;
  56644. private _depthCorrection;
  56645. private _frustumCornersWorldSpace;
  56646. private _frustumCenter;
  56647. private _shadowCameraPos;
  56648. private _shadowMaxZ;
  56649. /**
  56650. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56651. * It defaults to camera.maxZ
  56652. */
  56653. get shadowMaxZ(): number;
  56654. /**
  56655. * Sets the shadow max z distance.
  56656. */
  56657. set shadowMaxZ(value: number);
  56658. protected _debug: boolean;
  56659. /**
  56660. * Gets or sets the debug flag.
  56661. * When enabled, the cascades are materialized by different colors on the screen.
  56662. */
  56663. get debug(): boolean;
  56664. set debug(dbg: boolean);
  56665. private _depthClamp;
  56666. /**
  56667. * Gets or sets the depth clamping value.
  56668. *
  56669. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56670. * to account for the shadow casters far away.
  56671. *
  56672. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56673. */
  56674. get depthClamp(): boolean;
  56675. set depthClamp(value: boolean);
  56676. private _cascadeBlendPercentage;
  56677. /**
  56678. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56679. * It defaults to 0.1 (10% blending).
  56680. */
  56681. get cascadeBlendPercentage(): number;
  56682. set cascadeBlendPercentage(value: number);
  56683. private _lambda;
  56684. /**
  56685. * Gets or set the lambda parameter.
  56686. * This parameter is used to split the camera frustum and create the cascades.
  56687. * 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.
  56688. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56689. */
  56690. get lambda(): number;
  56691. set lambda(value: number);
  56692. /**
  56693. * Gets the view matrix corresponding to a given cascade
  56694. * @param cascadeNum cascade to retrieve the view matrix from
  56695. * @returns the cascade view matrix
  56696. */
  56697. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56698. /**
  56699. * Gets the projection matrix corresponding to a given cascade
  56700. * @param cascadeNum cascade to retrieve the projection matrix from
  56701. * @returns the cascade projection matrix
  56702. */
  56703. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56704. /**
  56705. * Gets the transformation matrix corresponding to a given cascade
  56706. * @param cascadeNum cascade to retrieve the transformation matrix from
  56707. * @returns the cascade transformation matrix
  56708. */
  56709. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56710. private _depthRenderer;
  56711. /**
  56712. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56713. *
  56714. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56715. *
  56716. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56717. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56718. * @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
  56719. */
  56720. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56721. private _depthReducer;
  56722. private _autoCalcDepthBounds;
  56723. /**
  56724. * Gets or sets the autoCalcDepthBounds property.
  56725. *
  56726. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56727. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56728. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56729. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56730. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56731. */
  56732. get autoCalcDepthBounds(): boolean;
  56733. set autoCalcDepthBounds(value: boolean);
  56734. /**
  56735. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56736. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56737. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56738. * for setting the refresh rate on the renderer yourself!
  56739. */
  56740. get autoCalcDepthBoundsRefreshRate(): number;
  56741. set autoCalcDepthBoundsRefreshRate(value: number);
  56742. /**
  56743. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56744. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56745. * you change the camera near/far planes!
  56746. */
  56747. splitFrustum(): void;
  56748. private _splitFrustum;
  56749. private _computeMatrices;
  56750. private _computeFrustumInWorldSpace;
  56751. private _computeCascadeFrustum;
  56752. /** @hidden */
  56753. static _SceneComponentInitialization: (scene: Scene) => void;
  56754. /**
  56755. * Creates a Cascaded Shadow Generator object.
  56756. * A ShadowGenerator is the required tool to use the shadows.
  56757. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56758. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56759. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56760. * @param light The directional light object generating the shadows.
  56761. * @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.
  56762. */
  56763. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56764. protected _initializeGenerator(): void;
  56765. protected _createTargetRenderTexture(): void;
  56766. protected _initializeShadowMap(): void;
  56767. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56768. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56769. /**
  56770. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56771. * @param defines Defines of the material we want to update
  56772. * @param lightIndex Index of the light in the enabled light list of the material
  56773. */
  56774. prepareDefines(defines: any, lightIndex: number): void;
  56775. /**
  56776. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56777. * defined in the generator but impacting the effect).
  56778. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56779. * @param effect The effect we are binfing the information for
  56780. */
  56781. bindShadowLight(lightIndex: string, effect: Effect): void;
  56782. /**
  56783. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56784. * (eq to view projection * shadow projection matrices)
  56785. * @returns The transform matrix used to create the shadow map
  56786. */
  56787. getTransformMatrix(): Matrix;
  56788. /**
  56789. * Disposes the ShadowGenerator.
  56790. * Returns nothing.
  56791. */
  56792. dispose(): void;
  56793. /**
  56794. * Serializes the shadow generator setup to a json object.
  56795. * @returns The serialized JSON object
  56796. */
  56797. serialize(): any;
  56798. /**
  56799. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56800. * @param parsedShadowGenerator The JSON object to parse
  56801. * @param scene The scene to create the shadow map for
  56802. * @returns The parsed shadow generator
  56803. */
  56804. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56805. }
  56806. }
  56807. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56808. import { Scene } from "babylonjs/scene";
  56809. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56810. import { AbstractScene } from "babylonjs/abstractScene";
  56811. /**
  56812. * Defines the shadow generator component responsible to manage any shadow generators
  56813. * in a given scene.
  56814. */
  56815. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56816. /**
  56817. * The component name helpfull to identify the component in the list of scene components.
  56818. */
  56819. readonly name: string;
  56820. /**
  56821. * The scene the component belongs to.
  56822. */
  56823. scene: Scene;
  56824. /**
  56825. * Creates a new instance of the component for the given scene
  56826. * @param scene Defines the scene to register the component in
  56827. */
  56828. constructor(scene: Scene);
  56829. /**
  56830. * Registers the component in a given scene
  56831. */
  56832. register(): void;
  56833. /**
  56834. * Rebuilds the elements related to this component in case of
  56835. * context lost for instance.
  56836. */
  56837. rebuild(): void;
  56838. /**
  56839. * Serializes the component data to the specified json object
  56840. * @param serializationObject The object to serialize to
  56841. */
  56842. serialize(serializationObject: any): void;
  56843. /**
  56844. * Adds all the elements from the container to the scene
  56845. * @param container the container holding the elements
  56846. */
  56847. addFromContainer(container: AbstractScene): void;
  56848. /**
  56849. * Removes all the elements in the container from the scene
  56850. * @param container contains the elements to remove
  56851. * @param dispose if the removed element should be disposed (default: false)
  56852. */
  56853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56854. /**
  56855. * Rebuilds the elements related to this component in case of
  56856. * context lost for instance.
  56857. */
  56858. dispose(): void;
  56859. private _gatherRenderTargets;
  56860. }
  56861. }
  56862. declare module "babylonjs/Lights/Shadows/index" {
  56863. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56864. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56865. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56866. }
  56867. declare module "babylonjs/Lights/pointLight" {
  56868. import { Scene } from "babylonjs/scene";
  56869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56871. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56872. import { Effect } from "babylonjs/Materials/effect";
  56873. /**
  56874. * A point light is a light defined by an unique point in world space.
  56875. * The light is emitted in every direction from this point.
  56876. * A good example of a point light is a standard light bulb.
  56877. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56878. */
  56879. export class PointLight extends ShadowLight {
  56880. private _shadowAngle;
  56881. /**
  56882. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56883. * This specifies what angle the shadow will use to be created.
  56884. *
  56885. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56886. */
  56887. get shadowAngle(): number;
  56888. /**
  56889. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56890. * This specifies what angle the shadow will use to be created.
  56891. *
  56892. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56893. */
  56894. set shadowAngle(value: number);
  56895. /**
  56896. * Gets the direction if it has been set.
  56897. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56898. */
  56899. get direction(): Vector3;
  56900. /**
  56901. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56902. */
  56903. set direction(value: Vector3);
  56904. /**
  56905. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56906. * A PointLight emits the light in every direction.
  56907. * It can cast shadows.
  56908. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56909. * ```javascript
  56910. * var pointLight = new PointLight("pl", camera.position, scene);
  56911. * ```
  56912. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56913. * @param name The light friendly name
  56914. * @param position The position of the point light in the scene
  56915. * @param scene The scene the lights belongs to
  56916. */
  56917. constructor(name: string, position: Vector3, scene: Scene);
  56918. /**
  56919. * Returns the string "PointLight"
  56920. * @returns the class name
  56921. */
  56922. getClassName(): string;
  56923. /**
  56924. * Returns the integer 0.
  56925. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56926. */
  56927. getTypeID(): number;
  56928. /**
  56929. * Specifies wether or not the shadowmap should be a cube texture.
  56930. * @returns true if the shadowmap needs to be a cube texture.
  56931. */
  56932. needCube(): boolean;
  56933. /**
  56934. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56935. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56936. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56937. */
  56938. getShadowDirection(faceIndex?: number): Vector3;
  56939. /**
  56940. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56941. * - fov = PI / 2
  56942. * - aspect ratio : 1.0
  56943. * - z-near and far equal to the active camera minZ and maxZ.
  56944. * Returns the PointLight.
  56945. */
  56946. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56947. protected _buildUniformLayout(): void;
  56948. /**
  56949. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56950. * @param effect The effect to update
  56951. * @param lightIndex The index of the light in the effect to update
  56952. * @returns The point light
  56953. */
  56954. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56955. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56956. /**
  56957. * Prepares the list of defines specific to the light type.
  56958. * @param defines the list of defines
  56959. * @param lightIndex defines the index of the light for the effect
  56960. */
  56961. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56962. }
  56963. }
  56964. declare module "babylonjs/Lights/index" {
  56965. export * from "babylonjs/Lights/light";
  56966. export * from "babylonjs/Lights/shadowLight";
  56967. export * from "babylonjs/Lights/Shadows/index";
  56968. export * from "babylonjs/Lights/directionalLight";
  56969. export * from "babylonjs/Lights/hemisphericLight";
  56970. export * from "babylonjs/Lights/pointLight";
  56971. export * from "babylonjs/Lights/spotLight";
  56972. }
  56973. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56974. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56975. /**
  56976. * Header information of HDR texture files.
  56977. */
  56978. export interface HDRInfo {
  56979. /**
  56980. * The height of the texture in pixels.
  56981. */
  56982. height: number;
  56983. /**
  56984. * The width of the texture in pixels.
  56985. */
  56986. width: number;
  56987. /**
  56988. * The index of the beginning of the data in the binary file.
  56989. */
  56990. dataPosition: number;
  56991. }
  56992. /**
  56993. * This groups tools to convert HDR texture to native colors array.
  56994. */
  56995. export class HDRTools {
  56996. private static Ldexp;
  56997. private static Rgbe2float;
  56998. private static readStringLine;
  56999. /**
  57000. * Reads header information from an RGBE texture stored in a native array.
  57001. * More information on this format are available here:
  57002. * https://en.wikipedia.org/wiki/RGBE_image_format
  57003. *
  57004. * @param uint8array The binary file stored in native array.
  57005. * @return The header information.
  57006. */
  57007. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57008. /**
  57009. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57010. * This RGBE texture needs to store the information as a panorama.
  57011. *
  57012. * More information on this format are available here:
  57013. * https://en.wikipedia.org/wiki/RGBE_image_format
  57014. *
  57015. * @param buffer The binary file stored in an array buffer.
  57016. * @param size The expected size of the extracted cubemap.
  57017. * @return The Cube Map information.
  57018. */
  57019. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57020. /**
  57021. * Returns the pixels data extracted from an RGBE texture.
  57022. * This pixels will be stored left to right up to down in the R G B order in one array.
  57023. *
  57024. * More information on this format are available here:
  57025. * https://en.wikipedia.org/wiki/RGBE_image_format
  57026. *
  57027. * @param uint8array The binary file stored in an array buffer.
  57028. * @param hdrInfo The header information of the file.
  57029. * @return The pixels data in RGB right to left up to down order.
  57030. */
  57031. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57032. private static RGBE_ReadPixels_RLE;
  57033. }
  57034. }
  57035. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57036. import { Nullable } from "babylonjs/types";
  57037. import { Scene } from "babylonjs/scene";
  57038. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57040. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57041. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57042. /**
  57043. * This represents a texture coming from an HDR input.
  57044. *
  57045. * The only supported format is currently panorama picture stored in RGBE format.
  57046. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57047. */
  57048. export class HDRCubeTexture extends BaseTexture {
  57049. private static _facesMapping;
  57050. private _generateHarmonics;
  57051. private _noMipmap;
  57052. private _textureMatrix;
  57053. private _size;
  57054. private _onLoad;
  57055. private _onError;
  57056. /**
  57057. * The texture URL.
  57058. */
  57059. url: string;
  57060. /**
  57061. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57062. */
  57063. coordinatesMode: number;
  57064. protected _isBlocking: boolean;
  57065. /**
  57066. * Sets wether or not the texture is blocking during loading.
  57067. */
  57068. set isBlocking(value: boolean);
  57069. /**
  57070. * Gets wether or not the texture is blocking during loading.
  57071. */
  57072. get isBlocking(): boolean;
  57073. protected _rotationY: number;
  57074. /**
  57075. * Sets texture matrix rotation angle around Y axis in radians.
  57076. */
  57077. set rotationY(value: number);
  57078. /**
  57079. * Gets texture matrix rotation angle around Y axis radians.
  57080. */
  57081. get rotationY(): number;
  57082. /**
  57083. * Gets or sets the center of the bounding box associated with the cube texture
  57084. * It must define where the camera used to render the texture was set
  57085. */
  57086. boundingBoxPosition: Vector3;
  57087. private _boundingBoxSize;
  57088. /**
  57089. * Gets or sets the size of the bounding box associated with the cube texture
  57090. * When defined, the cubemap will switch to local mode
  57091. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57092. * @example https://www.babylonjs-playground.com/#RNASML
  57093. */
  57094. set boundingBoxSize(value: Vector3);
  57095. get boundingBoxSize(): Vector3;
  57096. /**
  57097. * Instantiates an HDRTexture from the following parameters.
  57098. *
  57099. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57100. * @param scene The scene the texture will be used in
  57101. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57102. * @param noMipmap Forces to not generate the mipmap if true
  57103. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57104. * @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)
  57105. * @param reserved Reserved flag for internal use.
  57106. */
  57107. 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>);
  57108. /**
  57109. * Get the current class name of the texture useful for serialization or dynamic coding.
  57110. * @returns "HDRCubeTexture"
  57111. */
  57112. getClassName(): string;
  57113. /**
  57114. * Occurs when the file is raw .hdr file.
  57115. */
  57116. private loadTexture;
  57117. clone(): HDRCubeTexture;
  57118. delayLoad(): void;
  57119. /**
  57120. * Get the texture reflection matrix used to rotate/transform the reflection.
  57121. * @returns the reflection matrix
  57122. */
  57123. getReflectionTextureMatrix(): Matrix;
  57124. /**
  57125. * Set the texture reflection matrix used to rotate/transform the reflection.
  57126. * @param value Define the reflection matrix to set
  57127. */
  57128. setReflectionTextureMatrix(value: Matrix): void;
  57129. /**
  57130. * Parses a JSON representation of an HDR Texture in order to create the texture
  57131. * @param parsedTexture Define the JSON representation
  57132. * @param scene Define the scene the texture should be created in
  57133. * @param rootUrl Define the root url in case we need to load relative dependencies
  57134. * @returns the newly created texture after parsing
  57135. */
  57136. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57137. serialize(): any;
  57138. }
  57139. }
  57140. declare module "babylonjs/Physics/physicsEngine" {
  57141. import { Nullable } from "babylonjs/types";
  57142. import { Vector3 } from "babylonjs/Maths/math.vector";
  57143. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57144. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57145. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57146. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57147. /**
  57148. * Class used to control physics engine
  57149. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57150. */
  57151. export class PhysicsEngine implements IPhysicsEngine {
  57152. private _physicsPlugin;
  57153. /**
  57154. * Global value used to control the smallest number supported by the simulation
  57155. */
  57156. static Epsilon: number;
  57157. private _impostors;
  57158. private _joints;
  57159. private _subTimeStep;
  57160. /**
  57161. * Gets the gravity vector used by the simulation
  57162. */
  57163. gravity: Vector3;
  57164. /**
  57165. * Factory used to create the default physics plugin.
  57166. * @returns The default physics plugin
  57167. */
  57168. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57169. /**
  57170. * Creates a new Physics Engine
  57171. * @param gravity defines the gravity vector used by the simulation
  57172. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57173. */
  57174. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57175. /**
  57176. * Sets the gravity vector used by the simulation
  57177. * @param gravity defines the gravity vector to use
  57178. */
  57179. setGravity(gravity: Vector3): void;
  57180. /**
  57181. * Set the time step of the physics engine.
  57182. * Default is 1/60.
  57183. * To slow it down, enter 1/600 for example.
  57184. * To speed it up, 1/30
  57185. * @param newTimeStep defines the new timestep to apply to this world.
  57186. */
  57187. setTimeStep(newTimeStep?: number): void;
  57188. /**
  57189. * Get the time step of the physics engine.
  57190. * @returns the current time step
  57191. */
  57192. getTimeStep(): number;
  57193. /**
  57194. * Set the sub time step of the physics engine.
  57195. * Default is 0 meaning there is no sub steps
  57196. * To increase physics resolution precision, set a small value (like 1 ms)
  57197. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57198. */
  57199. setSubTimeStep(subTimeStep?: number): void;
  57200. /**
  57201. * Get the sub time step of the physics engine.
  57202. * @returns the current sub time step
  57203. */
  57204. getSubTimeStep(): number;
  57205. /**
  57206. * Release all resources
  57207. */
  57208. dispose(): void;
  57209. /**
  57210. * Gets the name of the current physics plugin
  57211. * @returns the name of the plugin
  57212. */
  57213. getPhysicsPluginName(): string;
  57214. /**
  57215. * Adding a new impostor for the impostor tracking.
  57216. * This will be done by the impostor itself.
  57217. * @param impostor the impostor to add
  57218. */
  57219. addImpostor(impostor: PhysicsImpostor): void;
  57220. /**
  57221. * Remove an impostor from the engine.
  57222. * This impostor and its mesh will not longer be updated by the physics engine.
  57223. * @param impostor the impostor to remove
  57224. */
  57225. removeImpostor(impostor: PhysicsImpostor): void;
  57226. /**
  57227. * Add a joint to the physics engine
  57228. * @param mainImpostor defines the main impostor to which the joint is added.
  57229. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57230. * @param joint defines the joint that will connect both impostors.
  57231. */
  57232. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57233. /**
  57234. * Removes a joint from the simulation
  57235. * @param mainImpostor defines the impostor used with the joint
  57236. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57237. * @param joint defines the joint to remove
  57238. */
  57239. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57240. /**
  57241. * Called by the scene. No need to call it.
  57242. * @param delta defines the timespam between frames
  57243. */
  57244. _step(delta: number): void;
  57245. /**
  57246. * Gets the current plugin used to run the simulation
  57247. * @returns current plugin
  57248. */
  57249. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57250. /**
  57251. * Gets the list of physic impostors
  57252. * @returns an array of PhysicsImpostor
  57253. */
  57254. getImpostors(): Array<PhysicsImpostor>;
  57255. /**
  57256. * Gets the impostor for a physics enabled object
  57257. * @param object defines the object impersonated by the impostor
  57258. * @returns the PhysicsImpostor or null if not found
  57259. */
  57260. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57261. /**
  57262. * Gets the impostor for a physics body object
  57263. * @param body defines physics body used by the impostor
  57264. * @returns the PhysicsImpostor or null if not found
  57265. */
  57266. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57267. /**
  57268. * Does a raycast in the physics world
  57269. * @param from when should the ray start?
  57270. * @param to when should the ray end?
  57271. * @returns PhysicsRaycastResult
  57272. */
  57273. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57274. }
  57275. }
  57276. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57277. import { Nullable } from "babylonjs/types";
  57278. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57280. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57281. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57282. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57283. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57284. /** @hidden */
  57285. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57286. private _useDeltaForWorldStep;
  57287. world: any;
  57288. name: string;
  57289. private _physicsMaterials;
  57290. private _fixedTimeStep;
  57291. private _cannonRaycastResult;
  57292. private _raycastResult;
  57293. private _physicsBodysToRemoveAfterStep;
  57294. BJSCANNON: any;
  57295. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57296. setGravity(gravity: Vector3): void;
  57297. setTimeStep(timeStep: number): void;
  57298. getTimeStep(): number;
  57299. executeStep(delta: number): void;
  57300. private _removeMarkedPhysicsBodiesFromWorld;
  57301. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57302. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57303. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57304. private _processChildMeshes;
  57305. removePhysicsBody(impostor: PhysicsImpostor): void;
  57306. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57307. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57308. private _addMaterial;
  57309. private _checkWithEpsilon;
  57310. private _createShape;
  57311. private _createHeightmap;
  57312. private _minus90X;
  57313. private _plus90X;
  57314. private _tmpPosition;
  57315. private _tmpDeltaPosition;
  57316. private _tmpUnityRotation;
  57317. private _updatePhysicsBodyTransformation;
  57318. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57319. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57320. isSupported(): boolean;
  57321. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57322. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57326. getBodyMass(impostor: PhysicsImpostor): number;
  57327. getBodyFriction(impostor: PhysicsImpostor): number;
  57328. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57329. getBodyRestitution(impostor: PhysicsImpostor): number;
  57330. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57331. sleepBody(impostor: PhysicsImpostor): void;
  57332. wakeUpBody(impostor: PhysicsImpostor): void;
  57333. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57334. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57335. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57336. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57337. getRadius(impostor: PhysicsImpostor): number;
  57338. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57339. dispose(): void;
  57340. private _extendNamespace;
  57341. /**
  57342. * Does a raycast in the physics world
  57343. * @param from when should the ray start?
  57344. * @param to when should the ray end?
  57345. * @returns PhysicsRaycastResult
  57346. */
  57347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57348. }
  57349. }
  57350. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57351. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57352. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57353. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57355. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57356. import { Nullable } from "babylonjs/types";
  57357. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57358. /** @hidden */
  57359. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57360. world: any;
  57361. name: string;
  57362. BJSOIMO: any;
  57363. private _raycastResult;
  57364. constructor(iterations?: number, oimoInjection?: any);
  57365. setGravity(gravity: Vector3): void;
  57366. setTimeStep(timeStep: number): void;
  57367. getTimeStep(): number;
  57368. private _tmpImpostorsArray;
  57369. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57370. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57371. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57372. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57373. private _tmpPositionVector;
  57374. removePhysicsBody(impostor: PhysicsImpostor): void;
  57375. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57376. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57377. isSupported(): boolean;
  57378. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57379. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57380. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57381. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57382. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57383. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57384. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57385. getBodyMass(impostor: PhysicsImpostor): number;
  57386. getBodyFriction(impostor: PhysicsImpostor): number;
  57387. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57388. getBodyRestitution(impostor: PhysicsImpostor): number;
  57389. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57390. sleepBody(impostor: PhysicsImpostor): void;
  57391. wakeUpBody(impostor: PhysicsImpostor): void;
  57392. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57393. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57394. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57395. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57396. getRadius(impostor: PhysicsImpostor): number;
  57397. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57398. dispose(): void;
  57399. /**
  57400. * Does a raycast in the physics world
  57401. * @param from when should the ray start?
  57402. * @param to when should the ray end?
  57403. * @returns PhysicsRaycastResult
  57404. */
  57405. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57406. }
  57407. }
  57408. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57409. import { Nullable } from "babylonjs/types";
  57410. import { Scene } from "babylonjs/scene";
  57411. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57412. import { Color4 } from "babylonjs/Maths/math.color";
  57413. import { Mesh } from "babylonjs/Meshes/mesh";
  57414. /**
  57415. * Class containing static functions to help procedurally build meshes
  57416. */
  57417. export class RibbonBuilder {
  57418. /**
  57419. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57420. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57421. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57422. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57423. * * 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
  57424. * * 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
  57425. * * 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
  57426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57429. * * 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
  57430. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57431. * * 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
  57432. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57434. * @param name defines the name of the mesh
  57435. * @param options defines the options used to create the mesh
  57436. * @param scene defines the hosting scene
  57437. * @returns the ribbon mesh
  57438. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57440. */
  57441. static CreateRibbon(name: string, options: {
  57442. pathArray: Vector3[][];
  57443. closeArray?: boolean;
  57444. closePath?: boolean;
  57445. offset?: number;
  57446. updatable?: boolean;
  57447. sideOrientation?: number;
  57448. frontUVs?: Vector4;
  57449. backUVs?: Vector4;
  57450. instance?: Mesh;
  57451. invertUV?: boolean;
  57452. uvs?: Vector2[];
  57453. colors?: Color4[];
  57454. }, scene?: Nullable<Scene>): Mesh;
  57455. }
  57456. }
  57457. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57458. import { Nullable } from "babylonjs/types";
  57459. import { Scene } from "babylonjs/scene";
  57460. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57461. import { Mesh } from "babylonjs/Meshes/mesh";
  57462. /**
  57463. * Class containing static functions to help procedurally build meshes
  57464. */
  57465. export class ShapeBuilder {
  57466. /**
  57467. * 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.
  57468. * * 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.
  57469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57470. * * 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.
  57471. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57472. * * 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
  57473. * * 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
  57474. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57479. * @param name defines the name of the mesh
  57480. * @param options defines the options used to create the mesh
  57481. * @param scene defines the hosting scene
  57482. * @returns the extruded shape mesh
  57483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57485. */
  57486. static ExtrudeShape(name: string, options: {
  57487. shape: Vector3[];
  57488. path: Vector3[];
  57489. scale?: number;
  57490. rotation?: number;
  57491. cap?: number;
  57492. updatable?: boolean;
  57493. sideOrientation?: number;
  57494. frontUVs?: Vector4;
  57495. backUVs?: Vector4;
  57496. instance?: Mesh;
  57497. invertUV?: boolean;
  57498. }, scene?: Nullable<Scene>): Mesh;
  57499. /**
  57500. * Creates an custom extruded shape mesh.
  57501. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57502. * * 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.
  57503. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57504. * * 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
  57505. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57506. * * 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
  57507. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57508. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57509. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57510. * * 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
  57511. * * 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
  57512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57517. * @param name defines the name of the mesh
  57518. * @param options defines the options used to create the mesh
  57519. * @param scene defines the hosting scene
  57520. * @returns the custom extruded shape mesh
  57521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57524. */
  57525. static ExtrudeShapeCustom(name: string, options: {
  57526. shape: Vector3[];
  57527. path: Vector3[];
  57528. scaleFunction?: any;
  57529. rotationFunction?: any;
  57530. ribbonCloseArray?: boolean;
  57531. ribbonClosePath?: boolean;
  57532. cap?: number;
  57533. updatable?: boolean;
  57534. sideOrientation?: number;
  57535. frontUVs?: Vector4;
  57536. backUVs?: Vector4;
  57537. instance?: Mesh;
  57538. invertUV?: boolean;
  57539. }, scene?: Nullable<Scene>): Mesh;
  57540. private static _ExtrudeShapeGeneric;
  57541. }
  57542. }
  57543. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57544. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57545. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57546. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57547. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57548. import { Nullable } from "babylonjs/types";
  57549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57550. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57551. /**
  57552. * AmmoJS Physics plugin
  57553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57554. * @see https://github.com/kripken/ammo.js/
  57555. */
  57556. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57557. private _useDeltaForWorldStep;
  57558. /**
  57559. * Reference to the Ammo library
  57560. */
  57561. bjsAMMO: any;
  57562. /**
  57563. * Created ammoJS world which physics bodies are added to
  57564. */
  57565. world: any;
  57566. /**
  57567. * Name of the plugin
  57568. */
  57569. name: string;
  57570. private _timeStep;
  57571. private _fixedTimeStep;
  57572. private _maxSteps;
  57573. private _tmpQuaternion;
  57574. private _tmpAmmoTransform;
  57575. private _tmpAmmoQuaternion;
  57576. private _tmpAmmoConcreteContactResultCallback;
  57577. private _collisionConfiguration;
  57578. private _dispatcher;
  57579. private _overlappingPairCache;
  57580. private _solver;
  57581. private _softBodySolver;
  57582. private _tmpAmmoVectorA;
  57583. private _tmpAmmoVectorB;
  57584. private _tmpAmmoVectorC;
  57585. private _tmpAmmoVectorD;
  57586. private _tmpContactCallbackResult;
  57587. private _tmpAmmoVectorRCA;
  57588. private _tmpAmmoVectorRCB;
  57589. private _raycastResult;
  57590. private static readonly DISABLE_COLLISION_FLAG;
  57591. private static readonly KINEMATIC_FLAG;
  57592. private static readonly DISABLE_DEACTIVATION_FLAG;
  57593. /**
  57594. * Initializes the ammoJS plugin
  57595. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57596. * @param ammoInjection can be used to inject your own ammo reference
  57597. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57598. */
  57599. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57600. /**
  57601. * Sets the gravity of the physics world (m/(s^2))
  57602. * @param gravity Gravity to set
  57603. */
  57604. setGravity(gravity: Vector3): void;
  57605. /**
  57606. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57607. * @param timeStep timestep to use in seconds
  57608. */
  57609. setTimeStep(timeStep: number): void;
  57610. /**
  57611. * 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)
  57612. * @param fixedTimeStep fixedTimeStep to use in seconds
  57613. */
  57614. setFixedTimeStep(fixedTimeStep: number): void;
  57615. /**
  57616. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57617. * @param maxSteps the maximum number of steps by the physics engine per frame
  57618. */
  57619. setMaxSteps(maxSteps: number): void;
  57620. /**
  57621. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57622. * @returns the current timestep in seconds
  57623. */
  57624. getTimeStep(): number;
  57625. /**
  57626. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57627. */
  57628. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57629. private _isImpostorInContact;
  57630. private _isImpostorPairInContact;
  57631. private _stepSimulation;
  57632. /**
  57633. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57634. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57635. * After the step the babylon meshes are set to the position of the physics imposters
  57636. * @param delta amount of time to step forward
  57637. * @param impostors array of imposters to update before/after the step
  57638. */
  57639. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57640. /**
  57641. * Update babylon mesh to match physics world object
  57642. * @param impostor imposter to match
  57643. */
  57644. private _afterSoftStep;
  57645. /**
  57646. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57647. * @param impostor imposter to match
  57648. */
  57649. private _ropeStep;
  57650. /**
  57651. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57652. * @param impostor imposter to match
  57653. */
  57654. private _softbodyOrClothStep;
  57655. private _tmpVector;
  57656. private _tmpMatrix;
  57657. /**
  57658. * Applies an impulse on the imposter
  57659. * @param impostor imposter to apply impulse to
  57660. * @param force amount of force to be applied to the imposter
  57661. * @param contactPoint the location to apply the impulse on the imposter
  57662. */
  57663. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57664. /**
  57665. * Applies a force on the imposter
  57666. * @param impostor imposter to apply force
  57667. * @param force amount of force to be applied to the imposter
  57668. * @param contactPoint the location to apply the force on the imposter
  57669. */
  57670. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57671. /**
  57672. * Creates a physics body using the plugin
  57673. * @param impostor the imposter to create the physics body on
  57674. */
  57675. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57676. /**
  57677. * Removes the physics body from the imposter and disposes of the body's memory
  57678. * @param impostor imposter to remove the physics body from
  57679. */
  57680. removePhysicsBody(impostor: PhysicsImpostor): void;
  57681. /**
  57682. * Generates a joint
  57683. * @param impostorJoint the imposter joint to create the joint with
  57684. */
  57685. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57686. /**
  57687. * Removes a joint
  57688. * @param impostorJoint the imposter joint to remove the joint from
  57689. */
  57690. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57691. private _addMeshVerts;
  57692. /**
  57693. * Initialise the soft body vertices to match its object's (mesh) vertices
  57694. * Softbody vertices (nodes) are in world space and to match this
  57695. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57696. * @param impostor to create the softbody for
  57697. */
  57698. private _softVertexData;
  57699. /**
  57700. * Create an impostor's soft body
  57701. * @param impostor to create the softbody for
  57702. */
  57703. private _createSoftbody;
  57704. /**
  57705. * Create cloth for an impostor
  57706. * @param impostor to create the softbody for
  57707. */
  57708. private _createCloth;
  57709. /**
  57710. * Create rope for an impostor
  57711. * @param impostor to create the softbody for
  57712. */
  57713. private _createRope;
  57714. /**
  57715. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57716. * @param impostor to create the custom physics shape for
  57717. */
  57718. private _createCustom;
  57719. private _addHullVerts;
  57720. private _createShape;
  57721. /**
  57722. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57723. * @param impostor imposter containing the physics body and babylon object
  57724. */
  57725. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57726. /**
  57727. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57728. * @param impostor imposter containing the physics body and babylon object
  57729. * @param newPosition new position
  57730. * @param newRotation new rotation
  57731. */
  57732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57733. /**
  57734. * If this plugin is supported
  57735. * @returns true if its supported
  57736. */
  57737. isSupported(): boolean;
  57738. /**
  57739. * Sets the linear velocity of the physics body
  57740. * @param impostor imposter to set the velocity on
  57741. * @param velocity velocity to set
  57742. */
  57743. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57744. /**
  57745. * Sets the angular velocity of the physics body
  57746. * @param impostor imposter to set the velocity on
  57747. * @param velocity velocity to set
  57748. */
  57749. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57750. /**
  57751. * gets the linear velocity
  57752. * @param impostor imposter to get linear velocity from
  57753. * @returns linear velocity
  57754. */
  57755. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57756. /**
  57757. * gets the angular velocity
  57758. * @param impostor imposter to get angular velocity from
  57759. * @returns angular velocity
  57760. */
  57761. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57762. /**
  57763. * Sets the mass of physics body
  57764. * @param impostor imposter to set the mass on
  57765. * @param mass mass to set
  57766. */
  57767. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57768. /**
  57769. * Gets the mass of the physics body
  57770. * @param impostor imposter to get the mass from
  57771. * @returns mass
  57772. */
  57773. getBodyMass(impostor: PhysicsImpostor): number;
  57774. /**
  57775. * Gets friction of the impostor
  57776. * @param impostor impostor to get friction from
  57777. * @returns friction value
  57778. */
  57779. getBodyFriction(impostor: PhysicsImpostor): number;
  57780. /**
  57781. * Sets friction of the impostor
  57782. * @param impostor impostor to set friction on
  57783. * @param friction friction value
  57784. */
  57785. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57786. /**
  57787. * Gets restitution of the impostor
  57788. * @param impostor impostor to get restitution from
  57789. * @returns restitution value
  57790. */
  57791. getBodyRestitution(impostor: PhysicsImpostor): number;
  57792. /**
  57793. * Sets resitution of the impostor
  57794. * @param impostor impostor to set resitution on
  57795. * @param restitution resitution value
  57796. */
  57797. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57798. /**
  57799. * Gets pressure inside the impostor
  57800. * @param impostor impostor to get pressure from
  57801. * @returns pressure value
  57802. */
  57803. getBodyPressure(impostor: PhysicsImpostor): number;
  57804. /**
  57805. * Sets pressure inside a soft body impostor
  57806. * Cloth and rope must remain 0 pressure
  57807. * @param impostor impostor to set pressure on
  57808. * @param pressure pressure value
  57809. */
  57810. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57811. /**
  57812. * Gets stiffness of the impostor
  57813. * @param impostor impostor to get stiffness from
  57814. * @returns pressure value
  57815. */
  57816. getBodyStiffness(impostor: PhysicsImpostor): number;
  57817. /**
  57818. * Sets stiffness of the impostor
  57819. * @param impostor impostor to set stiffness on
  57820. * @param stiffness stiffness value from 0 to 1
  57821. */
  57822. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57823. /**
  57824. * Gets velocityIterations of the impostor
  57825. * @param impostor impostor to get velocity iterations from
  57826. * @returns velocityIterations value
  57827. */
  57828. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57829. /**
  57830. * Sets velocityIterations of the impostor
  57831. * @param impostor impostor to set velocity iterations on
  57832. * @param velocityIterations velocityIterations value
  57833. */
  57834. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57835. /**
  57836. * Gets positionIterations of the impostor
  57837. * @param impostor impostor to get position iterations from
  57838. * @returns positionIterations value
  57839. */
  57840. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57841. /**
  57842. * Sets positionIterations of the impostor
  57843. * @param impostor impostor to set position on
  57844. * @param positionIterations positionIterations value
  57845. */
  57846. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57847. /**
  57848. * Append an anchor to a cloth object
  57849. * @param impostor is the cloth impostor to add anchor to
  57850. * @param otherImpostor is the rigid impostor to anchor to
  57851. * @param width ratio across width from 0 to 1
  57852. * @param height ratio up height from 0 to 1
  57853. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57854. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57855. */
  57856. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57857. /**
  57858. * Append an hook to a rope object
  57859. * @param impostor is the rope impostor to add hook to
  57860. * @param otherImpostor is the rigid impostor to hook to
  57861. * @param length ratio along the rope from 0 to 1
  57862. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57863. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57864. */
  57865. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57866. /**
  57867. * Sleeps the physics body and stops it from being active
  57868. * @param impostor impostor to sleep
  57869. */
  57870. sleepBody(impostor: PhysicsImpostor): void;
  57871. /**
  57872. * Activates the physics body
  57873. * @param impostor impostor to activate
  57874. */
  57875. wakeUpBody(impostor: PhysicsImpostor): void;
  57876. /**
  57877. * Updates the distance parameters of the joint
  57878. * @param joint joint to update
  57879. * @param maxDistance maximum distance of the joint
  57880. * @param minDistance minimum distance of the joint
  57881. */
  57882. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57883. /**
  57884. * Sets a motor on the joint
  57885. * @param joint joint to set motor on
  57886. * @param speed speed of the motor
  57887. * @param maxForce maximum force of the motor
  57888. * @param motorIndex index of the motor
  57889. */
  57890. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57891. /**
  57892. * Sets the motors limit
  57893. * @param joint joint to set limit on
  57894. * @param upperLimit upper limit
  57895. * @param lowerLimit lower limit
  57896. */
  57897. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57898. /**
  57899. * Syncs the position and rotation of a mesh with the impostor
  57900. * @param mesh mesh to sync
  57901. * @param impostor impostor to update the mesh with
  57902. */
  57903. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57904. /**
  57905. * Gets the radius of the impostor
  57906. * @param impostor impostor to get radius from
  57907. * @returns the radius
  57908. */
  57909. getRadius(impostor: PhysicsImpostor): number;
  57910. /**
  57911. * Gets the box size of the impostor
  57912. * @param impostor impostor to get box size from
  57913. * @param result the resulting box size
  57914. */
  57915. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57916. /**
  57917. * Disposes of the impostor
  57918. */
  57919. dispose(): void;
  57920. /**
  57921. * Does a raycast in the physics world
  57922. * @param from when should the ray start?
  57923. * @param to when should the ray end?
  57924. * @returns PhysicsRaycastResult
  57925. */
  57926. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57927. }
  57928. }
  57929. declare module "babylonjs/Probes/reflectionProbe" {
  57930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57931. import { Vector3 } from "babylonjs/Maths/math.vector";
  57932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57933. import { Nullable } from "babylonjs/types";
  57934. import { Scene } from "babylonjs/scene";
  57935. module "babylonjs/abstractScene" {
  57936. interface AbstractScene {
  57937. /**
  57938. * The list of reflection probes added to the scene
  57939. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57940. */
  57941. reflectionProbes: Array<ReflectionProbe>;
  57942. /**
  57943. * Removes the given reflection probe from this scene.
  57944. * @param toRemove The reflection probe to remove
  57945. * @returns The index of the removed reflection probe
  57946. */
  57947. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57948. /**
  57949. * Adds the given reflection probe to this scene.
  57950. * @param newReflectionProbe The reflection probe to add
  57951. */
  57952. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57953. }
  57954. }
  57955. /**
  57956. * Class used to generate realtime reflection / refraction cube textures
  57957. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57958. */
  57959. export class ReflectionProbe {
  57960. /** defines the name of the probe */
  57961. name: string;
  57962. private _scene;
  57963. private _renderTargetTexture;
  57964. private _projectionMatrix;
  57965. private _viewMatrix;
  57966. private _target;
  57967. private _add;
  57968. private _attachedMesh;
  57969. private _invertYAxis;
  57970. /** Gets or sets probe position (center of the cube map) */
  57971. position: Vector3;
  57972. /**
  57973. * Creates a new reflection probe
  57974. * @param name defines the name of the probe
  57975. * @param size defines the texture resolution (for each face)
  57976. * @param scene defines the hosting scene
  57977. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57978. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57979. */
  57980. constructor(
  57981. /** defines the name of the probe */
  57982. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57983. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57984. get samples(): number;
  57985. set samples(value: number);
  57986. /** Gets or sets the refresh rate to use (on every frame by default) */
  57987. get refreshRate(): number;
  57988. set refreshRate(value: number);
  57989. /**
  57990. * Gets the hosting scene
  57991. * @returns a Scene
  57992. */
  57993. getScene(): Scene;
  57994. /** Gets the internal CubeTexture used to render to */
  57995. get cubeTexture(): RenderTargetTexture;
  57996. /** Gets the list of meshes to render */
  57997. get renderList(): Nullable<AbstractMesh[]>;
  57998. /**
  57999. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58000. * @param mesh defines the mesh to attach to
  58001. */
  58002. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58003. /**
  58004. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58005. * @param renderingGroupId The rendering group id corresponding to its index
  58006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58007. */
  58008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58009. /**
  58010. * Clean all associated resources
  58011. */
  58012. dispose(): void;
  58013. /**
  58014. * Converts the reflection probe information to a readable string for debug purpose.
  58015. * @param fullDetails Supports for multiple levels of logging within scene loading
  58016. * @returns the human readable reflection probe info
  58017. */
  58018. toString(fullDetails?: boolean): string;
  58019. /**
  58020. * Get the class name of the relfection probe.
  58021. * @returns "ReflectionProbe"
  58022. */
  58023. getClassName(): string;
  58024. /**
  58025. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58026. * @returns The JSON representation of the texture
  58027. */
  58028. serialize(): any;
  58029. /**
  58030. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58031. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58032. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58033. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58034. * @returns The parsed reflection probe if successful
  58035. */
  58036. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58037. }
  58038. }
  58039. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58040. /** @hidden */
  58041. export var _BabylonLoaderRegistered: boolean;
  58042. /**
  58043. * Helps setting up some configuration for the babylon file loader.
  58044. */
  58045. export class BabylonFileLoaderConfiguration {
  58046. /**
  58047. * The loader does not allow injecting custom physix engine into the plugins.
  58048. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58049. * So you could set this variable to your engine import to make it work.
  58050. */
  58051. static LoaderInjectedPhysicsEngine: any;
  58052. }
  58053. }
  58054. declare module "babylonjs/Loading/Plugins/index" {
  58055. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58056. }
  58057. declare module "babylonjs/Loading/index" {
  58058. export * from "babylonjs/Loading/loadingScreen";
  58059. export * from "babylonjs/Loading/Plugins/index";
  58060. export * from "babylonjs/Loading/sceneLoader";
  58061. export * from "babylonjs/Loading/sceneLoaderFlags";
  58062. }
  58063. declare module "babylonjs/Materials/Background/index" {
  58064. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58065. }
  58066. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58067. import { Scene } from "babylonjs/scene";
  58068. import { Color3 } from "babylonjs/Maths/math.color";
  58069. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58071. /**
  58072. * The Physically based simple base material of BJS.
  58073. *
  58074. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58075. * It is used as the base class for both the specGloss and metalRough conventions.
  58076. */
  58077. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58078. /**
  58079. * Number of Simultaneous lights allowed on the material.
  58080. */
  58081. maxSimultaneousLights: number;
  58082. /**
  58083. * If sets to true, disables all the lights affecting the material.
  58084. */
  58085. disableLighting: boolean;
  58086. /**
  58087. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58088. */
  58089. environmentTexture: BaseTexture;
  58090. /**
  58091. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58092. */
  58093. invertNormalMapX: boolean;
  58094. /**
  58095. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58096. */
  58097. invertNormalMapY: boolean;
  58098. /**
  58099. * Normal map used in the model.
  58100. */
  58101. normalTexture: BaseTexture;
  58102. /**
  58103. * Emissivie color used to self-illuminate the model.
  58104. */
  58105. emissiveColor: Color3;
  58106. /**
  58107. * Emissivie texture used to self-illuminate the model.
  58108. */
  58109. emissiveTexture: BaseTexture;
  58110. /**
  58111. * Occlusion Channel Strenght.
  58112. */
  58113. occlusionStrength: number;
  58114. /**
  58115. * Occlusion Texture of the material (adding extra occlusion effects).
  58116. */
  58117. occlusionTexture: BaseTexture;
  58118. /**
  58119. * Defines the alpha limits in alpha test mode.
  58120. */
  58121. alphaCutOff: number;
  58122. /**
  58123. * Gets the current double sided mode.
  58124. */
  58125. get doubleSided(): boolean;
  58126. /**
  58127. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58128. */
  58129. set doubleSided(value: boolean);
  58130. /**
  58131. * Stores the pre-calculated light information of a mesh in a texture.
  58132. */
  58133. lightmapTexture: BaseTexture;
  58134. /**
  58135. * If true, the light map contains occlusion information instead of lighting info.
  58136. */
  58137. useLightmapAsShadowmap: boolean;
  58138. /**
  58139. * Instantiates a new PBRMaterial instance.
  58140. *
  58141. * @param name The material name
  58142. * @param scene The scene the material will be use in.
  58143. */
  58144. constructor(name: string, scene: Scene);
  58145. getClassName(): string;
  58146. }
  58147. }
  58148. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58149. import { Scene } from "babylonjs/scene";
  58150. import { Color3 } from "babylonjs/Maths/math.color";
  58151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58152. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58153. /**
  58154. * The PBR material of BJS following the metal roughness convention.
  58155. *
  58156. * This fits to the PBR convention in the GLTF definition:
  58157. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58158. */
  58159. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58160. /**
  58161. * The base color has two different interpretations depending on the value of metalness.
  58162. * When the material is a metal, the base color is the specific measured reflectance value
  58163. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58164. * of the material.
  58165. */
  58166. baseColor: Color3;
  58167. /**
  58168. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58169. * well as opacity information in the alpha channel.
  58170. */
  58171. baseTexture: BaseTexture;
  58172. /**
  58173. * Specifies the metallic scalar value of the material.
  58174. * Can also be used to scale the metalness values of the metallic texture.
  58175. */
  58176. metallic: number;
  58177. /**
  58178. * Specifies the roughness scalar value of the material.
  58179. * Can also be used to scale the roughness values of the metallic texture.
  58180. */
  58181. roughness: number;
  58182. /**
  58183. * Texture containing both the metallic value in the B channel and the
  58184. * roughness value in the G channel to keep better precision.
  58185. */
  58186. metallicRoughnessTexture: BaseTexture;
  58187. /**
  58188. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58189. *
  58190. * @param name The material name
  58191. * @param scene The scene the material will be use in.
  58192. */
  58193. constructor(name: string, scene: Scene);
  58194. /**
  58195. * Return the currrent class name of the material.
  58196. */
  58197. getClassName(): string;
  58198. /**
  58199. * Makes a duplicate of the current material.
  58200. * @param name - name to use for the new material.
  58201. */
  58202. clone(name: string): PBRMetallicRoughnessMaterial;
  58203. /**
  58204. * Serialize the material to a parsable JSON object.
  58205. */
  58206. serialize(): any;
  58207. /**
  58208. * Parses a JSON object correponding to the serialize function.
  58209. */
  58210. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58211. }
  58212. }
  58213. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58214. import { Scene } from "babylonjs/scene";
  58215. import { Color3 } from "babylonjs/Maths/math.color";
  58216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58217. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58218. /**
  58219. * The PBR material of BJS following the specular glossiness convention.
  58220. *
  58221. * This fits to the PBR convention in the GLTF definition:
  58222. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58223. */
  58224. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58225. /**
  58226. * Specifies the diffuse color of the material.
  58227. */
  58228. diffuseColor: Color3;
  58229. /**
  58230. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58231. * channel.
  58232. */
  58233. diffuseTexture: BaseTexture;
  58234. /**
  58235. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58236. */
  58237. specularColor: Color3;
  58238. /**
  58239. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58240. */
  58241. glossiness: number;
  58242. /**
  58243. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58244. */
  58245. specularGlossinessTexture: BaseTexture;
  58246. /**
  58247. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58248. *
  58249. * @param name The material name
  58250. * @param scene The scene the material will be use in.
  58251. */
  58252. constructor(name: string, scene: Scene);
  58253. /**
  58254. * Return the currrent class name of the material.
  58255. */
  58256. getClassName(): string;
  58257. /**
  58258. * Makes a duplicate of the current material.
  58259. * @param name - name to use for the new material.
  58260. */
  58261. clone(name: string): PBRSpecularGlossinessMaterial;
  58262. /**
  58263. * Serialize the material to a parsable JSON object.
  58264. */
  58265. serialize(): any;
  58266. /**
  58267. * Parses a JSON object correponding to the serialize function.
  58268. */
  58269. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58270. }
  58271. }
  58272. declare module "babylonjs/Materials/PBR/index" {
  58273. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58274. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58275. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58276. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58277. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58278. }
  58279. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58280. import { Nullable } from "babylonjs/types";
  58281. import { Scene } from "babylonjs/scene";
  58282. import { Matrix } from "babylonjs/Maths/math.vector";
  58283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58284. /**
  58285. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58286. * It can help converting any input color in a desired output one. This can then be used to create effects
  58287. * from sepia, black and white to sixties or futuristic rendering...
  58288. *
  58289. * The only supported format is currently 3dl.
  58290. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58291. */
  58292. export class ColorGradingTexture extends BaseTexture {
  58293. /**
  58294. * The current texture matrix. (will always be identity in color grading texture)
  58295. */
  58296. private _textureMatrix;
  58297. /**
  58298. * The texture URL.
  58299. */
  58300. url: string;
  58301. /**
  58302. * Empty line regex stored for GC.
  58303. */
  58304. private static _noneEmptyLineRegex;
  58305. private _engine;
  58306. /**
  58307. * Instantiates a ColorGradingTexture from the following parameters.
  58308. *
  58309. * @param url The location of the color gradind data (currently only supporting 3dl)
  58310. * @param scene The scene the texture will be used in
  58311. */
  58312. constructor(url: string, scene: Scene);
  58313. /**
  58314. * Returns the texture matrix used in most of the material.
  58315. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58316. */
  58317. getTextureMatrix(): Matrix;
  58318. /**
  58319. * Occurs when the file being loaded is a .3dl LUT file.
  58320. */
  58321. private load3dlTexture;
  58322. /**
  58323. * Starts the loading process of the texture.
  58324. */
  58325. private loadTexture;
  58326. /**
  58327. * Clones the color gradind texture.
  58328. */
  58329. clone(): ColorGradingTexture;
  58330. /**
  58331. * Called during delayed load for textures.
  58332. */
  58333. delayLoad(): void;
  58334. /**
  58335. * Parses a color grading texture serialized by Babylon.
  58336. * @param parsedTexture The texture information being parsedTexture
  58337. * @param scene The scene to load the texture in
  58338. * @param rootUrl The root url of the data assets to load
  58339. * @return A color gradind texture
  58340. */
  58341. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58342. /**
  58343. * Serializes the LUT texture to json format.
  58344. */
  58345. serialize(): any;
  58346. }
  58347. }
  58348. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58350. import { Scene } from "babylonjs/scene";
  58351. import { Nullable } from "babylonjs/types";
  58352. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58353. /**
  58354. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58355. */
  58356. export class EquiRectangularCubeTexture extends BaseTexture {
  58357. /** The six faces of the cube. */
  58358. private static _FacesMapping;
  58359. private _noMipmap;
  58360. private _onLoad;
  58361. private _onError;
  58362. /** The size of the cubemap. */
  58363. private _size;
  58364. /** The buffer of the image. */
  58365. private _buffer;
  58366. /** The width of the input image. */
  58367. private _width;
  58368. /** The height of the input image. */
  58369. private _height;
  58370. /** The URL to the image. */
  58371. url: string;
  58372. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58373. coordinatesMode: number;
  58374. /**
  58375. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58376. * @param url The location of the image
  58377. * @param scene The scene the texture will be used in
  58378. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58379. * @param noMipmap Forces to not generate the mipmap if true
  58380. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58381. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58382. * @param onLoad — defines a callback called when texture is loaded
  58383. * @param onError — defines a callback called if there is an error
  58384. */
  58385. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58386. /**
  58387. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58388. */
  58389. private loadImage;
  58390. /**
  58391. * Convert the image buffer into a cubemap and create a CubeTexture.
  58392. */
  58393. private loadTexture;
  58394. /**
  58395. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58396. * @param buffer The ArrayBuffer that should be converted.
  58397. * @returns The buffer as Float32Array.
  58398. */
  58399. private getFloat32ArrayFromArrayBuffer;
  58400. /**
  58401. * Get the current class name of the texture useful for serialization or dynamic coding.
  58402. * @returns "EquiRectangularCubeTexture"
  58403. */
  58404. getClassName(): string;
  58405. /**
  58406. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58407. * @returns A clone of the current EquiRectangularCubeTexture.
  58408. */
  58409. clone(): EquiRectangularCubeTexture;
  58410. }
  58411. }
  58412. declare module "babylonjs/Misc/tga" {
  58413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58414. /**
  58415. * Based on jsTGALoader - Javascript loader for TGA file
  58416. * By Vincent Thibault
  58417. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58418. */
  58419. export class TGATools {
  58420. private static _TYPE_INDEXED;
  58421. private static _TYPE_RGB;
  58422. private static _TYPE_GREY;
  58423. private static _TYPE_RLE_INDEXED;
  58424. private static _TYPE_RLE_RGB;
  58425. private static _TYPE_RLE_GREY;
  58426. private static _ORIGIN_MASK;
  58427. private static _ORIGIN_SHIFT;
  58428. private static _ORIGIN_BL;
  58429. private static _ORIGIN_BR;
  58430. private static _ORIGIN_UL;
  58431. private static _ORIGIN_UR;
  58432. /**
  58433. * Gets the header of a TGA file
  58434. * @param data defines the TGA data
  58435. * @returns the header
  58436. */
  58437. static GetTGAHeader(data: Uint8Array): any;
  58438. /**
  58439. * Uploads TGA content to a Babylon Texture
  58440. * @hidden
  58441. */
  58442. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58443. /** @hidden */
  58444. 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;
  58445. /** @hidden */
  58446. 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;
  58447. /** @hidden */
  58448. 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;
  58449. /** @hidden */
  58450. 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;
  58451. /** @hidden */
  58452. 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;
  58453. /** @hidden */
  58454. 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;
  58455. }
  58456. }
  58457. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58458. import { Nullable } from "babylonjs/types";
  58459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58460. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58461. /**
  58462. * Implementation of the TGA Texture Loader.
  58463. * @hidden
  58464. */
  58465. export class _TGATextureLoader implements IInternalTextureLoader {
  58466. /**
  58467. * Defines wether the loader supports cascade loading the different faces.
  58468. */
  58469. readonly supportCascades: boolean;
  58470. /**
  58471. * This returns if the loader support the current file information.
  58472. * @param extension defines the file extension of the file being loaded
  58473. * @returns true if the loader can load the specified file
  58474. */
  58475. canLoad(extension: string): boolean;
  58476. /**
  58477. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58478. * @param data contains the texture data
  58479. * @param texture defines the BabylonJS internal texture
  58480. * @param createPolynomials will be true if polynomials have been requested
  58481. * @param onLoad defines the callback to trigger once the texture is ready
  58482. * @param onError defines the callback to trigger in case of error
  58483. */
  58484. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58485. /**
  58486. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58487. * @param data contains the texture data
  58488. * @param texture defines the BabylonJS internal texture
  58489. * @param callback defines the method to call once ready to upload
  58490. */
  58491. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58492. }
  58493. }
  58494. declare module "babylonjs/Misc/basis" {
  58495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58496. /**
  58497. * Info about the .basis files
  58498. */
  58499. class BasisFileInfo {
  58500. /**
  58501. * If the file has alpha
  58502. */
  58503. hasAlpha: boolean;
  58504. /**
  58505. * Info about each image of the basis file
  58506. */
  58507. images: Array<{
  58508. levels: Array<{
  58509. width: number;
  58510. height: number;
  58511. transcodedPixels: ArrayBufferView;
  58512. }>;
  58513. }>;
  58514. }
  58515. /**
  58516. * Result of transcoding a basis file
  58517. */
  58518. class TranscodeResult {
  58519. /**
  58520. * Info about the .basis file
  58521. */
  58522. fileInfo: BasisFileInfo;
  58523. /**
  58524. * Format to use when loading the file
  58525. */
  58526. format: number;
  58527. }
  58528. /**
  58529. * Configuration options for the Basis transcoder
  58530. */
  58531. export class BasisTranscodeConfiguration {
  58532. /**
  58533. * Supported compression formats used to determine the supported output format of the transcoder
  58534. */
  58535. supportedCompressionFormats?: {
  58536. /**
  58537. * etc1 compression format
  58538. */
  58539. etc1?: boolean;
  58540. /**
  58541. * s3tc compression format
  58542. */
  58543. s3tc?: boolean;
  58544. /**
  58545. * pvrtc compression format
  58546. */
  58547. pvrtc?: boolean;
  58548. /**
  58549. * etc2 compression format
  58550. */
  58551. etc2?: boolean;
  58552. };
  58553. /**
  58554. * If mipmap levels should be loaded for transcoded images (Default: true)
  58555. */
  58556. loadMipmapLevels?: boolean;
  58557. /**
  58558. * Index of a single image to load (Default: all images)
  58559. */
  58560. loadSingleImage?: number;
  58561. }
  58562. /**
  58563. * Used to load .Basis files
  58564. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58565. */
  58566. export class BasisTools {
  58567. private static _IgnoreSupportedFormats;
  58568. /**
  58569. * URL to use when loading the basis transcoder
  58570. */
  58571. static JSModuleURL: string;
  58572. /**
  58573. * URL to use when loading the wasm module for the transcoder
  58574. */
  58575. static WasmModuleURL: string;
  58576. /**
  58577. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58578. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58579. * @returns internal format corresponding to the Basis format
  58580. */
  58581. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58582. private static _WorkerPromise;
  58583. private static _Worker;
  58584. private static _actionId;
  58585. private static _CreateWorkerAsync;
  58586. /**
  58587. * Transcodes a loaded image file to compressed pixel data
  58588. * @param data image data to transcode
  58589. * @param config configuration options for the transcoding
  58590. * @returns a promise resulting in the transcoded image
  58591. */
  58592. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58593. /**
  58594. * Loads a texture from the transcode result
  58595. * @param texture texture load to
  58596. * @param transcodeResult the result of transcoding the basis file to load from
  58597. */
  58598. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58599. }
  58600. }
  58601. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58602. import { Nullable } from "babylonjs/types";
  58603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58605. /**
  58606. * Loader for .basis file format
  58607. */
  58608. export class _BasisTextureLoader implements IInternalTextureLoader {
  58609. /**
  58610. * Defines whether the loader supports cascade loading the different faces.
  58611. */
  58612. readonly supportCascades: boolean;
  58613. /**
  58614. * This returns if the loader support the current file information.
  58615. * @param extension defines the file extension of the file being loaded
  58616. * @returns true if the loader can load the specified file
  58617. */
  58618. canLoad(extension: string): boolean;
  58619. /**
  58620. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58621. * @param data contains the texture data
  58622. * @param texture defines the BabylonJS internal texture
  58623. * @param createPolynomials will be true if polynomials have been requested
  58624. * @param onLoad defines the callback to trigger once the texture is ready
  58625. * @param onError defines the callback to trigger in case of error
  58626. */
  58627. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58628. /**
  58629. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58630. * @param data contains the texture data
  58631. * @param texture defines the BabylonJS internal texture
  58632. * @param callback defines the method to call once ready to upload
  58633. */
  58634. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58635. }
  58636. }
  58637. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58638. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58639. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58640. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58641. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58642. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58643. }
  58644. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58645. import { Scene } from "babylonjs/scene";
  58646. import { Texture } from "babylonjs/Materials/Textures/texture";
  58647. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58648. /**
  58649. * 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.
  58650. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58651. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58652. */
  58653. export class CustomProceduralTexture extends ProceduralTexture {
  58654. private _animate;
  58655. private _time;
  58656. private _config;
  58657. private _texturePath;
  58658. /**
  58659. * Instantiates a new Custom Procedural Texture.
  58660. * 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.
  58661. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58662. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58663. * @param name Define the name of the texture
  58664. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58665. * @param size Define the size of the texture to create
  58666. * @param scene Define the scene the texture belongs to
  58667. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58668. * @param generateMipMaps Define if the texture should creates mip maps or not
  58669. */
  58670. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58671. private _loadJson;
  58672. /**
  58673. * Is the texture ready to be used ? (rendered at least once)
  58674. * @returns true if ready, otherwise, false.
  58675. */
  58676. isReady(): boolean;
  58677. /**
  58678. * Render the texture to its associated render target.
  58679. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58680. */
  58681. render(useCameraPostProcess?: boolean): void;
  58682. /**
  58683. * Update the list of dependant textures samplers in the shader.
  58684. */
  58685. updateTextures(): void;
  58686. /**
  58687. * Update the uniform values of the procedural texture in the shader.
  58688. */
  58689. updateShaderUniforms(): void;
  58690. /**
  58691. * Define if the texture animates or not.
  58692. */
  58693. get animate(): boolean;
  58694. set animate(value: boolean);
  58695. }
  58696. }
  58697. declare module "babylonjs/Shaders/noise.fragment" {
  58698. /** @hidden */
  58699. export var noisePixelShader: {
  58700. name: string;
  58701. shader: string;
  58702. };
  58703. }
  58704. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58705. import { Nullable } from "babylonjs/types";
  58706. import { Scene } from "babylonjs/scene";
  58707. import { Texture } from "babylonjs/Materials/Textures/texture";
  58708. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58709. import "babylonjs/Shaders/noise.fragment";
  58710. /**
  58711. * Class used to generate noise procedural textures
  58712. */
  58713. export class NoiseProceduralTexture extends ProceduralTexture {
  58714. private _time;
  58715. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58716. brightness: number;
  58717. /** Defines the number of octaves to process */
  58718. octaves: number;
  58719. /** Defines the level of persistence (0.8 by default) */
  58720. persistence: number;
  58721. /** Gets or sets animation speed factor (default is 1) */
  58722. animationSpeedFactor: number;
  58723. /**
  58724. * Creates a new NoiseProceduralTexture
  58725. * @param name defines the name fo the texture
  58726. * @param size defines the size of the texture (default is 256)
  58727. * @param scene defines the hosting scene
  58728. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58729. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58730. */
  58731. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58732. private _updateShaderUniforms;
  58733. protected _getDefines(): string;
  58734. /** Generate the current state of the procedural texture */
  58735. render(useCameraPostProcess?: boolean): void;
  58736. /**
  58737. * Serializes this noise procedural texture
  58738. * @returns a serialized noise procedural texture object
  58739. */
  58740. serialize(): any;
  58741. /**
  58742. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58743. * @param parsedTexture defines parsed texture data
  58744. * @param scene defines the current scene
  58745. * @param rootUrl defines the root URL containing noise procedural texture information
  58746. * @returns a parsed NoiseProceduralTexture
  58747. */
  58748. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58749. }
  58750. }
  58751. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58752. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58753. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58754. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58755. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58756. }
  58757. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58758. import { Nullable } from "babylonjs/types";
  58759. import { Scene } from "babylonjs/scene";
  58760. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58762. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58763. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58764. /**
  58765. * Raw cube texture where the raw buffers are passed in
  58766. */
  58767. export class RawCubeTexture extends CubeTexture {
  58768. /**
  58769. * Creates a cube texture where the raw buffers are passed in.
  58770. * @param scene defines the scene the texture is attached to
  58771. * @param data defines the array of data to use to create each face
  58772. * @param size defines the size of the textures
  58773. * @param format defines the format of the data
  58774. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58775. * @param generateMipMaps defines if the engine should generate the mip levels
  58776. * @param invertY defines if data must be stored with Y axis inverted
  58777. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58778. * @param compression defines the compression used (null by default)
  58779. */
  58780. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58781. /**
  58782. * Updates the raw cube texture.
  58783. * @param data defines the data to store
  58784. * @param format defines the data format
  58785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58786. * @param invertY defines if data must be stored with Y axis inverted
  58787. * @param compression defines the compression used (null by default)
  58788. * @param level defines which level of the texture to update
  58789. */
  58790. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58791. /**
  58792. * Updates a raw cube texture with RGBD encoded data.
  58793. * @param data defines the array of data [mipmap][face] to use to create each face
  58794. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58797. * @returns a promsie that resolves when the operation is complete
  58798. */
  58799. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58800. /**
  58801. * Clones the raw cube texture.
  58802. * @return a new cube texture
  58803. */
  58804. clone(): CubeTexture;
  58805. /** @hidden */
  58806. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58807. }
  58808. }
  58809. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58810. import { Scene } from "babylonjs/scene";
  58811. import { Texture } from "babylonjs/Materials/Textures/texture";
  58812. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58813. /**
  58814. * Class used to store 3D textures containing user data
  58815. */
  58816. export class RawTexture3D extends Texture {
  58817. /** Gets or sets the texture format to use */
  58818. format: number;
  58819. private _engine;
  58820. /**
  58821. * Create a new RawTexture3D
  58822. * @param data defines the data of the texture
  58823. * @param width defines the width of the texture
  58824. * @param height defines the height of the texture
  58825. * @param depth defines the depth of the texture
  58826. * @param format defines the texture format to use
  58827. * @param scene defines the hosting scene
  58828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58829. * @param invertY defines if texture must be stored with Y axis inverted
  58830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58832. */
  58833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58834. /** Gets or sets the texture format to use */
  58835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58836. /**
  58837. * Update the texture with new data
  58838. * @param data defines the data to store in the texture
  58839. */
  58840. update(data: ArrayBufferView): void;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58844. import { Scene } from "babylonjs/scene";
  58845. import { Texture } from "babylonjs/Materials/Textures/texture";
  58846. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58847. /**
  58848. * Class used to store 2D array textures containing user data
  58849. */
  58850. export class RawTexture2DArray extends Texture {
  58851. /** Gets or sets the texture format to use */
  58852. format: number;
  58853. private _engine;
  58854. /**
  58855. * Create a new RawTexture2DArray
  58856. * @param data defines the data of the texture
  58857. * @param width defines the width of the texture
  58858. * @param height defines the height of the texture
  58859. * @param depth defines the number of layers of the texture
  58860. * @param format defines the texture format to use
  58861. * @param scene defines the hosting scene
  58862. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58863. * @param invertY defines if texture must be stored with Y axis inverted
  58864. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58865. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58866. */
  58867. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58868. /** Gets or sets the texture format to use */
  58869. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58870. /**
  58871. * Update the texture with new data
  58872. * @param data defines the data to store in the texture
  58873. */
  58874. update(data: ArrayBufferView): void;
  58875. }
  58876. }
  58877. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58878. import { Scene } from "babylonjs/scene";
  58879. import { Plane } from "babylonjs/Maths/math.plane";
  58880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58881. /**
  58882. * Creates a refraction texture used by refraction channel of the standard material.
  58883. * It is like a mirror but to see through a material.
  58884. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58885. */
  58886. export class RefractionTexture extends RenderTargetTexture {
  58887. /**
  58888. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58889. * 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.
  58890. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58891. */
  58892. refractionPlane: Plane;
  58893. /**
  58894. * Define how deep under the surface we should see.
  58895. */
  58896. depth: number;
  58897. /**
  58898. * Creates a refraction texture used by refraction channel of the standard material.
  58899. * It is like a mirror but to see through a material.
  58900. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58901. * @param name Define the texture name
  58902. * @param size Define the size of the underlying texture
  58903. * @param scene Define the scene the refraction belongs to
  58904. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58905. */
  58906. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58907. /**
  58908. * Clone the refraction texture.
  58909. * @returns the cloned texture
  58910. */
  58911. clone(): RefractionTexture;
  58912. /**
  58913. * Serialize the texture to a JSON representation you could use in Parse later on
  58914. * @returns the serialized JSON representation
  58915. */
  58916. serialize(): any;
  58917. }
  58918. }
  58919. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58920. import { Nullable } from "babylonjs/types";
  58921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58922. import { Matrix } from "babylonjs/Maths/math.vector";
  58923. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58924. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58925. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58926. import { Scene } from "babylonjs/scene";
  58927. /**
  58928. * Defines the options related to the creation of an HtmlElementTexture
  58929. */
  58930. export interface IHtmlElementTextureOptions {
  58931. /**
  58932. * Defines wether mip maps should be created or not.
  58933. */
  58934. generateMipMaps?: boolean;
  58935. /**
  58936. * Defines the sampling mode of the texture.
  58937. */
  58938. samplingMode?: number;
  58939. /**
  58940. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58941. */
  58942. engine: Nullable<ThinEngine>;
  58943. /**
  58944. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58945. */
  58946. scene: Nullable<Scene>;
  58947. }
  58948. /**
  58949. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58950. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58951. * is automatically managed.
  58952. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58953. * in your application.
  58954. *
  58955. * As the update is not automatic, you need to call them manually.
  58956. */
  58957. export class HtmlElementTexture extends BaseTexture {
  58958. /**
  58959. * The texture URL.
  58960. */
  58961. element: HTMLVideoElement | HTMLCanvasElement;
  58962. private static readonly DefaultOptions;
  58963. private _textureMatrix;
  58964. private _engine;
  58965. private _isVideo;
  58966. private _generateMipMaps;
  58967. private _samplingMode;
  58968. /**
  58969. * Instantiates a HtmlElementTexture from the following parameters.
  58970. *
  58971. * @param name Defines the name of the texture
  58972. * @param element Defines the video or canvas the texture is filled with
  58973. * @param options Defines the other none mandatory texture creation options
  58974. */
  58975. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58976. private _createInternalTexture;
  58977. /**
  58978. * Returns the texture matrix used in most of the material.
  58979. */
  58980. getTextureMatrix(): Matrix;
  58981. /**
  58982. * Updates the content of the texture.
  58983. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58984. */
  58985. update(invertY?: Nullable<boolean>): void;
  58986. }
  58987. }
  58988. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58989. import { Vector2 } from "babylonjs/Maths/math.vector";
  58990. /**
  58991. * Defines the basic options interface of a TexturePacker Frame
  58992. */
  58993. export interface ITexturePackerFrame {
  58994. /**
  58995. * The frame ID
  58996. */
  58997. id: number;
  58998. /**
  58999. * The frames Scale
  59000. */
  59001. scale: Vector2;
  59002. /**
  59003. * The Frames offset
  59004. */
  59005. offset: Vector2;
  59006. }
  59007. /**
  59008. * This is a support class for frame Data on texture packer sets.
  59009. */
  59010. export class TexturePackerFrame implements ITexturePackerFrame {
  59011. /**
  59012. * The frame ID
  59013. */
  59014. id: number;
  59015. /**
  59016. * The frames Scale
  59017. */
  59018. scale: Vector2;
  59019. /**
  59020. * The Frames offset
  59021. */
  59022. offset: Vector2;
  59023. /**
  59024. * Initializes a texture package frame.
  59025. * @param id The numerical frame identifier
  59026. * @param scale Scalar Vector2 for UV frame
  59027. * @param offset Vector2 for the frame position in UV units.
  59028. * @returns TexturePackerFrame
  59029. */
  59030. constructor(id: number, scale: Vector2, offset: Vector2);
  59031. }
  59032. }
  59033. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59035. import { Scene } from "babylonjs/scene";
  59036. import { Nullable } from "babylonjs/types";
  59037. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59038. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59039. /**
  59040. * Defines the basic options interface of a TexturePacker
  59041. */
  59042. export interface ITexturePackerOptions {
  59043. /**
  59044. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59045. */
  59046. map?: string[];
  59047. /**
  59048. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59049. */
  59050. uvsIn?: string;
  59051. /**
  59052. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59053. */
  59054. uvsOut?: string;
  59055. /**
  59056. * number representing the layout style. Defaults to LAYOUT_STRIP
  59057. */
  59058. layout?: number;
  59059. /**
  59060. * number of columns if using custom column count layout(2). This defaults to 4.
  59061. */
  59062. colnum?: number;
  59063. /**
  59064. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59065. */
  59066. updateInputMeshes?: boolean;
  59067. /**
  59068. * boolean flag to dispose all the source textures. Defaults to true.
  59069. */
  59070. disposeSources?: boolean;
  59071. /**
  59072. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59073. */
  59074. fillBlanks?: boolean;
  59075. /**
  59076. * string value representing the context fill style color. Defaults to 'black'.
  59077. */
  59078. customFillColor?: string;
  59079. /**
  59080. * Width and Height Value of each Frame in the TexturePacker Sets
  59081. */
  59082. frameSize?: number;
  59083. /**
  59084. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59085. */
  59086. paddingRatio?: number;
  59087. /**
  59088. * Number that declares the fill method for the padding gutter.
  59089. */
  59090. paddingMode?: number;
  59091. /**
  59092. * If in SUBUV_COLOR padding mode what color to use.
  59093. */
  59094. paddingColor?: Color3 | Color4;
  59095. }
  59096. /**
  59097. * Defines the basic interface of a TexturePacker JSON File
  59098. */
  59099. export interface ITexturePackerJSON {
  59100. /**
  59101. * The frame ID
  59102. */
  59103. name: string;
  59104. /**
  59105. * The base64 channel data
  59106. */
  59107. sets: any;
  59108. /**
  59109. * The options of the Packer
  59110. */
  59111. options: ITexturePackerOptions;
  59112. /**
  59113. * The frame data of the Packer
  59114. */
  59115. frames: Array<number>;
  59116. }
  59117. /**
  59118. * This is a support class that generates a series of packed texture sets.
  59119. * @see https://doc.babylonjs.com/babylon101/materials
  59120. */
  59121. export class TexturePacker {
  59122. /** Packer Layout Constant 0 */
  59123. static readonly LAYOUT_STRIP: number;
  59124. /** Packer Layout Constant 1 */
  59125. static readonly LAYOUT_POWER2: number;
  59126. /** Packer Layout Constant 2 */
  59127. static readonly LAYOUT_COLNUM: number;
  59128. /** Packer Layout Constant 0 */
  59129. static readonly SUBUV_WRAP: number;
  59130. /** Packer Layout Constant 1 */
  59131. static readonly SUBUV_EXTEND: number;
  59132. /** Packer Layout Constant 2 */
  59133. static readonly SUBUV_COLOR: number;
  59134. /** The Name of the Texture Package */
  59135. name: string;
  59136. /** The scene scope of the TexturePacker */
  59137. scene: Scene;
  59138. /** The Meshes to target */
  59139. meshes: AbstractMesh[];
  59140. /** Arguments passed with the Constructor */
  59141. options: ITexturePackerOptions;
  59142. /** The promise that is started upon initialization */
  59143. promise: Nullable<Promise<TexturePacker | string>>;
  59144. /** The Container object for the channel sets that are generated */
  59145. sets: object;
  59146. /** The Container array for the frames that are generated */
  59147. frames: TexturePackerFrame[];
  59148. /** The expected number of textures the system is parsing. */
  59149. private _expecting;
  59150. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59151. private _paddingValue;
  59152. /**
  59153. * Initializes a texture package series from an array of meshes or a single mesh.
  59154. * @param name The name of the package
  59155. * @param meshes The target meshes to compose the package from
  59156. * @param options The arguments that texture packer should follow while building.
  59157. * @param scene The scene which the textures are scoped to.
  59158. * @returns TexturePacker
  59159. */
  59160. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59161. /**
  59162. * Starts the package process
  59163. * @param resolve The promises resolution function
  59164. * @returns TexturePacker
  59165. */
  59166. private _createFrames;
  59167. /**
  59168. * Calculates the Size of the Channel Sets
  59169. * @returns Vector2
  59170. */
  59171. private _calculateSize;
  59172. /**
  59173. * Calculates the UV data for the frames.
  59174. * @param baseSize the base frameSize
  59175. * @param padding the base frame padding
  59176. * @param dtSize size of the Dynamic Texture for that channel
  59177. * @param dtUnits is 1/dtSize
  59178. * @param update flag to update the input meshes
  59179. */
  59180. private _calculateMeshUVFrames;
  59181. /**
  59182. * Calculates the frames Offset.
  59183. * @param index of the frame
  59184. * @returns Vector2
  59185. */
  59186. private _getFrameOffset;
  59187. /**
  59188. * Updates a Mesh to the frame data
  59189. * @param mesh that is the target
  59190. * @param frameID or the frame index
  59191. */
  59192. private _updateMeshUV;
  59193. /**
  59194. * Updates a Meshes materials to use the texture packer channels
  59195. * @param m is the mesh to target
  59196. * @param force all channels on the packer to be set.
  59197. */
  59198. private _updateTextureReferences;
  59199. /**
  59200. * Public method to set a Mesh to a frame
  59201. * @param m that is the target
  59202. * @param frameID or the frame index
  59203. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59204. */
  59205. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59206. /**
  59207. * Starts the async promise to compile the texture packer.
  59208. * @returns Promise<void>
  59209. */
  59210. processAsync(): Promise<void>;
  59211. /**
  59212. * Disposes all textures associated with this packer
  59213. */
  59214. dispose(): void;
  59215. /**
  59216. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59217. * @param imageType is the image type to use.
  59218. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59219. */
  59220. download(imageType?: string, quality?: number): void;
  59221. /**
  59222. * Public method to load a texturePacker JSON file.
  59223. * @param data of the JSON file in string format.
  59224. */
  59225. updateFromJSON(data: string): void;
  59226. }
  59227. }
  59228. declare module "babylonjs/Materials/Textures/Packer/index" {
  59229. export * from "babylonjs/Materials/Textures/Packer/packer";
  59230. export * from "babylonjs/Materials/Textures/Packer/frame";
  59231. }
  59232. declare module "babylonjs/Materials/Textures/index" {
  59233. export * from "babylonjs/Materials/Textures/baseTexture";
  59234. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59235. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59236. export * from "babylonjs/Materials/Textures/cubeTexture";
  59237. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59238. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59239. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59240. export * from "babylonjs/Materials/Textures/internalTexture";
  59241. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59242. export * from "babylonjs/Materials/Textures/Loaders/index";
  59243. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59244. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59245. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59246. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59247. export * from "babylonjs/Materials/Textures/rawTexture";
  59248. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59249. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59250. export * from "babylonjs/Materials/Textures/refractionTexture";
  59251. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59252. export * from "babylonjs/Materials/Textures/texture";
  59253. export * from "babylonjs/Materials/Textures/videoTexture";
  59254. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59255. export * from "babylonjs/Materials/Textures/Packer/index";
  59256. }
  59257. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59258. /**
  59259. * Enum used to define the target of a block
  59260. */
  59261. export enum NodeMaterialBlockTargets {
  59262. /** Vertex shader */
  59263. Vertex = 1,
  59264. /** Fragment shader */
  59265. Fragment = 2,
  59266. /** Neutral */
  59267. Neutral = 4,
  59268. /** Vertex and Fragment */
  59269. VertexAndFragment = 3
  59270. }
  59271. }
  59272. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59273. /**
  59274. * Defines the kind of connection point for node based material
  59275. */
  59276. export enum NodeMaterialBlockConnectionPointTypes {
  59277. /** Float */
  59278. Float = 1,
  59279. /** Int */
  59280. Int = 2,
  59281. /** Vector2 */
  59282. Vector2 = 4,
  59283. /** Vector3 */
  59284. Vector3 = 8,
  59285. /** Vector4 */
  59286. Vector4 = 16,
  59287. /** Color3 */
  59288. Color3 = 32,
  59289. /** Color4 */
  59290. Color4 = 64,
  59291. /** Matrix */
  59292. Matrix = 128,
  59293. /** Detect type based on connection */
  59294. AutoDetect = 1024,
  59295. /** Output type that will be defined by input type */
  59296. BasedOnInput = 2048
  59297. }
  59298. }
  59299. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59300. /**
  59301. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59302. */
  59303. export enum NodeMaterialBlockConnectionPointMode {
  59304. /** Value is an uniform */
  59305. Uniform = 0,
  59306. /** Value is a mesh attribute */
  59307. Attribute = 1,
  59308. /** Value is a varying between vertex and fragment shaders */
  59309. Varying = 2,
  59310. /** Mode is undefined */
  59311. Undefined = 3
  59312. }
  59313. }
  59314. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59315. /**
  59316. * Enum used to define system values e.g. values automatically provided by the system
  59317. */
  59318. export enum NodeMaterialSystemValues {
  59319. /** World */
  59320. World = 1,
  59321. /** View */
  59322. View = 2,
  59323. /** Projection */
  59324. Projection = 3,
  59325. /** ViewProjection */
  59326. ViewProjection = 4,
  59327. /** WorldView */
  59328. WorldView = 5,
  59329. /** WorldViewProjection */
  59330. WorldViewProjection = 6,
  59331. /** CameraPosition */
  59332. CameraPosition = 7,
  59333. /** Fog Color */
  59334. FogColor = 8,
  59335. /** Delta time */
  59336. DeltaTime = 9
  59337. }
  59338. }
  59339. declare module "babylonjs/Materials/Node/Enums/index" {
  59340. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59341. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59342. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59343. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59344. }
  59345. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59347. /**
  59348. * Root class for all node material optimizers
  59349. */
  59350. export class NodeMaterialOptimizer {
  59351. /**
  59352. * Function used to optimize a NodeMaterial graph
  59353. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59354. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59355. */
  59356. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59357. }
  59358. }
  59359. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59363. import { Scene } from "babylonjs/scene";
  59364. /**
  59365. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59366. */
  59367. export class TransformBlock extends NodeMaterialBlock {
  59368. /**
  59369. * Defines the value to use to complement W value to transform it to a Vector4
  59370. */
  59371. complementW: number;
  59372. /**
  59373. * Defines the value to use to complement z value to transform it to a Vector4
  59374. */
  59375. complementZ: number;
  59376. /**
  59377. * Creates a new TransformBlock
  59378. * @param name defines the block name
  59379. */
  59380. constructor(name: string);
  59381. /**
  59382. * Gets the current class name
  59383. * @returns the class name
  59384. */
  59385. getClassName(): string;
  59386. /**
  59387. * Gets the vector input
  59388. */
  59389. get vector(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the output component
  59392. */
  59393. get output(): NodeMaterialConnectionPoint;
  59394. /**
  59395. * Gets the xyz output component
  59396. */
  59397. get xyz(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the matrix transform input
  59400. */
  59401. get transform(): NodeMaterialConnectionPoint;
  59402. protected _buildBlock(state: NodeMaterialBuildState): this;
  59403. serialize(): any;
  59404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59405. protected _dumpPropertiesCode(): string;
  59406. }
  59407. }
  59408. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59412. /**
  59413. * Block used to output the vertex position
  59414. */
  59415. export class VertexOutputBlock extends NodeMaterialBlock {
  59416. /**
  59417. * Creates a new VertexOutputBlock
  59418. * @param name defines the block name
  59419. */
  59420. constructor(name: string);
  59421. /**
  59422. * Gets the current class name
  59423. * @returns the class name
  59424. */
  59425. getClassName(): string;
  59426. /**
  59427. * Gets the vector input component
  59428. */
  59429. get vector(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59437. /**
  59438. * Block used to output the final color
  59439. */
  59440. export class FragmentOutputBlock extends NodeMaterialBlock {
  59441. /**
  59442. * Create a new FragmentOutputBlock
  59443. * @param name defines the block name
  59444. */
  59445. constructor(name: string);
  59446. /**
  59447. * Gets the current class name
  59448. * @returns the class name
  59449. */
  59450. getClassName(): string;
  59451. /**
  59452. * Gets the rgba input component
  59453. */
  59454. get rgba(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the rgb input component
  59457. */
  59458. get rgb(): NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the a input component
  59461. */
  59462. get a(): NodeMaterialConnectionPoint;
  59463. protected _buildBlock(state: NodeMaterialBuildState): this;
  59464. }
  59465. }
  59466. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59472. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59473. import { Effect } from "babylonjs/Materials/effect";
  59474. import { Mesh } from "babylonjs/Meshes/mesh";
  59475. import { Nullable } from "babylonjs/types";
  59476. import { Scene } from "babylonjs/scene";
  59477. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59478. /**
  59479. * Block used to read a reflection texture from a sampler
  59480. */
  59481. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59482. private _define3DName;
  59483. private _defineCubicName;
  59484. private _defineExplicitName;
  59485. private _defineProjectionName;
  59486. private _defineLocalCubicName;
  59487. private _defineSphericalName;
  59488. private _definePlanarName;
  59489. private _defineEquirectangularName;
  59490. private _defineMirroredEquirectangularFixedName;
  59491. private _defineEquirectangularFixedName;
  59492. private _defineSkyboxName;
  59493. private _cubeSamplerName;
  59494. private _2DSamplerName;
  59495. private _positionUVWName;
  59496. private _directionWName;
  59497. private _reflectionCoordsName;
  59498. private _reflection2DCoordsName;
  59499. private _reflectionColorName;
  59500. private _reflectionMatrixName;
  59501. /**
  59502. * Gets or sets the texture associated with the node
  59503. */
  59504. texture: Nullable<BaseTexture>;
  59505. /**
  59506. * Create a new TextureBlock
  59507. * @param name defines the block name
  59508. */
  59509. constructor(name: string);
  59510. /**
  59511. * Gets the current class name
  59512. * @returns the class name
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Gets the world position input component
  59517. */
  59518. get position(): NodeMaterialConnectionPoint;
  59519. /**
  59520. * Gets the world position input component
  59521. */
  59522. get worldPosition(): NodeMaterialConnectionPoint;
  59523. /**
  59524. * Gets the world normal input component
  59525. */
  59526. get worldNormal(): NodeMaterialConnectionPoint;
  59527. /**
  59528. * Gets the world input component
  59529. */
  59530. get world(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the camera (or eye) position component
  59533. */
  59534. get cameraPosition(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the view input component
  59537. */
  59538. get view(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the rgb output component
  59541. */
  59542. get rgb(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the r output component
  59545. */
  59546. get r(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the g output component
  59549. */
  59550. get g(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the b output component
  59553. */
  59554. get b(): NodeMaterialConnectionPoint;
  59555. autoConfigure(material: NodeMaterial): void;
  59556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59557. isReady(): boolean;
  59558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59559. private _injectVertexCode;
  59560. private _writeOutput;
  59561. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59562. protected _dumpPropertiesCode(): string;
  59563. serialize(): any;
  59564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59565. }
  59566. }
  59567. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59569. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59570. import { Scene } from "babylonjs/scene";
  59571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59572. import { Matrix } from "babylonjs/Maths/math.vector";
  59573. import { Mesh } from "babylonjs/Meshes/mesh";
  59574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59575. import { Observable } from "babylonjs/Misc/observable";
  59576. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59577. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59578. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59579. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59580. import { Nullable } from "babylonjs/types";
  59581. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59582. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59583. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59584. /**
  59585. * Interface used to configure the node material editor
  59586. */
  59587. export interface INodeMaterialEditorOptions {
  59588. /** Define the URl to load node editor script */
  59589. editorURL?: string;
  59590. }
  59591. /** @hidden */
  59592. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59593. NORMAL: boolean;
  59594. TANGENT: boolean;
  59595. UV1: boolean;
  59596. /** BONES */
  59597. NUM_BONE_INFLUENCERS: number;
  59598. BonesPerMesh: number;
  59599. BONETEXTURE: boolean;
  59600. /** MORPH TARGETS */
  59601. MORPHTARGETS: boolean;
  59602. MORPHTARGETS_NORMAL: boolean;
  59603. MORPHTARGETS_TANGENT: boolean;
  59604. MORPHTARGETS_UV: boolean;
  59605. NUM_MORPH_INFLUENCERS: number;
  59606. /** IMAGE PROCESSING */
  59607. IMAGEPROCESSING: boolean;
  59608. VIGNETTE: boolean;
  59609. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59610. VIGNETTEBLENDMODEOPAQUE: boolean;
  59611. TONEMAPPING: boolean;
  59612. TONEMAPPING_ACES: boolean;
  59613. CONTRAST: boolean;
  59614. EXPOSURE: boolean;
  59615. COLORCURVES: boolean;
  59616. COLORGRADING: boolean;
  59617. COLORGRADING3D: boolean;
  59618. SAMPLER3DGREENDEPTH: boolean;
  59619. SAMPLER3DBGRMAP: boolean;
  59620. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59621. /** MISC. */
  59622. BUMPDIRECTUV: number;
  59623. constructor();
  59624. setValue(name: string, value: boolean): void;
  59625. }
  59626. /**
  59627. * Class used to configure NodeMaterial
  59628. */
  59629. export interface INodeMaterialOptions {
  59630. /**
  59631. * Defines if blocks should emit comments
  59632. */
  59633. emitComments: boolean;
  59634. }
  59635. /**
  59636. * Class used to create a node based material built by assembling shader blocks
  59637. */
  59638. export class NodeMaterial extends PushMaterial {
  59639. private static _BuildIdGenerator;
  59640. private _options;
  59641. private _vertexCompilationState;
  59642. private _fragmentCompilationState;
  59643. private _sharedData;
  59644. private _buildId;
  59645. private _buildWasSuccessful;
  59646. private _cachedWorldViewMatrix;
  59647. private _cachedWorldViewProjectionMatrix;
  59648. private _optimizers;
  59649. private _animationFrame;
  59650. /** Define the Url to load node editor script */
  59651. static EditorURL: string;
  59652. /** Define the Url to load snippets */
  59653. static SnippetUrl: string;
  59654. private BJSNODEMATERIALEDITOR;
  59655. /** Get the inspector from bundle or global */
  59656. private _getGlobalNodeMaterialEditor;
  59657. /**
  59658. * Gets or sets data used by visual editor
  59659. * @see https://nme.babylonjs.com
  59660. */
  59661. editorData: any;
  59662. /**
  59663. * 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)
  59664. */
  59665. ignoreAlpha: boolean;
  59666. /**
  59667. * Defines the maximum number of lights that can be used in the material
  59668. */
  59669. maxSimultaneousLights: number;
  59670. /**
  59671. * Observable raised when the material is built
  59672. */
  59673. onBuildObservable: Observable<NodeMaterial>;
  59674. /**
  59675. * Gets or sets the root nodes of the material vertex shader
  59676. */
  59677. _vertexOutputNodes: NodeMaterialBlock[];
  59678. /**
  59679. * Gets or sets the root nodes of the material fragment (pixel) shader
  59680. */
  59681. _fragmentOutputNodes: NodeMaterialBlock[];
  59682. /** Gets or sets options to control the node material overall behavior */
  59683. get options(): INodeMaterialOptions;
  59684. set options(options: INodeMaterialOptions);
  59685. /**
  59686. * Default configuration related to image processing available in the standard Material.
  59687. */
  59688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59689. /**
  59690. * Gets the image processing configuration used either in this material.
  59691. */
  59692. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59693. /**
  59694. * Sets the Default image processing configuration used either in the this material.
  59695. *
  59696. * If sets to null, the scene one is in use.
  59697. */
  59698. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59699. /**
  59700. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59701. */
  59702. attachedBlocks: NodeMaterialBlock[];
  59703. /**
  59704. * Create a new node based material
  59705. * @param name defines the material name
  59706. * @param scene defines the hosting scene
  59707. * @param options defines creation option
  59708. */
  59709. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59710. /**
  59711. * Gets the current class name of the material e.g. "NodeMaterial"
  59712. * @returns the class name
  59713. */
  59714. getClassName(): string;
  59715. /**
  59716. * Keep track of the image processing observer to allow dispose and replace.
  59717. */
  59718. private _imageProcessingObserver;
  59719. /**
  59720. * Attaches a new image processing configuration to the Standard Material.
  59721. * @param configuration
  59722. */
  59723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59724. /**
  59725. * Get a block by its name
  59726. * @param name defines the name of the block to retrieve
  59727. * @returns the required block or null if not found
  59728. */
  59729. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59730. /**
  59731. * Get a block by its name
  59732. * @param predicate defines the predicate used to find the good candidate
  59733. * @returns the required block or null if not found
  59734. */
  59735. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59736. /**
  59737. * Get an input block by its name
  59738. * @param predicate defines the predicate used to find the good candidate
  59739. * @returns the required input block or null if not found
  59740. */
  59741. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59742. /**
  59743. * Gets the list of input blocks attached to this material
  59744. * @returns an array of InputBlocks
  59745. */
  59746. getInputBlocks(): InputBlock[];
  59747. /**
  59748. * Adds a new optimizer to the list of optimizers
  59749. * @param optimizer defines the optimizers to add
  59750. * @returns the current material
  59751. */
  59752. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59753. /**
  59754. * Remove an optimizer from the list of optimizers
  59755. * @param optimizer defines the optimizers to remove
  59756. * @returns the current material
  59757. */
  59758. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59759. /**
  59760. * Add a new block to the list of output nodes
  59761. * @param node defines the node to add
  59762. * @returns the current material
  59763. */
  59764. addOutputNode(node: NodeMaterialBlock): this;
  59765. /**
  59766. * Remove a block from the list of root nodes
  59767. * @param node defines the node to remove
  59768. * @returns the current material
  59769. */
  59770. removeOutputNode(node: NodeMaterialBlock): this;
  59771. private _addVertexOutputNode;
  59772. private _removeVertexOutputNode;
  59773. private _addFragmentOutputNode;
  59774. private _removeFragmentOutputNode;
  59775. /**
  59776. * Specifies if the material will require alpha blending
  59777. * @returns a boolean specifying if alpha blending is needed
  59778. */
  59779. needAlphaBlending(): boolean;
  59780. /**
  59781. * Specifies if this material should be rendered in alpha test mode
  59782. * @returns a boolean specifying if an alpha test is needed.
  59783. */
  59784. needAlphaTesting(): boolean;
  59785. private _initializeBlock;
  59786. private _resetDualBlocks;
  59787. /**
  59788. * Remove a block from the current node material
  59789. * @param block defines the block to remove
  59790. */
  59791. removeBlock(block: NodeMaterialBlock): void;
  59792. /**
  59793. * Build the material and generates the inner effect
  59794. * @param verbose defines if the build should log activity
  59795. */
  59796. build(verbose?: boolean): void;
  59797. /**
  59798. * Runs an otpimization phase to try to improve the shader code
  59799. */
  59800. optimize(): void;
  59801. private _prepareDefinesForAttributes;
  59802. /**
  59803. * Get if the submesh is ready to be used and all its information available.
  59804. * Child classes can use it to update shaders
  59805. * @param mesh defines the mesh to check
  59806. * @param subMesh defines which submesh to check
  59807. * @param useInstances specifies that instances should be used
  59808. * @returns a boolean indicating that the submesh is ready or not
  59809. */
  59810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59811. /**
  59812. * Get a string representing the shaders built by the current node graph
  59813. */
  59814. get compiledShaders(): string;
  59815. /**
  59816. * Binds the world matrix to the material
  59817. * @param world defines the world transformation matrix
  59818. */
  59819. bindOnlyWorldMatrix(world: Matrix): void;
  59820. /**
  59821. * Binds the submesh to this material by preparing the effect and shader to draw
  59822. * @param world defines the world transformation matrix
  59823. * @param mesh defines the mesh containing the submesh
  59824. * @param subMesh defines the submesh to bind the material to
  59825. */
  59826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59827. /**
  59828. * Gets the active textures from the material
  59829. * @returns an array of textures
  59830. */
  59831. getActiveTextures(): BaseTexture[];
  59832. /**
  59833. * Gets the list of texture blocks
  59834. * @returns an array of texture blocks
  59835. */
  59836. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59837. /**
  59838. * Specifies if the material uses a texture
  59839. * @param texture defines the texture to check against the material
  59840. * @returns a boolean specifying if the material uses the texture
  59841. */
  59842. hasTexture(texture: BaseTexture): boolean;
  59843. /**
  59844. * Disposes the material
  59845. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59846. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59847. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59848. */
  59849. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59850. /** Creates the node editor window. */
  59851. private _createNodeEditor;
  59852. /**
  59853. * Launch the node material editor
  59854. * @param config Define the configuration of the editor
  59855. * @return a promise fulfilled when the node editor is visible
  59856. */
  59857. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59858. /**
  59859. * Clear the current material
  59860. */
  59861. clear(): void;
  59862. /**
  59863. * Clear the current material and set it to a default state
  59864. */
  59865. setToDefault(): void;
  59866. /**
  59867. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59868. * @param url defines the url to load from
  59869. * @returns a promise that will fullfil when the material is fully loaded
  59870. */
  59871. loadAsync(url: string): Promise<void>;
  59872. private _gatherBlocks;
  59873. /**
  59874. * Generate a string containing the code declaration required to create an equivalent of this material
  59875. * @returns a string
  59876. */
  59877. generateCode(): string;
  59878. /**
  59879. * Serializes this material in a JSON representation
  59880. * @returns the serialized material object
  59881. */
  59882. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59883. private _restoreConnections;
  59884. /**
  59885. * Clear the current graph and load a new one from a serialization object
  59886. * @param source defines the JSON representation of the material
  59887. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59888. */
  59889. loadFromSerialization(source: any, rootUrl?: string): void;
  59890. /**
  59891. * Creates a node material from parsed material data
  59892. * @param source defines the JSON representation of the material
  59893. * @param scene defines the hosting scene
  59894. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59895. * @returns a new node material
  59896. */
  59897. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59898. /**
  59899. * Creates a node material from a snippet saved in a remote file
  59900. * @param name defines the name of the material to create
  59901. * @param url defines the url to load from
  59902. * @param scene defines the hosting scene
  59903. * @returns a promise that will resolve to the new node material
  59904. */
  59905. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59906. /**
  59907. * Creates a node material from a snippet saved by the node material editor
  59908. * @param snippetId defines the snippet to load
  59909. * @param scene defines the hosting scene
  59910. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59911. * @returns a promise that will resolve to the new node material
  59912. */
  59913. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59914. /**
  59915. * Creates a new node material set to default basic configuration
  59916. * @param name defines the name of the material
  59917. * @param scene defines the hosting scene
  59918. * @returns a new NodeMaterial
  59919. */
  59920. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59921. }
  59922. }
  59923. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59926. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59929. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59930. import { Effect } from "babylonjs/Materials/effect";
  59931. import { Mesh } from "babylonjs/Meshes/mesh";
  59932. import { Nullable } from "babylonjs/types";
  59933. import { Texture } from "babylonjs/Materials/Textures/texture";
  59934. import { Scene } from "babylonjs/scene";
  59935. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59936. /**
  59937. * Block used to read a texture from a sampler
  59938. */
  59939. export class TextureBlock extends NodeMaterialBlock {
  59940. private _defineName;
  59941. private _linearDefineName;
  59942. private _tempTextureRead;
  59943. private _samplerName;
  59944. private _transformedUVName;
  59945. private _textureTransformName;
  59946. private _textureInfoName;
  59947. private _mainUVName;
  59948. private _mainUVDefineName;
  59949. /**
  59950. * Gets or sets the texture associated with the node
  59951. */
  59952. texture: Nullable<Texture>;
  59953. /**
  59954. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59955. */
  59956. convertToGammaSpace: boolean;
  59957. /**
  59958. * Create a new TextureBlock
  59959. * @param name defines the block name
  59960. */
  59961. constructor(name: string);
  59962. /**
  59963. * Gets the current class name
  59964. * @returns the class name
  59965. */
  59966. getClassName(): string;
  59967. /**
  59968. * Gets the uv input component
  59969. */
  59970. get uv(): NodeMaterialConnectionPoint;
  59971. /**
  59972. * Gets the rgba output component
  59973. */
  59974. get rgba(): NodeMaterialConnectionPoint;
  59975. /**
  59976. * Gets the rgb output component
  59977. */
  59978. get rgb(): NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the r output component
  59981. */
  59982. get r(): NodeMaterialConnectionPoint;
  59983. /**
  59984. * Gets the g output component
  59985. */
  59986. get g(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the b output component
  59989. */
  59990. get b(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the a output component
  59993. */
  59994. get a(): NodeMaterialConnectionPoint;
  59995. get target(): NodeMaterialBlockTargets;
  59996. autoConfigure(material: NodeMaterial): void;
  59997. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59999. isReady(): boolean;
  60000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60001. private get _isMixed();
  60002. private _injectVertexCode;
  60003. private _writeTextureRead;
  60004. private _writeOutput;
  60005. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60006. protected _dumpPropertiesCode(): string;
  60007. serialize(): any;
  60008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60009. }
  60010. }
  60011. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60014. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60015. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60016. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60017. import { Scene } from "babylonjs/scene";
  60018. /**
  60019. * Class used to store shared data between 2 NodeMaterialBuildState
  60020. */
  60021. export class NodeMaterialBuildStateSharedData {
  60022. /**
  60023. * Gets the list of emitted varyings
  60024. */
  60025. temps: string[];
  60026. /**
  60027. * Gets the list of emitted varyings
  60028. */
  60029. varyings: string[];
  60030. /**
  60031. * Gets the varying declaration string
  60032. */
  60033. varyingDeclaration: string;
  60034. /**
  60035. * Input blocks
  60036. */
  60037. inputBlocks: InputBlock[];
  60038. /**
  60039. * Input blocks
  60040. */
  60041. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60042. /**
  60043. * Bindable blocks (Blocks that need to set data to the effect)
  60044. */
  60045. bindableBlocks: NodeMaterialBlock[];
  60046. /**
  60047. * List of blocks that can provide a compilation fallback
  60048. */
  60049. blocksWithFallbacks: NodeMaterialBlock[];
  60050. /**
  60051. * List of blocks that can provide a define update
  60052. */
  60053. blocksWithDefines: NodeMaterialBlock[];
  60054. /**
  60055. * List of blocks that can provide a repeatable content
  60056. */
  60057. repeatableContentBlocks: NodeMaterialBlock[];
  60058. /**
  60059. * List of blocks that can provide a dynamic list of uniforms
  60060. */
  60061. dynamicUniformBlocks: NodeMaterialBlock[];
  60062. /**
  60063. * List of blocks that can block the isReady function for the material
  60064. */
  60065. blockingBlocks: NodeMaterialBlock[];
  60066. /**
  60067. * Gets the list of animated inputs
  60068. */
  60069. animatedInputs: InputBlock[];
  60070. /**
  60071. * Build Id used to avoid multiple recompilations
  60072. */
  60073. buildId: number;
  60074. /** List of emitted variables */
  60075. variableNames: {
  60076. [key: string]: number;
  60077. };
  60078. /** List of emitted defines */
  60079. defineNames: {
  60080. [key: string]: number;
  60081. };
  60082. /** Should emit comments? */
  60083. emitComments: boolean;
  60084. /** Emit build activity */
  60085. verbose: boolean;
  60086. /** Gets or sets the hosting scene */
  60087. scene: Scene;
  60088. /**
  60089. * Gets the compilation hints emitted at compilation time
  60090. */
  60091. hints: {
  60092. needWorldViewMatrix: boolean;
  60093. needWorldViewProjectionMatrix: boolean;
  60094. needAlphaBlending: boolean;
  60095. needAlphaTesting: boolean;
  60096. };
  60097. /**
  60098. * List of compilation checks
  60099. */
  60100. checks: {
  60101. emitVertex: boolean;
  60102. emitFragment: boolean;
  60103. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60104. };
  60105. /** Creates a new shared data */
  60106. constructor();
  60107. /**
  60108. * Emits console errors and exceptions if there is a failing check
  60109. */
  60110. emitErrors(): void;
  60111. }
  60112. }
  60113. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60114. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60115. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60116. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60117. /**
  60118. * Class used to store node based material build state
  60119. */
  60120. export class NodeMaterialBuildState {
  60121. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60122. supportUniformBuffers: boolean;
  60123. /**
  60124. * Gets the list of emitted attributes
  60125. */
  60126. attributes: string[];
  60127. /**
  60128. * Gets the list of emitted uniforms
  60129. */
  60130. uniforms: string[];
  60131. /**
  60132. * Gets the list of emitted constants
  60133. */
  60134. constants: string[];
  60135. /**
  60136. * Gets the list of emitted samplers
  60137. */
  60138. samplers: string[];
  60139. /**
  60140. * Gets the list of emitted functions
  60141. */
  60142. functions: {
  60143. [key: string]: string;
  60144. };
  60145. /**
  60146. * Gets the list of emitted extensions
  60147. */
  60148. extensions: {
  60149. [key: string]: string;
  60150. };
  60151. /**
  60152. * Gets the target of the compilation state
  60153. */
  60154. target: NodeMaterialBlockTargets;
  60155. /**
  60156. * Gets the list of emitted counters
  60157. */
  60158. counters: {
  60159. [key: string]: number;
  60160. };
  60161. /**
  60162. * Shared data between multiple NodeMaterialBuildState instances
  60163. */
  60164. sharedData: NodeMaterialBuildStateSharedData;
  60165. /** @hidden */
  60166. _vertexState: NodeMaterialBuildState;
  60167. /** @hidden */
  60168. _attributeDeclaration: string;
  60169. /** @hidden */
  60170. _uniformDeclaration: string;
  60171. /** @hidden */
  60172. _constantDeclaration: string;
  60173. /** @hidden */
  60174. _samplerDeclaration: string;
  60175. /** @hidden */
  60176. _varyingTransfer: string;
  60177. private _repeatableContentAnchorIndex;
  60178. /** @hidden */
  60179. _builtCompilationString: string;
  60180. /**
  60181. * Gets the emitted compilation strings
  60182. */
  60183. compilationString: string;
  60184. /**
  60185. * Finalize the compilation strings
  60186. * @param state defines the current compilation state
  60187. */
  60188. finalize(state: NodeMaterialBuildState): void;
  60189. /** @hidden */
  60190. get _repeatableContentAnchor(): string;
  60191. /** @hidden */
  60192. _getFreeVariableName(prefix: string): string;
  60193. /** @hidden */
  60194. _getFreeDefineName(prefix: string): string;
  60195. /** @hidden */
  60196. _excludeVariableName(name: string): void;
  60197. /** @hidden */
  60198. _emit2DSampler(name: string): void;
  60199. /** @hidden */
  60200. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60201. /** @hidden */
  60202. _emitExtension(name: string, extension: string): void;
  60203. /** @hidden */
  60204. _emitFunction(name: string, code: string, comments: string): void;
  60205. /** @hidden */
  60206. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60207. replaceStrings?: {
  60208. search: RegExp;
  60209. replace: string;
  60210. }[];
  60211. repeatKey?: string;
  60212. }): string;
  60213. /** @hidden */
  60214. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60215. repeatKey?: string;
  60216. removeAttributes?: boolean;
  60217. removeUniforms?: boolean;
  60218. removeVaryings?: boolean;
  60219. removeIfDef?: boolean;
  60220. replaceStrings?: {
  60221. search: RegExp;
  60222. replace: string;
  60223. }[];
  60224. }, storeKey?: string): void;
  60225. /** @hidden */
  60226. _registerTempVariable(name: string): boolean;
  60227. /** @hidden */
  60228. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60229. /** @hidden */
  60230. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60231. /** @hidden */
  60232. _emitFloat(value: number): string;
  60233. }
  60234. }
  60235. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60236. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60238. import { Nullable } from "babylonjs/types";
  60239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60240. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60241. import { Effect } from "babylonjs/Materials/effect";
  60242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60243. import { Mesh } from "babylonjs/Meshes/mesh";
  60244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60245. import { Scene } from "babylonjs/scene";
  60246. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60247. /**
  60248. * Defines a block that can be used inside a node based material
  60249. */
  60250. export class NodeMaterialBlock {
  60251. private _buildId;
  60252. private _buildTarget;
  60253. private _target;
  60254. private _isFinalMerger;
  60255. private _isInput;
  60256. protected _isUnique: boolean;
  60257. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60258. inputsAreExclusive: boolean;
  60259. /** @hidden */
  60260. _codeVariableName: string;
  60261. /** @hidden */
  60262. _inputs: NodeMaterialConnectionPoint[];
  60263. /** @hidden */
  60264. _outputs: NodeMaterialConnectionPoint[];
  60265. /** @hidden */
  60266. _preparationId: number;
  60267. /**
  60268. * Gets or sets the name of the block
  60269. */
  60270. name: string;
  60271. /**
  60272. * Gets or sets the unique id of the node
  60273. */
  60274. uniqueId: number;
  60275. /**
  60276. * Gets or sets the comments associated with this block
  60277. */
  60278. comments: string;
  60279. /**
  60280. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60281. */
  60282. get isUnique(): boolean;
  60283. /**
  60284. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60285. */
  60286. get isFinalMerger(): boolean;
  60287. /**
  60288. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60289. */
  60290. get isInput(): boolean;
  60291. /**
  60292. * Gets or sets the build Id
  60293. */
  60294. get buildId(): number;
  60295. set buildId(value: number);
  60296. /**
  60297. * Gets or sets the target of the block
  60298. */
  60299. get target(): NodeMaterialBlockTargets;
  60300. set target(value: NodeMaterialBlockTargets);
  60301. /**
  60302. * Gets the list of input points
  60303. */
  60304. get inputs(): NodeMaterialConnectionPoint[];
  60305. /** Gets the list of output points */
  60306. get outputs(): NodeMaterialConnectionPoint[];
  60307. /**
  60308. * Find an input by its name
  60309. * @param name defines the name of the input to look for
  60310. * @returns the input or null if not found
  60311. */
  60312. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60313. /**
  60314. * Find an output by its name
  60315. * @param name defines the name of the outputto look for
  60316. * @returns the output or null if not found
  60317. */
  60318. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60319. /**
  60320. * Creates a new NodeMaterialBlock
  60321. * @param name defines the block name
  60322. * @param target defines the target of that block (Vertex by default)
  60323. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60324. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60325. */
  60326. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60327. /**
  60328. * Initialize the block and prepare the context for build
  60329. * @param state defines the state that will be used for the build
  60330. */
  60331. initialize(state: NodeMaterialBuildState): void;
  60332. /**
  60333. * Bind data to effect. Will only be called for blocks with isBindable === true
  60334. * @param effect defines the effect to bind data to
  60335. * @param nodeMaterial defines the hosting NodeMaterial
  60336. * @param mesh defines the mesh that will be rendered
  60337. */
  60338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60339. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60340. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60341. protected _writeFloat(value: number): string;
  60342. /**
  60343. * Gets the current class name e.g. "NodeMaterialBlock"
  60344. * @returns the class name
  60345. */
  60346. getClassName(): string;
  60347. /**
  60348. * Register a new input. Must be called inside a block constructor
  60349. * @param name defines the connection point name
  60350. * @param type defines the connection point type
  60351. * @param isOptional defines a boolean indicating that this input can be omitted
  60352. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60353. * @returns the current block
  60354. */
  60355. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60356. /**
  60357. * Register a new output. Must be called inside a block constructor
  60358. * @param name defines the connection point name
  60359. * @param type defines the connection point type
  60360. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60361. * @returns the current block
  60362. */
  60363. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60364. /**
  60365. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60366. * @param forOutput defines an optional connection point to check compatibility with
  60367. * @returns the first available input or null
  60368. */
  60369. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60370. /**
  60371. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60372. * @param forBlock defines an optional block to check compatibility with
  60373. * @returns the first available input or null
  60374. */
  60375. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60376. /**
  60377. * Gets the sibling of the given output
  60378. * @param current defines the current output
  60379. * @returns the next output in the list or null
  60380. */
  60381. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60382. /**
  60383. * Connect current block with another block
  60384. * @param other defines the block to connect with
  60385. * @param options define the various options to help pick the right connections
  60386. * @returns the current block
  60387. */
  60388. connectTo(other: NodeMaterialBlock, options?: {
  60389. input?: string;
  60390. output?: string;
  60391. outputSwizzle?: string;
  60392. }): this | undefined;
  60393. protected _buildBlock(state: NodeMaterialBuildState): void;
  60394. /**
  60395. * Add uniforms, samplers and uniform buffers at compilation time
  60396. * @param state defines the state to update
  60397. * @param nodeMaterial defines the node material requesting the update
  60398. * @param defines defines the material defines to update
  60399. * @param uniformBuffers defines the list of uniform buffer names
  60400. */
  60401. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60402. /**
  60403. * Add potential fallbacks if shader compilation fails
  60404. * @param mesh defines the mesh to be rendered
  60405. * @param fallbacks defines the current prioritized list of fallbacks
  60406. */
  60407. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60408. /**
  60409. * Initialize defines for shader compilation
  60410. * @param mesh defines the mesh to be rendered
  60411. * @param nodeMaterial defines the node material requesting the update
  60412. * @param defines defines the material defines to update
  60413. * @param useInstances specifies that instances should be used
  60414. */
  60415. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60416. /**
  60417. * Update defines for shader compilation
  60418. * @param mesh defines the mesh to be rendered
  60419. * @param nodeMaterial defines the node material requesting the update
  60420. * @param defines defines the material defines to update
  60421. * @param useInstances specifies that instances should be used
  60422. */
  60423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60424. /**
  60425. * Lets the block try to connect some inputs automatically
  60426. * @param material defines the hosting NodeMaterial
  60427. */
  60428. autoConfigure(material: NodeMaterial): void;
  60429. /**
  60430. * Function called when a block is declared as repeatable content generator
  60431. * @param vertexShaderState defines the current compilation state for the vertex shader
  60432. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60433. * @param mesh defines the mesh to be rendered
  60434. * @param defines defines the material defines to update
  60435. */
  60436. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60437. /**
  60438. * Checks if the block is ready
  60439. * @param mesh defines the mesh to be rendered
  60440. * @param nodeMaterial defines the node material requesting the update
  60441. * @param defines defines the material defines to update
  60442. * @param useInstances specifies that instances should be used
  60443. * @returns true if the block is ready
  60444. */
  60445. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60446. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60447. private _processBuild;
  60448. /**
  60449. * Compile the current node and generate the shader code
  60450. * @param state defines the current compilation state (uniforms, samplers, current string)
  60451. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60452. * @returns true if already built
  60453. */
  60454. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60455. protected _inputRename(name: string): string;
  60456. protected _outputRename(name: string): string;
  60457. protected _dumpPropertiesCode(): string;
  60458. /** @hidden */
  60459. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60460. /** @hidden */
  60461. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60462. /**
  60463. * Clone the current block to a new identical block
  60464. * @param scene defines the hosting scene
  60465. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60466. * @returns a copy of the current block
  60467. */
  60468. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60469. /**
  60470. * Serializes this block in a JSON representation
  60471. * @returns the serialized block object
  60472. */
  60473. serialize(): any;
  60474. /** @hidden */
  60475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60476. /**
  60477. * Release resources
  60478. */
  60479. dispose(): void;
  60480. }
  60481. }
  60482. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60483. /**
  60484. * Enum defining the type of animations supported by InputBlock
  60485. */
  60486. export enum AnimatedInputBlockTypes {
  60487. /** No animation */
  60488. None = 0,
  60489. /** Time based animation. Will only work for floats */
  60490. Time = 1
  60491. }
  60492. }
  60493. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60495. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60496. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60497. import { Nullable } from "babylonjs/types";
  60498. import { Effect } from "babylonjs/Materials/effect";
  60499. import { Matrix } from "babylonjs/Maths/math.vector";
  60500. import { Scene } from "babylonjs/scene";
  60501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60503. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60504. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60505. import { Observable } from "babylonjs/Misc/observable";
  60506. /**
  60507. * Block used to expose an input value
  60508. */
  60509. export class InputBlock extends NodeMaterialBlock {
  60510. private _mode;
  60511. private _associatedVariableName;
  60512. private _storedValue;
  60513. private _valueCallback;
  60514. private _type;
  60515. private _animationType;
  60516. /** Gets or set a value used to limit the range of float values */
  60517. min: number;
  60518. /** Gets or set a value used to limit the range of float values */
  60519. max: number;
  60520. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60521. isBoolean: boolean;
  60522. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60523. matrixMode: number;
  60524. /** @hidden */
  60525. _systemValue: Nullable<NodeMaterialSystemValues>;
  60526. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60527. visibleInInspector: boolean;
  60528. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60529. isConstant: boolean;
  60530. /** Gets or sets the group to use to display this block in the Inspector */
  60531. groupInInspector: string;
  60532. /** Gets an observable raised when the value is changed */
  60533. onValueChangedObservable: Observable<InputBlock>;
  60534. /**
  60535. * Gets or sets the connection point type (default is float)
  60536. */
  60537. get type(): NodeMaterialBlockConnectionPointTypes;
  60538. /**
  60539. * Creates a new InputBlock
  60540. * @param name defines the block name
  60541. * @param target defines the target of that block (Vertex by default)
  60542. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60543. */
  60544. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60545. /**
  60546. * Gets the output component
  60547. */
  60548. get output(): NodeMaterialConnectionPoint;
  60549. /**
  60550. * Set the source of this connection point to a vertex attribute
  60551. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60552. * @returns the current connection point
  60553. */
  60554. setAsAttribute(attributeName?: string): InputBlock;
  60555. /**
  60556. * Set the source of this connection point to a system value
  60557. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60558. * @returns the current connection point
  60559. */
  60560. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60561. /**
  60562. * Gets or sets the value of that point.
  60563. * Please note that this value will be ignored if valueCallback is defined
  60564. */
  60565. get value(): any;
  60566. set value(value: any);
  60567. /**
  60568. * Gets or sets a callback used to get the value of that point.
  60569. * Please note that setting this value will force the connection point to ignore the value property
  60570. */
  60571. get valueCallback(): () => any;
  60572. set valueCallback(value: () => any);
  60573. /**
  60574. * Gets or sets the associated variable name in the shader
  60575. */
  60576. get associatedVariableName(): string;
  60577. set associatedVariableName(value: string);
  60578. /** Gets or sets the type of animation applied to the input */
  60579. get animationType(): AnimatedInputBlockTypes;
  60580. set animationType(value: AnimatedInputBlockTypes);
  60581. /**
  60582. * Gets a boolean indicating that this connection point not defined yet
  60583. */
  60584. get isUndefined(): boolean;
  60585. /**
  60586. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60587. * In this case the connection point name must be the name of the uniform to use.
  60588. * Can only be set on inputs
  60589. */
  60590. get isUniform(): boolean;
  60591. set isUniform(value: boolean);
  60592. /**
  60593. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60594. * In this case the connection point name must be the name of the attribute to use
  60595. * Can only be set on inputs
  60596. */
  60597. get isAttribute(): boolean;
  60598. set isAttribute(value: boolean);
  60599. /**
  60600. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60601. * Can only be set on exit points
  60602. */
  60603. get isVarying(): boolean;
  60604. set isVarying(value: boolean);
  60605. /**
  60606. * Gets a boolean indicating that the current connection point is a system value
  60607. */
  60608. get isSystemValue(): boolean;
  60609. /**
  60610. * Gets or sets the current well known value or null if not defined as a system value
  60611. */
  60612. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60613. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60614. /**
  60615. * Gets the current class name
  60616. * @returns the class name
  60617. */
  60618. getClassName(): string;
  60619. /**
  60620. * Animate the input if animationType !== None
  60621. * @param scene defines the rendering scene
  60622. */
  60623. animate(scene: Scene): void;
  60624. private _emitDefine;
  60625. initialize(state: NodeMaterialBuildState): void;
  60626. /**
  60627. * Set the input block to its default value (based on its type)
  60628. */
  60629. setDefaultValue(): void;
  60630. private _emitConstant;
  60631. private _emit;
  60632. /** @hidden */
  60633. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60634. /** @hidden */
  60635. _transmit(effect: Effect, scene: Scene): void;
  60636. protected _buildBlock(state: NodeMaterialBuildState): void;
  60637. protected _dumpPropertiesCode(): string;
  60638. dispose(): void;
  60639. serialize(): any;
  60640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60641. }
  60642. }
  60643. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60644. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60645. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60646. import { Nullable } from "babylonjs/types";
  60647. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60648. import { Observable } from "babylonjs/Misc/observable";
  60649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60650. /**
  60651. * Enum used to define the compatibility state between two connection points
  60652. */
  60653. export enum NodeMaterialConnectionPointCompatibilityStates {
  60654. /** Points are compatibles */
  60655. Compatible = 0,
  60656. /** Points are incompatible because of their types */
  60657. TypeIncompatible = 1,
  60658. /** Points are incompatible because of their targets (vertex vs fragment) */
  60659. TargetIncompatible = 2
  60660. }
  60661. /**
  60662. * Defines the direction of a connection point
  60663. */
  60664. export enum NodeMaterialConnectionPointDirection {
  60665. /** Input */
  60666. Input = 0,
  60667. /** Output */
  60668. Output = 1
  60669. }
  60670. /**
  60671. * Defines a connection point for a block
  60672. */
  60673. export class NodeMaterialConnectionPoint {
  60674. /** @hidden */
  60675. _ownerBlock: NodeMaterialBlock;
  60676. /** @hidden */
  60677. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60678. private _endpoints;
  60679. private _associatedVariableName;
  60680. private _direction;
  60681. /** @hidden */
  60682. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60683. /** @hidden */
  60684. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60685. private _type;
  60686. /** @hidden */
  60687. _enforceAssociatedVariableName: boolean;
  60688. /** Gets the direction of the point */
  60689. get direction(): NodeMaterialConnectionPointDirection;
  60690. /**
  60691. * Gets or sets the additional types supported by this connection point
  60692. */
  60693. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60694. /**
  60695. * Gets or sets the additional types excluded by this connection point
  60696. */
  60697. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60698. /**
  60699. * Observable triggered when this point is connected
  60700. */
  60701. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60702. /**
  60703. * Gets or sets the associated variable name in the shader
  60704. */
  60705. get associatedVariableName(): string;
  60706. set associatedVariableName(value: string);
  60707. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60708. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60709. /**
  60710. * Gets or sets the connection point type (default is float)
  60711. */
  60712. get type(): NodeMaterialBlockConnectionPointTypes;
  60713. set type(value: NodeMaterialBlockConnectionPointTypes);
  60714. /**
  60715. * Gets or sets the connection point name
  60716. */
  60717. name: string;
  60718. /**
  60719. * Gets or sets a boolean indicating that this connection point can be omitted
  60720. */
  60721. isOptional: boolean;
  60722. /**
  60723. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60724. */
  60725. define: string;
  60726. /** @hidden */
  60727. _prioritizeVertex: boolean;
  60728. private _target;
  60729. /** Gets or sets the target of that connection point */
  60730. get target(): NodeMaterialBlockTargets;
  60731. set target(value: NodeMaterialBlockTargets);
  60732. /**
  60733. * Gets a boolean indicating that the current point is connected
  60734. */
  60735. get isConnected(): boolean;
  60736. /**
  60737. * Gets a boolean indicating that the current point is connected to an input block
  60738. */
  60739. get isConnectedToInputBlock(): boolean;
  60740. /**
  60741. * Gets a the connected input block (if any)
  60742. */
  60743. get connectInputBlock(): Nullable<InputBlock>;
  60744. /** Get the other side of the connection (if any) */
  60745. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60746. /** Get the block that owns this connection point */
  60747. get ownerBlock(): NodeMaterialBlock;
  60748. /** Get the block connected on the other side of this connection (if any) */
  60749. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60750. /** Get the block connected on the endpoints of this connection (if any) */
  60751. get connectedBlocks(): Array<NodeMaterialBlock>;
  60752. /** Gets the list of connected endpoints */
  60753. get endpoints(): NodeMaterialConnectionPoint[];
  60754. /** Gets a boolean indicating if that output point is connected to at least one input */
  60755. get hasEndpoints(): boolean;
  60756. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60757. get isConnectedInVertexShader(): boolean;
  60758. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60759. get isConnectedInFragmentShader(): boolean;
  60760. /**
  60761. * Creates a new connection point
  60762. * @param name defines the connection point name
  60763. * @param ownerBlock defines the block hosting this connection point
  60764. * @param direction defines the direction of the connection point
  60765. */
  60766. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60767. /**
  60768. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60769. * @returns the class name
  60770. */
  60771. getClassName(): string;
  60772. /**
  60773. * Gets a boolean indicating if the current point can be connected to another point
  60774. * @param connectionPoint defines the other connection point
  60775. * @returns a boolean
  60776. */
  60777. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60778. /**
  60779. * Gets a number indicating if the current point can be connected to another point
  60780. * @param connectionPoint defines the other connection point
  60781. * @returns a number defining the compatibility state
  60782. */
  60783. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60784. /**
  60785. * Connect this point to another connection point
  60786. * @param connectionPoint defines the other connection point
  60787. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60788. * @returns the current connection point
  60789. */
  60790. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60791. /**
  60792. * Disconnect this point from one of his endpoint
  60793. * @param endpoint defines the other connection point
  60794. * @returns the current connection point
  60795. */
  60796. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60797. /**
  60798. * Serializes this point in a JSON representation
  60799. * @returns the serialized point object
  60800. */
  60801. serialize(): any;
  60802. /**
  60803. * Release resources
  60804. */
  60805. dispose(): void;
  60806. }
  60807. }
  60808. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60812. import { Mesh } from "babylonjs/Meshes/mesh";
  60813. import { Effect } from "babylonjs/Materials/effect";
  60814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60816. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60817. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60818. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60819. /**
  60820. * Block used to add support for vertex skinning (bones)
  60821. */
  60822. export class BonesBlock extends NodeMaterialBlock {
  60823. /**
  60824. * Creates a new BonesBlock
  60825. * @param name defines the block name
  60826. */
  60827. constructor(name: string);
  60828. /**
  60829. * Initialize the block and prepare the context for build
  60830. * @param state defines the state that will be used for the build
  60831. */
  60832. initialize(state: NodeMaterialBuildState): void;
  60833. /**
  60834. * Gets the current class name
  60835. * @returns the class name
  60836. */
  60837. getClassName(): string;
  60838. /**
  60839. * Gets the matrix indices input component
  60840. */
  60841. get matricesIndices(): NodeMaterialConnectionPoint;
  60842. /**
  60843. * Gets the matrix weights input component
  60844. */
  60845. get matricesWeights(): NodeMaterialConnectionPoint;
  60846. /**
  60847. * Gets the extra matrix indices input component
  60848. */
  60849. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60850. /**
  60851. * Gets the extra matrix weights input component
  60852. */
  60853. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the world input component
  60856. */
  60857. get world(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the output component
  60860. */
  60861. get output(): NodeMaterialConnectionPoint;
  60862. autoConfigure(material: NodeMaterial): void;
  60863. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60866. protected _buildBlock(state: NodeMaterialBuildState): this;
  60867. }
  60868. }
  60869. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60875. /**
  60876. * Block used to add support for instances
  60877. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60878. */
  60879. export class InstancesBlock extends NodeMaterialBlock {
  60880. /**
  60881. * Creates a new InstancesBlock
  60882. * @param name defines the block name
  60883. */
  60884. constructor(name: string);
  60885. /**
  60886. * Gets the current class name
  60887. * @returns the class name
  60888. */
  60889. getClassName(): string;
  60890. /**
  60891. * Gets the first world row input component
  60892. */
  60893. get world0(): NodeMaterialConnectionPoint;
  60894. /**
  60895. * Gets the second world row input component
  60896. */
  60897. get world1(): NodeMaterialConnectionPoint;
  60898. /**
  60899. * Gets the third world row input component
  60900. */
  60901. get world2(): NodeMaterialConnectionPoint;
  60902. /**
  60903. * Gets the forth world row input component
  60904. */
  60905. get world3(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the world input component
  60908. */
  60909. get world(): NodeMaterialConnectionPoint;
  60910. /**
  60911. * Gets the output component
  60912. */
  60913. get output(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the isntanceID component
  60916. */
  60917. get instanceID(): NodeMaterialConnectionPoint;
  60918. autoConfigure(material: NodeMaterial): void;
  60919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60920. protected _buildBlock(state: NodeMaterialBuildState): this;
  60921. }
  60922. }
  60923. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60928. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60929. import { Effect } from "babylonjs/Materials/effect";
  60930. import { Mesh } from "babylonjs/Meshes/mesh";
  60931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60932. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60933. /**
  60934. * Block used to add morph targets support to vertex shader
  60935. */
  60936. export class MorphTargetsBlock extends NodeMaterialBlock {
  60937. private _repeatableContentAnchor;
  60938. /**
  60939. * Create a new MorphTargetsBlock
  60940. * @param name defines the block name
  60941. */
  60942. constructor(name: string);
  60943. /**
  60944. * Gets the current class name
  60945. * @returns the class name
  60946. */
  60947. getClassName(): string;
  60948. /**
  60949. * Gets the position input component
  60950. */
  60951. get position(): NodeMaterialConnectionPoint;
  60952. /**
  60953. * Gets the normal input component
  60954. */
  60955. get normal(): NodeMaterialConnectionPoint;
  60956. /**
  60957. * Gets the tangent input component
  60958. */
  60959. get tangent(): NodeMaterialConnectionPoint;
  60960. /**
  60961. * Gets the tangent input component
  60962. */
  60963. get uv(): NodeMaterialConnectionPoint;
  60964. /**
  60965. * Gets the position output component
  60966. */
  60967. get positionOutput(): NodeMaterialConnectionPoint;
  60968. /**
  60969. * Gets the normal output component
  60970. */
  60971. get normalOutput(): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Gets the tangent output component
  60974. */
  60975. get tangentOutput(): NodeMaterialConnectionPoint;
  60976. /**
  60977. * Gets the tangent output component
  60978. */
  60979. get uvOutput(): NodeMaterialConnectionPoint;
  60980. initialize(state: NodeMaterialBuildState): void;
  60981. autoConfigure(material: NodeMaterial): void;
  60982. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60984. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60985. protected _buildBlock(state: NodeMaterialBuildState): this;
  60986. }
  60987. }
  60988. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60992. import { Nullable } from "babylonjs/types";
  60993. import { Scene } from "babylonjs/scene";
  60994. import { Effect } from "babylonjs/Materials/effect";
  60995. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60996. import { Mesh } from "babylonjs/Meshes/mesh";
  60997. import { Light } from "babylonjs/Lights/light";
  60998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60999. /**
  61000. * Block used to get data information from a light
  61001. */
  61002. export class LightInformationBlock extends NodeMaterialBlock {
  61003. private _lightDataUniformName;
  61004. private _lightColorUniformName;
  61005. private _lightTypeDefineName;
  61006. /**
  61007. * Gets or sets the light associated with this block
  61008. */
  61009. light: Nullable<Light>;
  61010. /**
  61011. * Creates a new LightInformationBlock
  61012. * @param name defines the block name
  61013. */
  61014. constructor(name: string);
  61015. /**
  61016. * Gets the current class name
  61017. * @returns the class name
  61018. */
  61019. getClassName(): string;
  61020. /**
  61021. * Gets the world position input component
  61022. */
  61023. get worldPosition(): NodeMaterialConnectionPoint;
  61024. /**
  61025. * Gets the direction output component
  61026. */
  61027. get direction(): NodeMaterialConnectionPoint;
  61028. /**
  61029. * Gets the direction output component
  61030. */
  61031. get color(): NodeMaterialConnectionPoint;
  61032. /**
  61033. * Gets the direction output component
  61034. */
  61035. get intensity(): NodeMaterialConnectionPoint;
  61036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61038. protected _buildBlock(state: NodeMaterialBuildState): this;
  61039. serialize(): any;
  61040. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61041. }
  61042. }
  61043. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61044. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61045. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61046. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61047. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61048. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61049. }
  61050. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61055. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61056. import { Effect } from "babylonjs/Materials/effect";
  61057. import { Mesh } from "babylonjs/Meshes/mesh";
  61058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61059. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61060. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61061. /**
  61062. * Block used to add image processing support to fragment shader
  61063. */
  61064. export class ImageProcessingBlock extends NodeMaterialBlock {
  61065. /**
  61066. * Create a new ImageProcessingBlock
  61067. * @param name defines the block name
  61068. */
  61069. constructor(name: string);
  61070. /**
  61071. * Gets the current class name
  61072. * @returns the class name
  61073. */
  61074. getClassName(): string;
  61075. /**
  61076. * Gets the color input component
  61077. */
  61078. get color(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the output component
  61081. */
  61082. get output(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Initialize the block and prepare the context for build
  61085. * @param state defines the state that will be used for the build
  61086. */
  61087. initialize(state: NodeMaterialBuildState): void;
  61088. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61091. protected _buildBlock(state: NodeMaterialBuildState): this;
  61092. }
  61093. }
  61094. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61100. import { Effect } from "babylonjs/Materials/effect";
  61101. import { Mesh } from "babylonjs/Meshes/mesh";
  61102. import { Scene } from "babylonjs/scene";
  61103. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61104. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61105. /**
  61106. * Block used to pertub normals based on a normal map
  61107. */
  61108. export class PerturbNormalBlock extends NodeMaterialBlock {
  61109. private _tangentSpaceParameterName;
  61110. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61111. invertX: boolean;
  61112. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61113. invertY: boolean;
  61114. /**
  61115. * Create a new PerturbNormalBlock
  61116. * @param name defines the block name
  61117. */
  61118. constructor(name: string);
  61119. /**
  61120. * Gets the current class name
  61121. * @returns the class name
  61122. */
  61123. getClassName(): string;
  61124. /**
  61125. * Gets the world position input component
  61126. */
  61127. get worldPosition(): NodeMaterialConnectionPoint;
  61128. /**
  61129. * Gets the world normal input component
  61130. */
  61131. get worldNormal(): NodeMaterialConnectionPoint;
  61132. /**
  61133. * Gets the world tangent input component
  61134. */
  61135. get worldTangent(): NodeMaterialConnectionPoint;
  61136. /**
  61137. * Gets the uv input component
  61138. */
  61139. get uv(): NodeMaterialConnectionPoint;
  61140. /**
  61141. * Gets the normal map color input component
  61142. */
  61143. get normalMapColor(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Gets the strength input component
  61146. */
  61147. get strength(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the output component
  61150. */
  61151. get output(): NodeMaterialConnectionPoint;
  61152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61154. autoConfigure(material: NodeMaterial): void;
  61155. protected _buildBlock(state: NodeMaterialBuildState): this;
  61156. protected _dumpPropertiesCode(): string;
  61157. serialize(): any;
  61158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61159. }
  61160. }
  61161. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61165. /**
  61166. * Block used to discard a pixel if a value is smaller than a cutoff
  61167. */
  61168. export class DiscardBlock extends NodeMaterialBlock {
  61169. /**
  61170. * Create a new DiscardBlock
  61171. * @param name defines the block name
  61172. */
  61173. constructor(name: string);
  61174. /**
  61175. * Gets the current class name
  61176. * @returns the class name
  61177. */
  61178. getClassName(): string;
  61179. /**
  61180. * Gets the color input component
  61181. */
  61182. get value(): NodeMaterialConnectionPoint;
  61183. /**
  61184. * Gets the cutoff input component
  61185. */
  61186. get cutoff(): NodeMaterialConnectionPoint;
  61187. protected _buildBlock(state: NodeMaterialBuildState): this;
  61188. }
  61189. }
  61190. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61194. /**
  61195. * Block used to test if the fragment shader is front facing
  61196. */
  61197. export class FrontFacingBlock extends NodeMaterialBlock {
  61198. /**
  61199. * Creates a new FrontFacingBlock
  61200. * @param name defines the block name
  61201. */
  61202. constructor(name: string);
  61203. /**
  61204. * Gets the current class name
  61205. * @returns the class name
  61206. */
  61207. getClassName(): string;
  61208. /**
  61209. * Gets the output component
  61210. */
  61211. get output(): NodeMaterialConnectionPoint;
  61212. protected _buildBlock(state: NodeMaterialBuildState): this;
  61213. }
  61214. }
  61215. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61219. /**
  61220. * Block used to get the derivative value on x and y of a given input
  61221. */
  61222. export class DerivativeBlock extends NodeMaterialBlock {
  61223. /**
  61224. * Create a new DerivativeBlock
  61225. * @param name defines the block name
  61226. */
  61227. constructor(name: string);
  61228. /**
  61229. * Gets the current class name
  61230. * @returns the class name
  61231. */
  61232. getClassName(): string;
  61233. /**
  61234. * Gets the input component
  61235. */
  61236. get input(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the derivative output on x
  61239. */
  61240. get dx(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the derivative output on y
  61243. */
  61244. get dy(): NodeMaterialConnectionPoint;
  61245. protected _buildBlock(state: NodeMaterialBuildState): this;
  61246. }
  61247. }
  61248. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61249. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61250. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61251. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61252. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61253. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61254. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61255. }
  61256. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61259. import { Mesh } from "babylonjs/Meshes/mesh";
  61260. import { Effect } from "babylonjs/Materials/effect";
  61261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61263. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61264. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61265. /**
  61266. * Block used to add support for scene fog
  61267. */
  61268. export class FogBlock extends NodeMaterialBlock {
  61269. private _fogDistanceName;
  61270. private _fogParameters;
  61271. /**
  61272. * Create a new FogBlock
  61273. * @param name defines the block name
  61274. */
  61275. constructor(name: string);
  61276. /**
  61277. * Gets the current class name
  61278. * @returns the class name
  61279. */
  61280. getClassName(): string;
  61281. /**
  61282. * Gets the world position input component
  61283. */
  61284. get worldPosition(): NodeMaterialConnectionPoint;
  61285. /**
  61286. * Gets the view input component
  61287. */
  61288. get view(): NodeMaterialConnectionPoint;
  61289. /**
  61290. * Gets the color input component
  61291. */
  61292. get input(): NodeMaterialConnectionPoint;
  61293. /**
  61294. * Gets the fog color input component
  61295. */
  61296. get fogColor(): NodeMaterialConnectionPoint;
  61297. /**
  61298. * Gets the output component
  61299. */
  61300. get output(): NodeMaterialConnectionPoint;
  61301. autoConfigure(material: NodeMaterial): void;
  61302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61303. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61304. protected _buildBlock(state: NodeMaterialBuildState): this;
  61305. }
  61306. }
  61307. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61312. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61313. import { Effect } from "babylonjs/Materials/effect";
  61314. import { Mesh } from "babylonjs/Meshes/mesh";
  61315. import { Light } from "babylonjs/Lights/light";
  61316. import { Nullable } from "babylonjs/types";
  61317. import { Scene } from "babylonjs/scene";
  61318. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61319. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61320. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61321. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61322. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61323. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61324. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61325. /**
  61326. * Block used to add light in the fragment shader
  61327. */
  61328. export class LightBlock extends NodeMaterialBlock {
  61329. private _lightId;
  61330. /**
  61331. * Gets or sets the light associated with this block
  61332. */
  61333. light: Nullable<Light>;
  61334. /**
  61335. * Create a new LightBlock
  61336. * @param name defines the block name
  61337. */
  61338. constructor(name: string);
  61339. /**
  61340. * Gets the current class name
  61341. * @returns the class name
  61342. */
  61343. getClassName(): string;
  61344. /**
  61345. * Gets the world position input component
  61346. */
  61347. get worldPosition(): NodeMaterialConnectionPoint;
  61348. /**
  61349. * Gets the world normal input component
  61350. */
  61351. get worldNormal(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the camera (or eye) position component
  61354. */
  61355. get cameraPosition(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the glossiness component
  61358. */
  61359. get glossiness(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the glossinness power component
  61362. */
  61363. get glossPower(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the diffuse color component
  61366. */
  61367. get diffuseColor(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the specular color component
  61370. */
  61371. get specularColor(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the diffuse output component
  61374. */
  61375. get diffuseOutput(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the specular output component
  61378. */
  61379. get specularOutput(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the shadow output component
  61382. */
  61383. get shadow(): NodeMaterialConnectionPoint;
  61384. autoConfigure(material: NodeMaterial): void;
  61385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61386. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61388. private _injectVertexCode;
  61389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61390. serialize(): any;
  61391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61392. }
  61393. }
  61394. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61395. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61396. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61397. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61398. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61399. }
  61400. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61401. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61402. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61403. }
  61404. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61408. /**
  61409. * Block used to multiply 2 values
  61410. */
  61411. export class MultiplyBlock extends NodeMaterialBlock {
  61412. /**
  61413. * Creates a new MultiplyBlock
  61414. * @param name defines the block name
  61415. */
  61416. constructor(name: string);
  61417. /**
  61418. * Gets the current class name
  61419. * @returns the class name
  61420. */
  61421. getClassName(): string;
  61422. /**
  61423. * Gets the left operand input component
  61424. */
  61425. get left(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the right operand input component
  61428. */
  61429. get right(): NodeMaterialConnectionPoint;
  61430. /**
  61431. * Gets the output component
  61432. */
  61433. get output(): NodeMaterialConnectionPoint;
  61434. protected _buildBlock(state: NodeMaterialBuildState): this;
  61435. }
  61436. }
  61437. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61441. /**
  61442. * Block used to add 2 vectors
  61443. */
  61444. export class AddBlock extends NodeMaterialBlock {
  61445. /**
  61446. * Creates a new AddBlock
  61447. * @param name defines the block name
  61448. */
  61449. constructor(name: string);
  61450. /**
  61451. * Gets the current class name
  61452. * @returns the class name
  61453. */
  61454. getClassName(): string;
  61455. /**
  61456. * Gets the left operand input component
  61457. */
  61458. get left(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the right operand input component
  61461. */
  61462. get right(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the output component
  61465. */
  61466. get output(): NodeMaterialConnectionPoint;
  61467. protected _buildBlock(state: NodeMaterialBuildState): this;
  61468. }
  61469. }
  61470. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61474. /**
  61475. * Block used to scale a vector by a float
  61476. */
  61477. export class ScaleBlock extends NodeMaterialBlock {
  61478. /**
  61479. * Creates a new ScaleBlock
  61480. * @param name defines the block name
  61481. */
  61482. constructor(name: string);
  61483. /**
  61484. * Gets the current class name
  61485. * @returns the class name
  61486. */
  61487. getClassName(): string;
  61488. /**
  61489. * Gets the input component
  61490. */
  61491. get input(): NodeMaterialConnectionPoint;
  61492. /**
  61493. * Gets the factor input component
  61494. */
  61495. get factor(): NodeMaterialConnectionPoint;
  61496. /**
  61497. * Gets the output component
  61498. */
  61499. get output(): NodeMaterialConnectionPoint;
  61500. protected _buildBlock(state: NodeMaterialBuildState): this;
  61501. }
  61502. }
  61503. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61507. import { Scene } from "babylonjs/scene";
  61508. /**
  61509. * Block used to clamp a float
  61510. */
  61511. export class ClampBlock extends NodeMaterialBlock {
  61512. /** Gets or sets the minimum range */
  61513. minimum: number;
  61514. /** Gets or sets the maximum range */
  61515. maximum: number;
  61516. /**
  61517. * Creates a new ClampBlock
  61518. * @param name defines the block name
  61519. */
  61520. constructor(name: string);
  61521. /**
  61522. * Gets the current class name
  61523. * @returns the class name
  61524. */
  61525. getClassName(): string;
  61526. /**
  61527. * Gets the value input component
  61528. */
  61529. get value(): NodeMaterialConnectionPoint;
  61530. /**
  61531. * Gets the output component
  61532. */
  61533. get output(): NodeMaterialConnectionPoint;
  61534. protected _buildBlock(state: NodeMaterialBuildState): this;
  61535. protected _dumpPropertiesCode(): string;
  61536. serialize(): any;
  61537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61538. }
  61539. }
  61540. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61544. /**
  61545. * Block used to apply a cross product between 2 vectors
  61546. */
  61547. export class CrossBlock extends NodeMaterialBlock {
  61548. /**
  61549. * Creates a new CrossBlock
  61550. * @param name defines the block name
  61551. */
  61552. constructor(name: string);
  61553. /**
  61554. * Gets the current class name
  61555. * @returns the class name
  61556. */
  61557. getClassName(): string;
  61558. /**
  61559. * Gets the left operand input component
  61560. */
  61561. get left(): NodeMaterialConnectionPoint;
  61562. /**
  61563. * Gets the right operand input component
  61564. */
  61565. get right(): NodeMaterialConnectionPoint;
  61566. /**
  61567. * Gets the output component
  61568. */
  61569. get output(): NodeMaterialConnectionPoint;
  61570. protected _buildBlock(state: NodeMaterialBuildState): this;
  61571. }
  61572. }
  61573. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61577. /**
  61578. * Block used to apply a dot product between 2 vectors
  61579. */
  61580. export class DotBlock extends NodeMaterialBlock {
  61581. /**
  61582. * Creates a new DotBlock
  61583. * @param name defines the block name
  61584. */
  61585. constructor(name: string);
  61586. /**
  61587. * Gets the current class name
  61588. * @returns the class name
  61589. */
  61590. getClassName(): string;
  61591. /**
  61592. * Gets the left operand input component
  61593. */
  61594. get left(): NodeMaterialConnectionPoint;
  61595. /**
  61596. * Gets the right operand input component
  61597. */
  61598. get right(): NodeMaterialConnectionPoint;
  61599. /**
  61600. * Gets the output component
  61601. */
  61602. get output(): NodeMaterialConnectionPoint;
  61603. protected _buildBlock(state: NodeMaterialBuildState): this;
  61604. }
  61605. }
  61606. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61610. import { Vector2 } from "babylonjs/Maths/math.vector";
  61611. import { Scene } from "babylonjs/scene";
  61612. /**
  61613. * Block used to remap a float from a range to a new one
  61614. */
  61615. export class RemapBlock extends NodeMaterialBlock {
  61616. /**
  61617. * Gets or sets the source range
  61618. */
  61619. sourceRange: Vector2;
  61620. /**
  61621. * Gets or sets the target range
  61622. */
  61623. targetRange: Vector2;
  61624. /**
  61625. * Creates a new RemapBlock
  61626. * @param name defines the block name
  61627. */
  61628. constructor(name: string);
  61629. /**
  61630. * Gets the current class name
  61631. * @returns the class name
  61632. */
  61633. getClassName(): string;
  61634. /**
  61635. * Gets the input component
  61636. */
  61637. get input(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the source min input component
  61640. */
  61641. get sourceMin(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the source max input component
  61644. */
  61645. get sourceMax(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the target min input component
  61648. */
  61649. get targetMin(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the target max input component
  61652. */
  61653. get targetMax(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the output component
  61656. */
  61657. get output(): NodeMaterialConnectionPoint;
  61658. protected _buildBlock(state: NodeMaterialBuildState): this;
  61659. protected _dumpPropertiesCode(): string;
  61660. serialize(): any;
  61661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61662. }
  61663. }
  61664. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61668. /**
  61669. * Block used to normalize a vector
  61670. */
  61671. export class NormalizeBlock extends NodeMaterialBlock {
  61672. /**
  61673. * Creates a new NormalizeBlock
  61674. * @param name defines the block name
  61675. */
  61676. constructor(name: string);
  61677. /**
  61678. * Gets the current class name
  61679. * @returns the class name
  61680. */
  61681. getClassName(): string;
  61682. /**
  61683. * Gets the input component
  61684. */
  61685. get input(): NodeMaterialConnectionPoint;
  61686. /**
  61687. * Gets the output component
  61688. */
  61689. get output(): NodeMaterialConnectionPoint;
  61690. protected _buildBlock(state: NodeMaterialBuildState): this;
  61691. }
  61692. }
  61693. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61697. import { Scene } from "babylonjs/scene";
  61698. /**
  61699. * Operations supported by the Trigonometry block
  61700. */
  61701. export enum TrigonometryBlockOperations {
  61702. /** Cos */
  61703. Cos = 0,
  61704. /** Sin */
  61705. Sin = 1,
  61706. /** Abs */
  61707. Abs = 2,
  61708. /** Exp */
  61709. Exp = 3,
  61710. /** Exp2 */
  61711. Exp2 = 4,
  61712. /** Round */
  61713. Round = 5,
  61714. /** Floor */
  61715. Floor = 6,
  61716. /** Ceiling */
  61717. Ceiling = 7,
  61718. /** Square root */
  61719. Sqrt = 8,
  61720. /** Log */
  61721. Log = 9,
  61722. /** Tangent */
  61723. Tan = 10,
  61724. /** Arc tangent */
  61725. ArcTan = 11,
  61726. /** Arc cosinus */
  61727. ArcCos = 12,
  61728. /** Arc sinus */
  61729. ArcSin = 13,
  61730. /** Fraction */
  61731. Fract = 14,
  61732. /** Sign */
  61733. Sign = 15,
  61734. /** To radians (from degrees) */
  61735. Radians = 16,
  61736. /** To degrees (from radians) */
  61737. Degrees = 17
  61738. }
  61739. /**
  61740. * Block used to apply trigonometry operation to floats
  61741. */
  61742. export class TrigonometryBlock extends NodeMaterialBlock {
  61743. /**
  61744. * Gets or sets the operation applied by the block
  61745. */
  61746. operation: TrigonometryBlockOperations;
  61747. /**
  61748. * Creates a new TrigonometryBlock
  61749. * @param name defines the block name
  61750. */
  61751. constructor(name: string);
  61752. /**
  61753. * Gets the current class name
  61754. * @returns the class name
  61755. */
  61756. getClassName(): string;
  61757. /**
  61758. * Gets the input component
  61759. */
  61760. get input(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the output component
  61763. */
  61764. get output(): NodeMaterialConnectionPoint;
  61765. protected _buildBlock(state: NodeMaterialBuildState): this;
  61766. serialize(): any;
  61767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61768. protected _dumpPropertiesCode(): string;
  61769. }
  61770. }
  61771. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61775. /**
  61776. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61777. */
  61778. export class ColorMergerBlock extends NodeMaterialBlock {
  61779. /**
  61780. * Create a new ColorMergerBlock
  61781. * @param name defines the block name
  61782. */
  61783. constructor(name: string);
  61784. /**
  61785. * Gets the current class name
  61786. * @returns the class name
  61787. */
  61788. getClassName(): string;
  61789. /**
  61790. * Gets the rgb component (input)
  61791. */
  61792. get rgbIn(): NodeMaterialConnectionPoint;
  61793. /**
  61794. * Gets the r component (input)
  61795. */
  61796. get r(): NodeMaterialConnectionPoint;
  61797. /**
  61798. * Gets the g component (input)
  61799. */
  61800. get g(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the b component (input)
  61803. */
  61804. get b(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the a component (input)
  61807. */
  61808. get a(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the rgba component (output)
  61811. */
  61812. get rgba(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the rgb component (output)
  61815. */
  61816. get rgbOut(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the rgb component (output)
  61819. * @deprecated Please use rgbOut instead.
  61820. */
  61821. get rgb(): NodeMaterialConnectionPoint;
  61822. protected _buildBlock(state: NodeMaterialBuildState): this;
  61823. }
  61824. }
  61825. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  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. /**
  61830. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61831. */
  61832. export class VectorMergerBlock extends NodeMaterialBlock {
  61833. /**
  61834. * Create a new VectorMergerBlock
  61835. * @param name defines the block name
  61836. */
  61837. constructor(name: string);
  61838. /**
  61839. * Gets the current class name
  61840. * @returns the class name
  61841. */
  61842. getClassName(): string;
  61843. /**
  61844. * Gets the xyz component (input)
  61845. */
  61846. get xyzIn(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the xy component (input)
  61849. */
  61850. get xyIn(): NodeMaterialConnectionPoint;
  61851. /**
  61852. * Gets the x component (input)
  61853. */
  61854. get x(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the y component (input)
  61857. */
  61858. get y(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the z component (input)
  61861. */
  61862. get z(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the w component (input)
  61865. */
  61866. get w(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the xyzw component (output)
  61869. */
  61870. get xyzw(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the xyz component (output)
  61873. */
  61874. get xyzOut(): NodeMaterialConnectionPoint;
  61875. /**
  61876. * Gets the xy component (output)
  61877. */
  61878. get xyOut(): NodeMaterialConnectionPoint;
  61879. /**
  61880. * Gets the xy component (output)
  61881. * @deprecated Please use xyOut instead.
  61882. */
  61883. get xy(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the xyz component (output)
  61886. * @deprecated Please use xyzOut instead.
  61887. */
  61888. get xyz(): NodeMaterialConnectionPoint;
  61889. protected _buildBlock(state: NodeMaterialBuildState): this;
  61890. }
  61891. }
  61892. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61896. /**
  61897. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61898. */
  61899. export class ColorSplitterBlock extends NodeMaterialBlock {
  61900. /**
  61901. * Create a new ColorSplitterBlock
  61902. * @param name defines the block name
  61903. */
  61904. constructor(name: string);
  61905. /**
  61906. * Gets the current class name
  61907. * @returns the class name
  61908. */
  61909. getClassName(): string;
  61910. /**
  61911. * Gets the rgba component (input)
  61912. */
  61913. get rgba(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the rgb component (input)
  61916. */
  61917. get rgbIn(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the rgb component (output)
  61920. */
  61921. get rgbOut(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the r component (output)
  61924. */
  61925. get r(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the g component (output)
  61928. */
  61929. get g(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the b component (output)
  61932. */
  61933. get b(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the a component (output)
  61936. */
  61937. get a(): NodeMaterialConnectionPoint;
  61938. protected _inputRename(name: string): string;
  61939. protected _outputRename(name: string): string;
  61940. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61941. }
  61942. }
  61943. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61947. /**
  61948. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61949. */
  61950. export class VectorSplitterBlock extends NodeMaterialBlock {
  61951. /**
  61952. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  61963. */
  61964. get xyzw(): NodeMaterialConnectionPoint;
  61965. /**
  61966. * Gets the xyz component (input)
  61967. */
  61968. get xyzIn(): NodeMaterialConnectionPoint;
  61969. /**
  61970. * Gets the xy component (input)
  61971. */
  61972. get xyIn(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the xyz component (output)
  61975. */
  61976. get xyzOut(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the xy component (output)
  61979. */
  61980. get xyOut(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the x component (output)
  61983. */
  61984. get x(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the y component (output)
  61987. */
  61988. get y(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the z component (output)
  61991. */
  61992. get z(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the w component (output)
  61995. */
  61996. get w(): NodeMaterialConnectionPoint;
  61997. protected _inputRename(name: string): string;
  61998. protected _outputRename(name: string): string;
  61999. protected _buildBlock(state: NodeMaterialBuildState): this;
  62000. }
  62001. }
  62002. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62006. /**
  62007. * Block used to lerp between 2 values
  62008. */
  62009. export class LerpBlock extends NodeMaterialBlock {
  62010. /**
  62011. * Creates a new LerpBlock
  62012. * @param name defines the block name
  62013. */
  62014. constructor(name: string);
  62015. /**
  62016. * Gets the current class name
  62017. * @returns the class name
  62018. */
  62019. getClassName(): string;
  62020. /**
  62021. * Gets the left operand input component
  62022. */
  62023. get left(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the right operand input component
  62026. */
  62027. get right(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the gradient operand input component
  62030. */
  62031. get gradient(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the output component
  62034. */
  62035. get output(): NodeMaterialConnectionPoint;
  62036. protected _buildBlock(state: NodeMaterialBuildState): this;
  62037. }
  62038. }
  62039. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62043. /**
  62044. * Block used to divide 2 vectors
  62045. */
  62046. export class DivideBlock extends NodeMaterialBlock {
  62047. /**
  62048. * Creates a new DivideBlock
  62049. * @param name defines the block name
  62050. */
  62051. constructor(name: string);
  62052. /**
  62053. * Gets the current class name
  62054. * @returns the class name
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * Gets the left operand input component
  62059. */
  62060. get left(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the right operand input component
  62063. */
  62064. get right(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the output component
  62067. */
  62068. get output(): NodeMaterialConnectionPoint;
  62069. protected _buildBlock(state: NodeMaterialBuildState): this;
  62070. }
  62071. }
  62072. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62076. /**
  62077. * Block used to subtract 2 vectors
  62078. */
  62079. export class SubtractBlock extends NodeMaterialBlock {
  62080. /**
  62081. * Creates a new SubtractBlock
  62082. * @param name defines the block name
  62083. */
  62084. constructor(name: string);
  62085. /**
  62086. * Gets the current class name
  62087. * @returns the class name
  62088. */
  62089. getClassName(): string;
  62090. /**
  62091. * Gets the left operand input component
  62092. */
  62093. get left(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the right operand input component
  62096. */
  62097. get right(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the output component
  62100. */
  62101. get output(): NodeMaterialConnectionPoint;
  62102. protected _buildBlock(state: NodeMaterialBuildState): this;
  62103. }
  62104. }
  62105. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62109. /**
  62110. * Block used to step a value
  62111. */
  62112. export class StepBlock extends NodeMaterialBlock {
  62113. /**
  62114. * Creates a new StepBlock
  62115. * @param name defines the block name
  62116. */
  62117. constructor(name: string);
  62118. /**
  62119. * Gets the current class name
  62120. * @returns the class name
  62121. */
  62122. getClassName(): string;
  62123. /**
  62124. * Gets the value operand input component
  62125. */
  62126. get value(): NodeMaterialConnectionPoint;
  62127. /**
  62128. * Gets the edge operand input component
  62129. */
  62130. get edge(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the output component
  62133. */
  62134. get output(): NodeMaterialConnectionPoint;
  62135. protected _buildBlock(state: NodeMaterialBuildState): this;
  62136. }
  62137. }
  62138. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62142. /**
  62143. * Block used to get the opposite (1 - x) of a value
  62144. */
  62145. export class OneMinusBlock extends NodeMaterialBlock {
  62146. /**
  62147. * Creates a new OneMinusBlock
  62148. * @param name defines the block name
  62149. */
  62150. constructor(name: string);
  62151. /**
  62152. * Gets the current class name
  62153. * @returns the class name
  62154. */
  62155. getClassName(): string;
  62156. /**
  62157. * Gets the input component
  62158. */
  62159. get input(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the output component
  62162. */
  62163. get output(): NodeMaterialConnectionPoint;
  62164. protected _buildBlock(state: NodeMaterialBuildState): this;
  62165. }
  62166. }
  62167. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62171. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62172. /**
  62173. * Block used to get the view direction
  62174. */
  62175. export class ViewDirectionBlock extends NodeMaterialBlock {
  62176. /**
  62177. * Creates a new ViewDirectionBlock
  62178. * @param name defines the block name
  62179. */
  62180. constructor(name: string);
  62181. /**
  62182. * Gets the current class name
  62183. * @returns the class name
  62184. */
  62185. getClassName(): string;
  62186. /**
  62187. * Gets the world position component
  62188. */
  62189. get worldPosition(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the camera position component
  62192. */
  62193. get cameraPosition(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the output component
  62196. */
  62197. get output(): NodeMaterialConnectionPoint;
  62198. autoConfigure(material: NodeMaterial): void;
  62199. protected _buildBlock(state: NodeMaterialBuildState): this;
  62200. }
  62201. }
  62202. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62206. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62207. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62208. /**
  62209. * Block used to compute fresnel value
  62210. */
  62211. export class FresnelBlock extends NodeMaterialBlock {
  62212. /**
  62213. * Create a new FresnelBlock
  62214. * @param name defines the block name
  62215. */
  62216. constructor(name: string);
  62217. /**
  62218. * Gets the current class name
  62219. * @returns the class name
  62220. */
  62221. getClassName(): string;
  62222. /**
  62223. * Gets the world normal input component
  62224. */
  62225. get worldNormal(): NodeMaterialConnectionPoint;
  62226. /**
  62227. * Gets the view direction input component
  62228. */
  62229. get viewDirection(): NodeMaterialConnectionPoint;
  62230. /**
  62231. * Gets the bias input component
  62232. */
  62233. get bias(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the camera (or eye) position component
  62236. */
  62237. get power(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the fresnel output component
  62240. */
  62241. get fresnel(): NodeMaterialConnectionPoint;
  62242. autoConfigure(material: NodeMaterial): void;
  62243. protected _buildBlock(state: NodeMaterialBuildState): this;
  62244. }
  62245. }
  62246. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62250. /**
  62251. * Block used to get the max of 2 values
  62252. */
  62253. export class MaxBlock extends NodeMaterialBlock {
  62254. /**
  62255. * Creates a new MaxBlock
  62256. * @param name defines the block name
  62257. */
  62258. constructor(name: string);
  62259. /**
  62260. * Gets the current class name
  62261. * @returns the class name
  62262. */
  62263. getClassName(): string;
  62264. /**
  62265. * Gets the left operand input component
  62266. */
  62267. get left(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the right operand input component
  62270. */
  62271. get right(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Gets the output component
  62274. */
  62275. get output(): NodeMaterialConnectionPoint;
  62276. protected _buildBlock(state: NodeMaterialBuildState): this;
  62277. }
  62278. }
  62279. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62283. /**
  62284. * Block used to get the min of 2 values
  62285. */
  62286. export class MinBlock extends NodeMaterialBlock {
  62287. /**
  62288. * Creates a new MinBlock
  62289. * @param name defines the block name
  62290. */
  62291. constructor(name: string);
  62292. /**
  62293. * Gets the current class name
  62294. * @returns the class name
  62295. */
  62296. getClassName(): string;
  62297. /**
  62298. * Gets the left operand input component
  62299. */
  62300. get left(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the right operand input component
  62303. */
  62304. get right(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the output component
  62307. */
  62308. get output(): NodeMaterialConnectionPoint;
  62309. protected _buildBlock(state: NodeMaterialBuildState): this;
  62310. }
  62311. }
  62312. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62316. /**
  62317. * Block used to get the distance between 2 values
  62318. */
  62319. export class DistanceBlock extends NodeMaterialBlock {
  62320. /**
  62321. * Creates a new DistanceBlock
  62322. * @param name defines the block name
  62323. */
  62324. constructor(name: string);
  62325. /**
  62326. * Gets the current class name
  62327. * @returns the class name
  62328. */
  62329. getClassName(): string;
  62330. /**
  62331. * Gets the left operand input component
  62332. */
  62333. get left(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the right operand input component
  62336. */
  62337. get right(): NodeMaterialConnectionPoint;
  62338. /**
  62339. * Gets the output component
  62340. */
  62341. get output(): NodeMaterialConnectionPoint;
  62342. protected _buildBlock(state: NodeMaterialBuildState): this;
  62343. }
  62344. }
  62345. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62349. /**
  62350. * Block used to get the length of a vector
  62351. */
  62352. export class LengthBlock extends NodeMaterialBlock {
  62353. /**
  62354. * Creates a new LengthBlock
  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. }
  62373. }
  62374. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62378. /**
  62379. * Block used to get negative version of a value (i.e. x * -1)
  62380. */
  62381. export class NegateBlock extends NodeMaterialBlock {
  62382. /**
  62383. * Creates a new NegateBlock
  62384. * @param name defines the block name
  62385. */
  62386. constructor(name: string);
  62387. /**
  62388. * Gets the current class name
  62389. * @returns the class name
  62390. */
  62391. getClassName(): string;
  62392. /**
  62393. * Gets the value input component
  62394. */
  62395. get value(): NodeMaterialConnectionPoint;
  62396. /**
  62397. * Gets the output component
  62398. */
  62399. get output(): NodeMaterialConnectionPoint;
  62400. protected _buildBlock(state: NodeMaterialBuildState): this;
  62401. }
  62402. }
  62403. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62407. /**
  62408. * Block used to get the value of the first parameter raised to the power of the second
  62409. */
  62410. export class PowBlock extends NodeMaterialBlock {
  62411. /**
  62412. * Creates a new PowBlock
  62413. * @param name defines the block name
  62414. */
  62415. constructor(name: string);
  62416. /**
  62417. * Gets the current class name
  62418. * @returns the class name
  62419. */
  62420. getClassName(): string;
  62421. /**
  62422. * Gets the value operand input component
  62423. */
  62424. get value(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the power operand input component
  62427. */
  62428. get power(): NodeMaterialConnectionPoint;
  62429. /**
  62430. * Gets the output component
  62431. */
  62432. get output(): NodeMaterialConnectionPoint;
  62433. protected _buildBlock(state: NodeMaterialBuildState): this;
  62434. }
  62435. }
  62436. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62440. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62441. /**
  62442. * Block used to get a random number
  62443. */
  62444. export class RandomNumberBlock extends NodeMaterialBlock {
  62445. /**
  62446. * Creates a new RandomNumberBlock
  62447. * @param name defines the block name
  62448. */
  62449. constructor(name: string);
  62450. /**
  62451. * Gets the current class name
  62452. * @returns the class name
  62453. */
  62454. getClassName(): string;
  62455. /**
  62456. * Gets the seed input component
  62457. */
  62458. get seed(): NodeMaterialConnectionPoint;
  62459. /**
  62460. * Gets the output component
  62461. */
  62462. get output(): NodeMaterialConnectionPoint;
  62463. protected _buildBlock(state: NodeMaterialBuildState): this;
  62464. }
  62465. }
  62466. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62470. /**
  62471. * Block used to compute arc tangent of 2 values
  62472. */
  62473. export class ArcTan2Block extends NodeMaterialBlock {
  62474. /**
  62475. * Creates a new ArcTan2Block
  62476. * @param name defines the block name
  62477. */
  62478. constructor(name: string);
  62479. /**
  62480. * Gets the current class name
  62481. * @returns the class name
  62482. */
  62483. getClassName(): string;
  62484. /**
  62485. * Gets the x operand input component
  62486. */
  62487. get x(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the y operand input component
  62490. */
  62491. get y(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the output component
  62494. */
  62495. get output(): NodeMaterialConnectionPoint;
  62496. protected _buildBlock(state: NodeMaterialBuildState): this;
  62497. }
  62498. }
  62499. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62503. /**
  62504. * Block used to smooth step a value
  62505. */
  62506. export class SmoothStepBlock extends NodeMaterialBlock {
  62507. /**
  62508. * Creates a new SmoothStepBlock
  62509. * @param name defines the block name
  62510. */
  62511. constructor(name: string);
  62512. /**
  62513. * Gets the current class name
  62514. * @returns the class name
  62515. */
  62516. getClassName(): string;
  62517. /**
  62518. * Gets the value operand input component
  62519. */
  62520. get value(): NodeMaterialConnectionPoint;
  62521. /**
  62522. * Gets the first edge operand input component
  62523. */
  62524. get edge0(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the second edge operand input component
  62527. */
  62528. get edge1(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the output component
  62531. */
  62532. get output(): NodeMaterialConnectionPoint;
  62533. protected _buildBlock(state: NodeMaterialBuildState): this;
  62534. }
  62535. }
  62536. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62540. /**
  62541. * Block used to get the reciprocal (1 / x) of a value
  62542. */
  62543. export class ReciprocalBlock extends NodeMaterialBlock {
  62544. /**
  62545. * Creates a new ReciprocalBlock
  62546. * @param name defines the block name
  62547. */
  62548. constructor(name: string);
  62549. /**
  62550. * Gets the current class name
  62551. * @returns the class name
  62552. */
  62553. getClassName(): string;
  62554. /**
  62555. * Gets the input component
  62556. */
  62557. get input(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the output component
  62560. */
  62561. get output(): NodeMaterialConnectionPoint;
  62562. protected _buildBlock(state: NodeMaterialBuildState): this;
  62563. }
  62564. }
  62565. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62569. /**
  62570. * Block used to replace a color by another one
  62571. */
  62572. export class ReplaceColorBlock extends NodeMaterialBlock {
  62573. /**
  62574. * Creates a new ReplaceColorBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Gets the current class name
  62580. * @returns the class name
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Gets the value input component
  62585. */
  62586. get value(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the reference input component
  62589. */
  62590. get reference(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the distance input component
  62593. */
  62594. get distance(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the replacement input component
  62597. */
  62598. get replacement(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the output component
  62601. */
  62602. get output(): NodeMaterialConnectionPoint;
  62603. protected _buildBlock(state: NodeMaterialBuildState): this;
  62604. }
  62605. }
  62606. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62610. /**
  62611. * Block used to posterize a value
  62612. * @see https://en.wikipedia.org/wiki/Posterization
  62613. */
  62614. export class PosterizeBlock extends NodeMaterialBlock {
  62615. /**
  62616. * Creates a new PosterizeBlock
  62617. * @param name defines the block name
  62618. */
  62619. constructor(name: string);
  62620. /**
  62621. * Gets the current class name
  62622. * @returns the class name
  62623. */
  62624. getClassName(): string;
  62625. /**
  62626. * Gets the value input component
  62627. */
  62628. get value(): NodeMaterialConnectionPoint;
  62629. /**
  62630. * Gets the steps input component
  62631. */
  62632. get steps(): NodeMaterialConnectionPoint;
  62633. /**
  62634. * Gets the output component
  62635. */
  62636. get output(): NodeMaterialConnectionPoint;
  62637. protected _buildBlock(state: NodeMaterialBuildState): this;
  62638. }
  62639. }
  62640. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62644. import { Scene } from "babylonjs/scene";
  62645. /**
  62646. * Operations supported by the Wave block
  62647. */
  62648. export enum WaveBlockKind {
  62649. /** SawTooth */
  62650. SawTooth = 0,
  62651. /** Square */
  62652. Square = 1,
  62653. /** Triangle */
  62654. Triangle = 2
  62655. }
  62656. /**
  62657. * Block used to apply wave operation to floats
  62658. */
  62659. export class WaveBlock extends NodeMaterialBlock {
  62660. /**
  62661. * Gets or sets the kibnd of wave to be applied by the block
  62662. */
  62663. kind: WaveBlockKind;
  62664. /**
  62665. * Creates a new WaveBlock
  62666. * @param name defines the block name
  62667. */
  62668. constructor(name: string);
  62669. /**
  62670. * Gets the current class name
  62671. * @returns the class name
  62672. */
  62673. getClassName(): string;
  62674. /**
  62675. * Gets the input component
  62676. */
  62677. get input(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the output component
  62680. */
  62681. get output(): NodeMaterialConnectionPoint;
  62682. protected _buildBlock(state: NodeMaterialBuildState): this;
  62683. serialize(): any;
  62684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62685. }
  62686. }
  62687. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62691. import { Color3 } from "babylonjs/Maths/math.color";
  62692. import { Scene } from "babylonjs/scene";
  62693. /**
  62694. * Class used to store a color step for the GradientBlock
  62695. */
  62696. export class GradientBlockColorStep {
  62697. /**
  62698. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62699. */
  62700. step: number;
  62701. /**
  62702. * Gets or sets the color associated with this step
  62703. */
  62704. color: Color3;
  62705. /**
  62706. * Creates a new GradientBlockColorStep
  62707. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62708. * @param color defines the color associated with this step
  62709. */
  62710. constructor(
  62711. /**
  62712. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62713. */
  62714. step: number,
  62715. /**
  62716. * Gets or sets the color associated with this step
  62717. */
  62718. color: Color3);
  62719. }
  62720. /**
  62721. * Block used to return a color from a gradient based on an input value between 0 and 1
  62722. */
  62723. export class GradientBlock extends NodeMaterialBlock {
  62724. /**
  62725. * Gets or sets the list of color steps
  62726. */
  62727. colorSteps: GradientBlockColorStep[];
  62728. /**
  62729. * Creates a new GradientBlock
  62730. * @param name defines the block name
  62731. */
  62732. constructor(name: string);
  62733. /**
  62734. * Gets the current class name
  62735. * @returns the class name
  62736. */
  62737. getClassName(): string;
  62738. /**
  62739. * Gets the gradient input component
  62740. */
  62741. get gradient(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the output component
  62744. */
  62745. get output(): NodeMaterialConnectionPoint;
  62746. private _writeColorConstant;
  62747. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62748. serialize(): any;
  62749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62750. protected _dumpPropertiesCode(): string;
  62751. }
  62752. }
  62753. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62757. /**
  62758. * Block used to normalize lerp between 2 values
  62759. */
  62760. export class NLerpBlock extends NodeMaterialBlock {
  62761. /**
  62762. * Creates a new NLerpBlock
  62763. * @param name defines the block name
  62764. */
  62765. constructor(name: string);
  62766. /**
  62767. * Gets the current class name
  62768. * @returns the class name
  62769. */
  62770. getClassName(): string;
  62771. /**
  62772. * Gets the left operand input component
  62773. */
  62774. get left(): NodeMaterialConnectionPoint;
  62775. /**
  62776. * Gets the right operand input component
  62777. */
  62778. get right(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the gradient operand input component
  62781. */
  62782. get gradient(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62794. import { Scene } from "babylonjs/scene";
  62795. /**
  62796. * block used to Generate a Worley Noise 3D Noise Pattern
  62797. */
  62798. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62799. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62800. manhattanDistance: boolean;
  62801. /**
  62802. * Creates a new WorleyNoise3DBlock
  62803. * @param name defines the block name
  62804. */
  62805. constructor(name: string);
  62806. /**
  62807. * Gets the current class name
  62808. * @returns the class name
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Gets the seed input component
  62813. */
  62814. get seed(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the jitter input component
  62817. */
  62818. get jitter(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the output component
  62821. */
  62822. get output(): NodeMaterialConnectionPoint;
  62823. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62824. /**
  62825. * Exposes the properties to the UI?
  62826. */
  62827. protected _dumpPropertiesCode(): string;
  62828. /**
  62829. * Exposes the properties to the Seralize?
  62830. */
  62831. serialize(): any;
  62832. /**
  62833. * Exposes the properties to the deseralize?
  62834. */
  62835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62836. }
  62837. }
  62838. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62842. /**
  62843. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62844. */
  62845. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62846. /**
  62847. * Creates a new SimplexPerlin3DBlock
  62848. * @param name defines the block name
  62849. */
  62850. constructor(name: string);
  62851. /**
  62852. * Gets the current class name
  62853. * @returns the class name
  62854. */
  62855. getClassName(): string;
  62856. /**
  62857. * Gets the seed operand input component
  62858. */
  62859. get seed(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the output component
  62862. */
  62863. get output(): NodeMaterialConnectionPoint;
  62864. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62865. }
  62866. }
  62867. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62871. /**
  62872. * Block used to blend normals
  62873. */
  62874. export class NormalBlendBlock extends NodeMaterialBlock {
  62875. /**
  62876. * Creates a new NormalBlendBlock
  62877. * @param name defines the block name
  62878. */
  62879. constructor(name: string);
  62880. /**
  62881. * Gets the current class name
  62882. * @returns the class name
  62883. */
  62884. getClassName(): string;
  62885. /**
  62886. * Gets the first input component
  62887. */
  62888. get normalMap0(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the second input component
  62891. */
  62892. get normalMap1(): NodeMaterialConnectionPoint;
  62893. /**
  62894. * Gets the output component
  62895. */
  62896. get output(): NodeMaterialConnectionPoint;
  62897. protected _buildBlock(state: NodeMaterialBuildState): this;
  62898. }
  62899. }
  62900. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62904. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62905. /**
  62906. * Block used to rotate a 2d vector by a given angle
  62907. */
  62908. export class Rotate2dBlock extends NodeMaterialBlock {
  62909. /**
  62910. * Creates a new Rotate2dBlock
  62911. * @param name defines the block name
  62912. */
  62913. constructor(name: string);
  62914. /**
  62915. * Gets the current class name
  62916. * @returns the class name
  62917. */
  62918. getClassName(): string;
  62919. /**
  62920. * Gets the input vector
  62921. */
  62922. get input(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the input angle
  62925. */
  62926. get angle(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the output component
  62929. */
  62930. get output(): NodeMaterialConnectionPoint;
  62931. autoConfigure(material: NodeMaterial): void;
  62932. protected _buildBlock(state: NodeMaterialBuildState): this;
  62933. }
  62934. }
  62935. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62939. /**
  62940. * Block used to get the reflected vector from a direction and a normal
  62941. */
  62942. export class ReflectBlock extends NodeMaterialBlock {
  62943. /**
  62944. * Creates a new ReflectBlock
  62945. * @param name defines the block name
  62946. */
  62947. constructor(name: string);
  62948. /**
  62949. * Gets the current class name
  62950. * @returns the class name
  62951. */
  62952. getClassName(): string;
  62953. /**
  62954. * Gets the incident component
  62955. */
  62956. get incident(): NodeMaterialConnectionPoint;
  62957. /**
  62958. * Gets the normal component
  62959. */
  62960. get normal(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the output component
  62963. */
  62964. get output(): NodeMaterialConnectionPoint;
  62965. protected _buildBlock(state: NodeMaterialBuildState): this;
  62966. }
  62967. }
  62968. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62972. /**
  62973. * Block used to get the refracted vector from a direction and a normal
  62974. */
  62975. export class RefractBlock extends NodeMaterialBlock {
  62976. /**
  62977. * Creates a new RefractBlock
  62978. * @param name defines the block name
  62979. */
  62980. constructor(name: string);
  62981. /**
  62982. * Gets the current class name
  62983. * @returns the class name
  62984. */
  62985. getClassName(): string;
  62986. /**
  62987. * Gets the incident component
  62988. */
  62989. get incident(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the normal component
  62992. */
  62993. get normal(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the index of refraction component
  62996. */
  62997. get ior(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the output component
  63000. */
  63001. get output(): NodeMaterialConnectionPoint;
  63002. protected _buildBlock(state: NodeMaterialBuildState): this;
  63003. }
  63004. }
  63005. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63009. /**
  63010. * Block used to desaturate a color
  63011. */
  63012. export class DesaturateBlock extends NodeMaterialBlock {
  63013. /**
  63014. * Creates a new DesaturateBlock
  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 color operand input component
  63025. */
  63026. get color(): NodeMaterialConnectionPoint;
  63027. /**
  63028. * Gets the level operand input component
  63029. */
  63030. get level(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the output component
  63033. */
  63034. get output(): NodeMaterialConnectionPoint;
  63035. protected _buildBlock(state: NodeMaterialBuildState): this;
  63036. }
  63037. }
  63038. declare module "babylonjs/Materials/Node/Blocks/index" {
  63039. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63040. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63041. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63042. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63043. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63048. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63049. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63050. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63051. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63052. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63053. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63072. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63086. }
  63087. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63088. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63089. }
  63090. declare module "babylonjs/Materials/Node/index" {
  63091. export * from "babylonjs/Materials/Node/Enums/index";
  63092. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63093. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63094. export * from "babylonjs/Materials/Node/nodeMaterial";
  63095. export * from "babylonjs/Materials/Node/Blocks/index";
  63096. export * from "babylonjs/Materials/Node/Optimizers/index";
  63097. }
  63098. declare module "babylonjs/Materials/effectRenderer" {
  63099. import { Nullable } from "babylonjs/types";
  63100. import { Texture } from "babylonjs/Materials/Textures/texture";
  63101. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63102. import { Viewport } from "babylonjs/Maths/math.viewport";
  63103. import { Observable } from "babylonjs/Misc/observable";
  63104. import { Effect } from "babylonjs/Materials/effect";
  63105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63106. import "babylonjs/Shaders/postprocess.vertex";
  63107. /**
  63108. * Effect Render Options
  63109. */
  63110. export interface IEffectRendererOptions {
  63111. /**
  63112. * Defines the vertices positions.
  63113. */
  63114. positions?: number[];
  63115. /**
  63116. * Defines the indices.
  63117. */
  63118. indices?: number[];
  63119. }
  63120. /**
  63121. * Helper class to render one or more effects
  63122. */
  63123. export class EffectRenderer {
  63124. private engine;
  63125. private static _DefaultOptions;
  63126. private _vertexBuffers;
  63127. private _indexBuffer;
  63128. private _ringBufferIndex;
  63129. private _ringScreenBuffer;
  63130. private _fullscreenViewport;
  63131. private _getNextFrameBuffer;
  63132. /**
  63133. * Creates an effect renderer
  63134. * @param engine the engine to use for rendering
  63135. * @param options defines the options of the effect renderer
  63136. */
  63137. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63138. /**
  63139. * Sets the current viewport in normalized coordinates 0-1
  63140. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63141. */
  63142. setViewport(viewport?: Viewport): void;
  63143. /**
  63144. * Binds the embedded attributes buffer to the effect.
  63145. * @param effect Defines the effect to bind the attributes for
  63146. */
  63147. bindBuffers(effect: Effect): void;
  63148. /**
  63149. * Sets the current effect wrapper to use during draw.
  63150. * The effect needs to be ready before calling this api.
  63151. * This also sets the default full screen position attribute.
  63152. * @param effectWrapper Defines the effect to draw with
  63153. */
  63154. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63155. /**
  63156. * Draws a full screen quad.
  63157. */
  63158. draw(): void;
  63159. /**
  63160. * renders one or more effects to a specified texture
  63161. * @param effectWrappers list of effects to renderer
  63162. * @param outputTexture texture to draw to, if null it will render to the screen
  63163. */
  63164. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63165. /**
  63166. * Disposes of the effect renderer
  63167. */
  63168. dispose(): void;
  63169. }
  63170. /**
  63171. * Options to create an EffectWrapper
  63172. */
  63173. interface EffectWrapperCreationOptions {
  63174. /**
  63175. * Engine to use to create the effect
  63176. */
  63177. engine: ThinEngine;
  63178. /**
  63179. * Fragment shader for the effect
  63180. */
  63181. fragmentShader: string;
  63182. /**
  63183. * Vertex shader for the effect
  63184. */
  63185. vertexShader?: string;
  63186. /**
  63187. * Attributes to use in the shader
  63188. */
  63189. attributeNames?: Array<string>;
  63190. /**
  63191. * Uniforms to use in the shader
  63192. */
  63193. uniformNames?: Array<string>;
  63194. /**
  63195. * Texture sampler names to use in the shader
  63196. */
  63197. samplerNames?: Array<string>;
  63198. /**
  63199. * The friendly name of the effect displayed in Spector.
  63200. */
  63201. name?: string;
  63202. }
  63203. /**
  63204. * Wraps an effect to be used for rendering
  63205. */
  63206. export class EffectWrapper {
  63207. /**
  63208. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63209. */
  63210. onApplyObservable: Observable<{}>;
  63211. /**
  63212. * The underlying effect
  63213. */
  63214. effect: Effect;
  63215. /**
  63216. * Creates an effect to be renderer
  63217. * @param creationOptions options to create the effect
  63218. */
  63219. constructor(creationOptions: EffectWrapperCreationOptions);
  63220. /**
  63221. * Disposes of the effect wrapper
  63222. */
  63223. dispose(): void;
  63224. }
  63225. }
  63226. declare module "babylonjs/Materials/index" {
  63227. export * from "babylonjs/Materials/Background/index";
  63228. export * from "babylonjs/Materials/colorCurves";
  63229. export * from "babylonjs/Materials/iEffectFallbacks";
  63230. export * from "babylonjs/Materials/effectFallbacks";
  63231. export * from "babylonjs/Materials/effect";
  63232. export * from "babylonjs/Materials/fresnelParameters";
  63233. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63234. export * from "babylonjs/Materials/material";
  63235. export * from "babylonjs/Materials/materialDefines";
  63236. export * from "babylonjs/Materials/materialHelper";
  63237. export * from "babylonjs/Materials/multiMaterial";
  63238. export * from "babylonjs/Materials/PBR/index";
  63239. export * from "babylonjs/Materials/pushMaterial";
  63240. export * from "babylonjs/Materials/shaderMaterial";
  63241. export * from "babylonjs/Materials/standardMaterial";
  63242. export * from "babylonjs/Materials/Textures/index";
  63243. export * from "babylonjs/Materials/uniformBuffer";
  63244. export * from "babylonjs/Materials/materialFlags";
  63245. export * from "babylonjs/Materials/Node/index";
  63246. export * from "babylonjs/Materials/effectRenderer";
  63247. }
  63248. declare module "babylonjs/Maths/index" {
  63249. export * from "babylonjs/Maths/math.scalar";
  63250. export * from "babylonjs/Maths/math";
  63251. export * from "babylonjs/Maths/sphericalPolynomial";
  63252. }
  63253. declare module "babylonjs/Misc/workerPool" {
  63254. import { IDisposable } from "babylonjs/scene";
  63255. /**
  63256. * Helper class to push actions to a pool of workers.
  63257. */
  63258. export class WorkerPool implements IDisposable {
  63259. private _workerInfos;
  63260. private _pendingActions;
  63261. /**
  63262. * Constructor
  63263. * @param workers Array of workers to use for actions
  63264. */
  63265. constructor(workers: Array<Worker>);
  63266. /**
  63267. * Terminates all workers and clears any pending actions.
  63268. */
  63269. dispose(): void;
  63270. /**
  63271. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63272. * pended until a worker has completed its action.
  63273. * @param action The action to perform. Call onComplete when the action is complete.
  63274. */
  63275. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63276. private _execute;
  63277. }
  63278. }
  63279. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63280. import { IDisposable } from "babylonjs/scene";
  63281. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63282. /**
  63283. * Configuration for Draco compression
  63284. */
  63285. export interface IDracoCompressionConfiguration {
  63286. /**
  63287. * Configuration for the decoder.
  63288. */
  63289. decoder: {
  63290. /**
  63291. * The url to the WebAssembly module.
  63292. */
  63293. wasmUrl?: string;
  63294. /**
  63295. * The url to the WebAssembly binary.
  63296. */
  63297. wasmBinaryUrl?: string;
  63298. /**
  63299. * The url to the fallback JavaScript module.
  63300. */
  63301. fallbackUrl?: string;
  63302. };
  63303. }
  63304. /**
  63305. * Draco compression (https://google.github.io/draco/)
  63306. *
  63307. * This class wraps the Draco module.
  63308. *
  63309. * **Encoder**
  63310. *
  63311. * The encoder is not currently implemented.
  63312. *
  63313. * **Decoder**
  63314. *
  63315. * 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.
  63316. *
  63317. * To update the configuration, use the following code:
  63318. * ```javascript
  63319. * DracoCompression.Configuration = {
  63320. * decoder: {
  63321. * wasmUrl: "<url to the WebAssembly library>",
  63322. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63323. * fallbackUrl: "<url to the fallback JavaScript library>",
  63324. * }
  63325. * };
  63326. * ```
  63327. *
  63328. * 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.
  63329. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63330. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63331. *
  63332. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63333. * ```javascript
  63334. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63335. * ```
  63336. *
  63337. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63338. */
  63339. export class DracoCompression implements IDisposable {
  63340. private _workerPoolPromise?;
  63341. private _decoderModulePromise?;
  63342. /**
  63343. * The configuration. Defaults to the following urls:
  63344. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63345. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63346. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63347. */
  63348. static Configuration: IDracoCompressionConfiguration;
  63349. /**
  63350. * Returns true if the decoder configuration is available.
  63351. */
  63352. static get DecoderAvailable(): boolean;
  63353. /**
  63354. * Default number of workers to create when creating the draco compression object.
  63355. */
  63356. static DefaultNumWorkers: number;
  63357. private static GetDefaultNumWorkers;
  63358. private static _Default;
  63359. /**
  63360. * Default instance for the draco compression object.
  63361. */
  63362. static get Default(): DracoCompression;
  63363. /**
  63364. * Constructor
  63365. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63366. */
  63367. constructor(numWorkers?: number);
  63368. /**
  63369. * Stop all async operations and release resources.
  63370. */
  63371. dispose(): void;
  63372. /**
  63373. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63374. * @returns a promise that resolves when ready
  63375. */
  63376. whenReadyAsync(): Promise<void>;
  63377. /**
  63378. * Decode Draco compressed mesh data to vertex data.
  63379. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63380. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63381. * @returns A promise that resolves with the decoded vertex data
  63382. */
  63383. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63384. [kind: string]: number;
  63385. }): Promise<VertexData>;
  63386. }
  63387. }
  63388. declare module "babylonjs/Meshes/Compression/index" {
  63389. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63390. }
  63391. declare module "babylonjs/Meshes/csg" {
  63392. import { Nullable } from "babylonjs/types";
  63393. import { Scene } from "babylonjs/scene";
  63394. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63395. import { Mesh } from "babylonjs/Meshes/mesh";
  63396. import { Material } from "babylonjs/Materials/material";
  63397. /**
  63398. * Class for building Constructive Solid Geometry
  63399. */
  63400. export class CSG {
  63401. private polygons;
  63402. /**
  63403. * The world matrix
  63404. */
  63405. matrix: Matrix;
  63406. /**
  63407. * Stores the position
  63408. */
  63409. position: Vector3;
  63410. /**
  63411. * Stores the rotation
  63412. */
  63413. rotation: Vector3;
  63414. /**
  63415. * Stores the rotation quaternion
  63416. */
  63417. rotationQuaternion: Nullable<Quaternion>;
  63418. /**
  63419. * Stores the scaling vector
  63420. */
  63421. scaling: Vector3;
  63422. /**
  63423. * Convert the Mesh to CSG
  63424. * @param mesh The Mesh to convert to CSG
  63425. * @returns A new CSG from the Mesh
  63426. */
  63427. static FromMesh(mesh: Mesh): CSG;
  63428. /**
  63429. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63430. * @param polygons Polygons used to construct a CSG solid
  63431. */
  63432. private static FromPolygons;
  63433. /**
  63434. * Clones, or makes a deep copy, of the CSG
  63435. * @returns A new CSG
  63436. */
  63437. clone(): CSG;
  63438. /**
  63439. * Unions this CSG with another CSG
  63440. * @param csg The CSG to union against this CSG
  63441. * @returns The unioned CSG
  63442. */
  63443. union(csg: CSG): CSG;
  63444. /**
  63445. * Unions this CSG with another CSG in place
  63446. * @param csg The CSG to union against this CSG
  63447. */
  63448. unionInPlace(csg: CSG): void;
  63449. /**
  63450. * Subtracts this CSG with another CSG
  63451. * @param csg The CSG to subtract against this CSG
  63452. * @returns A new CSG
  63453. */
  63454. subtract(csg: CSG): CSG;
  63455. /**
  63456. * Subtracts this CSG with another CSG in place
  63457. * @param csg The CSG to subtact against this CSG
  63458. */
  63459. subtractInPlace(csg: CSG): void;
  63460. /**
  63461. * Intersect this CSG with another CSG
  63462. * @param csg The CSG to intersect against this CSG
  63463. * @returns A new CSG
  63464. */
  63465. intersect(csg: CSG): CSG;
  63466. /**
  63467. * Intersects this CSG with another CSG in place
  63468. * @param csg The CSG to intersect against this CSG
  63469. */
  63470. intersectInPlace(csg: CSG): void;
  63471. /**
  63472. * Return a new CSG solid with solid and empty space switched. This solid is
  63473. * not modified.
  63474. * @returns A new CSG solid with solid and empty space switched
  63475. */
  63476. inverse(): CSG;
  63477. /**
  63478. * Inverses the CSG in place
  63479. */
  63480. inverseInPlace(): void;
  63481. /**
  63482. * This is used to keep meshes transformations so they can be restored
  63483. * when we build back a Babylon Mesh
  63484. * NB : All CSG operations are performed in world coordinates
  63485. * @param csg The CSG to copy the transform attributes from
  63486. * @returns This CSG
  63487. */
  63488. copyTransformAttributes(csg: CSG): CSG;
  63489. /**
  63490. * Build Raw mesh from CSG
  63491. * Coordinates here are in world space
  63492. * @param name The name of the mesh geometry
  63493. * @param scene The Scene
  63494. * @param keepSubMeshes Specifies if the submeshes should be kept
  63495. * @returns A new Mesh
  63496. */
  63497. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63498. /**
  63499. * Build Mesh from CSG taking material and transforms into account
  63500. * @param name The name of the Mesh
  63501. * @param material The material of the Mesh
  63502. * @param scene The Scene
  63503. * @param keepSubMeshes Specifies if submeshes should be kept
  63504. * @returns The new Mesh
  63505. */
  63506. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63507. }
  63508. }
  63509. declare module "babylonjs/Meshes/trailMesh" {
  63510. import { Mesh } from "babylonjs/Meshes/mesh";
  63511. import { Scene } from "babylonjs/scene";
  63512. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63513. /**
  63514. * Class used to create a trail following a mesh
  63515. */
  63516. export class TrailMesh extends Mesh {
  63517. private _generator;
  63518. private _autoStart;
  63519. private _running;
  63520. private _diameter;
  63521. private _length;
  63522. private _sectionPolygonPointsCount;
  63523. private _sectionVectors;
  63524. private _sectionNormalVectors;
  63525. private _beforeRenderObserver;
  63526. /**
  63527. * @constructor
  63528. * @param name The value used by scene.getMeshByName() to do a lookup.
  63529. * @param generator The mesh or transform node to generate a trail.
  63530. * @param scene The scene to add this mesh to.
  63531. * @param diameter Diameter of trailing mesh. Default is 1.
  63532. * @param length Length of trailing mesh. Default is 60.
  63533. * @param autoStart Automatically start trailing mesh. Default true.
  63534. */
  63535. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63536. /**
  63537. * "TrailMesh"
  63538. * @returns "TrailMesh"
  63539. */
  63540. getClassName(): string;
  63541. private _createMesh;
  63542. /**
  63543. * Start trailing mesh.
  63544. */
  63545. start(): void;
  63546. /**
  63547. * Stop trailing mesh.
  63548. */
  63549. stop(): void;
  63550. /**
  63551. * Update trailing mesh geometry.
  63552. */
  63553. update(): void;
  63554. /**
  63555. * Returns a new TrailMesh object.
  63556. * @param name is a string, the name given to the new mesh
  63557. * @param newGenerator use new generator object for cloned trail mesh
  63558. * @returns a new mesh
  63559. */
  63560. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63561. /**
  63562. * Serializes this trail mesh
  63563. * @param serializationObject object to write serialization to
  63564. */
  63565. serialize(serializationObject: any): void;
  63566. /**
  63567. * Parses a serialized trail mesh
  63568. * @param parsedMesh the serialized mesh
  63569. * @param scene the scene to create the trail mesh in
  63570. * @returns the created trail mesh
  63571. */
  63572. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63573. }
  63574. }
  63575. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63576. import { Nullable } from "babylonjs/types";
  63577. import { Scene } from "babylonjs/scene";
  63578. import { Vector4 } from "babylonjs/Maths/math.vector";
  63579. import { Color4 } from "babylonjs/Maths/math.color";
  63580. import { Mesh } from "babylonjs/Meshes/mesh";
  63581. /**
  63582. * Class containing static functions to help procedurally build meshes
  63583. */
  63584. export class TiledBoxBuilder {
  63585. /**
  63586. * Creates a box mesh
  63587. * 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)
  63588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63592. * @param name defines the name of the mesh
  63593. * @param options defines the options used to create the mesh
  63594. * @param scene defines the hosting scene
  63595. * @returns the box mesh
  63596. */
  63597. static CreateTiledBox(name: string, options: {
  63598. pattern?: number;
  63599. width?: number;
  63600. height?: number;
  63601. depth?: number;
  63602. tileSize?: number;
  63603. tileWidth?: number;
  63604. tileHeight?: number;
  63605. alignHorizontal?: number;
  63606. alignVertical?: number;
  63607. faceUV?: Vector4[];
  63608. faceColors?: Color4[];
  63609. sideOrientation?: number;
  63610. updatable?: boolean;
  63611. }, scene?: Nullable<Scene>): Mesh;
  63612. }
  63613. }
  63614. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63615. import { Vector4 } from "babylonjs/Maths/math.vector";
  63616. import { Mesh } from "babylonjs/Meshes/mesh";
  63617. /**
  63618. * Class containing static functions to help procedurally build meshes
  63619. */
  63620. export class TorusKnotBuilder {
  63621. /**
  63622. * Creates a torus knot mesh
  63623. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63624. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63625. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63626. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63630. * @param name defines the name of the mesh
  63631. * @param options defines the options used to create the mesh
  63632. * @param scene defines the hosting scene
  63633. * @returns the torus knot mesh
  63634. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63635. */
  63636. static CreateTorusKnot(name: string, options: {
  63637. radius?: number;
  63638. tube?: number;
  63639. radialSegments?: number;
  63640. tubularSegments?: number;
  63641. p?: number;
  63642. q?: number;
  63643. updatable?: boolean;
  63644. sideOrientation?: number;
  63645. frontUVs?: Vector4;
  63646. backUVs?: Vector4;
  63647. }, scene: any): Mesh;
  63648. }
  63649. }
  63650. declare module "babylonjs/Meshes/polygonMesh" {
  63651. import { Scene } from "babylonjs/scene";
  63652. import { Vector2 } from "babylonjs/Maths/math.vector";
  63653. import { Mesh } from "babylonjs/Meshes/mesh";
  63654. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63655. import { Path2 } from "babylonjs/Maths/math.path";
  63656. /**
  63657. * Polygon
  63658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63659. */
  63660. export class Polygon {
  63661. /**
  63662. * Creates a rectangle
  63663. * @param xmin bottom X coord
  63664. * @param ymin bottom Y coord
  63665. * @param xmax top X coord
  63666. * @param ymax top Y coord
  63667. * @returns points that make the resulting rectation
  63668. */
  63669. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63670. /**
  63671. * Creates a circle
  63672. * @param radius radius of circle
  63673. * @param cx scale in x
  63674. * @param cy scale in y
  63675. * @param numberOfSides number of sides that make up the circle
  63676. * @returns points that make the resulting circle
  63677. */
  63678. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63679. /**
  63680. * Creates a polygon from input string
  63681. * @param input Input polygon data
  63682. * @returns the parsed points
  63683. */
  63684. static Parse(input: string): Vector2[];
  63685. /**
  63686. * Starts building a polygon from x and y coordinates
  63687. * @param x x coordinate
  63688. * @param y y coordinate
  63689. * @returns the started path2
  63690. */
  63691. static StartingAt(x: number, y: number): Path2;
  63692. }
  63693. /**
  63694. * Builds a polygon
  63695. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63696. */
  63697. export class PolygonMeshBuilder {
  63698. private _points;
  63699. private _outlinepoints;
  63700. private _holes;
  63701. private _name;
  63702. private _scene;
  63703. private _epoints;
  63704. private _eholes;
  63705. private _addToepoint;
  63706. /**
  63707. * Babylon reference to the earcut plugin.
  63708. */
  63709. bjsEarcut: any;
  63710. /**
  63711. * Creates a PolygonMeshBuilder
  63712. * @param name name of the builder
  63713. * @param contours Path of the polygon
  63714. * @param scene scene to add to when creating the mesh
  63715. * @param earcutInjection can be used to inject your own earcut reference
  63716. */
  63717. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63718. /**
  63719. * Adds a whole within the polygon
  63720. * @param hole Array of points defining the hole
  63721. * @returns this
  63722. */
  63723. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63724. /**
  63725. * Creates the polygon
  63726. * @param updatable If the mesh should be updatable
  63727. * @param depth The depth of the mesh created
  63728. * @returns the created mesh
  63729. */
  63730. build(updatable?: boolean, depth?: number): Mesh;
  63731. /**
  63732. * Creates the polygon
  63733. * @param depth The depth of the mesh created
  63734. * @returns the created VertexData
  63735. */
  63736. buildVertexData(depth?: number): VertexData;
  63737. /**
  63738. * Adds a side to the polygon
  63739. * @param positions points that make the polygon
  63740. * @param normals normals of the polygon
  63741. * @param uvs uvs of the polygon
  63742. * @param indices indices of the polygon
  63743. * @param bounds bounds of the polygon
  63744. * @param points points of the polygon
  63745. * @param depth depth of the polygon
  63746. * @param flip flip of the polygon
  63747. */
  63748. private addSide;
  63749. }
  63750. }
  63751. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63752. import { Scene } from "babylonjs/scene";
  63753. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63754. import { Color4 } from "babylonjs/Maths/math.color";
  63755. import { Mesh } from "babylonjs/Meshes/mesh";
  63756. import { Nullable } from "babylonjs/types";
  63757. /**
  63758. * Class containing static functions to help procedurally build meshes
  63759. */
  63760. export class PolygonBuilder {
  63761. /**
  63762. * Creates a polygon mesh
  63763. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63764. * * 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
  63765. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63768. * * Remember you can only change the shape positions, not their number when updating a polygon
  63769. * @param name defines the name of the mesh
  63770. * @param options defines the options used to create the mesh
  63771. * @param scene defines the hosting scene
  63772. * @param earcutInjection can be used to inject your own earcut reference
  63773. * @returns the polygon mesh
  63774. */
  63775. static CreatePolygon(name: string, options: {
  63776. shape: Vector3[];
  63777. holes?: Vector3[][];
  63778. depth?: number;
  63779. faceUV?: Vector4[];
  63780. faceColors?: Color4[];
  63781. updatable?: boolean;
  63782. sideOrientation?: number;
  63783. frontUVs?: Vector4;
  63784. backUVs?: Vector4;
  63785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63786. /**
  63787. * Creates an extruded polygon mesh, with depth in the Y direction.
  63788. * * 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)
  63789. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63790. * @param name defines the name of the mesh
  63791. * @param options defines the options used to create the mesh
  63792. * @param scene defines the hosting scene
  63793. * @param earcutInjection can be used to inject your own earcut reference
  63794. * @returns the polygon mesh
  63795. */
  63796. static ExtrudePolygon(name: string, options: {
  63797. shape: Vector3[];
  63798. holes?: Vector3[][];
  63799. depth?: number;
  63800. faceUV?: Vector4[];
  63801. faceColors?: Color4[];
  63802. updatable?: boolean;
  63803. sideOrientation?: number;
  63804. frontUVs?: Vector4;
  63805. backUVs?: Vector4;
  63806. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63807. }
  63808. }
  63809. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63810. import { Scene } from "babylonjs/scene";
  63811. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63812. import { Mesh } from "babylonjs/Meshes/mesh";
  63813. import { Nullable } from "babylonjs/types";
  63814. /**
  63815. * Class containing static functions to help procedurally build meshes
  63816. */
  63817. export class LatheBuilder {
  63818. /**
  63819. * Creates lathe mesh.
  63820. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63821. * * 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
  63822. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63823. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63824. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63825. * * 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
  63826. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63827. * * 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
  63828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63832. * @param name defines the name of the mesh
  63833. * @param options defines the options used to create the mesh
  63834. * @param scene defines the hosting scene
  63835. * @returns the lathe mesh
  63836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63837. */
  63838. static CreateLathe(name: string, options: {
  63839. shape: Vector3[];
  63840. radius?: number;
  63841. tessellation?: number;
  63842. clip?: number;
  63843. arc?: number;
  63844. closed?: boolean;
  63845. updatable?: boolean;
  63846. sideOrientation?: number;
  63847. frontUVs?: Vector4;
  63848. backUVs?: Vector4;
  63849. cap?: number;
  63850. invertUV?: boolean;
  63851. }, scene?: Nullable<Scene>): Mesh;
  63852. }
  63853. }
  63854. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63855. import { Nullable } from "babylonjs/types";
  63856. import { Scene } from "babylonjs/scene";
  63857. import { Vector4 } from "babylonjs/Maths/math.vector";
  63858. import { Mesh } from "babylonjs/Meshes/mesh";
  63859. /**
  63860. * Class containing static functions to help procedurally build meshes
  63861. */
  63862. export class TiledPlaneBuilder {
  63863. /**
  63864. * Creates a tiled plane mesh
  63865. * * The parameter `pattern` will, depending on value, do nothing or
  63866. * * * flip (reflect about central vertical) alternate tiles across and up
  63867. * * * flip every tile on alternate rows
  63868. * * * rotate (180 degs) alternate tiles across and up
  63869. * * * rotate every tile on alternate rows
  63870. * * * flip and rotate alternate tiles across and up
  63871. * * * flip and rotate every tile on alternate rows
  63872. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63873. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63876. * * 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)
  63877. * * 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)
  63878. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63879. * @param name defines the name of the mesh
  63880. * @param options defines the options used to create the mesh
  63881. * @param scene defines the hosting scene
  63882. * @returns the box mesh
  63883. */
  63884. static CreateTiledPlane(name: string, options: {
  63885. pattern?: number;
  63886. tileSize?: number;
  63887. tileWidth?: number;
  63888. tileHeight?: number;
  63889. size?: number;
  63890. width?: number;
  63891. height?: number;
  63892. alignHorizontal?: number;
  63893. alignVertical?: number;
  63894. sideOrientation?: number;
  63895. frontUVs?: Vector4;
  63896. backUVs?: Vector4;
  63897. updatable?: boolean;
  63898. }, scene?: Nullable<Scene>): Mesh;
  63899. }
  63900. }
  63901. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63902. import { Nullable } from "babylonjs/types";
  63903. import { Scene } from "babylonjs/scene";
  63904. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63905. import { Mesh } from "babylonjs/Meshes/mesh";
  63906. /**
  63907. * Class containing static functions to help procedurally build meshes
  63908. */
  63909. export class TubeBuilder {
  63910. /**
  63911. * Creates a tube mesh.
  63912. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63913. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63914. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63915. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63916. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63917. * * 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)
  63918. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63919. * * 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
  63920. * * 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
  63921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63925. * @param name defines the name of the mesh
  63926. * @param options defines the options used to create the mesh
  63927. * @param scene defines the hosting scene
  63928. * @returns the tube mesh
  63929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63930. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63931. */
  63932. static CreateTube(name: string, options: {
  63933. path: Vector3[];
  63934. radius?: number;
  63935. tessellation?: number;
  63936. radiusFunction?: {
  63937. (i: number, distance: number): number;
  63938. };
  63939. cap?: number;
  63940. arc?: number;
  63941. updatable?: boolean;
  63942. sideOrientation?: number;
  63943. frontUVs?: Vector4;
  63944. backUVs?: Vector4;
  63945. instance?: Mesh;
  63946. invertUV?: boolean;
  63947. }, scene?: Nullable<Scene>): Mesh;
  63948. }
  63949. }
  63950. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63951. import { Scene } from "babylonjs/scene";
  63952. import { Vector4 } from "babylonjs/Maths/math.vector";
  63953. import { Mesh } from "babylonjs/Meshes/mesh";
  63954. import { Nullable } from "babylonjs/types";
  63955. /**
  63956. * Class containing static functions to help procedurally build meshes
  63957. */
  63958. export class IcoSphereBuilder {
  63959. /**
  63960. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63961. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63962. * * 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`)
  63963. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63964. * * 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
  63965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63968. * @param name defines the name of the mesh
  63969. * @param options defines the options used to create the mesh
  63970. * @param scene defines the hosting scene
  63971. * @returns the icosahedron mesh
  63972. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63973. */
  63974. static CreateIcoSphere(name: string, options: {
  63975. radius?: number;
  63976. radiusX?: number;
  63977. radiusY?: number;
  63978. radiusZ?: number;
  63979. flat?: boolean;
  63980. subdivisions?: number;
  63981. sideOrientation?: number;
  63982. frontUVs?: Vector4;
  63983. backUVs?: Vector4;
  63984. updatable?: boolean;
  63985. }, scene?: Nullable<Scene>): Mesh;
  63986. }
  63987. }
  63988. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63989. import { Vector3 } from "babylonjs/Maths/math.vector";
  63990. import { Mesh } from "babylonjs/Meshes/mesh";
  63991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63992. /**
  63993. * Class containing static functions to help procedurally build meshes
  63994. */
  63995. export class DecalBuilder {
  63996. /**
  63997. * Creates a decal mesh.
  63998. * 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
  63999. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64000. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64001. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64002. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64003. * @param name defines the name of the mesh
  64004. * @param sourceMesh defines the mesh where the decal must be applied
  64005. * @param options defines the options used to create the mesh
  64006. * @param scene defines the hosting scene
  64007. * @returns the decal mesh
  64008. * @see https://doc.babylonjs.com/how_to/decals
  64009. */
  64010. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64011. position?: Vector3;
  64012. normal?: Vector3;
  64013. size?: Vector3;
  64014. angle?: number;
  64015. }): Mesh;
  64016. }
  64017. }
  64018. declare module "babylonjs/Meshes/meshBuilder" {
  64019. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64020. import { Nullable } from "babylonjs/types";
  64021. import { Scene } from "babylonjs/scene";
  64022. import { Mesh } from "babylonjs/Meshes/mesh";
  64023. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64024. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64026. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64027. import { Plane } from "babylonjs/Maths/math.plane";
  64028. /**
  64029. * Class containing static functions to help procedurally build meshes
  64030. */
  64031. export class MeshBuilder {
  64032. /**
  64033. * Creates a box mesh
  64034. * * The parameter `size` sets the size (float) of each box side (default 1)
  64035. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64036. * * 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)
  64037. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64041. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64042. * @param name defines the name of the mesh
  64043. * @param options defines the options used to create the mesh
  64044. * @param scene defines the hosting scene
  64045. * @returns the box mesh
  64046. */
  64047. static CreateBox(name: string, options: {
  64048. size?: number;
  64049. width?: number;
  64050. height?: number;
  64051. depth?: number;
  64052. faceUV?: Vector4[];
  64053. faceColors?: Color4[];
  64054. sideOrientation?: number;
  64055. frontUVs?: Vector4;
  64056. backUVs?: Vector4;
  64057. updatable?: boolean;
  64058. }, scene?: Nullable<Scene>): Mesh;
  64059. /**
  64060. * Creates a tiled box mesh
  64061. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64063. * @param name defines the name of the mesh
  64064. * @param options defines the options used to create the mesh
  64065. * @param scene defines the hosting scene
  64066. * @returns the tiled box mesh
  64067. */
  64068. static CreateTiledBox(name: string, options: {
  64069. pattern?: number;
  64070. size?: number;
  64071. width?: number;
  64072. height?: number;
  64073. depth: number;
  64074. tileSize?: number;
  64075. tileWidth?: number;
  64076. tileHeight?: number;
  64077. faceUV?: Vector4[];
  64078. faceColors?: Color4[];
  64079. alignHorizontal?: number;
  64080. alignVertical?: number;
  64081. sideOrientation?: number;
  64082. updatable?: boolean;
  64083. }, scene?: Nullable<Scene>): Mesh;
  64084. /**
  64085. * Creates a sphere mesh
  64086. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64087. * * 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`)
  64088. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64089. * * 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
  64090. * * 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)
  64091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64094. * @param name defines the name of the mesh
  64095. * @param options defines the options used to create the mesh
  64096. * @param scene defines the hosting scene
  64097. * @returns the sphere mesh
  64098. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64099. */
  64100. static CreateSphere(name: string, options: {
  64101. segments?: number;
  64102. diameter?: number;
  64103. diameterX?: number;
  64104. diameterY?: number;
  64105. diameterZ?: number;
  64106. arc?: number;
  64107. slice?: number;
  64108. sideOrientation?: number;
  64109. frontUVs?: Vector4;
  64110. backUVs?: Vector4;
  64111. updatable?: boolean;
  64112. }, scene?: Nullable<Scene>): Mesh;
  64113. /**
  64114. * Creates a plane polygonal mesh. By default, this is a disc
  64115. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64116. * * 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
  64117. * * 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
  64118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64121. * @param name defines the name of the mesh
  64122. * @param options defines the options used to create the mesh
  64123. * @param scene defines the hosting scene
  64124. * @returns the plane polygonal mesh
  64125. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64126. */
  64127. static CreateDisc(name: string, options: {
  64128. radius?: number;
  64129. tessellation?: number;
  64130. arc?: number;
  64131. updatable?: boolean;
  64132. sideOrientation?: number;
  64133. frontUVs?: Vector4;
  64134. backUVs?: Vector4;
  64135. }, scene?: Nullable<Scene>): Mesh;
  64136. /**
  64137. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64138. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64139. * * 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`)
  64140. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64141. * * 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
  64142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64145. * @param name defines the name of the mesh
  64146. * @param options defines the options used to create the mesh
  64147. * @param scene defines the hosting scene
  64148. * @returns the icosahedron mesh
  64149. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64150. */
  64151. static CreateIcoSphere(name: string, options: {
  64152. radius?: number;
  64153. radiusX?: number;
  64154. radiusY?: number;
  64155. radiusZ?: number;
  64156. flat?: boolean;
  64157. subdivisions?: number;
  64158. sideOrientation?: number;
  64159. frontUVs?: Vector4;
  64160. backUVs?: Vector4;
  64161. updatable?: boolean;
  64162. }, scene?: Nullable<Scene>): Mesh;
  64163. /**
  64164. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64165. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64166. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64167. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64168. * * 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
  64169. * * 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
  64170. * * 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
  64171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64174. * * 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
  64175. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64176. * * 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
  64177. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64179. * @param name defines the name of the mesh
  64180. * @param options defines the options used to create the mesh
  64181. * @param scene defines the hosting scene
  64182. * @returns the ribbon mesh
  64183. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64184. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64185. */
  64186. static CreateRibbon(name: string, options: {
  64187. pathArray: Vector3[][];
  64188. closeArray?: boolean;
  64189. closePath?: boolean;
  64190. offset?: number;
  64191. updatable?: boolean;
  64192. sideOrientation?: number;
  64193. frontUVs?: Vector4;
  64194. backUVs?: Vector4;
  64195. instance?: Mesh;
  64196. invertUV?: boolean;
  64197. uvs?: Vector2[];
  64198. colors?: Color4[];
  64199. }, scene?: Nullable<Scene>): Mesh;
  64200. /**
  64201. * Creates a cylinder or a cone mesh
  64202. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64203. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64204. * * 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.
  64205. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64206. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64207. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64208. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64209. * * 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).
  64210. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64211. * * 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).
  64212. * * 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
  64213. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64214. * * 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
  64215. * * 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.
  64216. * * If `enclose` is false, a ring surface is one element.
  64217. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64218. * * 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
  64219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64222. * @param name defines the name of the mesh
  64223. * @param options defines the options used to create the mesh
  64224. * @param scene defines the hosting scene
  64225. * @returns the cylinder mesh
  64226. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64227. */
  64228. static CreateCylinder(name: string, options: {
  64229. height?: number;
  64230. diameterTop?: number;
  64231. diameterBottom?: number;
  64232. diameter?: number;
  64233. tessellation?: number;
  64234. subdivisions?: number;
  64235. arc?: number;
  64236. faceColors?: Color4[];
  64237. faceUV?: Vector4[];
  64238. updatable?: boolean;
  64239. hasRings?: boolean;
  64240. enclose?: boolean;
  64241. cap?: number;
  64242. sideOrientation?: number;
  64243. frontUVs?: Vector4;
  64244. backUVs?: Vector4;
  64245. }, scene?: Nullable<Scene>): Mesh;
  64246. /**
  64247. * Creates a torus mesh
  64248. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64249. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64250. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64254. * @param name defines the name of the mesh
  64255. * @param options defines the options used to create the mesh
  64256. * @param scene defines the hosting scene
  64257. * @returns the torus mesh
  64258. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64259. */
  64260. static CreateTorus(name: string, options: {
  64261. diameter?: number;
  64262. thickness?: number;
  64263. tessellation?: number;
  64264. updatable?: boolean;
  64265. sideOrientation?: number;
  64266. frontUVs?: Vector4;
  64267. backUVs?: Vector4;
  64268. }, scene?: Nullable<Scene>): Mesh;
  64269. /**
  64270. * Creates a torus knot mesh
  64271. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64272. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64273. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64274. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64278. * @param name defines the name of the mesh
  64279. * @param options defines the options used to create the mesh
  64280. * @param scene defines the hosting scene
  64281. * @returns the torus knot mesh
  64282. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64283. */
  64284. static CreateTorusKnot(name: string, options: {
  64285. radius?: number;
  64286. tube?: number;
  64287. radialSegments?: number;
  64288. tubularSegments?: number;
  64289. p?: number;
  64290. q?: number;
  64291. updatable?: boolean;
  64292. sideOrientation?: number;
  64293. frontUVs?: Vector4;
  64294. backUVs?: Vector4;
  64295. }, scene?: Nullable<Scene>): Mesh;
  64296. /**
  64297. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64298. * * 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
  64299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64300. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64301. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64302. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64303. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64304. * * 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
  64305. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64308. * @param name defines the name of the new line system
  64309. * @param options defines the options used to create the line system
  64310. * @param scene defines the hosting scene
  64311. * @returns a new line system mesh
  64312. */
  64313. static CreateLineSystem(name: string, options: {
  64314. lines: Vector3[][];
  64315. updatable?: boolean;
  64316. instance?: Nullable<LinesMesh>;
  64317. colors?: Nullable<Color4[][]>;
  64318. useVertexAlpha?: boolean;
  64319. }, scene: Nullable<Scene>): LinesMesh;
  64320. /**
  64321. * Creates a line mesh
  64322. * 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
  64323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64324. * * The parameter `points` is an array successive Vector3
  64325. * * 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
  64326. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64327. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64328. * * When updating an instance, remember that only point positions can change, not the number of points
  64329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64331. * @param name defines the name of the new line system
  64332. * @param options defines the options used to create the line system
  64333. * @param scene defines the hosting scene
  64334. * @returns a new line mesh
  64335. */
  64336. static CreateLines(name: string, options: {
  64337. points: Vector3[];
  64338. updatable?: boolean;
  64339. instance?: Nullable<LinesMesh>;
  64340. colors?: Color4[];
  64341. useVertexAlpha?: boolean;
  64342. }, scene?: Nullable<Scene>): LinesMesh;
  64343. /**
  64344. * Creates a dashed line mesh
  64345. * * 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
  64346. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64347. * * The parameter `points` is an array successive Vector3
  64348. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64349. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64350. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64351. * * 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
  64352. * * When updating an instance, remember that only point positions can change, not the number of points
  64353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64354. * @param name defines the name of the mesh
  64355. * @param options defines the options used to create the mesh
  64356. * @param scene defines the hosting scene
  64357. * @returns the dashed line mesh
  64358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64359. */
  64360. static CreateDashedLines(name: string, options: {
  64361. points: Vector3[];
  64362. dashSize?: number;
  64363. gapSize?: number;
  64364. dashNb?: number;
  64365. updatable?: boolean;
  64366. instance?: LinesMesh;
  64367. }, scene?: Nullable<Scene>): LinesMesh;
  64368. /**
  64369. * 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.
  64370. * * 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.
  64371. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64372. * * 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.
  64373. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64374. * * 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
  64375. * * 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
  64376. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64381. * @param name defines the name of the mesh
  64382. * @param options defines the options used to create the mesh
  64383. * @param scene defines the hosting scene
  64384. * @returns the extruded shape mesh
  64385. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64387. */
  64388. static ExtrudeShape(name: string, options: {
  64389. shape: Vector3[];
  64390. path: Vector3[];
  64391. scale?: number;
  64392. rotation?: number;
  64393. cap?: number;
  64394. updatable?: boolean;
  64395. sideOrientation?: number;
  64396. frontUVs?: Vector4;
  64397. backUVs?: Vector4;
  64398. instance?: Mesh;
  64399. invertUV?: boolean;
  64400. }, scene?: Nullable<Scene>): Mesh;
  64401. /**
  64402. * Creates an custom extruded shape mesh.
  64403. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64404. * * 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.
  64405. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64406. * * 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
  64407. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64408. * * 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
  64409. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64410. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64411. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64412. * * 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
  64413. * * 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
  64414. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64419. * @param name defines the name of the mesh
  64420. * @param options defines the options used to create the mesh
  64421. * @param scene defines the hosting scene
  64422. * @returns the custom extruded shape mesh
  64423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64426. */
  64427. static ExtrudeShapeCustom(name: string, options: {
  64428. shape: Vector3[];
  64429. path: Vector3[];
  64430. scaleFunction?: any;
  64431. rotationFunction?: any;
  64432. ribbonCloseArray?: boolean;
  64433. ribbonClosePath?: boolean;
  64434. cap?: number;
  64435. updatable?: boolean;
  64436. sideOrientation?: number;
  64437. frontUVs?: Vector4;
  64438. backUVs?: Vector4;
  64439. instance?: Mesh;
  64440. invertUV?: boolean;
  64441. }, scene?: Nullable<Scene>): Mesh;
  64442. /**
  64443. * Creates lathe mesh.
  64444. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64445. * * 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
  64446. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64447. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64448. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64449. * * 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
  64450. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64451. * * 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
  64452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64456. * @param name defines the name of the mesh
  64457. * @param options defines the options used to create the mesh
  64458. * @param scene defines the hosting scene
  64459. * @returns the lathe mesh
  64460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64461. */
  64462. static CreateLathe(name: string, options: {
  64463. shape: Vector3[];
  64464. radius?: number;
  64465. tessellation?: number;
  64466. clip?: number;
  64467. arc?: number;
  64468. closed?: boolean;
  64469. updatable?: boolean;
  64470. sideOrientation?: number;
  64471. frontUVs?: Vector4;
  64472. backUVs?: Vector4;
  64473. cap?: number;
  64474. invertUV?: boolean;
  64475. }, scene?: Nullable<Scene>): Mesh;
  64476. /**
  64477. * Creates a tiled plane mesh
  64478. * * You can set a limited pattern arrangement with the tiles
  64479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64482. * @param name defines the name of the mesh
  64483. * @param options defines the options used to create the mesh
  64484. * @param scene defines the hosting scene
  64485. * @returns the plane mesh
  64486. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64487. */
  64488. static CreateTiledPlane(name: string, options: {
  64489. pattern?: number;
  64490. tileSize?: number;
  64491. tileWidth?: number;
  64492. tileHeight?: number;
  64493. size?: number;
  64494. width?: number;
  64495. height?: number;
  64496. alignHorizontal?: number;
  64497. alignVertical?: number;
  64498. sideOrientation?: number;
  64499. frontUVs?: Vector4;
  64500. backUVs?: Vector4;
  64501. updatable?: boolean;
  64502. }, scene?: Nullable<Scene>): Mesh;
  64503. /**
  64504. * Creates a plane mesh
  64505. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64506. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64507. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64511. * @param name defines the name of the mesh
  64512. * @param options defines the options used to create the mesh
  64513. * @param scene defines the hosting scene
  64514. * @returns the plane mesh
  64515. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64516. */
  64517. static CreatePlane(name: string, options: {
  64518. size?: number;
  64519. width?: number;
  64520. height?: number;
  64521. sideOrientation?: number;
  64522. frontUVs?: Vector4;
  64523. backUVs?: Vector4;
  64524. updatable?: boolean;
  64525. sourcePlane?: Plane;
  64526. }, scene?: Nullable<Scene>): Mesh;
  64527. /**
  64528. * Creates a ground mesh
  64529. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64530. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64532. * @param name defines the name of the mesh
  64533. * @param options defines the options used to create the mesh
  64534. * @param scene defines the hosting scene
  64535. * @returns the ground mesh
  64536. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64537. */
  64538. static CreateGround(name: string, options: {
  64539. width?: number;
  64540. height?: number;
  64541. subdivisions?: number;
  64542. subdivisionsX?: number;
  64543. subdivisionsY?: number;
  64544. updatable?: boolean;
  64545. }, scene?: Nullable<Scene>): Mesh;
  64546. /**
  64547. * Creates a tiled ground mesh
  64548. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64549. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64550. * * 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
  64551. * * 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
  64552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64553. * @param name defines the name of the mesh
  64554. * @param options defines the options used to create the mesh
  64555. * @param scene defines the hosting scene
  64556. * @returns the tiled ground mesh
  64557. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64558. */
  64559. static CreateTiledGround(name: string, options: {
  64560. xmin: number;
  64561. zmin: number;
  64562. xmax: number;
  64563. zmax: number;
  64564. subdivisions?: {
  64565. w: number;
  64566. h: number;
  64567. };
  64568. precision?: {
  64569. w: number;
  64570. h: number;
  64571. };
  64572. updatable?: boolean;
  64573. }, scene?: Nullable<Scene>): Mesh;
  64574. /**
  64575. * Creates a ground mesh from a height map
  64576. * * The parameter `url` sets the URL of the height map image resource.
  64577. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64578. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64579. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64580. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64581. * * 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.
  64582. * * 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).
  64583. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64585. * @param name defines the name of the mesh
  64586. * @param url defines the url to the height map
  64587. * @param options defines the options used to create the mesh
  64588. * @param scene defines the hosting scene
  64589. * @returns the ground mesh
  64590. * @see https://doc.babylonjs.com/babylon101/height_map
  64591. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64592. */
  64593. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64594. width?: number;
  64595. height?: number;
  64596. subdivisions?: number;
  64597. minHeight?: number;
  64598. maxHeight?: number;
  64599. colorFilter?: Color3;
  64600. alphaFilter?: number;
  64601. updatable?: boolean;
  64602. onReady?: (mesh: GroundMesh) => void;
  64603. }, scene?: Nullable<Scene>): GroundMesh;
  64604. /**
  64605. * Creates a polygon mesh
  64606. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64607. * * 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
  64608. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64611. * * Remember you can only change the shape positions, not their number when updating a polygon
  64612. * @param name defines the name of the mesh
  64613. * @param options defines the options used to create the mesh
  64614. * @param scene defines the hosting scene
  64615. * @param earcutInjection can be used to inject your own earcut reference
  64616. * @returns the polygon mesh
  64617. */
  64618. static CreatePolygon(name: string, options: {
  64619. shape: Vector3[];
  64620. holes?: Vector3[][];
  64621. depth?: number;
  64622. faceUV?: Vector4[];
  64623. faceColors?: Color4[];
  64624. updatable?: boolean;
  64625. sideOrientation?: number;
  64626. frontUVs?: Vector4;
  64627. backUVs?: Vector4;
  64628. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64629. /**
  64630. * Creates an extruded polygon mesh, with depth in the Y direction.
  64631. * * 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)
  64632. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64633. * @param name defines the name of the mesh
  64634. * @param options defines the options used to create the mesh
  64635. * @param scene defines the hosting scene
  64636. * @param earcutInjection can be used to inject your own earcut reference
  64637. * @returns the polygon mesh
  64638. */
  64639. static ExtrudePolygon(name: string, options: {
  64640. shape: Vector3[];
  64641. holes?: Vector3[][];
  64642. depth?: number;
  64643. faceUV?: Vector4[];
  64644. faceColors?: Color4[];
  64645. updatable?: boolean;
  64646. sideOrientation?: number;
  64647. frontUVs?: Vector4;
  64648. backUVs?: Vector4;
  64649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64650. /**
  64651. * Creates a tube mesh.
  64652. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64653. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64654. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64655. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64656. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64657. * * 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)
  64658. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64659. * * 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
  64660. * * 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
  64661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64665. * @param name defines the name of the mesh
  64666. * @param options defines the options used to create the mesh
  64667. * @param scene defines the hosting scene
  64668. * @returns the tube mesh
  64669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64670. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64671. */
  64672. static CreateTube(name: string, options: {
  64673. path: Vector3[];
  64674. radius?: number;
  64675. tessellation?: number;
  64676. radiusFunction?: {
  64677. (i: number, distance: number): number;
  64678. };
  64679. cap?: number;
  64680. arc?: number;
  64681. updatable?: boolean;
  64682. sideOrientation?: number;
  64683. frontUVs?: Vector4;
  64684. backUVs?: Vector4;
  64685. instance?: Mesh;
  64686. invertUV?: boolean;
  64687. }, scene?: Nullable<Scene>): Mesh;
  64688. /**
  64689. * Creates a polyhedron mesh
  64690. * * 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
  64691. * * The parameter `size` (positive float, default 1) sets the polygon size
  64692. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64693. * * 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`
  64694. * * 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
  64695. * * 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)`)
  64696. * * 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
  64697. * * 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
  64698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64701. * @param name defines the name of the mesh
  64702. * @param options defines the options used to create the mesh
  64703. * @param scene defines the hosting scene
  64704. * @returns the polyhedron mesh
  64705. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64706. */
  64707. static CreatePolyhedron(name: string, options: {
  64708. type?: number;
  64709. size?: number;
  64710. sizeX?: number;
  64711. sizeY?: number;
  64712. sizeZ?: number;
  64713. custom?: any;
  64714. faceUV?: Vector4[];
  64715. faceColors?: Color4[];
  64716. flat?: boolean;
  64717. updatable?: boolean;
  64718. sideOrientation?: number;
  64719. frontUVs?: Vector4;
  64720. backUVs?: Vector4;
  64721. }, scene?: Nullable<Scene>): Mesh;
  64722. /**
  64723. * Creates a decal mesh.
  64724. * 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
  64725. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64726. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64727. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64728. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64729. * @param name defines the name of the mesh
  64730. * @param sourceMesh defines the mesh where the decal must be applied
  64731. * @param options defines the options used to create the mesh
  64732. * @param scene defines the hosting scene
  64733. * @returns the decal mesh
  64734. * @see https://doc.babylonjs.com/how_to/decals
  64735. */
  64736. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64737. position?: Vector3;
  64738. normal?: Vector3;
  64739. size?: Vector3;
  64740. angle?: number;
  64741. }): Mesh;
  64742. }
  64743. }
  64744. declare module "babylonjs/Meshes/meshSimplification" {
  64745. import { Mesh } from "babylonjs/Meshes/mesh";
  64746. /**
  64747. * A simplifier interface for future simplification implementations
  64748. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64749. */
  64750. export interface ISimplifier {
  64751. /**
  64752. * Simplification of a given mesh according to the given settings.
  64753. * Since this requires computation, it is assumed that the function runs async.
  64754. * @param settings The settings of the simplification, including quality and distance
  64755. * @param successCallback A callback that will be called after the mesh was simplified.
  64756. * @param errorCallback in case of an error, this callback will be called. optional.
  64757. */
  64758. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64759. }
  64760. /**
  64761. * Expected simplification settings.
  64762. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64764. */
  64765. export interface ISimplificationSettings {
  64766. /**
  64767. * Gets or sets the expected quality
  64768. */
  64769. quality: number;
  64770. /**
  64771. * Gets or sets the distance when this optimized version should be used
  64772. */
  64773. distance: number;
  64774. /**
  64775. * Gets an already optimized mesh
  64776. */
  64777. optimizeMesh?: boolean;
  64778. }
  64779. /**
  64780. * Class used to specify simplification options
  64781. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64782. */
  64783. export class SimplificationSettings implements ISimplificationSettings {
  64784. /** expected quality */
  64785. quality: number;
  64786. /** distance when this optimized version should be used */
  64787. distance: number;
  64788. /** already optimized mesh */
  64789. optimizeMesh?: boolean | undefined;
  64790. /**
  64791. * Creates a SimplificationSettings
  64792. * @param quality expected quality
  64793. * @param distance distance when this optimized version should be used
  64794. * @param optimizeMesh already optimized mesh
  64795. */
  64796. constructor(
  64797. /** expected quality */
  64798. quality: number,
  64799. /** distance when this optimized version should be used */
  64800. distance: number,
  64801. /** already optimized mesh */
  64802. optimizeMesh?: boolean | undefined);
  64803. }
  64804. /**
  64805. * Interface used to define a simplification task
  64806. */
  64807. export interface ISimplificationTask {
  64808. /**
  64809. * Array of settings
  64810. */
  64811. settings: Array<ISimplificationSettings>;
  64812. /**
  64813. * Simplification type
  64814. */
  64815. simplificationType: SimplificationType;
  64816. /**
  64817. * Mesh to simplify
  64818. */
  64819. mesh: Mesh;
  64820. /**
  64821. * Callback called on success
  64822. */
  64823. successCallback?: () => void;
  64824. /**
  64825. * Defines if parallel processing can be used
  64826. */
  64827. parallelProcessing: boolean;
  64828. }
  64829. /**
  64830. * Queue used to order the simplification tasks
  64831. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64832. */
  64833. export class SimplificationQueue {
  64834. private _simplificationArray;
  64835. /**
  64836. * Gets a boolean indicating that the process is still running
  64837. */
  64838. running: boolean;
  64839. /**
  64840. * Creates a new queue
  64841. */
  64842. constructor();
  64843. /**
  64844. * Adds a new simplification task
  64845. * @param task defines a task to add
  64846. */
  64847. addTask(task: ISimplificationTask): void;
  64848. /**
  64849. * Execute next task
  64850. */
  64851. executeNext(): void;
  64852. /**
  64853. * Execute a simplification task
  64854. * @param task defines the task to run
  64855. */
  64856. runSimplification(task: ISimplificationTask): void;
  64857. private getSimplifier;
  64858. }
  64859. /**
  64860. * The implemented types of simplification
  64861. * At the moment only Quadratic Error Decimation is implemented
  64862. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64863. */
  64864. export enum SimplificationType {
  64865. /** Quadratic error decimation */
  64866. QUADRATIC = 0
  64867. }
  64868. }
  64869. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64870. import { Scene } from "babylonjs/scene";
  64871. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64872. import { ISceneComponent } from "babylonjs/sceneComponent";
  64873. module "babylonjs/scene" {
  64874. interface Scene {
  64875. /** @hidden (Backing field) */
  64876. _simplificationQueue: SimplificationQueue;
  64877. /**
  64878. * Gets or sets the simplification queue attached to the scene
  64879. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64880. */
  64881. simplificationQueue: SimplificationQueue;
  64882. }
  64883. }
  64884. module "babylonjs/Meshes/mesh" {
  64885. interface Mesh {
  64886. /**
  64887. * Simplify the mesh according to the given array of settings.
  64888. * Function will return immediately and will simplify async
  64889. * @param settings a collection of simplification settings
  64890. * @param parallelProcessing should all levels calculate parallel or one after the other
  64891. * @param simplificationType the type of simplification to run
  64892. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64893. * @returns the current mesh
  64894. */
  64895. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64896. }
  64897. }
  64898. /**
  64899. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64900. * created in a scene
  64901. */
  64902. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64903. /**
  64904. * The component name helpfull to identify the component in the list of scene components.
  64905. */
  64906. readonly name: string;
  64907. /**
  64908. * The scene the component belongs to.
  64909. */
  64910. scene: Scene;
  64911. /**
  64912. * Creates a new instance of the component for the given scene
  64913. * @param scene Defines the scene to register the component in
  64914. */
  64915. constructor(scene: Scene);
  64916. /**
  64917. * Registers the component in a given scene
  64918. */
  64919. register(): void;
  64920. /**
  64921. * Rebuilds the elements related to this component in case of
  64922. * context lost for instance.
  64923. */
  64924. rebuild(): void;
  64925. /**
  64926. * Disposes the component and the associated ressources
  64927. */
  64928. dispose(): void;
  64929. private _beforeCameraUpdate;
  64930. }
  64931. }
  64932. declare module "babylonjs/Meshes/Builders/index" {
  64933. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64934. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64935. export * from "babylonjs/Meshes/Builders/discBuilder";
  64936. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64937. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64938. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64939. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64940. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64941. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64942. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64943. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64944. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64945. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64946. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64947. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64948. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64949. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64950. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64951. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64952. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64953. }
  64954. declare module "babylonjs/Meshes/index" {
  64955. export * from "babylonjs/Meshes/abstractMesh";
  64956. export * from "babylonjs/Meshes/buffer";
  64957. export * from "babylonjs/Meshes/Compression/index";
  64958. export * from "babylonjs/Meshes/csg";
  64959. export * from "babylonjs/Meshes/geometry";
  64960. export * from "babylonjs/Meshes/groundMesh";
  64961. export * from "babylonjs/Meshes/trailMesh";
  64962. export * from "babylonjs/Meshes/instancedMesh";
  64963. export * from "babylonjs/Meshes/linesMesh";
  64964. export * from "babylonjs/Meshes/mesh";
  64965. export * from "babylonjs/Meshes/mesh.vertexData";
  64966. export * from "babylonjs/Meshes/meshBuilder";
  64967. export * from "babylonjs/Meshes/meshSimplification";
  64968. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64969. export * from "babylonjs/Meshes/polygonMesh";
  64970. export * from "babylonjs/Meshes/subMesh";
  64971. export * from "babylonjs/Meshes/meshLODLevel";
  64972. export * from "babylonjs/Meshes/transformNode";
  64973. export * from "babylonjs/Meshes/Builders/index";
  64974. export * from "babylonjs/Meshes/dataBuffer";
  64975. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64976. }
  64977. declare module "babylonjs/Morph/index" {
  64978. export * from "babylonjs/Morph/morphTarget";
  64979. export * from "babylonjs/Morph/morphTargetManager";
  64980. }
  64981. declare module "babylonjs/Navigation/INavigationEngine" {
  64982. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64983. import { Vector3 } from "babylonjs/Maths/math";
  64984. import { Mesh } from "babylonjs/Meshes/mesh";
  64985. import { Scene } from "babylonjs/scene";
  64986. /**
  64987. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64988. */
  64989. export interface INavigationEnginePlugin {
  64990. /**
  64991. * plugin name
  64992. */
  64993. name: string;
  64994. /**
  64995. * Creates a navigation mesh
  64996. * @param meshes array of all the geometry used to compute the navigatio mesh
  64997. * @param parameters bunch of parameters used to filter geometry
  64998. */
  64999. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65000. /**
  65001. * Create a navigation mesh debug mesh
  65002. * @param scene is where the mesh will be added
  65003. * @returns debug display mesh
  65004. */
  65005. createDebugNavMesh(scene: Scene): Mesh;
  65006. /**
  65007. * Get a navigation mesh constrained position, closest to the parameter position
  65008. * @param position world position
  65009. * @returns the closest point to position constrained by the navigation mesh
  65010. */
  65011. getClosestPoint(position: Vector3): Vector3;
  65012. /**
  65013. * Get a navigation mesh constrained position, within a particular radius
  65014. * @param position world position
  65015. * @param maxRadius the maximum distance to the constrained world position
  65016. * @returns the closest point to position constrained by the navigation mesh
  65017. */
  65018. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65019. /**
  65020. * Compute the final position from a segment made of destination-position
  65021. * @param position world position
  65022. * @param destination world position
  65023. * @returns the resulting point along the navmesh
  65024. */
  65025. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65026. /**
  65027. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65028. * @param start world position
  65029. * @param end world position
  65030. * @returns array containing world position composing the path
  65031. */
  65032. computePath(start: Vector3, end: Vector3): Vector3[];
  65033. /**
  65034. * If this plugin is supported
  65035. * @returns true if plugin is supported
  65036. */
  65037. isSupported(): boolean;
  65038. /**
  65039. * Create a new Crowd so you can add agents
  65040. * @param maxAgents the maximum agent count in the crowd
  65041. * @param maxAgentRadius the maximum radius an agent can have
  65042. * @param scene to attach the crowd to
  65043. * @returns the crowd you can add agents to
  65044. */
  65045. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65046. /**
  65047. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65048. * The queries will try to find a solution within those bounds
  65049. * default is (1,1,1)
  65050. * @param extent x,y,z value that define the extent around the queries point of reference
  65051. */
  65052. setDefaultQueryExtent(extent: Vector3): void;
  65053. /**
  65054. * Get the Bounding box extent specified by setDefaultQueryExtent
  65055. * @returns the box extent values
  65056. */
  65057. getDefaultQueryExtent(): Vector3;
  65058. /**
  65059. * Release all resources
  65060. */
  65061. dispose(): void;
  65062. }
  65063. /**
  65064. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65065. */
  65066. export interface ICrowd {
  65067. /**
  65068. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65069. * You can attach anything to that node. The node position is updated in the scene update tick.
  65070. * @param pos world position that will be constrained by the navigation mesh
  65071. * @param parameters agent parameters
  65072. * @param transform hooked to the agent that will be update by the scene
  65073. * @returns agent index
  65074. */
  65075. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65076. /**
  65077. * Returns the agent position in world space
  65078. * @param index agent index returned by addAgent
  65079. * @returns world space position
  65080. */
  65081. getAgentPosition(index: number): Vector3;
  65082. /**
  65083. * Gets the agent velocity in world space
  65084. * @param index agent index returned by addAgent
  65085. * @returns world space velocity
  65086. */
  65087. getAgentVelocity(index: number): Vector3;
  65088. /**
  65089. * remove a particular agent previously created
  65090. * @param index agent index returned by addAgent
  65091. */
  65092. removeAgent(index: number): void;
  65093. /**
  65094. * get the list of all agents attached to this crowd
  65095. * @returns list of agent indices
  65096. */
  65097. getAgents(): number[];
  65098. /**
  65099. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65100. * @param deltaTime in seconds
  65101. */
  65102. update(deltaTime: number): void;
  65103. /**
  65104. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65105. * @param index agent index returned by addAgent
  65106. * @param destination targeted world position
  65107. */
  65108. agentGoto(index: number, destination: Vector3): void;
  65109. /**
  65110. * Teleport the agent to a new position
  65111. * @param index agent index returned by addAgent
  65112. * @param destination targeted world position
  65113. */
  65114. agentTeleport(index: number, destination: Vector3): void;
  65115. /**
  65116. * Update agent parameters
  65117. * @param index agent index returned by addAgent
  65118. * @param parameters agent parameters
  65119. */
  65120. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65121. /**
  65122. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65123. * The queries will try to find a solution within those bounds
  65124. * default is (1,1,1)
  65125. * @param extent x,y,z value that define the extent around the queries point of reference
  65126. */
  65127. setDefaultQueryExtent(extent: Vector3): void;
  65128. /**
  65129. * Get the Bounding box extent specified by setDefaultQueryExtent
  65130. * @returns the box extent values
  65131. */
  65132. getDefaultQueryExtent(): Vector3;
  65133. /**
  65134. * Release all resources
  65135. */
  65136. dispose(): void;
  65137. }
  65138. /**
  65139. * Configures an agent
  65140. */
  65141. export interface IAgentParameters {
  65142. /**
  65143. * Agent radius. [Limit: >= 0]
  65144. */
  65145. radius: number;
  65146. /**
  65147. * Agent height. [Limit: > 0]
  65148. */
  65149. height: number;
  65150. /**
  65151. * Maximum allowed acceleration. [Limit: >= 0]
  65152. */
  65153. maxAcceleration: number;
  65154. /**
  65155. * Maximum allowed speed. [Limit: >= 0]
  65156. */
  65157. maxSpeed: number;
  65158. /**
  65159. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65160. */
  65161. collisionQueryRange: number;
  65162. /**
  65163. * The path visibility optimization range. [Limit: > 0]
  65164. */
  65165. pathOptimizationRange: number;
  65166. /**
  65167. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65168. */
  65169. separationWeight: number;
  65170. }
  65171. /**
  65172. * Configures the navigation mesh creation
  65173. */
  65174. export interface INavMeshParameters {
  65175. /**
  65176. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65177. */
  65178. cs: number;
  65179. /**
  65180. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65181. */
  65182. ch: number;
  65183. /**
  65184. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65185. */
  65186. walkableSlopeAngle: number;
  65187. /**
  65188. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65189. * be considered walkable. [Limit: >= 3] [Units: vx]
  65190. */
  65191. walkableHeight: number;
  65192. /**
  65193. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65194. */
  65195. walkableClimb: number;
  65196. /**
  65197. * The distance to erode/shrink the walkable area of the heightfield away from
  65198. * obstructions. [Limit: >=0] [Units: vx]
  65199. */
  65200. walkableRadius: number;
  65201. /**
  65202. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65203. */
  65204. maxEdgeLen: number;
  65205. /**
  65206. * The maximum distance a simplfied contour's border edges should deviate
  65207. * the original raw contour. [Limit: >=0] [Units: vx]
  65208. */
  65209. maxSimplificationError: number;
  65210. /**
  65211. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65212. */
  65213. minRegionArea: number;
  65214. /**
  65215. * Any regions with a span count smaller than this value will, if possible,
  65216. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65217. */
  65218. mergeRegionArea: number;
  65219. /**
  65220. * The maximum number of vertices allowed for polygons generated during the
  65221. * contour to polygon conversion process. [Limit: >= 3]
  65222. */
  65223. maxVertsPerPoly: number;
  65224. /**
  65225. * Sets the sampling distance to use when generating the detail mesh.
  65226. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65227. */
  65228. detailSampleDist: number;
  65229. /**
  65230. * The maximum distance the detail mesh surface should deviate from heightfield
  65231. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65232. */
  65233. detailSampleMaxError: number;
  65234. }
  65235. }
  65236. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65237. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65238. import { Mesh } from "babylonjs/Meshes/mesh";
  65239. import { Scene } from "babylonjs/scene";
  65240. import { Vector3 } from "babylonjs/Maths/math";
  65241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65242. /**
  65243. * RecastJS navigation plugin
  65244. */
  65245. export class RecastJSPlugin implements INavigationEnginePlugin {
  65246. /**
  65247. * Reference to the Recast library
  65248. */
  65249. bjsRECAST: any;
  65250. /**
  65251. * plugin name
  65252. */
  65253. name: string;
  65254. /**
  65255. * the first navmesh created. We might extend this to support multiple navmeshes
  65256. */
  65257. navMesh: any;
  65258. /**
  65259. * Initializes the recastJS plugin
  65260. * @param recastInjection can be used to inject your own recast reference
  65261. */
  65262. constructor(recastInjection?: any);
  65263. /**
  65264. * Creates a navigation mesh
  65265. * @param meshes array of all the geometry used to compute the navigatio mesh
  65266. * @param parameters bunch of parameters used to filter geometry
  65267. */
  65268. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65269. /**
  65270. * Create a navigation mesh debug mesh
  65271. * @param scene is where the mesh will be added
  65272. * @returns debug display mesh
  65273. */
  65274. createDebugNavMesh(scene: Scene): Mesh;
  65275. /**
  65276. * Get a navigation mesh constrained position, closest to the parameter position
  65277. * @param position world position
  65278. * @returns the closest point to position constrained by the navigation mesh
  65279. */
  65280. getClosestPoint(position: Vector3): Vector3;
  65281. /**
  65282. * Get a navigation mesh constrained position, within a particular radius
  65283. * @param position world position
  65284. * @param maxRadius the maximum distance to the constrained world position
  65285. * @returns the closest point to position constrained by the navigation mesh
  65286. */
  65287. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65288. /**
  65289. * Compute the final position from a segment made of destination-position
  65290. * @param position world position
  65291. * @param destination world position
  65292. * @returns the resulting point along the navmesh
  65293. */
  65294. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65295. /**
  65296. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65297. * @param start world position
  65298. * @param end world position
  65299. * @returns array containing world position composing the path
  65300. */
  65301. computePath(start: Vector3, end: Vector3): Vector3[];
  65302. /**
  65303. * Create a new Crowd so you can add agents
  65304. * @param maxAgents the maximum agent count in the crowd
  65305. * @param maxAgentRadius the maximum radius an agent can have
  65306. * @param scene to attach the crowd to
  65307. * @returns the crowd you can add agents to
  65308. */
  65309. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65310. /**
  65311. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65312. * The queries will try to find a solution within those bounds
  65313. * default is (1,1,1)
  65314. * @param extent x,y,z value that define the extent around the queries point of reference
  65315. */
  65316. setDefaultQueryExtent(extent: Vector3): void;
  65317. /**
  65318. * Get the Bounding box extent specified by setDefaultQueryExtent
  65319. * @returns the box extent values
  65320. */
  65321. getDefaultQueryExtent(): Vector3;
  65322. /**
  65323. * Disposes
  65324. */
  65325. dispose(): void;
  65326. /**
  65327. * If this plugin is supported
  65328. * @returns true if plugin is supported
  65329. */
  65330. isSupported(): boolean;
  65331. }
  65332. /**
  65333. * Recast detour crowd implementation
  65334. */
  65335. export class RecastJSCrowd implements ICrowd {
  65336. /**
  65337. * Recast/detour plugin
  65338. */
  65339. bjsRECASTPlugin: RecastJSPlugin;
  65340. /**
  65341. * Link to the detour crowd
  65342. */
  65343. recastCrowd: any;
  65344. /**
  65345. * One transform per agent
  65346. */
  65347. transforms: TransformNode[];
  65348. /**
  65349. * All agents created
  65350. */
  65351. agents: number[];
  65352. /**
  65353. * Link to the scene is kept to unregister the crowd from the scene
  65354. */
  65355. private _scene;
  65356. /**
  65357. * Observer for crowd updates
  65358. */
  65359. private _onBeforeAnimationsObserver;
  65360. /**
  65361. * Constructor
  65362. * @param plugin recastJS plugin
  65363. * @param maxAgents the maximum agent count in the crowd
  65364. * @param maxAgentRadius the maximum radius an agent can have
  65365. * @param scene to attach the crowd to
  65366. * @returns the crowd you can add agents to
  65367. */
  65368. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65369. /**
  65370. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65371. * You can attach anything to that node. The node position is updated in the scene update tick.
  65372. * @param pos world position that will be constrained by the navigation mesh
  65373. * @param parameters agent parameters
  65374. * @param transform hooked to the agent that will be update by the scene
  65375. * @returns agent index
  65376. */
  65377. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65378. /**
  65379. * Returns the agent position in world space
  65380. * @param index agent index returned by addAgent
  65381. * @returns world space position
  65382. */
  65383. getAgentPosition(index: number): Vector3;
  65384. /**
  65385. * Returns the agent velocity in world space
  65386. * @param index agent index returned by addAgent
  65387. * @returns world space velocity
  65388. */
  65389. getAgentVelocity(index: number): Vector3;
  65390. /**
  65391. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65392. * @param index agent index returned by addAgent
  65393. * @param destination targeted world position
  65394. */
  65395. agentGoto(index: number, destination: Vector3): void;
  65396. /**
  65397. * Teleport the agent to a new position
  65398. * @param index agent index returned by addAgent
  65399. * @param destination targeted world position
  65400. */
  65401. agentTeleport(index: number, destination: Vector3): void;
  65402. /**
  65403. * Update agent parameters
  65404. * @param index agent index returned by addAgent
  65405. * @param parameters agent parameters
  65406. */
  65407. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65408. /**
  65409. * remove a particular agent previously created
  65410. * @param index agent index returned by addAgent
  65411. */
  65412. removeAgent(index: number): void;
  65413. /**
  65414. * get the list of all agents attached to this crowd
  65415. * @returns list of agent indices
  65416. */
  65417. getAgents(): number[];
  65418. /**
  65419. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65420. * @param deltaTime in seconds
  65421. */
  65422. update(deltaTime: number): void;
  65423. /**
  65424. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65425. * The queries will try to find a solution within those bounds
  65426. * default is (1,1,1)
  65427. * @param extent x,y,z value that define the extent around the queries point of reference
  65428. */
  65429. setDefaultQueryExtent(extent: Vector3): void;
  65430. /**
  65431. * Get the Bounding box extent specified by setDefaultQueryExtent
  65432. * @returns the box extent values
  65433. */
  65434. getDefaultQueryExtent(): Vector3;
  65435. /**
  65436. * Release all resources
  65437. */
  65438. dispose(): void;
  65439. }
  65440. }
  65441. declare module "babylonjs/Navigation/Plugins/index" {
  65442. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65443. }
  65444. declare module "babylonjs/Navigation/index" {
  65445. export * from "babylonjs/Navigation/INavigationEngine";
  65446. export * from "babylonjs/Navigation/Plugins/index";
  65447. }
  65448. declare module "babylonjs/Offline/database" {
  65449. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65450. /**
  65451. * Class used to enable access to IndexedDB
  65452. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65453. */
  65454. export class Database implements IOfflineProvider {
  65455. private _callbackManifestChecked;
  65456. private _currentSceneUrl;
  65457. private _db;
  65458. private _enableSceneOffline;
  65459. private _enableTexturesOffline;
  65460. private _manifestVersionFound;
  65461. private _mustUpdateRessources;
  65462. private _hasReachedQuota;
  65463. private _isSupported;
  65464. private _idbFactory;
  65465. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65466. private static IsUASupportingBlobStorage;
  65467. /**
  65468. * Gets a boolean indicating if Database storate is enabled (off by default)
  65469. */
  65470. static IDBStorageEnabled: boolean;
  65471. /**
  65472. * Gets a boolean indicating if scene must be saved in the database
  65473. */
  65474. get enableSceneOffline(): boolean;
  65475. /**
  65476. * Gets a boolean indicating if textures must be saved in the database
  65477. */
  65478. get enableTexturesOffline(): boolean;
  65479. /**
  65480. * Creates a new Database
  65481. * @param urlToScene defines the url to load the scene
  65482. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65483. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65484. */
  65485. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65486. private static _ParseURL;
  65487. private static _ReturnFullUrlLocation;
  65488. private _checkManifestFile;
  65489. /**
  65490. * Open the database and make it available
  65491. * @param successCallback defines the callback to call on success
  65492. * @param errorCallback defines the callback to call on error
  65493. */
  65494. open(successCallback: () => void, errorCallback: () => void): void;
  65495. /**
  65496. * Loads an image from the database
  65497. * @param url defines the url to load from
  65498. * @param image defines the target DOM image
  65499. */
  65500. loadImage(url: string, image: HTMLImageElement): void;
  65501. private _loadImageFromDBAsync;
  65502. private _saveImageIntoDBAsync;
  65503. private _checkVersionFromDB;
  65504. private _loadVersionFromDBAsync;
  65505. private _saveVersionIntoDBAsync;
  65506. /**
  65507. * Loads a file from database
  65508. * @param url defines the URL to load from
  65509. * @param sceneLoaded defines a callback to call on success
  65510. * @param progressCallBack defines a callback to call when progress changed
  65511. * @param errorCallback defines a callback to call on error
  65512. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65513. */
  65514. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65515. private _loadFileAsync;
  65516. private _saveFileAsync;
  65517. /**
  65518. * Validates if xhr data is correct
  65519. * @param xhr defines the request to validate
  65520. * @param dataType defines the expected data type
  65521. * @returns true if data is correct
  65522. */
  65523. private static _ValidateXHRData;
  65524. }
  65525. }
  65526. declare module "babylonjs/Offline/index" {
  65527. export * from "babylonjs/Offline/database";
  65528. export * from "babylonjs/Offline/IOfflineProvider";
  65529. }
  65530. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65531. /** @hidden */
  65532. export var gpuUpdateParticlesPixelShader: {
  65533. name: string;
  65534. shader: string;
  65535. };
  65536. }
  65537. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65538. /** @hidden */
  65539. export var gpuUpdateParticlesVertexShader: {
  65540. name: string;
  65541. shader: string;
  65542. };
  65543. }
  65544. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65545. /** @hidden */
  65546. export var clipPlaneFragmentDeclaration2: {
  65547. name: string;
  65548. shader: string;
  65549. };
  65550. }
  65551. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65552. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65553. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65554. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65555. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65556. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65557. /** @hidden */
  65558. export var gpuRenderParticlesPixelShader: {
  65559. name: string;
  65560. shader: string;
  65561. };
  65562. }
  65563. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65564. /** @hidden */
  65565. export var clipPlaneVertexDeclaration2: {
  65566. name: string;
  65567. shader: string;
  65568. };
  65569. }
  65570. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65573. /** @hidden */
  65574. export var gpuRenderParticlesVertexShader: {
  65575. name: string;
  65576. shader: string;
  65577. };
  65578. }
  65579. declare module "babylonjs/Particles/gpuParticleSystem" {
  65580. import { Nullable } from "babylonjs/types";
  65581. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65582. import { Observable } from "babylonjs/Misc/observable";
  65583. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65585. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65586. import { Scene, IDisposable } from "babylonjs/scene";
  65587. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65589. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65590. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65591. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65592. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65593. /**
  65594. * This represents a GPU particle system in Babylon
  65595. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65596. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65597. */
  65598. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65599. /**
  65600. * The layer mask we are rendering the particles through.
  65601. */
  65602. layerMask: number;
  65603. private _capacity;
  65604. private _activeCount;
  65605. private _currentActiveCount;
  65606. private _accumulatedCount;
  65607. private _renderEffect;
  65608. private _updateEffect;
  65609. private _buffer0;
  65610. private _buffer1;
  65611. private _spriteBuffer;
  65612. private _updateVAO;
  65613. private _renderVAO;
  65614. private _targetIndex;
  65615. private _sourceBuffer;
  65616. private _targetBuffer;
  65617. private _engine;
  65618. private _currentRenderId;
  65619. private _started;
  65620. private _stopped;
  65621. private _timeDelta;
  65622. private _randomTexture;
  65623. private _randomTexture2;
  65624. private _attributesStrideSize;
  65625. private _updateEffectOptions;
  65626. private _randomTextureSize;
  65627. private _actualFrame;
  65628. private readonly _rawTextureWidth;
  65629. /**
  65630. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65631. */
  65632. static get IsSupported(): boolean;
  65633. /**
  65634. * An event triggered when the system is disposed.
  65635. */
  65636. onDisposeObservable: Observable<GPUParticleSystem>;
  65637. /**
  65638. * Gets the maximum number of particles active at the same time.
  65639. * @returns The max number of active particles.
  65640. */
  65641. getCapacity(): number;
  65642. /**
  65643. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65644. * to override the particles.
  65645. */
  65646. forceDepthWrite: boolean;
  65647. /**
  65648. * Gets or set the number of active particles
  65649. */
  65650. get activeParticleCount(): number;
  65651. set activeParticleCount(value: number);
  65652. private _preWarmDone;
  65653. /**
  65654. * Specifies if the particles are updated in emitter local space or world space.
  65655. * This is always false for GPU particles
  65656. */
  65657. get isLocal(): boolean;
  65658. set isLocal(value: boolean);
  65659. /**
  65660. * Is this system ready to be used/rendered
  65661. * @return true if the system is ready
  65662. */
  65663. isReady(): boolean;
  65664. /**
  65665. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65666. * @returns True if it has been started, otherwise false.
  65667. */
  65668. isStarted(): boolean;
  65669. /**
  65670. * Starts the particle system and begins to emit
  65671. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65672. */
  65673. start(delay?: number): void;
  65674. /**
  65675. * Stops the particle system.
  65676. */
  65677. stop(): void;
  65678. /**
  65679. * Remove all active particles
  65680. */
  65681. reset(): void;
  65682. /**
  65683. * Returns the string "GPUParticleSystem"
  65684. * @returns a string containing the class name
  65685. */
  65686. getClassName(): string;
  65687. private _colorGradientsTexture;
  65688. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65689. /**
  65690. * Adds a new color gradient
  65691. * @param gradient defines the gradient to use (between 0 and 1)
  65692. * @param color1 defines the color to affect to the specified gradient
  65693. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65694. * @returns the current particle system
  65695. */
  65696. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65697. /**
  65698. * Remove a specific color gradient
  65699. * @param gradient defines the gradient to remove
  65700. * @returns the current particle system
  65701. */
  65702. removeColorGradient(gradient: number): GPUParticleSystem;
  65703. private _angularSpeedGradientsTexture;
  65704. private _sizeGradientsTexture;
  65705. private _velocityGradientsTexture;
  65706. private _limitVelocityGradientsTexture;
  65707. private _dragGradientsTexture;
  65708. private _addFactorGradient;
  65709. /**
  65710. * Adds a new size gradient
  65711. * @param gradient defines the gradient to use (between 0 and 1)
  65712. * @param factor defines the size factor to affect to the specified gradient
  65713. * @returns the current particle system
  65714. */
  65715. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65716. /**
  65717. * Remove a specific size gradient
  65718. * @param gradient defines the gradient to remove
  65719. * @returns the current particle system
  65720. */
  65721. removeSizeGradient(gradient: number): GPUParticleSystem;
  65722. /**
  65723. * Adds a new angular speed gradient
  65724. * @param gradient defines the gradient to use (between 0 and 1)
  65725. * @param factor defines the angular speed to affect to the specified gradient
  65726. * @returns the current particle system
  65727. */
  65728. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65729. /**
  65730. * Remove a specific angular speed gradient
  65731. * @param gradient defines the gradient to remove
  65732. * @returns the current particle system
  65733. */
  65734. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65735. /**
  65736. * Adds a new velocity gradient
  65737. * @param gradient defines the gradient to use (between 0 and 1)
  65738. * @param factor defines the velocity to affect to the specified gradient
  65739. * @returns the current particle system
  65740. */
  65741. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65742. /**
  65743. * Remove a specific velocity gradient
  65744. * @param gradient defines the gradient to remove
  65745. * @returns the current particle system
  65746. */
  65747. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65748. /**
  65749. * Adds a new limit velocity gradient
  65750. * @param gradient defines the gradient to use (between 0 and 1)
  65751. * @param factor defines the limit velocity value to affect to the specified gradient
  65752. * @returns the current particle system
  65753. */
  65754. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65755. /**
  65756. * Remove a specific limit velocity gradient
  65757. * @param gradient defines the gradient to remove
  65758. * @returns the current particle system
  65759. */
  65760. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65761. /**
  65762. * Adds a new drag gradient
  65763. * @param gradient defines the gradient to use (between 0 and 1)
  65764. * @param factor defines the drag value to affect to the specified gradient
  65765. * @returns the current particle system
  65766. */
  65767. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65768. /**
  65769. * Remove a specific drag gradient
  65770. * @param gradient defines the gradient to remove
  65771. * @returns the current particle system
  65772. */
  65773. removeDragGradient(gradient: number): GPUParticleSystem;
  65774. /**
  65775. * Not supported by GPUParticleSystem
  65776. * @param gradient defines the gradient to use (between 0 and 1)
  65777. * @param factor defines the emit rate value to affect to the specified gradient
  65778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65779. * @returns the current particle system
  65780. */
  65781. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65782. /**
  65783. * Not supported by GPUParticleSystem
  65784. * @param gradient defines the gradient to remove
  65785. * @returns the current particle system
  65786. */
  65787. removeEmitRateGradient(gradient: number): IParticleSystem;
  65788. /**
  65789. * Not supported by GPUParticleSystem
  65790. * @param gradient defines the gradient to use (between 0 and 1)
  65791. * @param factor defines the start size value to affect to the specified gradient
  65792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65793. * @returns the current particle system
  65794. */
  65795. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65796. /**
  65797. * Not supported by GPUParticleSystem
  65798. * @param gradient defines the gradient to remove
  65799. * @returns the current particle system
  65800. */
  65801. removeStartSizeGradient(gradient: number): IParticleSystem;
  65802. /**
  65803. * Not supported by GPUParticleSystem
  65804. * @param gradient defines the gradient to use (between 0 and 1)
  65805. * @param min defines the color remap minimal range
  65806. * @param max defines the color remap maximal range
  65807. * @returns the current particle system
  65808. */
  65809. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65810. /**
  65811. * Not supported by GPUParticleSystem
  65812. * @param gradient defines the gradient to remove
  65813. * @returns the current particle system
  65814. */
  65815. removeColorRemapGradient(): IParticleSystem;
  65816. /**
  65817. * Not supported by GPUParticleSystem
  65818. * @param gradient defines the gradient to use (between 0 and 1)
  65819. * @param min defines the alpha remap minimal range
  65820. * @param max defines the alpha remap maximal range
  65821. * @returns the current particle system
  65822. */
  65823. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65824. /**
  65825. * Not supported by GPUParticleSystem
  65826. * @param gradient defines the gradient to remove
  65827. * @returns the current particle system
  65828. */
  65829. removeAlphaRemapGradient(): IParticleSystem;
  65830. /**
  65831. * Not supported by GPUParticleSystem
  65832. * @param gradient defines the gradient to use (between 0 and 1)
  65833. * @param color defines the color to affect to the specified gradient
  65834. * @returns the current particle system
  65835. */
  65836. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65837. /**
  65838. * Not supported by GPUParticleSystem
  65839. * @param gradient defines the gradient to remove
  65840. * @returns the current particle system
  65841. */
  65842. removeRampGradient(): IParticleSystem;
  65843. /**
  65844. * Not supported by GPUParticleSystem
  65845. * @returns the list of ramp gradients
  65846. */
  65847. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65848. /**
  65849. * Not supported by GPUParticleSystem
  65850. * Gets or sets a boolean indicating that ramp gradients must be used
  65851. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65852. */
  65853. get useRampGradients(): boolean;
  65854. set useRampGradients(value: boolean);
  65855. /**
  65856. * Not supported by GPUParticleSystem
  65857. * @param gradient defines the gradient to use (between 0 and 1)
  65858. * @param factor defines the life time factor to affect to the specified gradient
  65859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65860. * @returns the current particle system
  65861. */
  65862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65863. /**
  65864. * Not supported by GPUParticleSystem
  65865. * @param gradient defines the gradient to remove
  65866. * @returns the current particle system
  65867. */
  65868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65869. /**
  65870. * Instantiates a GPU particle system.
  65871. * 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.
  65872. * @param name The name of the particle system
  65873. * @param options The options used to create the system
  65874. * @param scene The scene the particle system belongs to
  65875. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65876. */
  65877. constructor(name: string, options: Partial<{
  65878. capacity: number;
  65879. randomTextureSize: number;
  65880. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65881. protected _reset(): void;
  65882. private _createUpdateVAO;
  65883. private _createRenderVAO;
  65884. private _initialize;
  65885. /** @hidden */
  65886. _recreateUpdateEffect(): void;
  65887. /** @hidden */
  65888. _recreateRenderEffect(): void;
  65889. /**
  65890. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65891. * @param preWarm defines if we are in the pre-warmimg phase
  65892. */
  65893. animate(preWarm?: boolean): void;
  65894. private _createFactorGradientTexture;
  65895. private _createSizeGradientTexture;
  65896. private _createAngularSpeedGradientTexture;
  65897. private _createVelocityGradientTexture;
  65898. private _createLimitVelocityGradientTexture;
  65899. private _createDragGradientTexture;
  65900. private _createColorGradientTexture;
  65901. /**
  65902. * Renders the particle system in its current state
  65903. * @param preWarm defines if the system should only update the particles but not render them
  65904. * @returns the current number of particles
  65905. */
  65906. render(preWarm?: boolean): number;
  65907. /**
  65908. * Rebuilds the particle system
  65909. */
  65910. rebuild(): void;
  65911. private _releaseBuffers;
  65912. private _releaseVAOs;
  65913. /**
  65914. * Disposes the particle system and free the associated resources
  65915. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65916. */
  65917. dispose(disposeTexture?: boolean): void;
  65918. /**
  65919. * Clones the particle system.
  65920. * @param name The name of the cloned object
  65921. * @param newEmitter The new emitter to use
  65922. * @returns the cloned particle system
  65923. */
  65924. clone(name: string, newEmitter: any): GPUParticleSystem;
  65925. /**
  65926. * Serializes the particle system to a JSON object.
  65927. * @returns the JSON object
  65928. */
  65929. serialize(): any;
  65930. /**
  65931. * Parses a JSON object to create a GPU particle system.
  65932. * @param parsedParticleSystem The JSON object to parse
  65933. * @param scene The scene to create the particle system in
  65934. * @param rootUrl The root url to use to load external dependencies like texture
  65935. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65936. * @returns the parsed GPU particle system
  65937. */
  65938. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65939. }
  65940. }
  65941. declare module "babylonjs/Particles/particleSystemSet" {
  65942. import { Nullable } from "babylonjs/types";
  65943. import { Color3 } from "babylonjs/Maths/math.color";
  65944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65946. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65947. import { Scene, IDisposable } from "babylonjs/scene";
  65948. /**
  65949. * Represents a set of particle systems working together to create a specific effect
  65950. */
  65951. export class ParticleSystemSet implements IDisposable {
  65952. /**
  65953. * Gets or sets base Assets URL
  65954. */
  65955. static BaseAssetsUrl: string;
  65956. private _emitterCreationOptions;
  65957. private _emitterNode;
  65958. /**
  65959. * Gets the particle system list
  65960. */
  65961. systems: IParticleSystem[];
  65962. /**
  65963. * Gets the emitter node used with this set
  65964. */
  65965. get emitterNode(): Nullable<TransformNode>;
  65966. /**
  65967. * Creates a new emitter mesh as a sphere
  65968. * @param options defines the options used to create the sphere
  65969. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65970. * @param scene defines the hosting scene
  65971. */
  65972. setEmitterAsSphere(options: {
  65973. diameter: number;
  65974. segments: number;
  65975. color: Color3;
  65976. }, renderingGroupId: number, scene: Scene): void;
  65977. /**
  65978. * Starts all particle systems of the set
  65979. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65980. */
  65981. start(emitter?: AbstractMesh): void;
  65982. /**
  65983. * Release all associated resources
  65984. */
  65985. dispose(): void;
  65986. /**
  65987. * Serialize the set into a JSON compatible object
  65988. * @returns a JSON compatible representation of the set
  65989. */
  65990. serialize(): any;
  65991. /**
  65992. * Parse a new ParticleSystemSet from a serialized source
  65993. * @param data defines a JSON compatible representation of the set
  65994. * @param scene defines the hosting scene
  65995. * @param gpu defines if we want GPU particles or CPU particles
  65996. * @returns a new ParticleSystemSet
  65997. */
  65998. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65999. }
  66000. }
  66001. declare module "babylonjs/Particles/particleHelper" {
  66002. import { Nullable } from "babylonjs/types";
  66003. import { Scene } from "babylonjs/scene";
  66004. import { Vector3 } from "babylonjs/Maths/math.vector";
  66005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66006. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66007. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66008. /**
  66009. * This class is made for on one-liner static method to help creating particle system set.
  66010. */
  66011. export class ParticleHelper {
  66012. /**
  66013. * Gets or sets base Assets URL
  66014. */
  66015. static BaseAssetsUrl: string;
  66016. /**
  66017. * Create a default particle system that you can tweak
  66018. * @param emitter defines the emitter to use
  66019. * @param capacity defines the system capacity (default is 500 particles)
  66020. * @param scene defines the hosting scene
  66021. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66022. * @returns the new Particle system
  66023. */
  66024. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66025. /**
  66026. * This is the main static method (one-liner) of this helper to create different particle systems
  66027. * @param type This string represents the type to the particle system to create
  66028. * @param scene The scene where the particle system should live
  66029. * @param gpu If the system will use gpu
  66030. * @returns the ParticleSystemSet created
  66031. */
  66032. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66033. /**
  66034. * Static function used to export a particle system to a ParticleSystemSet variable.
  66035. * Please note that the emitter shape is not exported
  66036. * @param systems defines the particle systems to export
  66037. * @returns the created particle system set
  66038. */
  66039. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66040. }
  66041. }
  66042. declare module "babylonjs/Particles/particleSystemComponent" {
  66043. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66044. import { Effect } from "babylonjs/Materials/effect";
  66045. import "babylonjs/Shaders/particles.vertex";
  66046. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66047. module "babylonjs/Engines/engine" {
  66048. interface Engine {
  66049. /**
  66050. * Create an effect to use with particle systems.
  66051. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66052. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66053. * @param uniformsNames defines a list of attribute names
  66054. * @param samplers defines an array of string used to represent textures
  66055. * @param defines defines the string containing the defines to use to compile the shaders
  66056. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66057. * @param onCompiled defines a function to call when the effect creation is successful
  66058. * @param onError defines a function to call when the effect creation has failed
  66059. * @returns the new Effect
  66060. */
  66061. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66062. }
  66063. }
  66064. module "babylonjs/Meshes/mesh" {
  66065. interface Mesh {
  66066. /**
  66067. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66068. * @returns an array of IParticleSystem
  66069. */
  66070. getEmittedParticleSystems(): IParticleSystem[];
  66071. /**
  66072. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66073. * @returns an array of IParticleSystem
  66074. */
  66075. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66076. }
  66077. }
  66078. /**
  66079. * @hidden
  66080. */
  66081. export var _IDoNeedToBeInTheBuild: number;
  66082. }
  66083. declare module "babylonjs/Particles/pointsCloudSystem" {
  66084. import { Color4 } from "babylonjs/Maths/math";
  66085. import { Mesh } from "babylonjs/Meshes/mesh";
  66086. import { Scene, IDisposable } from "babylonjs/scene";
  66087. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66088. /** Defines the 4 color options */
  66089. export enum PointColor {
  66090. /** color value */
  66091. Color = 2,
  66092. /** uv value */
  66093. UV = 1,
  66094. /** random value */
  66095. Random = 0,
  66096. /** stated value */
  66097. Stated = 3
  66098. }
  66099. /**
  66100. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66101. * 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.
  66102. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66103. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66104. *
  66105. * Full documentation here : TO BE ENTERED
  66106. */
  66107. export class PointsCloudSystem implements IDisposable {
  66108. /**
  66109. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66110. * Example : var p = SPS.particles[i];
  66111. */
  66112. particles: CloudPoint[];
  66113. /**
  66114. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66115. */
  66116. nbParticles: number;
  66117. /**
  66118. * This a counter for your own usage. It's not set by any SPS functions.
  66119. */
  66120. counter: number;
  66121. /**
  66122. * The PCS name. This name is also given to the underlying mesh.
  66123. */
  66124. name: string;
  66125. /**
  66126. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66127. */
  66128. mesh: Mesh;
  66129. /**
  66130. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66131. * Please read :
  66132. */
  66133. vars: any;
  66134. /**
  66135. * @hidden
  66136. */
  66137. _size: number;
  66138. private _scene;
  66139. private _promises;
  66140. private _positions;
  66141. private _indices;
  66142. private _normals;
  66143. private _colors;
  66144. private _uvs;
  66145. private _indices32;
  66146. private _positions32;
  66147. private _colors32;
  66148. private _uvs32;
  66149. private _updatable;
  66150. private _isVisibilityBoxLocked;
  66151. private _alwaysVisible;
  66152. private _groups;
  66153. private _groupCounter;
  66154. private _computeParticleColor;
  66155. private _computeParticleTexture;
  66156. private _computeParticleRotation;
  66157. private _computeBoundingBox;
  66158. private _isReady;
  66159. /**
  66160. * Creates a PCS (Points Cloud System) object
  66161. * @param name (String) is the PCS name, this will be the underlying mesh name
  66162. * @param pointSize (number) is the size for each point
  66163. * @param scene (Scene) is the scene in which the PCS is added
  66164. * @param options defines the options of the PCS e.g.
  66165. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66166. */
  66167. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66168. updatable?: boolean;
  66169. });
  66170. /**
  66171. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66172. * If no points were added to the PCS, the returned mesh is just a single point.
  66173. * @returns a promise for the created mesh
  66174. */
  66175. buildMeshAsync(): Promise<Mesh>;
  66176. /**
  66177. * @hidden
  66178. */
  66179. private _buildMesh;
  66180. private _addParticle;
  66181. private _randomUnitVector;
  66182. private _getColorIndicesForCoord;
  66183. private _setPointsColorOrUV;
  66184. private _colorFromTexture;
  66185. private _calculateDensity;
  66186. /**
  66187. * Adds points to the PCS in random positions within a unit sphere
  66188. * @param nb (positive integer) the number of particles to be created from this model
  66189. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66190. * @returns the number of groups in the system
  66191. */
  66192. addPoints(nb: number, pointFunction?: any): number;
  66193. /**
  66194. * Adds points to the PCS from the surface of the model shape
  66195. * @param mesh is any Mesh object that will be used as a surface model for the points
  66196. * @param nb (positive integer) the number of particles to be created from this model
  66197. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66198. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66199. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66200. * @returns the number of groups in the system
  66201. */
  66202. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66203. /**
  66204. * Adds points to the PCS inside the model shape
  66205. * @param mesh is any Mesh object that will be used as a surface model for the points
  66206. * @param nb (positive integer) the number of particles to be created from this model
  66207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66210. * @returns the number of groups in the system
  66211. */
  66212. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66213. /**
  66214. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66215. * This method calls `updateParticle()` for each particle of the SPS.
  66216. * For an animated SPS, it is usually called within the render loop.
  66217. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66218. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66219. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66220. * @returns the PCS.
  66221. */
  66222. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66223. /**
  66224. * Disposes the PCS.
  66225. */
  66226. dispose(): void;
  66227. /**
  66228. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66229. * doc :
  66230. * @returns the PCS.
  66231. */
  66232. refreshVisibleSize(): PointsCloudSystem;
  66233. /**
  66234. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66235. * @param size the size (float) of the visibility box
  66236. * note : this doesn't lock the PCS mesh bounding box.
  66237. * doc :
  66238. */
  66239. setVisibilityBox(size: number): void;
  66240. /**
  66241. * Gets whether the PCS is always visible or not
  66242. * doc :
  66243. */
  66244. get isAlwaysVisible(): boolean;
  66245. /**
  66246. * Sets the PCS as always visible or not
  66247. * doc :
  66248. */
  66249. set isAlwaysVisible(val: boolean);
  66250. /**
  66251. * Tells to `setParticles()` to compute the particle rotations or not
  66252. * Default value : false. The PCS is faster when it's set to false
  66253. * Note : particle rotations are only applied to parent particles
  66254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66255. */
  66256. set computeParticleRotation(val: boolean);
  66257. /**
  66258. * Tells to `setParticles()` to compute the particle colors or not.
  66259. * Default value : true. The PCS is faster when it's set to false.
  66260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66261. */
  66262. set computeParticleColor(val: boolean);
  66263. set computeParticleTexture(val: boolean);
  66264. /**
  66265. * Gets if `setParticles()` computes the particle colors or not.
  66266. * Default value : false. The PCS is faster when it's set to false.
  66267. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66268. */
  66269. get computeParticleColor(): boolean;
  66270. /**
  66271. * Gets if `setParticles()` computes the particle textures or not.
  66272. * Default value : false. The PCS is faster when it's set to false.
  66273. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66274. */
  66275. get computeParticleTexture(): boolean;
  66276. /**
  66277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66278. */
  66279. set computeBoundingBox(val: boolean);
  66280. /**
  66281. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66282. */
  66283. get computeBoundingBox(): boolean;
  66284. /**
  66285. * This function does nothing. It may be overwritten to set all the particle first values.
  66286. * The PCS doesn't call this function, you may have to call it by your own.
  66287. * doc :
  66288. */
  66289. initParticles(): void;
  66290. /**
  66291. * This function does nothing. It may be overwritten to recycle a particle
  66292. * The PCS doesn't call this function, you can to call it
  66293. * doc :
  66294. * @param particle The particle to recycle
  66295. * @returns the recycled particle
  66296. */
  66297. recycleParticle(particle: CloudPoint): CloudPoint;
  66298. /**
  66299. * Updates a particle : this function should be overwritten by the user.
  66300. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66301. * doc :
  66302. * @example : just set a particle position or velocity and recycle conditions
  66303. * @param particle The particle to update
  66304. * @returns the updated particle
  66305. */
  66306. updateParticle(particle: CloudPoint): CloudPoint;
  66307. /**
  66308. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66309. * This does nothing and may be overwritten by the user.
  66310. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66311. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66312. * @param update the boolean update value actually passed to setParticles()
  66313. */
  66314. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66315. /**
  66316. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66317. * This will be passed three parameters.
  66318. * This does nothing and may be overwritten by the user.
  66319. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66321. * @param update the boolean update value actually passed to setParticles()
  66322. */
  66323. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66324. }
  66325. }
  66326. declare module "babylonjs/Particles/cloudPoint" {
  66327. import { Nullable } from "babylonjs/types";
  66328. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66329. import { Mesh } from "babylonjs/Meshes/mesh";
  66330. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66331. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66332. /**
  66333. * Represents one particle of a points cloud system.
  66334. */
  66335. export class CloudPoint {
  66336. /**
  66337. * particle global index
  66338. */
  66339. idx: number;
  66340. /**
  66341. * The color of the particle
  66342. */
  66343. color: Nullable<Color4>;
  66344. /**
  66345. * The world space position of the particle.
  66346. */
  66347. position: Vector3;
  66348. /**
  66349. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66350. */
  66351. rotation: Vector3;
  66352. /**
  66353. * The world space rotation quaternion of the particle.
  66354. */
  66355. rotationQuaternion: Nullable<Quaternion>;
  66356. /**
  66357. * The uv of the particle.
  66358. */
  66359. uv: Nullable<Vector2>;
  66360. /**
  66361. * The current speed of the particle.
  66362. */
  66363. velocity: Vector3;
  66364. /**
  66365. * The pivot point in the particle local space.
  66366. */
  66367. pivot: Vector3;
  66368. /**
  66369. * Must the particle be translated from its pivot point in its local space ?
  66370. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66371. * Default : false
  66372. */
  66373. translateFromPivot: boolean;
  66374. /**
  66375. * Index of this particle in the global "positions" array (Internal use)
  66376. * @hidden
  66377. */
  66378. _pos: number;
  66379. /**
  66380. * @hidden Index of this particle in the global "indices" array (Internal use)
  66381. */
  66382. _ind: number;
  66383. /**
  66384. * Group this particle belongs to
  66385. */
  66386. _group: PointsGroup;
  66387. /**
  66388. * Group id of this particle
  66389. */
  66390. groupId: number;
  66391. /**
  66392. * Index of the particle in its group id (Internal use)
  66393. */
  66394. idxInGroup: number;
  66395. /**
  66396. * @hidden Particle BoundingInfo object (Internal use)
  66397. */
  66398. _boundingInfo: BoundingInfo;
  66399. /**
  66400. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66401. */
  66402. _pcs: PointsCloudSystem;
  66403. /**
  66404. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66405. */
  66406. _stillInvisible: boolean;
  66407. /**
  66408. * @hidden Last computed particle rotation matrix
  66409. */
  66410. _rotationMatrix: number[];
  66411. /**
  66412. * Parent particle Id, if any.
  66413. * Default null.
  66414. */
  66415. parentId: Nullable<number>;
  66416. /**
  66417. * @hidden Internal global position in the PCS.
  66418. */
  66419. _globalPosition: Vector3;
  66420. /**
  66421. * Creates a Point Cloud object.
  66422. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66423. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66424. * @param group (PointsGroup) is the group the particle belongs to
  66425. * @param groupId (integer) is the group identifier in the PCS.
  66426. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66427. * @param pcs defines the PCS it is associated to
  66428. */
  66429. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66430. /**
  66431. * get point size
  66432. */
  66433. get size(): Vector3;
  66434. /**
  66435. * Set point size
  66436. */
  66437. set size(scale: Vector3);
  66438. /**
  66439. * Legacy support, changed quaternion to rotationQuaternion
  66440. */
  66441. get quaternion(): Nullable<Quaternion>;
  66442. /**
  66443. * Legacy support, changed quaternion to rotationQuaternion
  66444. */
  66445. set quaternion(q: Nullable<Quaternion>);
  66446. /**
  66447. * Returns a boolean. True if the particle intersects a mesh, else false
  66448. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66449. * @param target is the object (point or mesh) what the intersection is computed against
  66450. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66451. * @returns true if it intersects
  66452. */
  66453. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66454. /**
  66455. * get the rotation matrix of the particle
  66456. * @hidden
  66457. */
  66458. getRotationMatrix(m: Matrix): void;
  66459. }
  66460. /**
  66461. * Represents a group of points in a points cloud system
  66462. * * PCS internal tool, don't use it manually.
  66463. */
  66464. export class PointsGroup {
  66465. /**
  66466. * The group id
  66467. * @hidden
  66468. */
  66469. groupID: number;
  66470. /**
  66471. * image data for group (internal use)
  66472. * @hidden
  66473. */
  66474. _groupImageData: Nullable<ArrayBufferView>;
  66475. /**
  66476. * Image Width (internal use)
  66477. * @hidden
  66478. */
  66479. _groupImgWidth: number;
  66480. /**
  66481. * Image Height (internal use)
  66482. * @hidden
  66483. */
  66484. _groupImgHeight: number;
  66485. /**
  66486. * Custom position function (internal use)
  66487. * @hidden
  66488. */
  66489. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66490. /**
  66491. * density per facet for surface points
  66492. * @hidden
  66493. */
  66494. _groupDensity: number[];
  66495. /**
  66496. * Only when points are colored by texture carries pointer to texture list array
  66497. * @hidden
  66498. */
  66499. _textureNb: number;
  66500. /**
  66501. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66502. * PCS internal tool, don't use it manually.
  66503. * @hidden
  66504. */
  66505. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66506. }
  66507. }
  66508. declare module "babylonjs/Particles/index" {
  66509. export * from "babylonjs/Particles/baseParticleSystem";
  66510. export * from "babylonjs/Particles/EmitterTypes/index";
  66511. export * from "babylonjs/Particles/gpuParticleSystem";
  66512. export * from "babylonjs/Particles/IParticleSystem";
  66513. export * from "babylonjs/Particles/particle";
  66514. export * from "babylonjs/Particles/particleHelper";
  66515. export * from "babylonjs/Particles/particleSystem";
  66516. export * from "babylonjs/Particles/particleSystemComponent";
  66517. export * from "babylonjs/Particles/particleSystemSet";
  66518. export * from "babylonjs/Particles/solidParticle";
  66519. export * from "babylonjs/Particles/solidParticleSystem";
  66520. export * from "babylonjs/Particles/cloudPoint";
  66521. export * from "babylonjs/Particles/pointsCloudSystem";
  66522. export * from "babylonjs/Particles/subEmitter";
  66523. }
  66524. declare module "babylonjs/Physics/physicsEngineComponent" {
  66525. import { Nullable } from "babylonjs/types";
  66526. import { Observable, Observer } from "babylonjs/Misc/observable";
  66527. import { Vector3 } from "babylonjs/Maths/math.vector";
  66528. import { Mesh } from "babylonjs/Meshes/mesh";
  66529. import { ISceneComponent } from "babylonjs/sceneComponent";
  66530. import { Scene } from "babylonjs/scene";
  66531. import { Node } from "babylonjs/node";
  66532. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66533. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66534. module "babylonjs/scene" {
  66535. interface Scene {
  66536. /** @hidden (Backing field) */
  66537. _physicsEngine: Nullable<IPhysicsEngine>;
  66538. /** @hidden */
  66539. _physicsTimeAccumulator: number;
  66540. /**
  66541. * Gets the current physics engine
  66542. * @returns a IPhysicsEngine or null if none attached
  66543. */
  66544. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66545. /**
  66546. * Enables physics to the current scene
  66547. * @param gravity defines the scene's gravity for the physics engine
  66548. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66549. * @return a boolean indicating if the physics engine was initialized
  66550. */
  66551. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66552. /**
  66553. * Disables and disposes the physics engine associated with the scene
  66554. */
  66555. disablePhysicsEngine(): void;
  66556. /**
  66557. * Gets a boolean indicating if there is an active physics engine
  66558. * @returns a boolean indicating if there is an active physics engine
  66559. */
  66560. isPhysicsEnabled(): boolean;
  66561. /**
  66562. * Deletes a physics compound impostor
  66563. * @param compound defines the compound to delete
  66564. */
  66565. deleteCompoundImpostor(compound: any): void;
  66566. /**
  66567. * An event triggered when physic simulation is about to be run
  66568. */
  66569. onBeforePhysicsObservable: Observable<Scene>;
  66570. /**
  66571. * An event triggered when physic simulation has been done
  66572. */
  66573. onAfterPhysicsObservable: Observable<Scene>;
  66574. }
  66575. }
  66576. module "babylonjs/Meshes/abstractMesh" {
  66577. interface AbstractMesh {
  66578. /** @hidden */
  66579. _physicsImpostor: Nullable<PhysicsImpostor>;
  66580. /**
  66581. * Gets or sets impostor used for physic simulation
  66582. * @see http://doc.babylonjs.com/features/physics_engine
  66583. */
  66584. physicsImpostor: Nullable<PhysicsImpostor>;
  66585. /**
  66586. * Gets the current physics impostor
  66587. * @see http://doc.babylonjs.com/features/physics_engine
  66588. * @returns a physics impostor or null
  66589. */
  66590. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66591. /** Apply a physic impulse to the mesh
  66592. * @param force defines the force to apply
  66593. * @param contactPoint defines where to apply the force
  66594. * @returns the current mesh
  66595. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66596. */
  66597. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66598. /**
  66599. * Creates a physic joint between two meshes
  66600. * @param otherMesh defines the other mesh to use
  66601. * @param pivot1 defines the pivot to use on this mesh
  66602. * @param pivot2 defines the pivot to use on the other mesh
  66603. * @param options defines additional options (can be plugin dependent)
  66604. * @returns the current mesh
  66605. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66606. */
  66607. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66608. /** @hidden */
  66609. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66610. }
  66611. }
  66612. /**
  66613. * Defines the physics engine scene component responsible to manage a physics engine
  66614. */
  66615. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66616. /**
  66617. * The component name helpful to identify the component in the list of scene components.
  66618. */
  66619. readonly name: string;
  66620. /**
  66621. * The scene the component belongs to.
  66622. */
  66623. scene: Scene;
  66624. /**
  66625. * Creates a new instance of the component for the given scene
  66626. * @param scene Defines the scene to register the component in
  66627. */
  66628. constructor(scene: Scene);
  66629. /**
  66630. * Registers the component in a given scene
  66631. */
  66632. register(): void;
  66633. /**
  66634. * Rebuilds the elements related to this component in case of
  66635. * context lost for instance.
  66636. */
  66637. rebuild(): void;
  66638. /**
  66639. * Disposes the component and the associated ressources
  66640. */
  66641. dispose(): void;
  66642. }
  66643. }
  66644. declare module "babylonjs/Physics/physicsHelper" {
  66645. import { Nullable } from "babylonjs/types";
  66646. import { Vector3 } from "babylonjs/Maths/math.vector";
  66647. import { Mesh } from "babylonjs/Meshes/mesh";
  66648. import { Scene } from "babylonjs/scene";
  66649. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66650. /**
  66651. * A helper for physics simulations
  66652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66653. */
  66654. export class PhysicsHelper {
  66655. private _scene;
  66656. private _physicsEngine;
  66657. /**
  66658. * Initializes the Physics helper
  66659. * @param scene Babylon.js scene
  66660. */
  66661. constructor(scene: Scene);
  66662. /**
  66663. * Applies a radial explosion impulse
  66664. * @param origin the origin of the explosion
  66665. * @param radiusOrEventOptions the radius or the options of radial explosion
  66666. * @param strength the explosion strength
  66667. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66668. * @returns A physics radial explosion event, or null
  66669. */
  66670. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66671. /**
  66672. * Applies a radial explosion force
  66673. * @param origin the origin of the explosion
  66674. * @param radiusOrEventOptions the radius or the options of radial explosion
  66675. * @param strength the explosion strength
  66676. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66677. * @returns A physics radial explosion event, or null
  66678. */
  66679. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66680. /**
  66681. * Creates a gravitational field
  66682. * @param origin the origin of the explosion
  66683. * @param radiusOrEventOptions the radius or the options of radial explosion
  66684. * @param strength the explosion strength
  66685. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66686. * @returns A physics gravitational field event, or null
  66687. */
  66688. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66689. /**
  66690. * Creates a physics updraft event
  66691. * @param origin the origin of the updraft
  66692. * @param radiusOrEventOptions the radius or the options of the updraft
  66693. * @param strength the strength of the updraft
  66694. * @param height the height of the updraft
  66695. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66696. * @returns A physics updraft event, or null
  66697. */
  66698. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66699. /**
  66700. * Creates a physics vortex event
  66701. * @param origin the of the vortex
  66702. * @param radiusOrEventOptions the radius or the options of the vortex
  66703. * @param strength the strength of the vortex
  66704. * @param height the height of the vortex
  66705. * @returns a Physics vortex event, or null
  66706. * A physics vortex event or null
  66707. */
  66708. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66709. }
  66710. /**
  66711. * Represents a physics radial explosion event
  66712. */
  66713. class PhysicsRadialExplosionEvent {
  66714. private _scene;
  66715. private _options;
  66716. private _sphere;
  66717. private _dataFetched;
  66718. /**
  66719. * Initializes a radial explosioin event
  66720. * @param _scene BabylonJS scene
  66721. * @param _options The options for the vortex event
  66722. */
  66723. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66724. /**
  66725. * Returns the data related to the radial explosion event (sphere).
  66726. * @returns The radial explosion event data
  66727. */
  66728. getData(): PhysicsRadialExplosionEventData;
  66729. /**
  66730. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66731. * @param impostor A physics imposter
  66732. * @param origin the origin of the explosion
  66733. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66734. */
  66735. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66736. /**
  66737. * Triggers affecterd impostors callbacks
  66738. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66739. */
  66740. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66741. /**
  66742. * Disposes the sphere.
  66743. * @param force Specifies if the sphere should be disposed by force
  66744. */
  66745. dispose(force?: boolean): void;
  66746. /*** Helpers ***/
  66747. private _prepareSphere;
  66748. private _intersectsWithSphere;
  66749. }
  66750. /**
  66751. * Represents a gravitational field event
  66752. */
  66753. class PhysicsGravitationalFieldEvent {
  66754. private _physicsHelper;
  66755. private _scene;
  66756. private _origin;
  66757. private _options;
  66758. private _tickCallback;
  66759. private _sphere;
  66760. private _dataFetched;
  66761. /**
  66762. * Initializes the physics gravitational field event
  66763. * @param _physicsHelper A physics helper
  66764. * @param _scene BabylonJS scene
  66765. * @param _origin The origin position of the gravitational field event
  66766. * @param _options The options for the vortex event
  66767. */
  66768. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66769. /**
  66770. * Returns the data related to the gravitational field event (sphere).
  66771. * @returns A gravitational field event
  66772. */
  66773. getData(): PhysicsGravitationalFieldEventData;
  66774. /**
  66775. * Enables the gravitational field.
  66776. */
  66777. enable(): void;
  66778. /**
  66779. * Disables the gravitational field.
  66780. */
  66781. disable(): void;
  66782. /**
  66783. * Disposes the sphere.
  66784. * @param force The force to dispose from the gravitational field event
  66785. */
  66786. dispose(force?: boolean): void;
  66787. private _tick;
  66788. }
  66789. /**
  66790. * Represents a physics updraft event
  66791. */
  66792. class PhysicsUpdraftEvent {
  66793. private _scene;
  66794. private _origin;
  66795. private _options;
  66796. private _physicsEngine;
  66797. private _originTop;
  66798. private _originDirection;
  66799. private _tickCallback;
  66800. private _cylinder;
  66801. private _cylinderPosition;
  66802. private _dataFetched;
  66803. /**
  66804. * Initializes the physics updraft event
  66805. * @param _scene BabylonJS scene
  66806. * @param _origin The origin position of the updraft
  66807. * @param _options The options for the updraft event
  66808. */
  66809. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66810. /**
  66811. * Returns the data related to the updraft event (cylinder).
  66812. * @returns A physics updraft event
  66813. */
  66814. getData(): PhysicsUpdraftEventData;
  66815. /**
  66816. * Enables the updraft.
  66817. */
  66818. enable(): void;
  66819. /**
  66820. * Disables the updraft.
  66821. */
  66822. disable(): void;
  66823. /**
  66824. * Disposes the cylinder.
  66825. * @param force Specifies if the updraft should be disposed by force
  66826. */
  66827. dispose(force?: boolean): void;
  66828. private getImpostorHitData;
  66829. private _tick;
  66830. /*** Helpers ***/
  66831. private _prepareCylinder;
  66832. private _intersectsWithCylinder;
  66833. }
  66834. /**
  66835. * Represents a physics vortex event
  66836. */
  66837. class PhysicsVortexEvent {
  66838. private _scene;
  66839. private _origin;
  66840. private _options;
  66841. private _physicsEngine;
  66842. private _originTop;
  66843. private _tickCallback;
  66844. private _cylinder;
  66845. private _cylinderPosition;
  66846. private _dataFetched;
  66847. /**
  66848. * Initializes the physics vortex event
  66849. * @param _scene The BabylonJS scene
  66850. * @param _origin The origin position of the vortex
  66851. * @param _options The options for the vortex event
  66852. */
  66853. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66854. /**
  66855. * Returns the data related to the vortex event (cylinder).
  66856. * @returns The physics vortex event data
  66857. */
  66858. getData(): PhysicsVortexEventData;
  66859. /**
  66860. * Enables the vortex.
  66861. */
  66862. enable(): void;
  66863. /**
  66864. * Disables the cortex.
  66865. */
  66866. disable(): void;
  66867. /**
  66868. * Disposes the sphere.
  66869. * @param force
  66870. */
  66871. dispose(force?: boolean): void;
  66872. private getImpostorHitData;
  66873. private _tick;
  66874. /*** Helpers ***/
  66875. private _prepareCylinder;
  66876. private _intersectsWithCylinder;
  66877. }
  66878. /**
  66879. * Options fot the radial explosion event
  66880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66881. */
  66882. export class PhysicsRadialExplosionEventOptions {
  66883. /**
  66884. * The radius of the sphere for the radial explosion.
  66885. */
  66886. radius: number;
  66887. /**
  66888. * The strenth of the explosion.
  66889. */
  66890. strength: number;
  66891. /**
  66892. * The strenght of the force in correspondence to the distance of the affected object
  66893. */
  66894. falloff: PhysicsRadialImpulseFalloff;
  66895. /**
  66896. * Sphere options for the radial explosion.
  66897. */
  66898. sphere: {
  66899. segments: number;
  66900. diameter: number;
  66901. };
  66902. /**
  66903. * Sphere options for the radial explosion.
  66904. */
  66905. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66906. }
  66907. /**
  66908. * Options fot the updraft event
  66909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66910. */
  66911. export class PhysicsUpdraftEventOptions {
  66912. /**
  66913. * The radius of the cylinder for the vortex
  66914. */
  66915. radius: number;
  66916. /**
  66917. * The strenth of the updraft.
  66918. */
  66919. strength: number;
  66920. /**
  66921. * The height of the cylinder for the updraft.
  66922. */
  66923. height: number;
  66924. /**
  66925. * The mode for the the updraft.
  66926. */
  66927. updraftMode: PhysicsUpdraftMode;
  66928. }
  66929. /**
  66930. * Options fot the vortex event
  66931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66932. */
  66933. export class PhysicsVortexEventOptions {
  66934. /**
  66935. * The radius of the cylinder for the vortex
  66936. */
  66937. radius: number;
  66938. /**
  66939. * The strenth of the vortex.
  66940. */
  66941. strength: number;
  66942. /**
  66943. * The height of the cylinder for the vortex.
  66944. */
  66945. height: number;
  66946. /**
  66947. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66948. */
  66949. centripetalForceThreshold: number;
  66950. /**
  66951. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66952. */
  66953. centripetalForceMultiplier: number;
  66954. /**
  66955. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66956. */
  66957. centrifugalForceMultiplier: number;
  66958. /**
  66959. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66960. */
  66961. updraftForceMultiplier: number;
  66962. }
  66963. /**
  66964. * The strenght of the force in correspondence to the distance of the affected object
  66965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66966. */
  66967. export enum PhysicsRadialImpulseFalloff {
  66968. /** Defines that impulse is constant in strength across it's whole radius */
  66969. Constant = 0,
  66970. /** Defines that impulse gets weaker if it's further from the origin */
  66971. Linear = 1
  66972. }
  66973. /**
  66974. * The strength of the force in correspondence to the distance of the affected object
  66975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66976. */
  66977. export enum PhysicsUpdraftMode {
  66978. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66979. Center = 0,
  66980. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66981. Perpendicular = 1
  66982. }
  66983. /**
  66984. * Interface for a physics hit data
  66985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66986. */
  66987. export interface PhysicsHitData {
  66988. /**
  66989. * The force applied at the contact point
  66990. */
  66991. force: Vector3;
  66992. /**
  66993. * The contact point
  66994. */
  66995. contactPoint: Vector3;
  66996. /**
  66997. * The distance from the origin to the contact point
  66998. */
  66999. distanceFromOrigin: number;
  67000. }
  67001. /**
  67002. * Interface for radial explosion event data
  67003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67004. */
  67005. export interface PhysicsRadialExplosionEventData {
  67006. /**
  67007. * A sphere used for the radial explosion event
  67008. */
  67009. sphere: Mesh;
  67010. }
  67011. /**
  67012. * Interface for gravitational field event data
  67013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67014. */
  67015. export interface PhysicsGravitationalFieldEventData {
  67016. /**
  67017. * A sphere mesh used for the gravitational field event
  67018. */
  67019. sphere: Mesh;
  67020. }
  67021. /**
  67022. * Interface for updraft event data
  67023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67024. */
  67025. export interface PhysicsUpdraftEventData {
  67026. /**
  67027. * A cylinder used for the updraft event
  67028. */
  67029. cylinder: Mesh;
  67030. }
  67031. /**
  67032. * Interface for vortex event data
  67033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67034. */
  67035. export interface PhysicsVortexEventData {
  67036. /**
  67037. * A cylinder used for the vortex event
  67038. */
  67039. cylinder: Mesh;
  67040. }
  67041. /**
  67042. * Interface for an affected physics impostor
  67043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67044. */
  67045. export interface PhysicsAffectedImpostorWithData {
  67046. /**
  67047. * The impostor affected by the effect
  67048. */
  67049. impostor: PhysicsImpostor;
  67050. /**
  67051. * The data about the hit/horce from the explosion
  67052. */
  67053. hitData: PhysicsHitData;
  67054. }
  67055. }
  67056. declare module "babylonjs/Physics/Plugins/index" {
  67057. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67058. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67059. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67060. }
  67061. declare module "babylonjs/Physics/index" {
  67062. export * from "babylonjs/Physics/IPhysicsEngine";
  67063. export * from "babylonjs/Physics/physicsEngine";
  67064. export * from "babylonjs/Physics/physicsEngineComponent";
  67065. export * from "babylonjs/Physics/physicsHelper";
  67066. export * from "babylonjs/Physics/physicsImpostor";
  67067. export * from "babylonjs/Physics/physicsJoint";
  67068. export * from "babylonjs/Physics/Plugins/index";
  67069. }
  67070. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67071. /** @hidden */
  67072. export var blackAndWhitePixelShader: {
  67073. name: string;
  67074. shader: string;
  67075. };
  67076. }
  67077. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67079. import { Camera } from "babylonjs/Cameras/camera";
  67080. import { Engine } from "babylonjs/Engines/engine";
  67081. import "babylonjs/Shaders/blackAndWhite.fragment";
  67082. /**
  67083. * Post process used to render in black and white
  67084. */
  67085. export class BlackAndWhitePostProcess extends PostProcess {
  67086. /**
  67087. * Linear about to convert he result to black and white (default: 1)
  67088. */
  67089. degree: number;
  67090. /**
  67091. * Creates a black and white post process
  67092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67093. * @param name The name of the effect.
  67094. * @param options The required width/height ratio to downsize to before computing the render pass.
  67095. * @param camera The camera to apply the render pass to.
  67096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67097. * @param engine The engine which the post process will be applied. (default: current engine)
  67098. * @param reusable If the post process can be reused on the same frame. (default: false)
  67099. */
  67100. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67101. }
  67102. }
  67103. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67104. import { Nullable } from "babylonjs/types";
  67105. import { Camera } from "babylonjs/Cameras/camera";
  67106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67107. import { Engine } from "babylonjs/Engines/engine";
  67108. /**
  67109. * This represents a set of one or more post processes in Babylon.
  67110. * A post process can be used to apply a shader to a texture after it is rendered.
  67111. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67112. */
  67113. export class PostProcessRenderEffect {
  67114. private _postProcesses;
  67115. private _getPostProcesses;
  67116. private _singleInstance;
  67117. private _cameras;
  67118. private _indicesForCamera;
  67119. /**
  67120. * Name of the effect
  67121. * @hidden
  67122. */
  67123. _name: string;
  67124. /**
  67125. * Instantiates a post process render effect.
  67126. * A post process can be used to apply a shader to a texture after it is rendered.
  67127. * @param engine The engine the effect is tied to
  67128. * @param name The name of the effect
  67129. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67130. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67131. */
  67132. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67133. /**
  67134. * Checks if all the post processes in the effect are supported.
  67135. */
  67136. get isSupported(): boolean;
  67137. /**
  67138. * Updates the current state of the effect
  67139. * @hidden
  67140. */
  67141. _update(): void;
  67142. /**
  67143. * Attaches the effect on cameras
  67144. * @param cameras The camera to attach to.
  67145. * @hidden
  67146. */
  67147. _attachCameras(cameras: Camera): void;
  67148. /**
  67149. * Attaches the effect on cameras
  67150. * @param cameras The camera to attach to.
  67151. * @hidden
  67152. */
  67153. _attachCameras(cameras: Camera[]): void;
  67154. /**
  67155. * Detaches the effect on cameras
  67156. * @param cameras The camera to detatch from.
  67157. * @hidden
  67158. */
  67159. _detachCameras(cameras: Camera): void;
  67160. /**
  67161. * Detatches the effect on cameras
  67162. * @param cameras The camera to detatch from.
  67163. * @hidden
  67164. */
  67165. _detachCameras(cameras: Camera[]): void;
  67166. /**
  67167. * Enables the effect on given cameras
  67168. * @param cameras The camera to enable.
  67169. * @hidden
  67170. */
  67171. _enable(cameras: Camera): void;
  67172. /**
  67173. * Enables the effect on given cameras
  67174. * @param cameras The camera to enable.
  67175. * @hidden
  67176. */
  67177. _enable(cameras: Nullable<Camera[]>): void;
  67178. /**
  67179. * Disables the effect on the given cameras
  67180. * @param cameras The camera to disable.
  67181. * @hidden
  67182. */
  67183. _disable(cameras: Camera): void;
  67184. /**
  67185. * Disables the effect on the given cameras
  67186. * @param cameras The camera to disable.
  67187. * @hidden
  67188. */
  67189. _disable(cameras: Nullable<Camera[]>): void;
  67190. /**
  67191. * Gets a list of the post processes contained in the effect.
  67192. * @param camera The camera to get the post processes on.
  67193. * @returns The list of the post processes in the effect.
  67194. */
  67195. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67196. }
  67197. }
  67198. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67199. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67200. /** @hidden */
  67201. export var extractHighlightsPixelShader: {
  67202. name: string;
  67203. shader: string;
  67204. };
  67205. }
  67206. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67207. import { Nullable } from "babylonjs/types";
  67208. import { Camera } from "babylonjs/Cameras/camera";
  67209. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67210. import { Engine } from "babylonjs/Engines/engine";
  67211. import "babylonjs/Shaders/extractHighlights.fragment";
  67212. /**
  67213. * 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.
  67214. */
  67215. export class ExtractHighlightsPostProcess extends PostProcess {
  67216. /**
  67217. * The luminance threshold, pixels below this value will be set to black.
  67218. */
  67219. threshold: number;
  67220. /** @hidden */
  67221. _exposure: number;
  67222. /**
  67223. * Post process which has the input texture to be used when performing highlight extraction
  67224. * @hidden
  67225. */
  67226. _inputPostProcess: Nullable<PostProcess>;
  67227. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67228. }
  67229. }
  67230. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67231. /** @hidden */
  67232. export var bloomMergePixelShader: {
  67233. name: string;
  67234. shader: string;
  67235. };
  67236. }
  67237. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67238. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67239. import { Nullable } from "babylonjs/types";
  67240. import { Engine } from "babylonjs/Engines/engine";
  67241. import { Camera } from "babylonjs/Cameras/camera";
  67242. import "babylonjs/Shaders/bloomMerge.fragment";
  67243. /**
  67244. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67245. */
  67246. export class BloomMergePostProcess extends PostProcess {
  67247. /** Weight of the bloom to be added to the original input. */
  67248. weight: number;
  67249. /**
  67250. * Creates a new instance of @see BloomMergePostProcess
  67251. * @param name The name of the effect.
  67252. * @param originalFromInput Post process which's input will be used for the merge.
  67253. * @param blurred Blurred highlights post process which's output will be used.
  67254. * @param weight Weight of the bloom to be added to the original input.
  67255. * @param options The required width/height ratio to downsize to before computing the render pass.
  67256. * @param camera The camera to apply the render pass to.
  67257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67258. * @param engine The engine which the post process will be applied. (default: current engine)
  67259. * @param reusable If the post process can be reused on the same frame. (default: false)
  67260. * @param textureType Type of textures used when performing the post process. (default: 0)
  67261. * @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)
  67262. */
  67263. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67264. /** Weight of the bloom to be added to the original input. */
  67265. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67266. }
  67267. }
  67268. declare module "babylonjs/PostProcesses/bloomEffect" {
  67269. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67270. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67271. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67272. import { Camera } from "babylonjs/Cameras/camera";
  67273. import { Scene } from "babylonjs/scene";
  67274. /**
  67275. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67276. */
  67277. export class BloomEffect extends PostProcessRenderEffect {
  67278. private bloomScale;
  67279. /**
  67280. * @hidden Internal
  67281. */
  67282. _effects: Array<PostProcess>;
  67283. /**
  67284. * @hidden Internal
  67285. */
  67286. _downscale: ExtractHighlightsPostProcess;
  67287. private _blurX;
  67288. private _blurY;
  67289. private _merge;
  67290. /**
  67291. * The luminance threshold to find bright areas of the image to bloom.
  67292. */
  67293. get threshold(): number;
  67294. set threshold(value: number);
  67295. /**
  67296. * The strength of the bloom.
  67297. */
  67298. get weight(): number;
  67299. set weight(value: number);
  67300. /**
  67301. * Specifies the size of the bloom blur kernel, relative to the final output size
  67302. */
  67303. get kernel(): number;
  67304. set kernel(value: number);
  67305. /**
  67306. * Creates a new instance of @see BloomEffect
  67307. * @param scene The scene the effect belongs to.
  67308. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67309. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67310. * @param bloomWeight The the strength of bloom.
  67311. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67312. * @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)
  67313. */
  67314. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67315. /**
  67316. * Disposes each of the internal effects for a given camera.
  67317. * @param camera The camera to dispose the effect on.
  67318. */
  67319. disposeEffects(camera: Camera): void;
  67320. /**
  67321. * @hidden Internal
  67322. */
  67323. _updateEffects(): void;
  67324. /**
  67325. * Internal
  67326. * @returns if all the contained post processes are ready.
  67327. * @hidden
  67328. */
  67329. _isReady(): boolean;
  67330. }
  67331. }
  67332. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67333. /** @hidden */
  67334. export var chromaticAberrationPixelShader: {
  67335. name: string;
  67336. shader: string;
  67337. };
  67338. }
  67339. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67340. import { Vector2 } from "babylonjs/Maths/math.vector";
  67341. import { Nullable } from "babylonjs/types";
  67342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67343. import { Camera } from "babylonjs/Cameras/camera";
  67344. import { Engine } from "babylonjs/Engines/engine";
  67345. import "babylonjs/Shaders/chromaticAberration.fragment";
  67346. /**
  67347. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67348. */
  67349. export class ChromaticAberrationPostProcess extends PostProcess {
  67350. /**
  67351. * The amount of seperation of rgb channels (default: 30)
  67352. */
  67353. aberrationAmount: number;
  67354. /**
  67355. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67356. */
  67357. radialIntensity: number;
  67358. /**
  67359. * 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))
  67360. */
  67361. direction: Vector2;
  67362. /**
  67363. * 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))
  67364. */
  67365. centerPosition: Vector2;
  67366. /**
  67367. * Creates a new instance ChromaticAberrationPostProcess
  67368. * @param name The name of the effect.
  67369. * @param screenWidth The width of the screen to apply the effect on.
  67370. * @param screenHeight The height of the screen to apply the effect on.
  67371. * @param options The required width/height ratio to downsize to before computing the render pass.
  67372. * @param camera The camera to apply the render pass to.
  67373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67374. * @param engine The engine which the post process will be applied. (default: current engine)
  67375. * @param reusable If the post process can be reused on the same frame. (default: false)
  67376. * @param textureType Type of textures used when performing the post process. (default: 0)
  67377. * @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)
  67378. */
  67379. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67380. }
  67381. }
  67382. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67383. /** @hidden */
  67384. export var circleOfConfusionPixelShader: {
  67385. name: string;
  67386. shader: string;
  67387. };
  67388. }
  67389. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67390. import { Nullable } from "babylonjs/types";
  67391. import { Engine } from "babylonjs/Engines/engine";
  67392. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67394. import { Camera } from "babylonjs/Cameras/camera";
  67395. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67396. /**
  67397. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67398. */
  67399. export class CircleOfConfusionPostProcess extends PostProcess {
  67400. /**
  67401. * 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.
  67402. */
  67403. lensSize: number;
  67404. /**
  67405. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67406. */
  67407. fStop: number;
  67408. /**
  67409. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67410. */
  67411. focusDistance: number;
  67412. /**
  67413. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67414. */
  67415. focalLength: number;
  67416. private _depthTexture;
  67417. /**
  67418. * Creates a new instance CircleOfConfusionPostProcess
  67419. * @param name The name of the effect.
  67420. * @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.
  67421. * @param options The required width/height ratio to downsize to before computing the render pass.
  67422. * @param camera The camera to apply the render pass to.
  67423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67424. * @param engine The engine which the post process will be applied. (default: current engine)
  67425. * @param reusable If the post process can be reused on the same frame. (default: false)
  67426. * @param textureType Type of textures used when performing the post process. (default: 0)
  67427. * @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)
  67428. */
  67429. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67430. /**
  67431. * 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.
  67432. */
  67433. set depthTexture(value: RenderTargetTexture);
  67434. }
  67435. }
  67436. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67437. /** @hidden */
  67438. export var colorCorrectionPixelShader: {
  67439. name: string;
  67440. shader: string;
  67441. };
  67442. }
  67443. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67444. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67445. import { Engine } from "babylonjs/Engines/engine";
  67446. import { Camera } from "babylonjs/Cameras/camera";
  67447. import "babylonjs/Shaders/colorCorrection.fragment";
  67448. /**
  67449. *
  67450. * This post-process allows the modification of rendered colors by using
  67451. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67452. *
  67453. * The object needs to be provided an url to a texture containing the color
  67454. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67455. * Use an image editing software to tweak the LUT to match your needs.
  67456. *
  67457. * For an example of a color LUT, see here:
  67458. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67459. * For explanations on color grading, see here:
  67460. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67461. *
  67462. */
  67463. export class ColorCorrectionPostProcess extends PostProcess {
  67464. private _colorTableTexture;
  67465. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67466. }
  67467. }
  67468. declare module "babylonjs/Shaders/convolution.fragment" {
  67469. /** @hidden */
  67470. export var convolutionPixelShader: {
  67471. name: string;
  67472. shader: string;
  67473. };
  67474. }
  67475. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67477. import { Nullable } from "babylonjs/types";
  67478. import { Camera } from "babylonjs/Cameras/camera";
  67479. import { Engine } from "babylonjs/Engines/engine";
  67480. import "babylonjs/Shaders/convolution.fragment";
  67481. /**
  67482. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67483. * input texture to perform effects such as edge detection or sharpening
  67484. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67485. */
  67486. export class ConvolutionPostProcess extends PostProcess {
  67487. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67488. kernel: number[];
  67489. /**
  67490. * Creates a new instance ConvolutionPostProcess
  67491. * @param name The name of the effect.
  67492. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67493. * @param options The required width/height ratio to downsize to before computing the render pass.
  67494. * @param camera The camera to apply the render pass to.
  67495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67496. * @param engine The engine which the post process will be applied. (default: current engine)
  67497. * @param reusable If the post process can be reused on the same frame. (default: false)
  67498. * @param textureType Type of textures used when performing the post process. (default: 0)
  67499. */
  67500. constructor(name: string,
  67501. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67502. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67503. /**
  67504. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67505. */
  67506. static EdgeDetect0Kernel: number[];
  67507. /**
  67508. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67509. */
  67510. static EdgeDetect1Kernel: number[];
  67511. /**
  67512. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67513. */
  67514. static EdgeDetect2Kernel: number[];
  67515. /**
  67516. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67517. */
  67518. static SharpenKernel: number[];
  67519. /**
  67520. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67521. */
  67522. static EmbossKernel: number[];
  67523. /**
  67524. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67525. */
  67526. static GaussianKernel: number[];
  67527. }
  67528. }
  67529. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67530. import { Nullable } from "babylonjs/types";
  67531. import { Vector2 } from "babylonjs/Maths/math.vector";
  67532. import { Camera } from "babylonjs/Cameras/camera";
  67533. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67534. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67535. import { Engine } from "babylonjs/Engines/engine";
  67536. import { Scene } from "babylonjs/scene";
  67537. /**
  67538. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67539. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67540. * based on samples that have a large difference in distance than the center pixel.
  67541. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67542. */
  67543. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67544. direction: Vector2;
  67545. /**
  67546. * Creates a new instance CircleOfConfusionPostProcess
  67547. * @param name The name of the effect.
  67548. * @param scene The scene the effect belongs to.
  67549. * @param direction The direction the blur should be applied.
  67550. * @param kernel The size of the kernel used to blur.
  67551. * @param options The required width/height ratio to downsize to before computing the render pass.
  67552. * @param camera The camera to apply the render pass to.
  67553. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67554. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67556. * @param engine The engine which the post process will be applied. (default: current engine)
  67557. * @param reusable If the post process can be reused on the same frame. (default: false)
  67558. * @param textureType Type of textures used when performing the post process. (default: 0)
  67559. * @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)
  67560. */
  67561. 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);
  67562. }
  67563. }
  67564. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67565. /** @hidden */
  67566. export var depthOfFieldMergePixelShader: {
  67567. name: string;
  67568. shader: string;
  67569. };
  67570. }
  67571. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67572. import { Nullable } from "babylonjs/types";
  67573. import { Camera } from "babylonjs/Cameras/camera";
  67574. import { Effect } from "babylonjs/Materials/effect";
  67575. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67576. import { Engine } from "babylonjs/Engines/engine";
  67577. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67578. /**
  67579. * Options to be set when merging outputs from the default pipeline.
  67580. */
  67581. export class DepthOfFieldMergePostProcessOptions {
  67582. /**
  67583. * The original image to merge on top of
  67584. */
  67585. originalFromInput: PostProcess;
  67586. /**
  67587. * Parameters to perform the merge of the depth of field effect
  67588. */
  67589. depthOfField?: {
  67590. circleOfConfusion: PostProcess;
  67591. blurSteps: Array<PostProcess>;
  67592. };
  67593. /**
  67594. * Parameters to perform the merge of bloom effect
  67595. */
  67596. bloom?: {
  67597. blurred: PostProcess;
  67598. weight: number;
  67599. };
  67600. }
  67601. /**
  67602. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67603. */
  67604. export class DepthOfFieldMergePostProcess extends PostProcess {
  67605. private blurSteps;
  67606. /**
  67607. * Creates a new instance of DepthOfFieldMergePostProcess
  67608. * @param name The name of the effect.
  67609. * @param originalFromInput Post process which's input will be used for the merge.
  67610. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67611. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67612. * @param options The required width/height ratio to downsize to before computing the render pass.
  67613. * @param camera The camera to apply the render pass to.
  67614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67615. * @param engine The engine which the post process will be applied. (default: current engine)
  67616. * @param reusable If the post process can be reused on the same frame. (default: false)
  67617. * @param textureType Type of textures used when performing the post process. (default: 0)
  67618. * @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)
  67619. */
  67620. 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);
  67621. /**
  67622. * Updates the effect with the current post process compile time values and recompiles the shader.
  67623. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67624. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67625. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67626. * @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
  67627. * @param onCompiled Called when the shader has been compiled.
  67628. * @param onError Called if there is an error when compiling a shader.
  67629. */
  67630. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67631. }
  67632. }
  67633. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67634. import { Nullable } from "babylonjs/types";
  67635. import { Camera } from "babylonjs/Cameras/camera";
  67636. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67637. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67638. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67639. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67640. import { Scene } from "babylonjs/scene";
  67641. /**
  67642. * Specifies the level of max blur that should be applied when using the depth of field effect
  67643. */
  67644. export enum DepthOfFieldEffectBlurLevel {
  67645. /**
  67646. * Subtle blur
  67647. */
  67648. Low = 0,
  67649. /**
  67650. * Medium blur
  67651. */
  67652. Medium = 1,
  67653. /**
  67654. * Large blur
  67655. */
  67656. High = 2
  67657. }
  67658. /**
  67659. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67660. */
  67661. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67662. private _circleOfConfusion;
  67663. /**
  67664. * @hidden Internal, blurs from high to low
  67665. */
  67666. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67667. private _depthOfFieldBlurY;
  67668. private _dofMerge;
  67669. /**
  67670. * @hidden Internal post processes in depth of field effect
  67671. */
  67672. _effects: Array<PostProcess>;
  67673. /**
  67674. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67675. */
  67676. set focalLength(value: number);
  67677. get focalLength(): number;
  67678. /**
  67679. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67680. */
  67681. set fStop(value: number);
  67682. get fStop(): number;
  67683. /**
  67684. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67685. */
  67686. set focusDistance(value: number);
  67687. get focusDistance(): number;
  67688. /**
  67689. * 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.
  67690. */
  67691. set lensSize(value: number);
  67692. get lensSize(): number;
  67693. /**
  67694. * Creates a new instance DepthOfFieldEffect
  67695. * @param scene The scene the effect belongs to.
  67696. * @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.
  67697. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67698. * @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)
  67699. */
  67700. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67701. /**
  67702. * Get the current class name of the current effet
  67703. * @returns "DepthOfFieldEffect"
  67704. */
  67705. getClassName(): string;
  67706. /**
  67707. * 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.
  67708. */
  67709. set depthTexture(value: RenderTargetTexture);
  67710. /**
  67711. * Disposes each of the internal effects for a given camera.
  67712. * @param camera The camera to dispose the effect on.
  67713. */
  67714. disposeEffects(camera: Camera): void;
  67715. /**
  67716. * @hidden Internal
  67717. */
  67718. _updateEffects(): void;
  67719. /**
  67720. * Internal
  67721. * @returns if all the contained post processes are ready.
  67722. * @hidden
  67723. */
  67724. _isReady(): boolean;
  67725. }
  67726. }
  67727. declare module "babylonjs/Shaders/displayPass.fragment" {
  67728. /** @hidden */
  67729. export var displayPassPixelShader: {
  67730. name: string;
  67731. shader: string;
  67732. };
  67733. }
  67734. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67735. import { Nullable } from "babylonjs/types";
  67736. import { Camera } from "babylonjs/Cameras/camera";
  67737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67738. import { Engine } from "babylonjs/Engines/engine";
  67739. import "babylonjs/Shaders/displayPass.fragment";
  67740. /**
  67741. * DisplayPassPostProcess which produces an output the same as it's input
  67742. */
  67743. export class DisplayPassPostProcess extends PostProcess {
  67744. /**
  67745. * Creates the DisplayPassPostProcess
  67746. * @param name The name of the effect.
  67747. * @param options The required width/height ratio to downsize to before computing the render pass.
  67748. * @param camera The camera to apply the render pass to.
  67749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67750. * @param engine The engine which the post process will be applied. (default: current engine)
  67751. * @param reusable If the post process can be reused on the same frame. (default: false)
  67752. */
  67753. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67754. }
  67755. }
  67756. declare module "babylonjs/Shaders/filter.fragment" {
  67757. /** @hidden */
  67758. export var filterPixelShader: {
  67759. name: string;
  67760. shader: string;
  67761. };
  67762. }
  67763. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67764. import { Nullable } from "babylonjs/types";
  67765. import { Matrix } from "babylonjs/Maths/math.vector";
  67766. import { Camera } from "babylonjs/Cameras/camera";
  67767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67768. import { Engine } from "babylonjs/Engines/engine";
  67769. import "babylonjs/Shaders/filter.fragment";
  67770. /**
  67771. * Applies a kernel filter to the image
  67772. */
  67773. export class FilterPostProcess extends PostProcess {
  67774. /** The matrix to be applied to the image */
  67775. kernelMatrix: Matrix;
  67776. /**
  67777. *
  67778. * @param name The name of the effect.
  67779. * @param kernelMatrix The matrix to be applied to the image
  67780. * @param options The required width/height ratio to downsize to before computing the render pass.
  67781. * @param camera The camera to apply the render pass to.
  67782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67783. * @param engine The engine which the post process will be applied. (default: current engine)
  67784. * @param reusable If the post process can be reused on the same frame. (default: false)
  67785. */
  67786. constructor(name: string,
  67787. /** The matrix to be applied to the image */
  67788. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67789. }
  67790. }
  67791. declare module "babylonjs/Shaders/fxaa.fragment" {
  67792. /** @hidden */
  67793. export var fxaaPixelShader: {
  67794. name: string;
  67795. shader: string;
  67796. };
  67797. }
  67798. declare module "babylonjs/Shaders/fxaa.vertex" {
  67799. /** @hidden */
  67800. export var fxaaVertexShader: {
  67801. name: string;
  67802. shader: string;
  67803. };
  67804. }
  67805. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67806. import { Nullable } from "babylonjs/types";
  67807. import { Camera } from "babylonjs/Cameras/camera";
  67808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67809. import { Engine } from "babylonjs/Engines/engine";
  67810. import "babylonjs/Shaders/fxaa.fragment";
  67811. import "babylonjs/Shaders/fxaa.vertex";
  67812. /**
  67813. * Fxaa post process
  67814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67815. */
  67816. export class FxaaPostProcess extends PostProcess {
  67817. /** @hidden */
  67818. texelWidth: number;
  67819. /** @hidden */
  67820. texelHeight: number;
  67821. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67822. private _getDefines;
  67823. }
  67824. }
  67825. declare module "babylonjs/Shaders/grain.fragment" {
  67826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67827. /** @hidden */
  67828. export var grainPixelShader: {
  67829. name: string;
  67830. shader: string;
  67831. };
  67832. }
  67833. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67834. import { Nullable } from "babylonjs/types";
  67835. import { Camera } from "babylonjs/Cameras/camera";
  67836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67837. import { Engine } from "babylonjs/Engines/engine";
  67838. import "babylonjs/Shaders/grain.fragment";
  67839. /**
  67840. * The GrainPostProcess adds noise to the image at mid luminance levels
  67841. */
  67842. export class GrainPostProcess extends PostProcess {
  67843. /**
  67844. * The intensity of the grain added (default: 30)
  67845. */
  67846. intensity: number;
  67847. /**
  67848. * If the grain should be randomized on every frame
  67849. */
  67850. animated: boolean;
  67851. /**
  67852. * Creates a new instance of @see GrainPostProcess
  67853. * @param name The name of the effect.
  67854. * @param options The required width/height ratio to downsize to before computing the render pass.
  67855. * @param camera The camera to apply the render pass to.
  67856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67857. * @param engine The engine which the post process will be applied. (default: current engine)
  67858. * @param reusable If the post process can be reused on the same frame. (default: false)
  67859. * @param textureType Type of textures used when performing the post process. (default: 0)
  67860. * @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)
  67861. */
  67862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67863. }
  67864. }
  67865. declare module "babylonjs/Shaders/highlights.fragment" {
  67866. /** @hidden */
  67867. export var highlightsPixelShader: {
  67868. name: string;
  67869. shader: string;
  67870. };
  67871. }
  67872. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67873. import { Nullable } from "babylonjs/types";
  67874. import { Camera } from "babylonjs/Cameras/camera";
  67875. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67876. import { Engine } from "babylonjs/Engines/engine";
  67877. import "babylonjs/Shaders/highlights.fragment";
  67878. /**
  67879. * Extracts highlights from the image
  67880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67881. */
  67882. export class HighlightsPostProcess extends PostProcess {
  67883. /**
  67884. * Extracts highlights from the image
  67885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67886. * @param name The name of the effect.
  67887. * @param options The required width/height ratio to downsize to before computing the render pass.
  67888. * @param camera The camera to apply the render pass to.
  67889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67890. * @param engine The engine which the post process will be applied. (default: current engine)
  67891. * @param reusable If the post process can be reused on the same frame. (default: false)
  67892. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67893. */
  67894. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67895. }
  67896. }
  67897. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67898. /** @hidden */
  67899. export var mrtFragmentDeclaration: {
  67900. name: string;
  67901. shader: string;
  67902. };
  67903. }
  67904. declare module "babylonjs/Shaders/geometry.fragment" {
  67905. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67906. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67907. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67908. /** @hidden */
  67909. export var geometryPixelShader: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module "babylonjs/Shaders/geometry.vertex" {
  67915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67919. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67920. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67921. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67922. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67923. /** @hidden */
  67924. export var geometryVertexShader: {
  67925. name: string;
  67926. shader: string;
  67927. };
  67928. }
  67929. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67930. import { Matrix } from "babylonjs/Maths/math.vector";
  67931. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67932. import { Mesh } from "babylonjs/Meshes/mesh";
  67933. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67934. import { Effect } from "babylonjs/Materials/effect";
  67935. import { Scene } from "babylonjs/scene";
  67936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67937. import "babylonjs/Shaders/geometry.fragment";
  67938. import "babylonjs/Shaders/geometry.vertex";
  67939. /** @hidden */
  67940. interface ISavedTransformationMatrix {
  67941. world: Matrix;
  67942. viewProjection: Matrix;
  67943. }
  67944. /**
  67945. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67946. */
  67947. export class GeometryBufferRenderer {
  67948. /**
  67949. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67950. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67951. */
  67952. static readonly POSITION_TEXTURE_TYPE: number;
  67953. /**
  67954. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67955. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67956. */
  67957. static readonly VELOCITY_TEXTURE_TYPE: number;
  67958. /**
  67959. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67960. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67961. */
  67962. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67963. /**
  67964. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67965. * in order to compute objects velocities when enableVelocity is set to "true"
  67966. * @hidden
  67967. */
  67968. _previousTransformationMatrices: {
  67969. [index: number]: ISavedTransformationMatrix;
  67970. };
  67971. /**
  67972. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67973. * in order to compute objects velocities when enableVelocity is set to "true"
  67974. * @hidden
  67975. */
  67976. _previousBonesTransformationMatrices: {
  67977. [index: number]: Float32Array;
  67978. };
  67979. /**
  67980. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67981. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67982. */
  67983. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67984. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67985. renderTransparentMeshes: boolean;
  67986. private _scene;
  67987. private _multiRenderTarget;
  67988. private _ratio;
  67989. private _enablePosition;
  67990. private _enableVelocity;
  67991. private _enableReflectivity;
  67992. private _positionIndex;
  67993. private _velocityIndex;
  67994. private _reflectivityIndex;
  67995. protected _effect: Effect;
  67996. protected _cachedDefines: string;
  67997. /**
  67998. * Set the render list (meshes to be rendered) used in the G buffer.
  67999. */
  68000. set renderList(meshes: Mesh[]);
  68001. /**
  68002. * Gets wether or not G buffer are supported by the running hardware.
  68003. * This requires draw buffer supports
  68004. */
  68005. get isSupported(): boolean;
  68006. /**
  68007. * Returns the index of the given texture type in the G-Buffer textures array
  68008. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68009. * @returns the index of the given texture type in the G-Buffer textures array
  68010. */
  68011. getTextureIndex(textureType: number): number;
  68012. /**
  68013. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68014. */
  68015. get enablePosition(): boolean;
  68016. /**
  68017. * Sets whether or not objects positions are enabled for the G buffer.
  68018. */
  68019. set enablePosition(enable: boolean);
  68020. /**
  68021. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68022. */
  68023. get enableVelocity(): boolean;
  68024. /**
  68025. * Sets wether or not objects velocities are enabled for the G buffer.
  68026. */
  68027. set enableVelocity(enable: boolean);
  68028. /**
  68029. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68030. */
  68031. get enableReflectivity(): boolean;
  68032. /**
  68033. * Sets wether or not objects roughness are enabled for the G buffer.
  68034. */
  68035. set enableReflectivity(enable: boolean);
  68036. /**
  68037. * Gets the scene associated with the buffer.
  68038. */
  68039. get scene(): Scene;
  68040. /**
  68041. * Gets the ratio used by the buffer during its creation.
  68042. * How big is the buffer related to the main canvas.
  68043. */
  68044. get ratio(): number;
  68045. /** @hidden */
  68046. static _SceneComponentInitialization: (scene: Scene) => void;
  68047. /**
  68048. * Creates a new G Buffer for the scene
  68049. * @param scene The scene the buffer belongs to
  68050. * @param ratio How big is the buffer related to the main canvas.
  68051. */
  68052. constructor(scene: Scene, ratio?: number);
  68053. /**
  68054. * Checks wether everything is ready to render a submesh to the G buffer.
  68055. * @param subMesh the submesh to check readiness for
  68056. * @param useInstances is the mesh drawn using instance or not
  68057. * @returns true if ready otherwise false
  68058. */
  68059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68060. /**
  68061. * Gets the current underlying G Buffer.
  68062. * @returns the buffer
  68063. */
  68064. getGBuffer(): MultiRenderTarget;
  68065. /**
  68066. * Gets the number of samples used to render the buffer (anti aliasing).
  68067. */
  68068. get samples(): number;
  68069. /**
  68070. * Sets the number of samples used to render the buffer (anti aliasing).
  68071. */
  68072. set samples(value: number);
  68073. /**
  68074. * Disposes the renderer and frees up associated resources.
  68075. */
  68076. dispose(): void;
  68077. protected _createRenderTargets(): void;
  68078. private _copyBonesTransformationMatrices;
  68079. }
  68080. }
  68081. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68082. import { Nullable } from "babylonjs/types";
  68083. import { Scene } from "babylonjs/scene";
  68084. import { ISceneComponent } from "babylonjs/sceneComponent";
  68085. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68086. module "babylonjs/scene" {
  68087. interface Scene {
  68088. /** @hidden (Backing field) */
  68089. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68090. /**
  68091. * Gets or Sets the current geometry buffer associated to the scene.
  68092. */
  68093. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68094. /**
  68095. * Enables a GeometryBufferRender and associates it with the scene
  68096. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68097. * @returns the GeometryBufferRenderer
  68098. */
  68099. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68100. /**
  68101. * Disables the GeometryBufferRender associated with the scene
  68102. */
  68103. disableGeometryBufferRenderer(): void;
  68104. }
  68105. }
  68106. /**
  68107. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68108. * in several rendering techniques.
  68109. */
  68110. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68111. /**
  68112. * The component name helpful to identify the component in the list of scene components.
  68113. */
  68114. readonly name: string;
  68115. /**
  68116. * The scene the component belongs to.
  68117. */
  68118. scene: Scene;
  68119. /**
  68120. * Creates a new instance of the component for the given scene
  68121. * @param scene Defines the scene to register the component in
  68122. */
  68123. constructor(scene: Scene);
  68124. /**
  68125. * Registers the component in a given scene
  68126. */
  68127. register(): void;
  68128. /**
  68129. * Rebuilds the elements related to this component in case of
  68130. * context lost for instance.
  68131. */
  68132. rebuild(): void;
  68133. /**
  68134. * Disposes the component and the associated ressources
  68135. */
  68136. dispose(): void;
  68137. private _gatherRenderTargets;
  68138. }
  68139. }
  68140. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68141. /** @hidden */
  68142. export var motionBlurPixelShader: {
  68143. name: string;
  68144. shader: string;
  68145. };
  68146. }
  68147. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68148. import { Nullable } from "babylonjs/types";
  68149. import { Camera } from "babylonjs/Cameras/camera";
  68150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68151. import { Scene } from "babylonjs/scene";
  68152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68153. import "babylonjs/Animations/animatable";
  68154. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68155. import "babylonjs/Shaders/motionBlur.fragment";
  68156. import { Engine } from "babylonjs/Engines/engine";
  68157. /**
  68158. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68159. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68160. * As an example, all you have to do is to create the post-process:
  68161. * var mb = new BABYLON.MotionBlurPostProcess(
  68162. * 'mb', // The name of the effect.
  68163. * scene, // The scene containing the objects to blur according to their velocity.
  68164. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68165. * camera // The camera to apply the render pass to.
  68166. * );
  68167. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68168. */
  68169. export class MotionBlurPostProcess extends PostProcess {
  68170. /**
  68171. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68172. */
  68173. motionStrength: number;
  68174. /**
  68175. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68176. */
  68177. get motionBlurSamples(): number;
  68178. /**
  68179. * Sets the number of iterations to be used for motion blur quality
  68180. */
  68181. set motionBlurSamples(samples: number);
  68182. private _motionBlurSamples;
  68183. private _geometryBufferRenderer;
  68184. /**
  68185. * Creates a new instance MotionBlurPostProcess
  68186. * @param name The name of the effect.
  68187. * @param scene The scene containing the objects to blur according to their velocity.
  68188. * @param options The required width/height ratio to downsize to before computing the render pass.
  68189. * @param camera The camera to apply the render pass to.
  68190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68191. * @param engine The engine which the post process will be applied. (default: current engine)
  68192. * @param reusable If the post process can be reused on the same frame. (default: false)
  68193. * @param textureType Type of textures used when performing the post process. (default: 0)
  68194. * @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)
  68195. */
  68196. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68197. /**
  68198. * Excludes the given skinned mesh from computing bones velocities.
  68199. * 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.
  68200. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68201. */
  68202. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68203. /**
  68204. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68205. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68206. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68207. */
  68208. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68209. /**
  68210. * Disposes the post process.
  68211. * @param camera The camera to dispose the post process on.
  68212. */
  68213. dispose(camera?: Camera): void;
  68214. }
  68215. }
  68216. declare module "babylonjs/Shaders/refraction.fragment" {
  68217. /** @hidden */
  68218. export var refractionPixelShader: {
  68219. name: string;
  68220. shader: string;
  68221. };
  68222. }
  68223. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68224. import { Color3 } from "babylonjs/Maths/math.color";
  68225. import { Camera } from "babylonjs/Cameras/camera";
  68226. import { Texture } from "babylonjs/Materials/Textures/texture";
  68227. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68228. import { Engine } from "babylonjs/Engines/engine";
  68229. import "babylonjs/Shaders/refraction.fragment";
  68230. /**
  68231. * Post process which applies a refractin texture
  68232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68233. */
  68234. export class RefractionPostProcess extends PostProcess {
  68235. /** the base color of the refraction (used to taint the rendering) */
  68236. color: Color3;
  68237. /** simulated refraction depth */
  68238. depth: number;
  68239. /** the coefficient of the base color (0 to remove base color tainting) */
  68240. colorLevel: number;
  68241. private _refTexture;
  68242. private _ownRefractionTexture;
  68243. /**
  68244. * Gets or sets the refraction texture
  68245. * Please note that you are responsible for disposing the texture if you set it manually
  68246. */
  68247. get refractionTexture(): Texture;
  68248. set refractionTexture(value: Texture);
  68249. /**
  68250. * Initializes the RefractionPostProcess
  68251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68252. * @param name The name of the effect.
  68253. * @param refractionTextureUrl Url of the refraction texture to use
  68254. * @param color the base color of the refraction (used to taint the rendering)
  68255. * @param depth simulated refraction depth
  68256. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68257. * @param camera The camera to apply the render pass to.
  68258. * @param options The required width/height ratio to downsize to before computing the render pass.
  68259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68260. * @param engine The engine which the post process will be applied. (default: current engine)
  68261. * @param reusable If the post process can be reused on the same frame. (default: false)
  68262. */
  68263. constructor(name: string, refractionTextureUrl: string,
  68264. /** the base color of the refraction (used to taint the rendering) */
  68265. color: Color3,
  68266. /** simulated refraction depth */
  68267. depth: number,
  68268. /** the coefficient of the base color (0 to remove base color tainting) */
  68269. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68270. /**
  68271. * Disposes of the post process
  68272. * @param camera Camera to dispose post process on
  68273. */
  68274. dispose(camera: Camera): void;
  68275. }
  68276. }
  68277. declare module "babylonjs/Shaders/sharpen.fragment" {
  68278. /** @hidden */
  68279. export var sharpenPixelShader: {
  68280. name: string;
  68281. shader: string;
  68282. };
  68283. }
  68284. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68285. import { Nullable } from "babylonjs/types";
  68286. import { Camera } from "babylonjs/Cameras/camera";
  68287. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68288. import "babylonjs/Shaders/sharpen.fragment";
  68289. import { Engine } from "babylonjs/Engines/engine";
  68290. /**
  68291. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68292. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68293. */
  68294. export class SharpenPostProcess extends PostProcess {
  68295. /**
  68296. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68297. */
  68298. colorAmount: number;
  68299. /**
  68300. * How much sharpness should be applied (default: 0.3)
  68301. */
  68302. edgeAmount: number;
  68303. /**
  68304. * Creates a new instance ConvolutionPostProcess
  68305. * @param name The name of the effect.
  68306. * @param options The required width/height ratio to downsize to before computing the render pass.
  68307. * @param camera The camera to apply the render pass to.
  68308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68309. * @param engine The engine which the post process will be applied. (default: current engine)
  68310. * @param reusable If the post process can be reused on the same frame. (default: false)
  68311. * @param textureType Type of textures used when performing the post process. (default: 0)
  68312. * @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)
  68313. */
  68314. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68315. }
  68316. }
  68317. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68318. import { Nullable } from "babylonjs/types";
  68319. import { Camera } from "babylonjs/Cameras/camera";
  68320. import { Engine } from "babylonjs/Engines/engine";
  68321. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68323. /**
  68324. * PostProcessRenderPipeline
  68325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68326. */
  68327. export class PostProcessRenderPipeline {
  68328. private engine;
  68329. private _renderEffects;
  68330. private _renderEffectsForIsolatedPass;
  68331. /**
  68332. * List of inspectable custom properties (used by the Inspector)
  68333. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68334. */
  68335. inspectableCustomProperties: IInspectable[];
  68336. /**
  68337. * @hidden
  68338. */
  68339. protected _cameras: Camera[];
  68340. /** @hidden */
  68341. _name: string;
  68342. /**
  68343. * Gets pipeline name
  68344. */
  68345. get name(): string;
  68346. /** Gets the list of attached cameras */
  68347. get cameras(): Camera[];
  68348. /**
  68349. * Initializes a PostProcessRenderPipeline
  68350. * @param engine engine to add the pipeline to
  68351. * @param name name of the pipeline
  68352. */
  68353. constructor(engine: Engine, name: string);
  68354. /**
  68355. * Gets the class name
  68356. * @returns "PostProcessRenderPipeline"
  68357. */
  68358. getClassName(): string;
  68359. /**
  68360. * If all the render effects in the pipeline are supported
  68361. */
  68362. get isSupported(): boolean;
  68363. /**
  68364. * Adds an effect to the pipeline
  68365. * @param renderEffect the effect to add
  68366. */
  68367. addEffect(renderEffect: PostProcessRenderEffect): void;
  68368. /** @hidden */
  68369. _rebuild(): void;
  68370. /** @hidden */
  68371. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68372. /** @hidden */
  68373. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68374. /** @hidden */
  68375. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68376. /** @hidden */
  68377. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68378. /** @hidden */
  68379. _attachCameras(cameras: Camera, unique: boolean): void;
  68380. /** @hidden */
  68381. _attachCameras(cameras: Camera[], unique: boolean): void;
  68382. /** @hidden */
  68383. _detachCameras(cameras: Camera): void;
  68384. /** @hidden */
  68385. _detachCameras(cameras: Nullable<Camera[]>): void;
  68386. /** @hidden */
  68387. _update(): void;
  68388. /** @hidden */
  68389. _reset(): void;
  68390. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68391. /**
  68392. * Disposes of the pipeline
  68393. */
  68394. dispose(): void;
  68395. }
  68396. }
  68397. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68398. import { Camera } from "babylonjs/Cameras/camera";
  68399. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68400. /**
  68401. * PostProcessRenderPipelineManager class
  68402. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68403. */
  68404. export class PostProcessRenderPipelineManager {
  68405. private _renderPipelines;
  68406. /**
  68407. * Initializes a PostProcessRenderPipelineManager
  68408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68409. */
  68410. constructor();
  68411. /**
  68412. * Gets the list of supported render pipelines
  68413. */
  68414. get supportedPipelines(): PostProcessRenderPipeline[];
  68415. /**
  68416. * Adds a pipeline to the manager
  68417. * @param renderPipeline The pipeline to add
  68418. */
  68419. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68420. /**
  68421. * Attaches a camera to the pipeline
  68422. * @param renderPipelineName The name of the pipeline to attach to
  68423. * @param cameras the camera to attach
  68424. * @param unique if the camera can be attached multiple times to the pipeline
  68425. */
  68426. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68427. /**
  68428. * Detaches a camera from the pipeline
  68429. * @param renderPipelineName The name of the pipeline to detach from
  68430. * @param cameras the camera to detach
  68431. */
  68432. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68433. /**
  68434. * Enables an effect by name on a pipeline
  68435. * @param renderPipelineName the name of the pipeline to enable the effect in
  68436. * @param renderEffectName the name of the effect to enable
  68437. * @param cameras the cameras that the effect should be enabled on
  68438. */
  68439. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68440. /**
  68441. * Disables an effect by name on a pipeline
  68442. * @param renderPipelineName the name of the pipeline to disable the effect in
  68443. * @param renderEffectName the name of the effect to disable
  68444. * @param cameras the cameras that the effect should be disabled on
  68445. */
  68446. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68447. /**
  68448. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68449. */
  68450. update(): void;
  68451. /** @hidden */
  68452. _rebuild(): void;
  68453. /**
  68454. * Disposes of the manager and pipelines
  68455. */
  68456. dispose(): void;
  68457. }
  68458. }
  68459. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68460. import { ISceneComponent } from "babylonjs/sceneComponent";
  68461. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68462. import { Scene } from "babylonjs/scene";
  68463. module "babylonjs/scene" {
  68464. interface Scene {
  68465. /** @hidden (Backing field) */
  68466. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68467. /**
  68468. * Gets the postprocess render pipeline manager
  68469. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68470. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68471. */
  68472. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68473. }
  68474. }
  68475. /**
  68476. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68477. */
  68478. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68479. /**
  68480. * The component name helpfull to identify the component in the list of scene components.
  68481. */
  68482. readonly name: string;
  68483. /**
  68484. * The scene the component belongs to.
  68485. */
  68486. scene: Scene;
  68487. /**
  68488. * Creates a new instance of the component for the given scene
  68489. * @param scene Defines the scene to register the component in
  68490. */
  68491. constructor(scene: Scene);
  68492. /**
  68493. * Registers the component in a given scene
  68494. */
  68495. register(): void;
  68496. /**
  68497. * Rebuilds the elements related to this component in case of
  68498. * context lost for instance.
  68499. */
  68500. rebuild(): void;
  68501. /**
  68502. * Disposes the component and the associated ressources
  68503. */
  68504. dispose(): void;
  68505. private _gatherRenderTargets;
  68506. }
  68507. }
  68508. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68509. import { Nullable } from "babylonjs/types";
  68510. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68511. import { Camera } from "babylonjs/Cameras/camera";
  68512. import { IDisposable } from "babylonjs/scene";
  68513. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68514. import { Scene } from "babylonjs/scene";
  68515. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68516. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68517. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68518. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68519. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68520. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68521. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68522. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68523. import { Animation } from "babylonjs/Animations/animation";
  68524. /**
  68525. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68526. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68527. */
  68528. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68529. private _scene;
  68530. private _camerasToBeAttached;
  68531. /**
  68532. * ID of the sharpen post process,
  68533. */
  68534. private readonly SharpenPostProcessId;
  68535. /**
  68536. * @ignore
  68537. * ID of the image processing post process;
  68538. */
  68539. readonly ImageProcessingPostProcessId: string;
  68540. /**
  68541. * @ignore
  68542. * ID of the Fast Approximate Anti-Aliasing post process;
  68543. */
  68544. readonly FxaaPostProcessId: string;
  68545. /**
  68546. * ID of the chromatic aberration post process,
  68547. */
  68548. private readonly ChromaticAberrationPostProcessId;
  68549. /**
  68550. * ID of the grain post process
  68551. */
  68552. private readonly GrainPostProcessId;
  68553. /**
  68554. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68555. */
  68556. sharpen: SharpenPostProcess;
  68557. private _sharpenEffect;
  68558. private bloom;
  68559. /**
  68560. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68561. */
  68562. depthOfField: DepthOfFieldEffect;
  68563. /**
  68564. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68565. */
  68566. fxaa: FxaaPostProcess;
  68567. /**
  68568. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68569. */
  68570. imageProcessing: ImageProcessingPostProcess;
  68571. /**
  68572. * Chromatic aberration post process which will shift rgb colors in the image
  68573. */
  68574. chromaticAberration: ChromaticAberrationPostProcess;
  68575. private _chromaticAberrationEffect;
  68576. /**
  68577. * Grain post process which add noise to the image
  68578. */
  68579. grain: GrainPostProcess;
  68580. private _grainEffect;
  68581. /**
  68582. * Glow post process which adds a glow to emissive areas of the image
  68583. */
  68584. private _glowLayer;
  68585. /**
  68586. * Animations which can be used to tweak settings over a period of time
  68587. */
  68588. animations: Animation[];
  68589. private _imageProcessingConfigurationObserver;
  68590. private _sharpenEnabled;
  68591. private _bloomEnabled;
  68592. private _depthOfFieldEnabled;
  68593. private _depthOfFieldBlurLevel;
  68594. private _fxaaEnabled;
  68595. private _imageProcessingEnabled;
  68596. private _defaultPipelineTextureType;
  68597. private _bloomScale;
  68598. private _chromaticAberrationEnabled;
  68599. private _grainEnabled;
  68600. private _buildAllowed;
  68601. /**
  68602. * Gets active scene
  68603. */
  68604. get scene(): Scene;
  68605. /**
  68606. * Enable or disable the sharpen process from the pipeline
  68607. */
  68608. set sharpenEnabled(enabled: boolean);
  68609. get sharpenEnabled(): boolean;
  68610. private _resizeObserver;
  68611. private _hardwareScaleLevel;
  68612. private _bloomKernel;
  68613. /**
  68614. * Specifies the size of the bloom blur kernel, relative to the final output size
  68615. */
  68616. get bloomKernel(): number;
  68617. set bloomKernel(value: number);
  68618. /**
  68619. * Specifies the weight of the bloom in the final rendering
  68620. */
  68621. private _bloomWeight;
  68622. /**
  68623. * Specifies the luma threshold for the area that will be blurred by the bloom
  68624. */
  68625. private _bloomThreshold;
  68626. private _hdr;
  68627. /**
  68628. * The strength of the bloom.
  68629. */
  68630. set bloomWeight(value: number);
  68631. get bloomWeight(): number;
  68632. /**
  68633. * The strength of the bloom.
  68634. */
  68635. set bloomThreshold(value: number);
  68636. get bloomThreshold(): number;
  68637. /**
  68638. * The scale of the bloom, lower value will provide better performance.
  68639. */
  68640. set bloomScale(value: number);
  68641. get bloomScale(): number;
  68642. /**
  68643. * Enable or disable the bloom from the pipeline
  68644. */
  68645. set bloomEnabled(enabled: boolean);
  68646. get bloomEnabled(): boolean;
  68647. private _rebuildBloom;
  68648. /**
  68649. * If the depth of field is enabled.
  68650. */
  68651. get depthOfFieldEnabled(): boolean;
  68652. set depthOfFieldEnabled(enabled: boolean);
  68653. /**
  68654. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68655. */
  68656. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68657. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68658. /**
  68659. * If the anti aliasing is enabled.
  68660. */
  68661. set fxaaEnabled(enabled: boolean);
  68662. get fxaaEnabled(): boolean;
  68663. private _samples;
  68664. /**
  68665. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68666. */
  68667. set samples(sampleCount: number);
  68668. get samples(): number;
  68669. /**
  68670. * If image processing is enabled.
  68671. */
  68672. set imageProcessingEnabled(enabled: boolean);
  68673. get imageProcessingEnabled(): boolean;
  68674. /**
  68675. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68676. */
  68677. set glowLayerEnabled(enabled: boolean);
  68678. get glowLayerEnabled(): boolean;
  68679. /**
  68680. * Gets the glow layer (or null if not defined)
  68681. */
  68682. get glowLayer(): Nullable<GlowLayer>;
  68683. /**
  68684. * Enable or disable the chromaticAberration process from the pipeline
  68685. */
  68686. set chromaticAberrationEnabled(enabled: boolean);
  68687. get chromaticAberrationEnabled(): boolean;
  68688. /**
  68689. * Enable or disable the grain process from the pipeline
  68690. */
  68691. set grainEnabled(enabled: boolean);
  68692. get grainEnabled(): boolean;
  68693. /**
  68694. * @constructor
  68695. * @param name - The rendering pipeline name (default: "")
  68696. * @param hdr - If high dynamic range textures should be used (default: true)
  68697. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68698. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68699. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68700. */
  68701. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68702. /**
  68703. * Get the class name
  68704. * @returns "DefaultRenderingPipeline"
  68705. */
  68706. getClassName(): string;
  68707. /**
  68708. * Force the compilation of the entire pipeline.
  68709. */
  68710. prepare(): void;
  68711. private _hasCleared;
  68712. private _prevPostProcess;
  68713. private _prevPrevPostProcess;
  68714. private _setAutoClearAndTextureSharing;
  68715. private _depthOfFieldSceneObserver;
  68716. private _buildPipeline;
  68717. private _disposePostProcesses;
  68718. /**
  68719. * Adds a camera to the pipeline
  68720. * @param camera the camera to be added
  68721. */
  68722. addCamera(camera: Camera): void;
  68723. /**
  68724. * Removes a camera from the pipeline
  68725. * @param camera the camera to remove
  68726. */
  68727. removeCamera(camera: Camera): void;
  68728. /**
  68729. * Dispose of the pipeline and stop all post processes
  68730. */
  68731. dispose(): void;
  68732. /**
  68733. * Serialize the rendering pipeline (Used when exporting)
  68734. * @returns the serialized object
  68735. */
  68736. serialize(): any;
  68737. /**
  68738. * Parse the serialized pipeline
  68739. * @param source Source pipeline.
  68740. * @param scene The scene to load the pipeline to.
  68741. * @param rootUrl The URL of the serialized pipeline.
  68742. * @returns An instantiated pipeline from the serialized object.
  68743. */
  68744. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68745. }
  68746. }
  68747. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68748. /** @hidden */
  68749. export var lensHighlightsPixelShader: {
  68750. name: string;
  68751. shader: string;
  68752. };
  68753. }
  68754. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68755. /** @hidden */
  68756. export var depthOfFieldPixelShader: {
  68757. name: string;
  68758. shader: string;
  68759. };
  68760. }
  68761. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68762. import { Camera } from "babylonjs/Cameras/camera";
  68763. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68764. import { Scene } from "babylonjs/scene";
  68765. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68766. import "babylonjs/Shaders/chromaticAberration.fragment";
  68767. import "babylonjs/Shaders/lensHighlights.fragment";
  68768. import "babylonjs/Shaders/depthOfField.fragment";
  68769. /**
  68770. * BABYLON.JS Chromatic Aberration GLSL Shader
  68771. * Author: Olivier Guyot
  68772. * Separates very slightly R, G and B colors on the edges of the screen
  68773. * Inspired by Francois Tarlier & Martins Upitis
  68774. */
  68775. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68776. /**
  68777. * @ignore
  68778. * The chromatic aberration PostProcess id in the pipeline
  68779. */
  68780. LensChromaticAberrationEffect: string;
  68781. /**
  68782. * @ignore
  68783. * The highlights enhancing PostProcess id in the pipeline
  68784. */
  68785. HighlightsEnhancingEffect: string;
  68786. /**
  68787. * @ignore
  68788. * The depth-of-field PostProcess id in the pipeline
  68789. */
  68790. LensDepthOfFieldEffect: string;
  68791. private _scene;
  68792. private _depthTexture;
  68793. private _grainTexture;
  68794. private _chromaticAberrationPostProcess;
  68795. private _highlightsPostProcess;
  68796. private _depthOfFieldPostProcess;
  68797. private _edgeBlur;
  68798. private _grainAmount;
  68799. private _chromaticAberration;
  68800. private _distortion;
  68801. private _highlightsGain;
  68802. private _highlightsThreshold;
  68803. private _dofDistance;
  68804. private _dofAperture;
  68805. private _dofDarken;
  68806. private _dofPentagon;
  68807. private _blurNoise;
  68808. /**
  68809. * @constructor
  68810. *
  68811. * Effect parameters are as follow:
  68812. * {
  68813. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68814. * edge_blur: number; // from 0 to x (1 for realism)
  68815. * distortion: number; // from 0 to x (1 for realism)
  68816. * grain_amount: number; // from 0 to 1
  68817. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68818. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68819. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68820. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68821. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68822. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68823. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68824. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68825. * }
  68826. * Note: if an effect parameter is unset, effect is disabled
  68827. *
  68828. * @param name The rendering pipeline name
  68829. * @param parameters - An object containing all parameters (see above)
  68830. * @param scene The scene linked to this pipeline
  68831. * @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)
  68832. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68833. */
  68834. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68835. /**
  68836. * Get the class name
  68837. * @returns "LensRenderingPipeline"
  68838. */
  68839. getClassName(): string;
  68840. /**
  68841. * Gets associated scene
  68842. */
  68843. get scene(): Scene;
  68844. /**
  68845. * Gets or sets the edge blur
  68846. */
  68847. get edgeBlur(): number;
  68848. set edgeBlur(value: number);
  68849. /**
  68850. * Gets or sets the grain amount
  68851. */
  68852. get grainAmount(): number;
  68853. set grainAmount(value: number);
  68854. /**
  68855. * Gets or sets the chromatic aberration amount
  68856. */
  68857. get chromaticAberration(): number;
  68858. set chromaticAberration(value: number);
  68859. /**
  68860. * Gets or sets the depth of field aperture
  68861. */
  68862. get dofAperture(): number;
  68863. set dofAperture(value: number);
  68864. /**
  68865. * Gets or sets the edge distortion
  68866. */
  68867. get edgeDistortion(): number;
  68868. set edgeDistortion(value: number);
  68869. /**
  68870. * Gets or sets the depth of field distortion
  68871. */
  68872. get dofDistortion(): number;
  68873. set dofDistortion(value: number);
  68874. /**
  68875. * Gets or sets the darken out of focus amount
  68876. */
  68877. get darkenOutOfFocus(): number;
  68878. set darkenOutOfFocus(value: number);
  68879. /**
  68880. * Gets or sets a boolean indicating if blur noise is enabled
  68881. */
  68882. get blurNoise(): boolean;
  68883. set blurNoise(value: boolean);
  68884. /**
  68885. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68886. */
  68887. get pentagonBokeh(): boolean;
  68888. set pentagonBokeh(value: boolean);
  68889. /**
  68890. * Gets or sets the highlight grain amount
  68891. */
  68892. get highlightsGain(): number;
  68893. set highlightsGain(value: number);
  68894. /**
  68895. * Gets or sets the highlight threshold
  68896. */
  68897. get highlightsThreshold(): number;
  68898. set highlightsThreshold(value: number);
  68899. /**
  68900. * Sets the amount of blur at the edges
  68901. * @param amount blur amount
  68902. */
  68903. setEdgeBlur(amount: number): void;
  68904. /**
  68905. * Sets edge blur to 0
  68906. */
  68907. disableEdgeBlur(): void;
  68908. /**
  68909. * Sets the amout of grain
  68910. * @param amount Amount of grain
  68911. */
  68912. setGrainAmount(amount: number): void;
  68913. /**
  68914. * Set grain amount to 0
  68915. */
  68916. disableGrain(): void;
  68917. /**
  68918. * Sets the chromatic aberration amount
  68919. * @param amount amount of chromatic aberration
  68920. */
  68921. setChromaticAberration(amount: number): void;
  68922. /**
  68923. * Sets chromatic aberration amount to 0
  68924. */
  68925. disableChromaticAberration(): void;
  68926. /**
  68927. * Sets the EdgeDistortion amount
  68928. * @param amount amount of EdgeDistortion
  68929. */
  68930. setEdgeDistortion(amount: number): void;
  68931. /**
  68932. * Sets edge distortion to 0
  68933. */
  68934. disableEdgeDistortion(): void;
  68935. /**
  68936. * Sets the FocusDistance amount
  68937. * @param amount amount of FocusDistance
  68938. */
  68939. setFocusDistance(amount: number): void;
  68940. /**
  68941. * Disables depth of field
  68942. */
  68943. disableDepthOfField(): void;
  68944. /**
  68945. * Sets the Aperture amount
  68946. * @param amount amount of Aperture
  68947. */
  68948. setAperture(amount: number): void;
  68949. /**
  68950. * Sets the DarkenOutOfFocus amount
  68951. * @param amount amount of DarkenOutOfFocus
  68952. */
  68953. setDarkenOutOfFocus(amount: number): void;
  68954. private _pentagonBokehIsEnabled;
  68955. /**
  68956. * Creates a pentagon bokeh effect
  68957. */
  68958. enablePentagonBokeh(): void;
  68959. /**
  68960. * Disables the pentagon bokeh effect
  68961. */
  68962. disablePentagonBokeh(): void;
  68963. /**
  68964. * Enables noise blur
  68965. */
  68966. enableNoiseBlur(): void;
  68967. /**
  68968. * Disables noise blur
  68969. */
  68970. disableNoiseBlur(): void;
  68971. /**
  68972. * Sets the HighlightsGain amount
  68973. * @param amount amount of HighlightsGain
  68974. */
  68975. setHighlightsGain(amount: number): void;
  68976. /**
  68977. * Sets the HighlightsThreshold amount
  68978. * @param amount amount of HighlightsThreshold
  68979. */
  68980. setHighlightsThreshold(amount: number): void;
  68981. /**
  68982. * Disables highlights
  68983. */
  68984. disableHighlights(): void;
  68985. /**
  68986. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68987. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68988. */
  68989. dispose(disableDepthRender?: boolean): void;
  68990. private _createChromaticAberrationPostProcess;
  68991. private _createHighlightsPostProcess;
  68992. private _createDepthOfFieldPostProcess;
  68993. private _createGrainTexture;
  68994. }
  68995. }
  68996. declare module "babylonjs/Shaders/ssao2.fragment" {
  68997. /** @hidden */
  68998. export var ssao2PixelShader: {
  68999. name: string;
  69000. shader: string;
  69001. };
  69002. }
  69003. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69004. /** @hidden */
  69005. export var ssaoCombinePixelShader: {
  69006. name: string;
  69007. shader: string;
  69008. };
  69009. }
  69010. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69011. import { Camera } from "babylonjs/Cameras/camera";
  69012. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69013. import { Scene } from "babylonjs/scene";
  69014. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69015. import "babylonjs/Shaders/ssao2.fragment";
  69016. import "babylonjs/Shaders/ssaoCombine.fragment";
  69017. /**
  69018. * Render pipeline to produce ssao effect
  69019. */
  69020. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69021. /**
  69022. * @ignore
  69023. * The PassPostProcess id in the pipeline that contains the original scene color
  69024. */
  69025. SSAOOriginalSceneColorEffect: string;
  69026. /**
  69027. * @ignore
  69028. * The SSAO PostProcess id in the pipeline
  69029. */
  69030. SSAORenderEffect: string;
  69031. /**
  69032. * @ignore
  69033. * The horizontal blur PostProcess id in the pipeline
  69034. */
  69035. SSAOBlurHRenderEffect: string;
  69036. /**
  69037. * @ignore
  69038. * The vertical blur PostProcess id in the pipeline
  69039. */
  69040. SSAOBlurVRenderEffect: string;
  69041. /**
  69042. * @ignore
  69043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69044. */
  69045. SSAOCombineRenderEffect: string;
  69046. /**
  69047. * The output strength of the SSAO post-process. Default value is 1.0.
  69048. */
  69049. totalStrength: number;
  69050. /**
  69051. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69052. */
  69053. maxZ: number;
  69054. /**
  69055. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69056. */
  69057. minZAspect: number;
  69058. private _samples;
  69059. /**
  69060. * Number of samples used for the SSAO calculations. Default value is 8
  69061. */
  69062. set samples(n: number);
  69063. get samples(): number;
  69064. private _textureSamples;
  69065. /**
  69066. * Number of samples to use for antialiasing
  69067. */
  69068. set textureSamples(n: number);
  69069. get textureSamples(): number;
  69070. /**
  69071. * Ratio object used for SSAO ratio and blur ratio
  69072. */
  69073. private _ratio;
  69074. /**
  69075. * Dynamically generated sphere sampler.
  69076. */
  69077. private _sampleSphere;
  69078. /**
  69079. * Blur filter offsets
  69080. */
  69081. private _samplerOffsets;
  69082. private _expensiveBlur;
  69083. /**
  69084. * If bilateral blur should be used
  69085. */
  69086. set expensiveBlur(b: boolean);
  69087. get expensiveBlur(): boolean;
  69088. /**
  69089. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69090. */
  69091. radius: number;
  69092. /**
  69093. * The base color of the SSAO post-process
  69094. * The final result is "base + ssao" between [0, 1]
  69095. */
  69096. base: number;
  69097. /**
  69098. * Support test.
  69099. */
  69100. static get IsSupported(): boolean;
  69101. private _scene;
  69102. private _depthTexture;
  69103. private _normalTexture;
  69104. private _randomTexture;
  69105. private _originalColorPostProcess;
  69106. private _ssaoPostProcess;
  69107. private _blurHPostProcess;
  69108. private _blurVPostProcess;
  69109. private _ssaoCombinePostProcess;
  69110. /**
  69111. * Gets active scene
  69112. */
  69113. get scene(): Scene;
  69114. /**
  69115. * @constructor
  69116. * @param name The rendering pipeline name
  69117. * @param scene The scene linked to this pipeline
  69118. * @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 }
  69119. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69120. */
  69121. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69122. /**
  69123. * Get the class name
  69124. * @returns "SSAO2RenderingPipeline"
  69125. */
  69126. getClassName(): string;
  69127. /**
  69128. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69129. */
  69130. dispose(disableGeometryBufferRenderer?: boolean): void;
  69131. private _createBlurPostProcess;
  69132. /** @hidden */
  69133. _rebuild(): void;
  69134. private _bits;
  69135. private _radicalInverse_VdC;
  69136. private _hammersley;
  69137. private _hemisphereSample_uniform;
  69138. private _generateHemisphere;
  69139. private _createSSAOPostProcess;
  69140. private _createSSAOCombinePostProcess;
  69141. private _createRandomTexture;
  69142. /**
  69143. * Serialize the rendering pipeline (Used when exporting)
  69144. * @returns the serialized object
  69145. */
  69146. serialize(): any;
  69147. /**
  69148. * Parse the serialized pipeline
  69149. * @param source Source pipeline.
  69150. * @param scene The scene to load the pipeline to.
  69151. * @param rootUrl The URL of the serialized pipeline.
  69152. * @returns An instantiated pipeline from the serialized object.
  69153. */
  69154. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69155. }
  69156. }
  69157. declare module "babylonjs/Shaders/ssao.fragment" {
  69158. /** @hidden */
  69159. export var ssaoPixelShader: {
  69160. name: string;
  69161. shader: string;
  69162. };
  69163. }
  69164. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69165. import { Camera } from "babylonjs/Cameras/camera";
  69166. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69167. import { Scene } from "babylonjs/scene";
  69168. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69169. import "babylonjs/Shaders/ssao.fragment";
  69170. import "babylonjs/Shaders/ssaoCombine.fragment";
  69171. /**
  69172. * Render pipeline to produce ssao effect
  69173. */
  69174. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69175. /**
  69176. * @ignore
  69177. * The PassPostProcess id in the pipeline that contains the original scene color
  69178. */
  69179. SSAOOriginalSceneColorEffect: string;
  69180. /**
  69181. * @ignore
  69182. * The SSAO PostProcess id in the pipeline
  69183. */
  69184. SSAORenderEffect: string;
  69185. /**
  69186. * @ignore
  69187. * The horizontal blur PostProcess id in the pipeline
  69188. */
  69189. SSAOBlurHRenderEffect: string;
  69190. /**
  69191. * @ignore
  69192. * The vertical blur PostProcess id in the pipeline
  69193. */
  69194. SSAOBlurVRenderEffect: string;
  69195. /**
  69196. * @ignore
  69197. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69198. */
  69199. SSAOCombineRenderEffect: string;
  69200. /**
  69201. * The output strength of the SSAO post-process. Default value is 1.0.
  69202. */
  69203. totalStrength: number;
  69204. /**
  69205. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69206. */
  69207. radius: number;
  69208. /**
  69209. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69210. * Must not be equal to fallOff and superior to fallOff.
  69211. * Default value is 0.0075
  69212. */
  69213. area: number;
  69214. /**
  69215. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69216. * Must not be equal to area and inferior to area.
  69217. * Default value is 0.000001
  69218. */
  69219. fallOff: number;
  69220. /**
  69221. * The base color of the SSAO post-process
  69222. * The final result is "base + ssao" between [0, 1]
  69223. */
  69224. base: number;
  69225. private _scene;
  69226. private _depthTexture;
  69227. private _randomTexture;
  69228. private _originalColorPostProcess;
  69229. private _ssaoPostProcess;
  69230. private _blurHPostProcess;
  69231. private _blurVPostProcess;
  69232. private _ssaoCombinePostProcess;
  69233. private _firstUpdate;
  69234. /**
  69235. * Gets active scene
  69236. */
  69237. get scene(): Scene;
  69238. /**
  69239. * @constructor
  69240. * @param name - The rendering pipeline name
  69241. * @param scene - The scene linked to this pipeline
  69242. * @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 }
  69243. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69244. */
  69245. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69246. /**
  69247. * Get the class name
  69248. * @returns "SSAORenderingPipeline"
  69249. */
  69250. getClassName(): string;
  69251. /**
  69252. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69253. */
  69254. dispose(disableDepthRender?: boolean): void;
  69255. private _createBlurPostProcess;
  69256. /** @hidden */
  69257. _rebuild(): void;
  69258. private _createSSAOPostProcess;
  69259. private _createSSAOCombinePostProcess;
  69260. private _createRandomTexture;
  69261. }
  69262. }
  69263. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69264. /** @hidden */
  69265. export var screenSpaceReflectionPixelShader: {
  69266. name: string;
  69267. shader: string;
  69268. };
  69269. }
  69270. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69271. import { Nullable } from "babylonjs/types";
  69272. import { Camera } from "babylonjs/Cameras/camera";
  69273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69274. import { Scene } from "babylonjs/scene";
  69275. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69276. import { Engine } from "babylonjs/Engines/engine";
  69277. /**
  69278. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69279. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69280. */
  69281. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69282. /**
  69283. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69284. */
  69285. threshold: number;
  69286. /**
  69287. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69288. */
  69289. strength: number;
  69290. /**
  69291. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69292. */
  69293. reflectionSpecularFalloffExponent: number;
  69294. /**
  69295. * 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]
  69296. */
  69297. step: number;
  69298. /**
  69299. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69300. */
  69301. roughnessFactor: number;
  69302. private _geometryBufferRenderer;
  69303. private _enableSmoothReflections;
  69304. private _reflectionSamples;
  69305. private _smoothSteps;
  69306. /**
  69307. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69308. * @param name The name of the effect.
  69309. * @param scene The scene containing the objects to calculate reflections.
  69310. * @param options The required width/height ratio to downsize to before computing the render pass.
  69311. * @param camera The camera to apply the render pass to.
  69312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69313. * @param engine The engine which the post process will be applied. (default: current engine)
  69314. * @param reusable If the post process can be reused on the same frame. (default: false)
  69315. * @param textureType Type of textures used when performing the post process. (default: 0)
  69316. * @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)
  69317. */
  69318. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69319. /**
  69320. * Gets wether or not smoothing reflections is enabled.
  69321. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69322. */
  69323. get enableSmoothReflections(): boolean;
  69324. /**
  69325. * Sets wether or not smoothing reflections is enabled.
  69326. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69327. */
  69328. set enableSmoothReflections(enabled: boolean);
  69329. /**
  69330. * Gets the number of samples taken while computing reflections. More samples count is high,
  69331. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69332. */
  69333. get reflectionSamples(): number;
  69334. /**
  69335. * Sets the number of samples taken while computing reflections. More samples count is high,
  69336. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69337. */
  69338. set reflectionSamples(samples: number);
  69339. /**
  69340. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69341. * more the post-process will require GPU power and can generate a drop in FPS.
  69342. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69343. */
  69344. get smoothSteps(): number;
  69345. set smoothSteps(steps: number);
  69346. private _updateEffectDefines;
  69347. }
  69348. }
  69349. declare module "babylonjs/Shaders/standard.fragment" {
  69350. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69351. /** @hidden */
  69352. export var standardPixelShader: {
  69353. name: string;
  69354. shader: string;
  69355. };
  69356. }
  69357. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69358. import { Nullable } from "babylonjs/types";
  69359. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69360. import { Camera } from "babylonjs/Cameras/camera";
  69361. import { Texture } from "babylonjs/Materials/Textures/texture";
  69362. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69363. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69364. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69365. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69366. import { IDisposable } from "babylonjs/scene";
  69367. import { SpotLight } from "babylonjs/Lights/spotLight";
  69368. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69369. import { Scene } from "babylonjs/scene";
  69370. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69371. import { Animation } from "babylonjs/Animations/animation";
  69372. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69373. import "babylonjs/Shaders/standard.fragment";
  69374. /**
  69375. * Standard rendering pipeline
  69376. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69377. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69378. */
  69379. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69380. /**
  69381. * Public members
  69382. */
  69383. /**
  69384. * Post-process which contains the original scene color before the pipeline applies all the effects
  69385. */
  69386. originalPostProcess: Nullable<PostProcess>;
  69387. /**
  69388. * Post-process used to down scale an image x4
  69389. */
  69390. downSampleX4PostProcess: Nullable<PostProcess>;
  69391. /**
  69392. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69393. */
  69394. brightPassPostProcess: Nullable<PostProcess>;
  69395. /**
  69396. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69397. */
  69398. blurHPostProcesses: PostProcess[];
  69399. /**
  69400. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69401. */
  69402. blurVPostProcesses: PostProcess[];
  69403. /**
  69404. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69405. */
  69406. textureAdderPostProcess: Nullable<PostProcess>;
  69407. /**
  69408. * Post-process used to create volumetric lighting effect
  69409. */
  69410. volumetricLightPostProcess: Nullable<PostProcess>;
  69411. /**
  69412. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69413. */
  69414. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69415. /**
  69416. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69417. */
  69418. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69419. /**
  69420. * Post-process used to merge the volumetric light effect and the real scene color
  69421. */
  69422. volumetricLightMergePostProces: Nullable<PostProcess>;
  69423. /**
  69424. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69425. */
  69426. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69427. /**
  69428. * Base post-process used to calculate the average luminance of the final image for HDR
  69429. */
  69430. luminancePostProcess: Nullable<PostProcess>;
  69431. /**
  69432. * Post-processes used to create down sample post-processes in order to get
  69433. * the average luminance of the final image for HDR
  69434. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69435. */
  69436. luminanceDownSamplePostProcesses: PostProcess[];
  69437. /**
  69438. * Post-process used to create a HDR effect (light adaptation)
  69439. */
  69440. hdrPostProcess: Nullable<PostProcess>;
  69441. /**
  69442. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69443. */
  69444. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69445. /**
  69446. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69447. */
  69448. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69449. /**
  69450. * Post-process used to merge the final HDR post-process and the real scene color
  69451. */
  69452. hdrFinalPostProcess: Nullable<PostProcess>;
  69453. /**
  69454. * Post-process used to create a lens flare effect
  69455. */
  69456. lensFlarePostProcess: Nullable<PostProcess>;
  69457. /**
  69458. * Post-process that merges the result of the lens flare post-process and the real scene color
  69459. */
  69460. lensFlareComposePostProcess: Nullable<PostProcess>;
  69461. /**
  69462. * Post-process used to create a motion blur effect
  69463. */
  69464. motionBlurPostProcess: Nullable<PostProcess>;
  69465. /**
  69466. * Post-process used to create a depth of field effect
  69467. */
  69468. depthOfFieldPostProcess: Nullable<PostProcess>;
  69469. /**
  69470. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69471. */
  69472. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69473. /**
  69474. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69475. */
  69476. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69477. /**
  69478. * Represents the brightness threshold in order to configure the illuminated surfaces
  69479. */
  69480. brightThreshold: number;
  69481. /**
  69482. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69483. */
  69484. blurWidth: number;
  69485. /**
  69486. * Sets if the blur for highlighted surfaces must be only horizontal
  69487. */
  69488. horizontalBlur: boolean;
  69489. /**
  69490. * Gets the overall exposure used by the pipeline
  69491. */
  69492. get exposure(): number;
  69493. /**
  69494. * Sets the overall exposure used by the pipeline
  69495. */
  69496. set exposure(value: number);
  69497. /**
  69498. * Texture used typically to simulate "dirty" on camera lens
  69499. */
  69500. lensTexture: Nullable<Texture>;
  69501. /**
  69502. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69503. */
  69504. volumetricLightCoefficient: number;
  69505. /**
  69506. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69507. */
  69508. volumetricLightPower: number;
  69509. /**
  69510. * Used the set the blur intensity to smooth the volumetric lights
  69511. */
  69512. volumetricLightBlurScale: number;
  69513. /**
  69514. * Light (spot or directional) used to generate the volumetric lights rays
  69515. * The source light must have a shadow generate so the pipeline can get its
  69516. * depth map
  69517. */
  69518. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69519. /**
  69520. * For eye adaptation, represents the minimum luminance the eye can see
  69521. */
  69522. hdrMinimumLuminance: number;
  69523. /**
  69524. * For eye adaptation, represents the decrease luminance speed
  69525. */
  69526. hdrDecreaseRate: number;
  69527. /**
  69528. * For eye adaptation, represents the increase luminance speed
  69529. */
  69530. hdrIncreaseRate: number;
  69531. /**
  69532. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69533. */
  69534. get hdrAutoExposure(): boolean;
  69535. /**
  69536. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69537. */
  69538. set hdrAutoExposure(value: boolean);
  69539. /**
  69540. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69541. */
  69542. lensColorTexture: Nullable<Texture>;
  69543. /**
  69544. * The overall strengh for the lens flare effect
  69545. */
  69546. lensFlareStrength: number;
  69547. /**
  69548. * Dispersion coefficient for lens flare ghosts
  69549. */
  69550. lensFlareGhostDispersal: number;
  69551. /**
  69552. * Main lens flare halo width
  69553. */
  69554. lensFlareHaloWidth: number;
  69555. /**
  69556. * Based on the lens distortion effect, defines how much the lens flare result
  69557. * is distorted
  69558. */
  69559. lensFlareDistortionStrength: number;
  69560. /**
  69561. * Configures the blur intensity used for for lens flare (halo)
  69562. */
  69563. lensFlareBlurWidth: number;
  69564. /**
  69565. * Lens star texture must be used to simulate rays on the flares and is available
  69566. * in the documentation
  69567. */
  69568. lensStarTexture: Nullable<Texture>;
  69569. /**
  69570. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69571. * flare effect by taking account of the dirt texture
  69572. */
  69573. lensFlareDirtTexture: Nullable<Texture>;
  69574. /**
  69575. * Represents the focal length for the depth of field effect
  69576. */
  69577. depthOfFieldDistance: number;
  69578. /**
  69579. * Represents the blur intensity for the blurred part of the depth of field effect
  69580. */
  69581. depthOfFieldBlurWidth: number;
  69582. /**
  69583. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69584. */
  69585. get motionStrength(): number;
  69586. /**
  69587. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69588. */
  69589. set motionStrength(strength: number);
  69590. /**
  69591. * Gets wether or not the motion blur post-process is object based or screen based.
  69592. */
  69593. get objectBasedMotionBlur(): boolean;
  69594. /**
  69595. * Sets wether or not the motion blur post-process should be object based or screen based
  69596. */
  69597. set objectBasedMotionBlur(value: boolean);
  69598. /**
  69599. * List of animations for the pipeline (IAnimatable implementation)
  69600. */
  69601. animations: Animation[];
  69602. /**
  69603. * Private members
  69604. */
  69605. private _scene;
  69606. private _currentDepthOfFieldSource;
  69607. private _basePostProcess;
  69608. private _fixedExposure;
  69609. private _currentExposure;
  69610. private _hdrAutoExposure;
  69611. private _hdrCurrentLuminance;
  69612. private _motionStrength;
  69613. private _isObjectBasedMotionBlur;
  69614. private _floatTextureType;
  69615. private _camerasToBeAttached;
  69616. private _ratio;
  69617. private _bloomEnabled;
  69618. private _depthOfFieldEnabled;
  69619. private _vlsEnabled;
  69620. private _lensFlareEnabled;
  69621. private _hdrEnabled;
  69622. private _motionBlurEnabled;
  69623. private _fxaaEnabled;
  69624. private _screenSpaceReflectionsEnabled;
  69625. private _motionBlurSamples;
  69626. private _volumetricLightStepsCount;
  69627. private _samples;
  69628. /**
  69629. * @ignore
  69630. * Specifies if the bloom pipeline is enabled
  69631. */
  69632. get BloomEnabled(): boolean;
  69633. set BloomEnabled(enabled: boolean);
  69634. /**
  69635. * @ignore
  69636. * Specifies if the depth of field pipeline is enabed
  69637. */
  69638. get DepthOfFieldEnabled(): boolean;
  69639. set DepthOfFieldEnabled(enabled: boolean);
  69640. /**
  69641. * @ignore
  69642. * Specifies if the lens flare pipeline is enabed
  69643. */
  69644. get LensFlareEnabled(): boolean;
  69645. set LensFlareEnabled(enabled: boolean);
  69646. /**
  69647. * @ignore
  69648. * Specifies if the HDR pipeline is enabled
  69649. */
  69650. get HDREnabled(): boolean;
  69651. set HDREnabled(enabled: boolean);
  69652. /**
  69653. * @ignore
  69654. * Specifies if the volumetric lights scattering effect is enabled
  69655. */
  69656. get VLSEnabled(): boolean;
  69657. set VLSEnabled(enabled: boolean);
  69658. /**
  69659. * @ignore
  69660. * Specifies if the motion blur effect is enabled
  69661. */
  69662. get MotionBlurEnabled(): boolean;
  69663. set MotionBlurEnabled(enabled: boolean);
  69664. /**
  69665. * Specifies if anti-aliasing is enabled
  69666. */
  69667. get fxaaEnabled(): boolean;
  69668. set fxaaEnabled(enabled: boolean);
  69669. /**
  69670. * Specifies if screen space reflections are enabled.
  69671. */
  69672. get screenSpaceReflectionsEnabled(): boolean;
  69673. set screenSpaceReflectionsEnabled(enabled: boolean);
  69674. /**
  69675. * Specifies the number of steps used to calculate the volumetric lights
  69676. * Typically in interval [50, 200]
  69677. */
  69678. get volumetricLightStepsCount(): number;
  69679. set volumetricLightStepsCount(count: number);
  69680. /**
  69681. * Specifies the number of samples used for the motion blur effect
  69682. * Typically in interval [16, 64]
  69683. */
  69684. get motionBlurSamples(): number;
  69685. set motionBlurSamples(samples: number);
  69686. /**
  69687. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69688. */
  69689. get samples(): number;
  69690. set samples(sampleCount: number);
  69691. /**
  69692. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69693. * @constructor
  69694. * @param name The rendering pipeline name
  69695. * @param scene The scene linked to this pipeline
  69696. * @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)
  69697. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69698. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69699. */
  69700. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69701. private _buildPipeline;
  69702. private _createDownSampleX4PostProcess;
  69703. private _createBrightPassPostProcess;
  69704. private _createBlurPostProcesses;
  69705. private _createTextureAdderPostProcess;
  69706. private _createVolumetricLightPostProcess;
  69707. private _createLuminancePostProcesses;
  69708. private _createHdrPostProcess;
  69709. private _createLensFlarePostProcess;
  69710. private _createDepthOfFieldPostProcess;
  69711. private _createMotionBlurPostProcess;
  69712. private _getDepthTexture;
  69713. private _disposePostProcesses;
  69714. /**
  69715. * Dispose of the pipeline and stop all post processes
  69716. */
  69717. dispose(): void;
  69718. /**
  69719. * Serialize the rendering pipeline (Used when exporting)
  69720. * @returns the serialized object
  69721. */
  69722. serialize(): any;
  69723. /**
  69724. * Parse the serialized pipeline
  69725. * @param source Source pipeline.
  69726. * @param scene The scene to load the pipeline to.
  69727. * @param rootUrl The URL of the serialized pipeline.
  69728. * @returns An instantiated pipeline from the serialized object.
  69729. */
  69730. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69731. /**
  69732. * Luminance steps
  69733. */
  69734. static LuminanceSteps: number;
  69735. }
  69736. }
  69737. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69738. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69739. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69740. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69741. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69742. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69743. }
  69744. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69745. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69750. }
  69751. declare module "babylonjs/Shaders/tonemap.fragment" {
  69752. /** @hidden */
  69753. export var tonemapPixelShader: {
  69754. name: string;
  69755. shader: string;
  69756. };
  69757. }
  69758. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69759. import { Camera } from "babylonjs/Cameras/camera";
  69760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69761. import "babylonjs/Shaders/tonemap.fragment";
  69762. import { Engine } from "babylonjs/Engines/engine";
  69763. /** Defines operator used for tonemapping */
  69764. export enum TonemappingOperator {
  69765. /** Hable */
  69766. Hable = 0,
  69767. /** Reinhard */
  69768. Reinhard = 1,
  69769. /** HejiDawson */
  69770. HejiDawson = 2,
  69771. /** Photographic */
  69772. Photographic = 3
  69773. }
  69774. /**
  69775. * Defines a post process to apply tone mapping
  69776. */
  69777. export class TonemapPostProcess extends PostProcess {
  69778. private _operator;
  69779. /** Defines the required exposure adjustement */
  69780. exposureAdjustment: number;
  69781. /**
  69782. * Creates a new TonemapPostProcess
  69783. * @param name defines the name of the postprocess
  69784. * @param _operator defines the operator to use
  69785. * @param exposureAdjustment defines the required exposure adjustement
  69786. * @param camera defines the camera to use (can be null)
  69787. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69788. * @param engine defines the hosting engine (can be ignore if camera is set)
  69789. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69790. */
  69791. constructor(name: string, _operator: TonemappingOperator,
  69792. /** Defines the required exposure adjustement */
  69793. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69794. }
  69795. }
  69796. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69797. /** @hidden */
  69798. export var volumetricLightScatteringPixelShader: {
  69799. name: string;
  69800. shader: string;
  69801. };
  69802. }
  69803. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69804. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69805. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69806. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69807. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69808. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69809. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69810. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69811. /** @hidden */
  69812. export var volumetricLightScatteringPassVertexShader: {
  69813. name: string;
  69814. shader: string;
  69815. };
  69816. }
  69817. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69818. /** @hidden */
  69819. export var volumetricLightScatteringPassPixelShader: {
  69820. name: string;
  69821. shader: string;
  69822. };
  69823. }
  69824. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69825. import { Vector3 } from "babylonjs/Maths/math.vector";
  69826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69827. import { Mesh } from "babylonjs/Meshes/mesh";
  69828. import { Camera } from "babylonjs/Cameras/camera";
  69829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69831. import { Scene } from "babylonjs/scene";
  69832. import "babylonjs/Meshes/Builders/planeBuilder";
  69833. import "babylonjs/Shaders/depth.vertex";
  69834. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69835. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69836. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69837. import { Engine } from "babylonjs/Engines/engine";
  69838. /**
  69839. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69840. */
  69841. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69842. private _volumetricLightScatteringPass;
  69843. private _volumetricLightScatteringRTT;
  69844. private _viewPort;
  69845. private _screenCoordinates;
  69846. private _cachedDefines;
  69847. /**
  69848. * If not undefined, the mesh position is computed from the attached node position
  69849. */
  69850. attachedNode: {
  69851. position: Vector3;
  69852. };
  69853. /**
  69854. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69855. */
  69856. customMeshPosition: Vector3;
  69857. /**
  69858. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69859. */
  69860. useCustomMeshPosition: boolean;
  69861. /**
  69862. * If the post-process should inverse the light scattering direction
  69863. */
  69864. invert: boolean;
  69865. /**
  69866. * The internal mesh used by the post-process
  69867. */
  69868. mesh: Mesh;
  69869. /**
  69870. * @hidden
  69871. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69872. */
  69873. get useDiffuseColor(): boolean;
  69874. set useDiffuseColor(useDiffuseColor: boolean);
  69875. /**
  69876. * Array containing the excluded meshes not rendered in the internal pass
  69877. */
  69878. excludedMeshes: AbstractMesh[];
  69879. /**
  69880. * Controls the overall intensity of the post-process
  69881. */
  69882. exposure: number;
  69883. /**
  69884. * Dissipates each sample's contribution in range [0, 1]
  69885. */
  69886. decay: number;
  69887. /**
  69888. * Controls the overall intensity of each sample
  69889. */
  69890. weight: number;
  69891. /**
  69892. * Controls the density of each sample
  69893. */
  69894. density: number;
  69895. /**
  69896. * @constructor
  69897. * @param name The post-process name
  69898. * @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)
  69899. * @param camera The camera that the post-process will be attached to
  69900. * @param mesh The mesh used to create the light scattering
  69901. * @param samples The post-process quality, default 100
  69902. * @param samplingModeThe post-process filtering mode
  69903. * @param engine The babylon engine
  69904. * @param reusable If the post-process is reusable
  69905. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69906. */
  69907. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69908. /**
  69909. * Returns the string "VolumetricLightScatteringPostProcess"
  69910. * @returns "VolumetricLightScatteringPostProcess"
  69911. */
  69912. getClassName(): string;
  69913. private _isReady;
  69914. /**
  69915. * Sets the new light position for light scattering effect
  69916. * @param position The new custom light position
  69917. */
  69918. setCustomMeshPosition(position: Vector3): void;
  69919. /**
  69920. * Returns the light position for light scattering effect
  69921. * @return Vector3 The custom light position
  69922. */
  69923. getCustomMeshPosition(): Vector3;
  69924. /**
  69925. * Disposes the internal assets and detaches the post-process from the camera
  69926. */
  69927. dispose(camera: Camera): void;
  69928. /**
  69929. * Returns the render target texture used by the post-process
  69930. * @return the render target texture used by the post-process
  69931. */
  69932. getPass(): RenderTargetTexture;
  69933. private _meshExcluded;
  69934. private _createPass;
  69935. private _updateMeshScreenCoordinates;
  69936. /**
  69937. * Creates a default mesh for the Volumeric Light Scattering post-process
  69938. * @param name The mesh name
  69939. * @param scene The scene where to create the mesh
  69940. * @return the default mesh
  69941. */
  69942. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69943. }
  69944. }
  69945. declare module "babylonjs/PostProcesses/index" {
  69946. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69947. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69948. export * from "babylonjs/PostProcesses/bloomEffect";
  69949. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69950. export * from "babylonjs/PostProcesses/blurPostProcess";
  69951. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69952. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69953. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69954. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69955. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69956. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69957. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69958. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69959. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69960. export * from "babylonjs/PostProcesses/filterPostProcess";
  69961. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69962. export * from "babylonjs/PostProcesses/grainPostProcess";
  69963. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69964. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69965. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69966. export * from "babylonjs/PostProcesses/passPostProcess";
  69967. export * from "babylonjs/PostProcesses/postProcess";
  69968. export * from "babylonjs/PostProcesses/postProcessManager";
  69969. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69970. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69971. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69972. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69973. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69974. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69975. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69976. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69977. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69978. }
  69979. declare module "babylonjs/Probes/index" {
  69980. export * from "babylonjs/Probes/reflectionProbe";
  69981. }
  69982. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69983. import { Scene } from "babylonjs/scene";
  69984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69985. import { SmartArray } from "babylonjs/Misc/smartArray";
  69986. import { ISceneComponent } from "babylonjs/sceneComponent";
  69987. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69988. import "babylonjs/Meshes/Builders/boxBuilder";
  69989. import "babylonjs/Shaders/color.fragment";
  69990. import "babylonjs/Shaders/color.vertex";
  69991. import { Color3 } from "babylonjs/Maths/math.color";
  69992. module "babylonjs/scene" {
  69993. interface Scene {
  69994. /** @hidden (Backing field) */
  69995. _boundingBoxRenderer: BoundingBoxRenderer;
  69996. /** @hidden (Backing field) */
  69997. _forceShowBoundingBoxes: boolean;
  69998. /**
  69999. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70000. */
  70001. forceShowBoundingBoxes: boolean;
  70002. /**
  70003. * Gets the bounding box renderer associated with the scene
  70004. * @returns a BoundingBoxRenderer
  70005. */
  70006. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70007. }
  70008. }
  70009. module "babylonjs/Meshes/abstractMesh" {
  70010. interface AbstractMesh {
  70011. /** @hidden (Backing field) */
  70012. _showBoundingBox: boolean;
  70013. /**
  70014. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70015. */
  70016. showBoundingBox: boolean;
  70017. }
  70018. }
  70019. /**
  70020. * Component responsible of rendering the bounding box of the meshes in a scene.
  70021. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70022. */
  70023. export class BoundingBoxRenderer implements ISceneComponent {
  70024. /**
  70025. * The component name helpfull to identify the component in the list of scene components.
  70026. */
  70027. readonly name: string;
  70028. /**
  70029. * The scene the component belongs to.
  70030. */
  70031. scene: Scene;
  70032. /**
  70033. * Color of the bounding box lines placed in front of an object
  70034. */
  70035. frontColor: Color3;
  70036. /**
  70037. * Color of the bounding box lines placed behind an object
  70038. */
  70039. backColor: Color3;
  70040. /**
  70041. * Defines if the renderer should show the back lines or not
  70042. */
  70043. showBackLines: boolean;
  70044. /**
  70045. * @hidden
  70046. */
  70047. renderList: SmartArray<BoundingBox>;
  70048. private _colorShader;
  70049. private _vertexBuffers;
  70050. private _indexBuffer;
  70051. private _fillIndexBuffer;
  70052. private _fillIndexData;
  70053. /**
  70054. * Instantiates a new bounding box renderer in a scene.
  70055. * @param scene the scene the renderer renders in
  70056. */
  70057. constructor(scene: Scene);
  70058. /**
  70059. * Registers the component in a given scene
  70060. */
  70061. register(): void;
  70062. private _evaluateSubMesh;
  70063. private _activeMesh;
  70064. private _prepareRessources;
  70065. private _createIndexBuffer;
  70066. /**
  70067. * Rebuilds the elements related to this component in case of
  70068. * context lost for instance.
  70069. */
  70070. rebuild(): void;
  70071. /**
  70072. * @hidden
  70073. */
  70074. reset(): void;
  70075. /**
  70076. * Render the bounding boxes of a specific rendering group
  70077. * @param renderingGroupId defines the rendering group to render
  70078. */
  70079. render(renderingGroupId: number): void;
  70080. /**
  70081. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70082. * @param mesh Define the mesh to render the occlusion bounding box for
  70083. */
  70084. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70085. /**
  70086. * Dispose and release the resources attached to this renderer.
  70087. */
  70088. dispose(): void;
  70089. }
  70090. }
  70091. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70092. import { Nullable } from "babylonjs/types";
  70093. import { Scene } from "babylonjs/scene";
  70094. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70095. import { Camera } from "babylonjs/Cameras/camera";
  70096. import { ISceneComponent } from "babylonjs/sceneComponent";
  70097. module "babylonjs/scene" {
  70098. interface Scene {
  70099. /** @hidden (Backing field) */
  70100. _depthRenderer: {
  70101. [id: string]: DepthRenderer;
  70102. };
  70103. /**
  70104. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70105. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70106. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70107. * @returns the created depth renderer
  70108. */
  70109. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70110. /**
  70111. * Disables a depth renderer for a given camera
  70112. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70113. */
  70114. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70115. }
  70116. }
  70117. /**
  70118. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70119. * in several rendering techniques.
  70120. */
  70121. export class DepthRendererSceneComponent implements ISceneComponent {
  70122. /**
  70123. * The component name helpfull to identify the component in the list of scene components.
  70124. */
  70125. readonly name: string;
  70126. /**
  70127. * The scene the component belongs to.
  70128. */
  70129. scene: Scene;
  70130. /**
  70131. * Creates a new instance of the component for the given scene
  70132. * @param scene Defines the scene to register the component in
  70133. */
  70134. constructor(scene: Scene);
  70135. /**
  70136. * Registers the component in a given scene
  70137. */
  70138. register(): void;
  70139. /**
  70140. * Rebuilds the elements related to this component in case of
  70141. * context lost for instance.
  70142. */
  70143. rebuild(): void;
  70144. /**
  70145. * Disposes the component and the associated ressources
  70146. */
  70147. dispose(): void;
  70148. private _gatherRenderTargets;
  70149. private _gatherActiveCameraRenderTargets;
  70150. }
  70151. }
  70152. declare module "babylonjs/Shaders/outline.fragment" {
  70153. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70154. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70155. /** @hidden */
  70156. export var outlinePixelShader: {
  70157. name: string;
  70158. shader: string;
  70159. };
  70160. }
  70161. declare module "babylonjs/Shaders/outline.vertex" {
  70162. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70164. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70165. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70166. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70167. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70168. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70169. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70170. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70171. /** @hidden */
  70172. export var outlineVertexShader: {
  70173. name: string;
  70174. shader: string;
  70175. };
  70176. }
  70177. declare module "babylonjs/Rendering/outlineRenderer" {
  70178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70179. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70180. import { Scene } from "babylonjs/scene";
  70181. import { ISceneComponent } from "babylonjs/sceneComponent";
  70182. import "babylonjs/Shaders/outline.fragment";
  70183. import "babylonjs/Shaders/outline.vertex";
  70184. module "babylonjs/scene" {
  70185. interface Scene {
  70186. /** @hidden */
  70187. _outlineRenderer: OutlineRenderer;
  70188. /**
  70189. * Gets the outline renderer associated with the scene
  70190. * @returns a OutlineRenderer
  70191. */
  70192. getOutlineRenderer(): OutlineRenderer;
  70193. }
  70194. }
  70195. module "babylonjs/Meshes/abstractMesh" {
  70196. interface AbstractMesh {
  70197. /** @hidden (Backing field) */
  70198. _renderOutline: boolean;
  70199. /**
  70200. * Gets or sets a boolean indicating if the outline must be rendered as well
  70201. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70202. */
  70203. renderOutline: boolean;
  70204. /** @hidden (Backing field) */
  70205. _renderOverlay: boolean;
  70206. /**
  70207. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70208. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70209. */
  70210. renderOverlay: boolean;
  70211. }
  70212. }
  70213. /**
  70214. * This class is responsible to draw bothe outline/overlay of meshes.
  70215. * It should not be used directly but through the available method on mesh.
  70216. */
  70217. export class OutlineRenderer implements ISceneComponent {
  70218. /**
  70219. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70220. */
  70221. private static _StencilReference;
  70222. /**
  70223. * The name of the component. Each component must have a unique name.
  70224. */
  70225. name: string;
  70226. /**
  70227. * The scene the component belongs to.
  70228. */
  70229. scene: Scene;
  70230. /**
  70231. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70232. */
  70233. zOffset: number;
  70234. private _engine;
  70235. private _effect;
  70236. private _cachedDefines;
  70237. private _savedDepthWrite;
  70238. /**
  70239. * Instantiates a new outline renderer. (There could be only one per scene).
  70240. * @param scene Defines the scene it belongs to
  70241. */
  70242. constructor(scene: Scene);
  70243. /**
  70244. * Register the component to one instance of a scene.
  70245. */
  70246. register(): void;
  70247. /**
  70248. * Rebuilds the elements related to this component in case of
  70249. * context lost for instance.
  70250. */
  70251. rebuild(): void;
  70252. /**
  70253. * Disposes the component and the associated ressources.
  70254. */
  70255. dispose(): void;
  70256. /**
  70257. * Renders the outline in the canvas.
  70258. * @param subMesh Defines the sumesh to render
  70259. * @param batch Defines the batch of meshes in case of instances
  70260. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70261. */
  70262. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70263. /**
  70264. * Returns whether or not the outline renderer is ready for a given submesh.
  70265. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70266. * @param subMesh Defines the submesh to check readyness for
  70267. * @param useInstances Defines wheter wee are trying to render instances or not
  70268. * @returns true if ready otherwise false
  70269. */
  70270. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70271. private _beforeRenderingMesh;
  70272. private _afterRenderingMesh;
  70273. }
  70274. }
  70275. declare module "babylonjs/Rendering/index" {
  70276. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70277. export * from "babylonjs/Rendering/depthRenderer";
  70278. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70279. export * from "babylonjs/Rendering/edgesRenderer";
  70280. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70281. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70282. export * from "babylonjs/Rendering/outlineRenderer";
  70283. export * from "babylonjs/Rendering/renderingGroup";
  70284. export * from "babylonjs/Rendering/renderingManager";
  70285. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70286. }
  70287. declare module "babylonjs/Sprites/ISprites" {
  70288. /**
  70289. * Defines the basic options interface of a Sprite Frame Source Size.
  70290. */
  70291. export interface ISpriteJSONSpriteSourceSize {
  70292. /**
  70293. * number of the original width of the Frame
  70294. */
  70295. w: number;
  70296. /**
  70297. * number of the original height of the Frame
  70298. */
  70299. h: number;
  70300. }
  70301. /**
  70302. * Defines the basic options interface of a Sprite Frame Data.
  70303. */
  70304. export interface ISpriteJSONSpriteFrameData {
  70305. /**
  70306. * number of the x offset of the Frame
  70307. */
  70308. x: number;
  70309. /**
  70310. * number of the y offset of the Frame
  70311. */
  70312. y: number;
  70313. /**
  70314. * number of the width of the Frame
  70315. */
  70316. w: number;
  70317. /**
  70318. * number of the height of the Frame
  70319. */
  70320. h: number;
  70321. }
  70322. /**
  70323. * Defines the basic options interface of a JSON Sprite.
  70324. */
  70325. export interface ISpriteJSONSprite {
  70326. /**
  70327. * string name of the Frame
  70328. */
  70329. filename: string;
  70330. /**
  70331. * ISpriteJSONSpriteFrame basic object of the frame data
  70332. */
  70333. frame: ISpriteJSONSpriteFrameData;
  70334. /**
  70335. * boolean to flag is the frame was rotated.
  70336. */
  70337. rotated: boolean;
  70338. /**
  70339. * boolean to flag is the frame was trimmed.
  70340. */
  70341. trimmed: boolean;
  70342. /**
  70343. * ISpriteJSONSpriteFrame basic object of the source data
  70344. */
  70345. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70346. /**
  70347. * ISpriteJSONSpriteFrame basic object of the source data
  70348. */
  70349. sourceSize: ISpriteJSONSpriteSourceSize;
  70350. }
  70351. /**
  70352. * Defines the basic options interface of a JSON atlas.
  70353. */
  70354. export interface ISpriteJSONAtlas {
  70355. /**
  70356. * Array of objects that contain the frame data.
  70357. */
  70358. frames: Array<ISpriteJSONSprite>;
  70359. /**
  70360. * object basic object containing the sprite meta data.
  70361. */
  70362. meta?: object;
  70363. }
  70364. }
  70365. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70366. /** @hidden */
  70367. export var spriteMapPixelShader: {
  70368. name: string;
  70369. shader: string;
  70370. };
  70371. }
  70372. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70373. /** @hidden */
  70374. export var spriteMapVertexShader: {
  70375. name: string;
  70376. shader: string;
  70377. };
  70378. }
  70379. declare module "babylonjs/Sprites/spriteMap" {
  70380. import { IDisposable, Scene } from "babylonjs/scene";
  70381. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70382. import { Texture } from "babylonjs/Materials/Textures/texture";
  70383. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70384. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70385. import "babylonjs/Meshes/Builders/planeBuilder";
  70386. import "babylonjs/Shaders/spriteMap.fragment";
  70387. import "babylonjs/Shaders/spriteMap.vertex";
  70388. /**
  70389. * Defines the basic options interface of a SpriteMap
  70390. */
  70391. export interface ISpriteMapOptions {
  70392. /**
  70393. * Vector2 of the number of cells in the grid.
  70394. */
  70395. stageSize?: Vector2;
  70396. /**
  70397. * Vector2 of the size of the output plane in World Units.
  70398. */
  70399. outputSize?: Vector2;
  70400. /**
  70401. * Vector3 of the position of the output plane in World Units.
  70402. */
  70403. outputPosition?: Vector3;
  70404. /**
  70405. * Vector3 of the rotation of the output plane.
  70406. */
  70407. outputRotation?: Vector3;
  70408. /**
  70409. * number of layers that the system will reserve in resources.
  70410. */
  70411. layerCount?: number;
  70412. /**
  70413. * number of max animation frames a single cell will reserve in resources.
  70414. */
  70415. maxAnimationFrames?: number;
  70416. /**
  70417. * number cell index of the base tile when the system compiles.
  70418. */
  70419. baseTile?: number;
  70420. /**
  70421. * boolean flip the sprite after its been repositioned by the framing data.
  70422. */
  70423. flipU?: boolean;
  70424. /**
  70425. * Vector3 scalar of the global RGB values of the SpriteMap.
  70426. */
  70427. colorMultiply?: Vector3;
  70428. }
  70429. /**
  70430. * Defines the IDisposable interface in order to be cleanable from resources.
  70431. */
  70432. export interface ISpriteMap extends IDisposable {
  70433. /**
  70434. * String name of the SpriteMap.
  70435. */
  70436. name: string;
  70437. /**
  70438. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70439. */
  70440. atlasJSON: ISpriteJSONAtlas;
  70441. /**
  70442. * Texture of the SpriteMap.
  70443. */
  70444. spriteSheet: Texture;
  70445. /**
  70446. * The parameters to initialize the SpriteMap with.
  70447. */
  70448. options: ISpriteMapOptions;
  70449. }
  70450. /**
  70451. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70452. */
  70453. export class SpriteMap implements ISpriteMap {
  70454. /** The Name of the spriteMap */
  70455. name: string;
  70456. /** The JSON file with the frame and meta data */
  70457. atlasJSON: ISpriteJSONAtlas;
  70458. /** The systems Sprite Sheet Texture */
  70459. spriteSheet: Texture;
  70460. /** Arguments passed with the Constructor */
  70461. options: ISpriteMapOptions;
  70462. /** Public Sprite Storage array, parsed from atlasJSON */
  70463. sprites: Array<ISpriteJSONSprite>;
  70464. /** Returns the Number of Sprites in the System */
  70465. get spriteCount(): number;
  70466. /** Returns the Position of Output Plane*/
  70467. get position(): Vector3;
  70468. /** Returns the Position of Output Plane*/
  70469. set position(v: Vector3);
  70470. /** Returns the Rotation of Output Plane*/
  70471. get rotation(): Vector3;
  70472. /** Returns the Rotation of Output Plane*/
  70473. set rotation(v: Vector3);
  70474. /** Sets the AnimationMap*/
  70475. get animationMap(): RawTexture;
  70476. /** Sets the AnimationMap*/
  70477. set animationMap(v: RawTexture);
  70478. /** Scene that the SpriteMap was created in */
  70479. private _scene;
  70480. /** Texture Buffer of Float32 that holds tile frame data*/
  70481. private _frameMap;
  70482. /** Texture Buffers of Float32 that holds tileMap data*/
  70483. private _tileMaps;
  70484. /** Texture Buffer of Float32 that holds Animation Data*/
  70485. private _animationMap;
  70486. /** Custom ShaderMaterial Central to the System*/
  70487. private _material;
  70488. /** Custom ShaderMaterial Central to the System*/
  70489. private _output;
  70490. /** Systems Time Ticker*/
  70491. private _time;
  70492. /**
  70493. * Creates a new SpriteMap
  70494. * @param name defines the SpriteMaps Name
  70495. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70496. * @param spriteSheet is the Texture that the Sprites are on.
  70497. * @param options a basic deployment configuration
  70498. * @param scene The Scene that the map is deployed on
  70499. */
  70500. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70501. /**
  70502. * Returns tileID location
  70503. * @returns Vector2 the cell position ID
  70504. */
  70505. getTileID(): Vector2;
  70506. /**
  70507. * Gets the UV location of the mouse over the SpriteMap.
  70508. * @returns Vector2 the UV position of the mouse interaction
  70509. */
  70510. getMousePosition(): Vector2;
  70511. /**
  70512. * Creates the "frame" texture Buffer
  70513. * -------------------------------------
  70514. * Structure of frames
  70515. * "filename": "Falling-Water-2.png",
  70516. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70517. * "rotated": true,
  70518. * "trimmed": true,
  70519. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70520. * "sourceSize": {"w":32,"h":32}
  70521. * @returns RawTexture of the frameMap
  70522. */
  70523. private _createFrameBuffer;
  70524. /**
  70525. * Creates the tileMap texture Buffer
  70526. * @param buffer normally and array of numbers, or a false to generate from scratch
  70527. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70528. * @returns RawTexture of the tileMap
  70529. */
  70530. private _createTileBuffer;
  70531. /**
  70532. * Modifies the data of the tileMaps
  70533. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70534. * @param pos is the iVector2 Coordinates of the Tile
  70535. * @param tile The SpriteIndex of the new Tile
  70536. */
  70537. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70538. /**
  70539. * Creates the animationMap texture Buffer
  70540. * @param buffer normally and array of numbers, or a false to generate from scratch
  70541. * @returns RawTexture of the animationMap
  70542. */
  70543. private _createTileAnimationBuffer;
  70544. /**
  70545. * Modifies the data of the animationMap
  70546. * @param cellID is the Index of the Sprite
  70547. * @param _frame is the target Animation frame
  70548. * @param toCell is the Target Index of the next frame of the animation
  70549. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70550. * @param speed is a global scalar of the time variable on the map.
  70551. */
  70552. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70553. /**
  70554. * Exports the .tilemaps file
  70555. */
  70556. saveTileMaps(): void;
  70557. /**
  70558. * Imports the .tilemaps file
  70559. * @param url of the .tilemaps file
  70560. */
  70561. loadTileMaps(url: string): void;
  70562. /**
  70563. * Release associated resources
  70564. */
  70565. dispose(): void;
  70566. }
  70567. }
  70568. declare module "babylonjs/Sprites/spritePackedManager" {
  70569. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70570. import { Scene } from "babylonjs/scene";
  70571. /**
  70572. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70573. * @see http://doc.babylonjs.com/babylon101/sprites
  70574. */
  70575. export class SpritePackedManager extends SpriteManager {
  70576. /** defines the packed manager's name */
  70577. name: string;
  70578. /**
  70579. * Creates a new sprite manager from a packed sprite sheet
  70580. * @param name defines the manager's name
  70581. * @param imgUrl defines the sprite sheet url
  70582. * @param capacity defines the maximum allowed number of sprites
  70583. * @param scene defines the hosting scene
  70584. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70585. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70586. * @param samplingMode defines the smapling mode to use with spritesheet
  70587. * @param fromPacked set to true; do not alter
  70588. */
  70589. constructor(
  70590. /** defines the packed manager's name */
  70591. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70592. }
  70593. }
  70594. declare module "babylonjs/Sprites/index" {
  70595. export * from "babylonjs/Sprites/sprite";
  70596. export * from "babylonjs/Sprites/ISprites";
  70597. export * from "babylonjs/Sprites/spriteManager";
  70598. export * from "babylonjs/Sprites/spriteMap";
  70599. export * from "babylonjs/Sprites/spritePackedManager";
  70600. export * from "babylonjs/Sprites/spriteSceneComponent";
  70601. }
  70602. declare module "babylonjs/States/index" {
  70603. export * from "babylonjs/States/alphaCullingState";
  70604. export * from "babylonjs/States/depthCullingState";
  70605. export * from "babylonjs/States/stencilState";
  70606. }
  70607. declare module "babylonjs/Misc/assetsManager" {
  70608. import { Scene } from "babylonjs/scene";
  70609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70610. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70611. import { Skeleton } from "babylonjs/Bones/skeleton";
  70612. import { Observable } from "babylonjs/Misc/observable";
  70613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70614. import { Texture } from "babylonjs/Materials/Textures/texture";
  70615. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70616. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70617. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70618. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70619. /**
  70620. * Defines the list of states available for a task inside a AssetsManager
  70621. */
  70622. export enum AssetTaskState {
  70623. /**
  70624. * Initialization
  70625. */
  70626. INIT = 0,
  70627. /**
  70628. * Running
  70629. */
  70630. RUNNING = 1,
  70631. /**
  70632. * Done
  70633. */
  70634. DONE = 2,
  70635. /**
  70636. * Error
  70637. */
  70638. ERROR = 3
  70639. }
  70640. /**
  70641. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70642. */
  70643. export abstract class AbstractAssetTask {
  70644. /**
  70645. * Task name
  70646. */ name: string;
  70647. /**
  70648. * Callback called when the task is successful
  70649. */
  70650. onSuccess: (task: any) => void;
  70651. /**
  70652. * Callback called when the task is not successful
  70653. */
  70654. onError: (task: any, message?: string, exception?: any) => void;
  70655. /**
  70656. * Creates a new AssetsManager
  70657. * @param name defines the name of the task
  70658. */
  70659. constructor(
  70660. /**
  70661. * Task name
  70662. */ name: string);
  70663. private _isCompleted;
  70664. private _taskState;
  70665. private _errorObject;
  70666. /**
  70667. * Get if the task is completed
  70668. */
  70669. get isCompleted(): boolean;
  70670. /**
  70671. * Gets the current state of the task
  70672. */
  70673. get taskState(): AssetTaskState;
  70674. /**
  70675. * Gets the current error object (if task is in error)
  70676. */
  70677. get errorObject(): {
  70678. message?: string;
  70679. exception?: any;
  70680. };
  70681. /**
  70682. * Internal only
  70683. * @hidden
  70684. */
  70685. _setErrorObject(message?: string, exception?: any): void;
  70686. /**
  70687. * Execute the current task
  70688. * @param scene defines the scene where you want your assets to be loaded
  70689. * @param onSuccess is a callback called when the task is successfully executed
  70690. * @param onError is a callback called if an error occurs
  70691. */
  70692. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70693. /**
  70694. * Execute the current task
  70695. * @param scene defines the scene where you want your assets to be loaded
  70696. * @param onSuccess is a callback called when the task is successfully executed
  70697. * @param onError is a callback called if an error occurs
  70698. */
  70699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70700. /**
  70701. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70702. * This can be used with failed tasks that have the reason for failure fixed.
  70703. */
  70704. reset(): void;
  70705. private onErrorCallback;
  70706. private onDoneCallback;
  70707. }
  70708. /**
  70709. * Define the interface used by progress events raised during assets loading
  70710. */
  70711. export interface IAssetsProgressEvent {
  70712. /**
  70713. * Defines the number of remaining tasks to process
  70714. */
  70715. remainingCount: number;
  70716. /**
  70717. * Defines the total number of tasks
  70718. */
  70719. totalCount: number;
  70720. /**
  70721. * Defines the task that was just processed
  70722. */
  70723. task: AbstractAssetTask;
  70724. }
  70725. /**
  70726. * Class used to share progress information about assets loading
  70727. */
  70728. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70729. /**
  70730. * Defines the number of remaining tasks to process
  70731. */
  70732. remainingCount: number;
  70733. /**
  70734. * Defines the total number of tasks
  70735. */
  70736. totalCount: number;
  70737. /**
  70738. * Defines the task that was just processed
  70739. */
  70740. task: AbstractAssetTask;
  70741. /**
  70742. * Creates a AssetsProgressEvent
  70743. * @param remainingCount defines the number of remaining tasks to process
  70744. * @param totalCount defines the total number of tasks
  70745. * @param task defines the task that was just processed
  70746. */
  70747. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70748. }
  70749. /**
  70750. * Define a task used by AssetsManager to load meshes
  70751. */
  70752. export class MeshAssetTask extends AbstractAssetTask {
  70753. /**
  70754. * Defines the name of the task
  70755. */
  70756. name: string;
  70757. /**
  70758. * Defines the list of mesh's names you want to load
  70759. */
  70760. meshesNames: any;
  70761. /**
  70762. * Defines the root url to use as a base to load your meshes and associated resources
  70763. */
  70764. rootUrl: string;
  70765. /**
  70766. * Defines the filename of the scene to load from
  70767. */
  70768. sceneFilename: string;
  70769. /**
  70770. * Gets the list of loaded meshes
  70771. */
  70772. loadedMeshes: Array<AbstractMesh>;
  70773. /**
  70774. * Gets the list of loaded particle systems
  70775. */
  70776. loadedParticleSystems: Array<IParticleSystem>;
  70777. /**
  70778. * Gets the list of loaded skeletons
  70779. */
  70780. loadedSkeletons: Array<Skeleton>;
  70781. /**
  70782. * Gets the list of loaded animation groups
  70783. */
  70784. loadedAnimationGroups: Array<AnimationGroup>;
  70785. /**
  70786. * Callback called when the task is successful
  70787. */
  70788. onSuccess: (task: MeshAssetTask) => void;
  70789. /**
  70790. * Callback called when the task is successful
  70791. */
  70792. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70793. /**
  70794. * Creates a new MeshAssetTask
  70795. * @param name defines the name of the task
  70796. * @param meshesNames defines the list of mesh's names you want to load
  70797. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70798. * @param sceneFilename defines the filename of the scene to load from
  70799. */
  70800. constructor(
  70801. /**
  70802. * Defines the name of the task
  70803. */
  70804. name: string,
  70805. /**
  70806. * Defines the list of mesh's names you want to load
  70807. */
  70808. meshesNames: any,
  70809. /**
  70810. * Defines the root url to use as a base to load your meshes and associated resources
  70811. */
  70812. rootUrl: string,
  70813. /**
  70814. * Defines the filename of the scene to load from
  70815. */
  70816. sceneFilename: string);
  70817. /**
  70818. * Execute the current task
  70819. * @param scene defines the scene where you want your assets to be loaded
  70820. * @param onSuccess is a callback called when the task is successfully executed
  70821. * @param onError is a callback called if an error occurs
  70822. */
  70823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70824. }
  70825. /**
  70826. * Define a task used by AssetsManager to load text content
  70827. */
  70828. export class TextFileAssetTask extends AbstractAssetTask {
  70829. /**
  70830. * Defines the name of the task
  70831. */
  70832. name: string;
  70833. /**
  70834. * Defines the location of the file to load
  70835. */
  70836. url: string;
  70837. /**
  70838. * Gets the loaded text string
  70839. */
  70840. text: string;
  70841. /**
  70842. * Callback called when the task is successful
  70843. */
  70844. onSuccess: (task: TextFileAssetTask) => void;
  70845. /**
  70846. * Callback called when the task is successful
  70847. */
  70848. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70849. /**
  70850. * Creates a new TextFileAssetTask object
  70851. * @param name defines the name of the task
  70852. * @param url defines the location of the file to load
  70853. */
  70854. constructor(
  70855. /**
  70856. * Defines the name of the task
  70857. */
  70858. name: string,
  70859. /**
  70860. * Defines the location of the file to load
  70861. */
  70862. url: string);
  70863. /**
  70864. * Execute the current task
  70865. * @param scene defines the scene where you want your assets to be loaded
  70866. * @param onSuccess is a callback called when the task is successfully executed
  70867. * @param onError is a callback called if an error occurs
  70868. */
  70869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70870. }
  70871. /**
  70872. * Define a task used by AssetsManager to load binary data
  70873. */
  70874. export class BinaryFileAssetTask extends AbstractAssetTask {
  70875. /**
  70876. * Defines the name of the task
  70877. */
  70878. name: string;
  70879. /**
  70880. * Defines the location of the file to load
  70881. */
  70882. url: string;
  70883. /**
  70884. * Gets the lodaded data (as an array buffer)
  70885. */
  70886. data: ArrayBuffer;
  70887. /**
  70888. * Callback called when the task is successful
  70889. */
  70890. onSuccess: (task: BinaryFileAssetTask) => void;
  70891. /**
  70892. * Callback called when the task is successful
  70893. */
  70894. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70895. /**
  70896. * Creates a new BinaryFileAssetTask object
  70897. * @param name defines the name of the new task
  70898. * @param url defines the location of the file to load
  70899. */
  70900. constructor(
  70901. /**
  70902. * Defines the name of the task
  70903. */
  70904. name: string,
  70905. /**
  70906. * Defines the location of the file to load
  70907. */
  70908. url: string);
  70909. /**
  70910. * Execute the current task
  70911. * @param scene defines the scene where you want your assets to be loaded
  70912. * @param onSuccess is a callback called when the task is successfully executed
  70913. * @param onError is a callback called if an error occurs
  70914. */
  70915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70916. }
  70917. /**
  70918. * Define a task used by AssetsManager to load images
  70919. */
  70920. export class ImageAssetTask extends AbstractAssetTask {
  70921. /**
  70922. * Defines the name of the task
  70923. */
  70924. name: string;
  70925. /**
  70926. * Defines the location of the image to load
  70927. */
  70928. url: string;
  70929. /**
  70930. * Gets the loaded images
  70931. */
  70932. image: HTMLImageElement;
  70933. /**
  70934. * Callback called when the task is successful
  70935. */
  70936. onSuccess: (task: ImageAssetTask) => void;
  70937. /**
  70938. * Callback called when the task is successful
  70939. */
  70940. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70941. /**
  70942. * Creates a new ImageAssetTask
  70943. * @param name defines the name of the task
  70944. * @param url defines the location of the image to load
  70945. */
  70946. constructor(
  70947. /**
  70948. * Defines the name of the task
  70949. */
  70950. name: string,
  70951. /**
  70952. * Defines the location of the image to load
  70953. */
  70954. url: string);
  70955. /**
  70956. * Execute the current task
  70957. * @param scene defines the scene where you want your assets to be loaded
  70958. * @param onSuccess is a callback called when the task is successfully executed
  70959. * @param onError is a callback called if an error occurs
  70960. */
  70961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70962. }
  70963. /**
  70964. * Defines the interface used by texture loading tasks
  70965. */
  70966. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70967. /**
  70968. * Gets the loaded texture
  70969. */
  70970. texture: TEX;
  70971. }
  70972. /**
  70973. * Define a task used by AssetsManager to load 2D textures
  70974. */
  70975. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70976. /**
  70977. * Defines the name of the task
  70978. */
  70979. name: string;
  70980. /**
  70981. * Defines the location of the file to load
  70982. */
  70983. url: string;
  70984. /**
  70985. * Defines if mipmap should not be generated (default is false)
  70986. */
  70987. noMipmap?: boolean | undefined;
  70988. /**
  70989. * Defines if texture must be inverted on Y axis (default is false)
  70990. */
  70991. invertY?: boolean | undefined;
  70992. /**
  70993. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70994. */
  70995. samplingMode: number;
  70996. /**
  70997. * Gets the loaded texture
  70998. */
  70999. texture: Texture;
  71000. /**
  71001. * Callback called when the task is successful
  71002. */
  71003. onSuccess: (task: TextureAssetTask) => void;
  71004. /**
  71005. * Callback called when the task is successful
  71006. */
  71007. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71008. /**
  71009. * Creates a new TextureAssetTask object
  71010. * @param name defines the name of the task
  71011. * @param url defines the location of the file to load
  71012. * @param noMipmap defines if mipmap should not be generated (default is false)
  71013. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71014. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71015. */
  71016. constructor(
  71017. /**
  71018. * Defines the name of the task
  71019. */
  71020. name: string,
  71021. /**
  71022. * Defines the location of the file to load
  71023. */
  71024. url: string,
  71025. /**
  71026. * Defines if mipmap should not be generated (default is false)
  71027. */
  71028. noMipmap?: boolean | undefined,
  71029. /**
  71030. * Defines if texture must be inverted on Y axis (default is false)
  71031. */
  71032. invertY?: boolean | undefined,
  71033. /**
  71034. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71035. */
  71036. samplingMode?: number);
  71037. /**
  71038. * Execute the current task
  71039. * @param scene defines the scene where you want your assets to be loaded
  71040. * @param onSuccess is a callback called when the task is successfully executed
  71041. * @param onError is a callback called if an error occurs
  71042. */
  71043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71044. }
  71045. /**
  71046. * Define a task used by AssetsManager to load cube textures
  71047. */
  71048. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71049. /**
  71050. * Defines the name of the task
  71051. */
  71052. name: string;
  71053. /**
  71054. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71055. */
  71056. url: string;
  71057. /**
  71058. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71059. */
  71060. extensions?: string[] | undefined;
  71061. /**
  71062. * Defines if mipmaps should not be generated (default is false)
  71063. */
  71064. noMipmap?: boolean | undefined;
  71065. /**
  71066. * Defines the explicit list of files (undefined by default)
  71067. */
  71068. files?: string[] | undefined;
  71069. /**
  71070. * Gets the loaded texture
  71071. */
  71072. texture: CubeTexture;
  71073. /**
  71074. * Callback called when the task is successful
  71075. */
  71076. onSuccess: (task: CubeTextureAssetTask) => void;
  71077. /**
  71078. * Callback called when the task is successful
  71079. */
  71080. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71081. /**
  71082. * Creates a new CubeTextureAssetTask
  71083. * @param name defines the name of the task
  71084. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71085. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71086. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71087. * @param files defines the explicit list of files (undefined by default)
  71088. */
  71089. constructor(
  71090. /**
  71091. * Defines the name of the task
  71092. */
  71093. name: string,
  71094. /**
  71095. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71096. */
  71097. url: string,
  71098. /**
  71099. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71100. */
  71101. extensions?: string[] | undefined,
  71102. /**
  71103. * Defines if mipmaps should not be generated (default is false)
  71104. */
  71105. noMipmap?: boolean | undefined,
  71106. /**
  71107. * Defines the explicit list of files (undefined by default)
  71108. */
  71109. files?: string[] | undefined);
  71110. /**
  71111. * Execute the current task
  71112. * @param scene defines the scene where you want your assets to be loaded
  71113. * @param onSuccess is a callback called when the task is successfully executed
  71114. * @param onError is a callback called if an error occurs
  71115. */
  71116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71117. }
  71118. /**
  71119. * Define a task used by AssetsManager to load HDR cube textures
  71120. */
  71121. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71122. /**
  71123. * Defines the name of the task
  71124. */
  71125. name: string;
  71126. /**
  71127. * Defines the location of the file to load
  71128. */
  71129. url: string;
  71130. /**
  71131. * Defines the desired size (the more it increases the longer the generation will be)
  71132. */
  71133. size: number;
  71134. /**
  71135. * Defines if mipmaps should not be generated (default is false)
  71136. */
  71137. noMipmap: boolean;
  71138. /**
  71139. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71140. */
  71141. generateHarmonics: boolean;
  71142. /**
  71143. * 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)
  71144. */
  71145. gammaSpace: boolean;
  71146. /**
  71147. * Internal Use Only
  71148. */
  71149. reserved: boolean;
  71150. /**
  71151. * Gets the loaded texture
  71152. */
  71153. texture: HDRCubeTexture;
  71154. /**
  71155. * Callback called when the task is successful
  71156. */
  71157. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71158. /**
  71159. * Callback called when the task is successful
  71160. */
  71161. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71162. /**
  71163. * Creates a new HDRCubeTextureAssetTask object
  71164. * @param name defines the name of the task
  71165. * @param url defines the location of the file to load
  71166. * @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.
  71167. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71168. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71169. * @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)
  71170. * @param reserved Internal use only
  71171. */
  71172. constructor(
  71173. /**
  71174. * Defines the name of the task
  71175. */
  71176. name: string,
  71177. /**
  71178. * Defines the location of the file to load
  71179. */
  71180. url: string,
  71181. /**
  71182. * Defines the desired size (the more it increases the longer the generation will be)
  71183. */
  71184. size: number,
  71185. /**
  71186. * Defines if mipmaps should not be generated (default is false)
  71187. */
  71188. noMipmap?: boolean,
  71189. /**
  71190. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71191. */
  71192. generateHarmonics?: boolean,
  71193. /**
  71194. * 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)
  71195. */
  71196. gammaSpace?: boolean,
  71197. /**
  71198. * Internal Use Only
  71199. */
  71200. reserved?: boolean);
  71201. /**
  71202. * Execute the current task
  71203. * @param scene defines the scene where you want your assets to be loaded
  71204. * @param onSuccess is a callback called when the task is successfully executed
  71205. * @param onError is a callback called if an error occurs
  71206. */
  71207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71208. }
  71209. /**
  71210. * Define a task used by AssetsManager to load Equirectangular cube textures
  71211. */
  71212. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71213. /**
  71214. * Defines the name of the task
  71215. */
  71216. name: string;
  71217. /**
  71218. * Defines the location of the file to load
  71219. */
  71220. url: string;
  71221. /**
  71222. * Defines the desired size (the more it increases the longer the generation will be)
  71223. */
  71224. size: number;
  71225. /**
  71226. * Defines if mipmaps should not be generated (default is false)
  71227. */
  71228. noMipmap: boolean;
  71229. /**
  71230. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71231. * but the standard material would require them in Gamma space) (default is true)
  71232. */
  71233. gammaSpace: boolean;
  71234. /**
  71235. * Gets the loaded texture
  71236. */
  71237. texture: EquiRectangularCubeTexture;
  71238. /**
  71239. * Callback called when the task is successful
  71240. */
  71241. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71242. /**
  71243. * Callback called when the task is successful
  71244. */
  71245. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71246. /**
  71247. * Creates a new EquiRectangularCubeTextureAssetTask object
  71248. * @param name defines the name of the task
  71249. * @param url defines the location of the file to load
  71250. * @param size defines the desired size (the more it increases the longer the generation will be)
  71251. * If the size is omitted this implies you are using a preprocessed cubemap.
  71252. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71253. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71254. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71255. * (default is true)
  71256. */
  71257. constructor(
  71258. /**
  71259. * Defines the name of the task
  71260. */
  71261. name: string,
  71262. /**
  71263. * Defines the location of the file to load
  71264. */
  71265. url: string,
  71266. /**
  71267. * Defines the desired size (the more it increases the longer the generation will be)
  71268. */
  71269. size: number,
  71270. /**
  71271. * Defines if mipmaps should not be generated (default is false)
  71272. */
  71273. noMipmap?: boolean,
  71274. /**
  71275. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71276. * but the standard material would require them in Gamma space) (default is true)
  71277. */
  71278. gammaSpace?: boolean);
  71279. /**
  71280. * Execute the current task
  71281. * @param scene defines the scene where you want your assets to be loaded
  71282. * @param onSuccess is a callback called when the task is successfully executed
  71283. * @param onError is a callback called if an error occurs
  71284. */
  71285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71286. }
  71287. /**
  71288. * This class can be used to easily import assets into a scene
  71289. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71290. */
  71291. export class AssetsManager {
  71292. private _scene;
  71293. private _isLoading;
  71294. protected _tasks: AbstractAssetTask[];
  71295. protected _waitingTasksCount: number;
  71296. protected _totalTasksCount: number;
  71297. /**
  71298. * Callback called when all tasks are processed
  71299. */
  71300. onFinish: (tasks: AbstractAssetTask[]) => void;
  71301. /**
  71302. * Callback called when a task is successful
  71303. */
  71304. onTaskSuccess: (task: AbstractAssetTask) => void;
  71305. /**
  71306. * Callback called when a task had an error
  71307. */
  71308. onTaskError: (task: AbstractAssetTask) => void;
  71309. /**
  71310. * Callback called when a task is done (whatever the result is)
  71311. */
  71312. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71313. /**
  71314. * Observable called when all tasks are processed
  71315. */
  71316. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71317. /**
  71318. * Observable called when a task had an error
  71319. */
  71320. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71321. /**
  71322. * Observable called when all tasks were executed
  71323. */
  71324. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71325. /**
  71326. * Observable called when a task is done (whatever the result is)
  71327. */
  71328. onProgressObservable: Observable<IAssetsProgressEvent>;
  71329. /**
  71330. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71331. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71332. */
  71333. useDefaultLoadingScreen: boolean;
  71334. /**
  71335. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71336. * when all assets have been downloaded.
  71337. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71338. */
  71339. autoHideLoadingUI: boolean;
  71340. /**
  71341. * Creates a new AssetsManager
  71342. * @param scene defines the scene to work on
  71343. */
  71344. constructor(scene: Scene);
  71345. /**
  71346. * Add a MeshAssetTask to the list of active tasks
  71347. * @param taskName defines the name of the new task
  71348. * @param meshesNames defines the name of meshes to load
  71349. * @param rootUrl defines the root url to use to locate files
  71350. * @param sceneFilename defines the filename of the scene file
  71351. * @returns a new MeshAssetTask object
  71352. */
  71353. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71354. /**
  71355. * Add a TextFileAssetTask to the list of active tasks
  71356. * @param taskName defines the name of the new task
  71357. * @param url defines the url of the file to load
  71358. * @returns a new TextFileAssetTask object
  71359. */
  71360. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71361. /**
  71362. * Add a BinaryFileAssetTask to the list of active tasks
  71363. * @param taskName defines the name of the new task
  71364. * @param url defines the url of the file to load
  71365. * @returns a new BinaryFileAssetTask object
  71366. */
  71367. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71368. /**
  71369. * Add a ImageAssetTask to the list of active tasks
  71370. * @param taskName defines the name of the new task
  71371. * @param url defines the url of the file to load
  71372. * @returns a new ImageAssetTask object
  71373. */
  71374. addImageTask(taskName: string, url: string): ImageAssetTask;
  71375. /**
  71376. * Add a TextureAssetTask to the list of active tasks
  71377. * @param taskName defines the name of the new task
  71378. * @param url defines the url of the file to load
  71379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71380. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71382. * @returns a new TextureAssetTask object
  71383. */
  71384. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71385. /**
  71386. * Add a CubeTextureAssetTask to the list of active tasks
  71387. * @param taskName defines the name of the new task
  71388. * @param url defines the url of the file to load
  71389. * @param extensions defines the extension to use to load the cube map (can be null)
  71390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71391. * @param files defines the list of files to load (can be null)
  71392. * @returns a new CubeTextureAssetTask object
  71393. */
  71394. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71395. /**
  71396. *
  71397. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71398. * @param taskName defines the name of the new task
  71399. * @param url defines the url of the file to load
  71400. * @param size defines the size you want for the cubemap (can be null)
  71401. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71402. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71403. * @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)
  71404. * @param reserved Internal use only
  71405. * @returns a new HDRCubeTextureAssetTask object
  71406. */
  71407. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71408. /**
  71409. *
  71410. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71411. * @param taskName defines the name of the new task
  71412. * @param url defines the url of the file to load
  71413. * @param size defines the size you want for the cubemap (can be null)
  71414. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71415. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71416. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71417. * @returns a new EquiRectangularCubeTextureAssetTask object
  71418. */
  71419. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71420. /**
  71421. * Remove a task from the assets manager.
  71422. * @param task the task to remove
  71423. */
  71424. removeTask(task: AbstractAssetTask): void;
  71425. private _decreaseWaitingTasksCount;
  71426. private _runTask;
  71427. /**
  71428. * Reset the AssetsManager and remove all tasks
  71429. * @return the current instance of the AssetsManager
  71430. */
  71431. reset(): AssetsManager;
  71432. /**
  71433. * Start the loading process
  71434. * @return the current instance of the AssetsManager
  71435. */
  71436. load(): AssetsManager;
  71437. /**
  71438. * Start the loading process as an async operation
  71439. * @return a promise returning the list of failed tasks
  71440. */
  71441. loadAsync(): Promise<void>;
  71442. }
  71443. }
  71444. declare module "babylonjs/Misc/deferred" {
  71445. /**
  71446. * Wrapper class for promise with external resolve and reject.
  71447. */
  71448. export class Deferred<T> {
  71449. /**
  71450. * The promise associated with this deferred object.
  71451. */
  71452. readonly promise: Promise<T>;
  71453. private _resolve;
  71454. private _reject;
  71455. /**
  71456. * The resolve method of the promise associated with this deferred object.
  71457. */
  71458. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71459. /**
  71460. * The reject method of the promise associated with this deferred object.
  71461. */
  71462. get reject(): (reason?: any) => void;
  71463. /**
  71464. * Constructor for this deferred object.
  71465. */
  71466. constructor();
  71467. }
  71468. }
  71469. declare module "babylonjs/Misc/meshExploder" {
  71470. import { Mesh } from "babylonjs/Meshes/mesh";
  71471. /**
  71472. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71473. */
  71474. export class MeshExploder {
  71475. private _centerMesh;
  71476. private _meshes;
  71477. private _meshesOrigins;
  71478. private _toCenterVectors;
  71479. private _scaledDirection;
  71480. private _newPosition;
  71481. private _centerPosition;
  71482. /**
  71483. * Explodes meshes from a center mesh.
  71484. * @param meshes The meshes to explode.
  71485. * @param centerMesh The mesh to be center of explosion.
  71486. */
  71487. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71488. private _setCenterMesh;
  71489. /**
  71490. * Get class name
  71491. * @returns "MeshExploder"
  71492. */
  71493. getClassName(): string;
  71494. /**
  71495. * "Exploded meshes"
  71496. * @returns Array of meshes with the centerMesh at index 0.
  71497. */
  71498. getMeshes(): Array<Mesh>;
  71499. /**
  71500. * Explodes meshes giving a specific direction
  71501. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71502. */
  71503. explode(direction?: number): void;
  71504. }
  71505. }
  71506. declare module "babylonjs/Misc/filesInput" {
  71507. import { Engine } from "babylonjs/Engines/engine";
  71508. import { Scene } from "babylonjs/scene";
  71509. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71510. /**
  71511. * Class used to help managing file picking and drag'n'drop
  71512. */
  71513. export class FilesInput {
  71514. /**
  71515. * List of files ready to be loaded
  71516. */
  71517. static get FilesToLoad(): {
  71518. [key: string]: File;
  71519. };
  71520. /**
  71521. * Callback called when a file is processed
  71522. */
  71523. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71524. private _engine;
  71525. private _currentScene;
  71526. private _sceneLoadedCallback;
  71527. private _progressCallback;
  71528. private _additionalRenderLoopLogicCallback;
  71529. private _textureLoadingCallback;
  71530. private _startingProcessingFilesCallback;
  71531. private _onReloadCallback;
  71532. private _errorCallback;
  71533. private _elementToMonitor;
  71534. private _sceneFileToLoad;
  71535. private _filesToLoad;
  71536. /**
  71537. * Creates a new FilesInput
  71538. * @param engine defines the rendering engine
  71539. * @param scene defines the hosting scene
  71540. * @param sceneLoadedCallback callback called when scene is loaded
  71541. * @param progressCallback callback called to track progress
  71542. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71543. * @param textureLoadingCallback callback called when a texture is loading
  71544. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71545. * @param onReloadCallback callback called when a reload is requested
  71546. * @param errorCallback callback call if an error occurs
  71547. */
  71548. 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);
  71549. private _dragEnterHandler;
  71550. private _dragOverHandler;
  71551. private _dropHandler;
  71552. /**
  71553. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71554. * @param elementToMonitor defines the DOM element to track
  71555. */
  71556. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71557. /**
  71558. * Release all associated resources
  71559. */
  71560. dispose(): void;
  71561. private renderFunction;
  71562. private drag;
  71563. private drop;
  71564. private _traverseFolder;
  71565. private _processFiles;
  71566. /**
  71567. * Load files from a drop event
  71568. * @param event defines the drop event to use as source
  71569. */
  71570. loadFiles(event: any): void;
  71571. private _processReload;
  71572. /**
  71573. * Reload the current scene from the loaded files
  71574. */
  71575. reload(): void;
  71576. }
  71577. }
  71578. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71579. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71580. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71581. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71582. }
  71583. declare module "babylonjs/Misc/sceneOptimizer" {
  71584. import { Scene, IDisposable } from "babylonjs/scene";
  71585. import { Observable } from "babylonjs/Misc/observable";
  71586. /**
  71587. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71589. */
  71590. export class SceneOptimization {
  71591. /**
  71592. * Defines the priority of this optimization (0 by default which means first in the list)
  71593. */
  71594. priority: number;
  71595. /**
  71596. * Gets a string describing the action executed by the current optimization
  71597. * @returns description string
  71598. */
  71599. getDescription(): string;
  71600. /**
  71601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71602. * @param scene defines the current scene where to apply this optimization
  71603. * @param optimizer defines the current optimizer
  71604. * @returns true if everything that can be done was applied
  71605. */
  71606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71607. /**
  71608. * Creates the SceneOptimization object
  71609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71610. * @param desc defines the description associated with the optimization
  71611. */
  71612. constructor(
  71613. /**
  71614. * Defines the priority of this optimization (0 by default which means first in the list)
  71615. */
  71616. priority?: number);
  71617. }
  71618. /**
  71619. * Defines an optimization used to reduce the size of render target textures
  71620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71621. */
  71622. export class TextureOptimization extends SceneOptimization {
  71623. /**
  71624. * Defines the priority of this optimization (0 by default which means first in the list)
  71625. */
  71626. priority: number;
  71627. /**
  71628. * 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
  71629. */
  71630. maximumSize: number;
  71631. /**
  71632. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71633. */
  71634. step: number;
  71635. /**
  71636. * Gets a string describing the action executed by the current optimization
  71637. * @returns description string
  71638. */
  71639. getDescription(): string;
  71640. /**
  71641. * Creates the TextureOptimization object
  71642. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71643. * @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
  71644. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71645. */
  71646. constructor(
  71647. /**
  71648. * Defines the priority of this optimization (0 by default which means first in the list)
  71649. */
  71650. priority?: number,
  71651. /**
  71652. * 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
  71653. */
  71654. maximumSize?: number,
  71655. /**
  71656. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71657. */
  71658. step?: number);
  71659. /**
  71660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71661. * @param scene defines the current scene where to apply this optimization
  71662. * @param optimizer defines the current optimizer
  71663. * @returns true if everything that can be done was applied
  71664. */
  71665. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71666. }
  71667. /**
  71668. * Defines an optimization used to increase or decrease the rendering resolution
  71669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71670. */
  71671. export class HardwareScalingOptimization extends SceneOptimization {
  71672. /**
  71673. * Defines the priority of this optimization (0 by default which means first in the list)
  71674. */
  71675. priority: number;
  71676. /**
  71677. * Defines the maximum scale to use (2 by default)
  71678. */
  71679. maximumScale: number;
  71680. /**
  71681. * Defines the step to use between two passes (0.5 by default)
  71682. */
  71683. step: number;
  71684. private _currentScale;
  71685. private _directionOffset;
  71686. /**
  71687. * Gets a string describing the action executed by the current optimization
  71688. * @return description string
  71689. */
  71690. getDescription(): string;
  71691. /**
  71692. * Creates the HardwareScalingOptimization object
  71693. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71694. * @param maximumScale defines the maximum scale to use (2 by default)
  71695. * @param step defines the step to use between two passes (0.5 by default)
  71696. */
  71697. constructor(
  71698. /**
  71699. * Defines the priority of this optimization (0 by default which means first in the list)
  71700. */
  71701. priority?: number,
  71702. /**
  71703. * Defines the maximum scale to use (2 by default)
  71704. */
  71705. maximumScale?: number,
  71706. /**
  71707. * Defines the step to use between two passes (0.5 by default)
  71708. */
  71709. step?: number);
  71710. /**
  71711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71712. * @param scene defines the current scene where to apply this optimization
  71713. * @param optimizer defines the current optimizer
  71714. * @returns true if everything that can be done was applied
  71715. */
  71716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71717. }
  71718. /**
  71719. * Defines an optimization used to remove shadows
  71720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71721. */
  71722. export class ShadowsOptimization extends SceneOptimization {
  71723. /**
  71724. * Gets a string describing the action executed by the current optimization
  71725. * @return description string
  71726. */
  71727. getDescription(): string;
  71728. /**
  71729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71730. * @param scene defines the current scene where to apply this optimization
  71731. * @param optimizer defines the current optimizer
  71732. * @returns true if everything that can be done was applied
  71733. */
  71734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71735. }
  71736. /**
  71737. * Defines an optimization used to turn post-processes off
  71738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71739. */
  71740. export class PostProcessesOptimization extends SceneOptimization {
  71741. /**
  71742. * Gets a string describing the action executed by the current optimization
  71743. * @return description string
  71744. */
  71745. getDescription(): string;
  71746. /**
  71747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71748. * @param scene defines the current scene where to apply this optimization
  71749. * @param optimizer defines the current optimizer
  71750. * @returns true if everything that can be done was applied
  71751. */
  71752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71753. }
  71754. /**
  71755. * Defines an optimization used to turn lens flares off
  71756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71757. */
  71758. export class LensFlaresOptimization extends SceneOptimization {
  71759. /**
  71760. * Gets a string describing the action executed by the current optimization
  71761. * @return description string
  71762. */
  71763. getDescription(): string;
  71764. /**
  71765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71766. * @param scene defines the current scene where to apply this optimization
  71767. * @param optimizer defines the current optimizer
  71768. * @returns true if everything that can be done was applied
  71769. */
  71770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71771. }
  71772. /**
  71773. * Defines an optimization based on user defined callback.
  71774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71775. */
  71776. export class CustomOptimization extends SceneOptimization {
  71777. /**
  71778. * Callback called to apply the custom optimization.
  71779. */
  71780. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71781. /**
  71782. * Callback called to get custom description
  71783. */
  71784. onGetDescription: () => string;
  71785. /**
  71786. * Gets a string describing the action executed by the current optimization
  71787. * @returns description string
  71788. */
  71789. getDescription(): string;
  71790. /**
  71791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71792. * @param scene defines the current scene where to apply this optimization
  71793. * @param optimizer defines the current optimizer
  71794. * @returns true if everything that can be done was applied
  71795. */
  71796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71797. }
  71798. /**
  71799. * Defines an optimization used to turn particles off
  71800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71801. */
  71802. export class ParticlesOptimization extends SceneOptimization {
  71803. /**
  71804. * Gets a string describing the action executed by the current optimization
  71805. * @return description string
  71806. */
  71807. getDescription(): string;
  71808. /**
  71809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71810. * @param scene defines the current scene where to apply this optimization
  71811. * @param optimizer defines the current optimizer
  71812. * @returns true if everything that can be done was applied
  71813. */
  71814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71815. }
  71816. /**
  71817. * Defines an optimization used to turn render targets off
  71818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71819. */
  71820. export class RenderTargetsOptimization extends SceneOptimization {
  71821. /**
  71822. * Gets a string describing the action executed by the current optimization
  71823. * @return description string
  71824. */
  71825. getDescription(): string;
  71826. /**
  71827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71828. * @param scene defines the current scene where to apply this optimization
  71829. * @param optimizer defines the current optimizer
  71830. * @returns true if everything that can be done was applied
  71831. */
  71832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71833. }
  71834. /**
  71835. * Defines an optimization used to merge meshes with compatible materials
  71836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71837. */
  71838. export class MergeMeshesOptimization extends SceneOptimization {
  71839. private static _UpdateSelectionTree;
  71840. /**
  71841. * Gets or sets a boolean which defines if optimization octree has to be updated
  71842. */
  71843. static get UpdateSelectionTree(): boolean;
  71844. /**
  71845. * Gets or sets a boolean which defines if optimization octree has to be updated
  71846. */
  71847. static set UpdateSelectionTree(value: boolean);
  71848. /**
  71849. * Gets a string describing the action executed by the current optimization
  71850. * @return description string
  71851. */
  71852. getDescription(): string;
  71853. private _canBeMerged;
  71854. /**
  71855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71856. * @param scene defines the current scene where to apply this optimization
  71857. * @param optimizer defines the current optimizer
  71858. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71859. * @returns true if everything that can be done was applied
  71860. */
  71861. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71862. }
  71863. /**
  71864. * Defines a list of options used by SceneOptimizer
  71865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71866. */
  71867. export class SceneOptimizerOptions {
  71868. /**
  71869. * Defines the target frame rate to reach (60 by default)
  71870. */
  71871. targetFrameRate: number;
  71872. /**
  71873. * Defines the interval between two checkes (2000ms by default)
  71874. */
  71875. trackerDuration: number;
  71876. /**
  71877. * Gets the list of optimizations to apply
  71878. */
  71879. optimizations: SceneOptimization[];
  71880. /**
  71881. * Creates a new list of options used by SceneOptimizer
  71882. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71883. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71884. */
  71885. constructor(
  71886. /**
  71887. * Defines the target frame rate to reach (60 by default)
  71888. */
  71889. targetFrameRate?: number,
  71890. /**
  71891. * Defines the interval between two checkes (2000ms by default)
  71892. */
  71893. trackerDuration?: number);
  71894. /**
  71895. * Add a new optimization
  71896. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71897. * @returns the current SceneOptimizerOptions
  71898. */
  71899. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71900. /**
  71901. * Add a new custom optimization
  71902. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71903. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71905. * @returns the current SceneOptimizerOptions
  71906. */
  71907. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71908. /**
  71909. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71910. * @param targetFrameRate defines the target frame rate (60 by default)
  71911. * @returns a SceneOptimizerOptions object
  71912. */
  71913. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71914. /**
  71915. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71916. * @param targetFrameRate defines the target frame rate (60 by default)
  71917. * @returns a SceneOptimizerOptions object
  71918. */
  71919. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71920. /**
  71921. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71922. * @param targetFrameRate defines the target frame rate (60 by default)
  71923. * @returns a SceneOptimizerOptions object
  71924. */
  71925. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71926. }
  71927. /**
  71928. * Class used to run optimizations in order to reach a target frame rate
  71929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71930. */
  71931. export class SceneOptimizer implements IDisposable {
  71932. private _isRunning;
  71933. private _options;
  71934. private _scene;
  71935. private _currentPriorityLevel;
  71936. private _targetFrameRate;
  71937. private _trackerDuration;
  71938. private _currentFrameRate;
  71939. private _sceneDisposeObserver;
  71940. private _improvementMode;
  71941. /**
  71942. * Defines an observable called when the optimizer reaches the target frame rate
  71943. */
  71944. onSuccessObservable: Observable<SceneOptimizer>;
  71945. /**
  71946. * Defines an observable called when the optimizer enables an optimization
  71947. */
  71948. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71949. /**
  71950. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71951. */
  71952. onFailureObservable: Observable<SceneOptimizer>;
  71953. /**
  71954. * Gets a boolean indicating if the optimizer is in improvement mode
  71955. */
  71956. get isInImprovementMode(): boolean;
  71957. /**
  71958. * Gets the current priority level (0 at start)
  71959. */
  71960. get currentPriorityLevel(): number;
  71961. /**
  71962. * Gets the current frame rate checked by the SceneOptimizer
  71963. */
  71964. get currentFrameRate(): number;
  71965. /**
  71966. * Gets or sets the current target frame rate (60 by default)
  71967. */
  71968. get targetFrameRate(): number;
  71969. /**
  71970. * Gets or sets the current target frame rate (60 by default)
  71971. */
  71972. set targetFrameRate(value: number);
  71973. /**
  71974. * Gets or sets the current interval between two checks (every 2000ms by default)
  71975. */
  71976. get trackerDuration(): number;
  71977. /**
  71978. * Gets or sets the current interval between two checks (every 2000ms by default)
  71979. */
  71980. set trackerDuration(value: number);
  71981. /**
  71982. * Gets the list of active optimizations
  71983. */
  71984. get optimizations(): SceneOptimization[];
  71985. /**
  71986. * Creates a new SceneOptimizer
  71987. * @param scene defines the scene to work on
  71988. * @param options defines the options to use with the SceneOptimizer
  71989. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71990. * @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)
  71991. */
  71992. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71993. /**
  71994. * Stops the current optimizer
  71995. */
  71996. stop(): void;
  71997. /**
  71998. * Reset the optimizer to initial step (current priority level = 0)
  71999. */
  72000. reset(): void;
  72001. /**
  72002. * Start the optimizer. By default it will try to reach a specific framerate
  72003. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72004. */
  72005. start(): void;
  72006. private _checkCurrentState;
  72007. /**
  72008. * Release all resources
  72009. */
  72010. dispose(): void;
  72011. /**
  72012. * Helper function to create a SceneOptimizer with one single line of code
  72013. * @param scene defines the scene to work on
  72014. * @param options defines the options to use with the SceneOptimizer
  72015. * @param onSuccess defines a callback to call on success
  72016. * @param onFailure defines a callback to call on failure
  72017. * @returns the new SceneOptimizer object
  72018. */
  72019. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72020. }
  72021. }
  72022. declare module "babylonjs/Misc/sceneSerializer" {
  72023. import { Scene } from "babylonjs/scene";
  72024. /**
  72025. * Class used to serialize a scene into a string
  72026. */
  72027. export class SceneSerializer {
  72028. /**
  72029. * Clear cache used by a previous serialization
  72030. */
  72031. static ClearCache(): void;
  72032. /**
  72033. * Serialize a scene into a JSON compatible object
  72034. * @param scene defines the scene to serialize
  72035. * @returns a JSON compatible object
  72036. */
  72037. static Serialize(scene: Scene): any;
  72038. /**
  72039. * Serialize a mesh into a JSON compatible object
  72040. * @param toSerialize defines the mesh to serialize
  72041. * @param withParents defines if parents must be serialized as well
  72042. * @param withChildren defines if children must be serialized as well
  72043. * @returns a JSON compatible object
  72044. */
  72045. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72046. }
  72047. }
  72048. declare module "babylonjs/Misc/textureTools" {
  72049. import { Texture } from "babylonjs/Materials/Textures/texture";
  72050. /**
  72051. * Class used to host texture specific utilities
  72052. */
  72053. export class TextureTools {
  72054. /**
  72055. * Uses the GPU to create a copy texture rescaled at a given size
  72056. * @param texture Texture to copy from
  72057. * @param width defines the desired width
  72058. * @param height defines the desired height
  72059. * @param useBilinearMode defines if bilinear mode has to be used
  72060. * @return the generated texture
  72061. */
  72062. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72063. }
  72064. }
  72065. declare module "babylonjs/Misc/videoRecorder" {
  72066. import { Nullable } from "babylonjs/types";
  72067. import { Engine } from "babylonjs/Engines/engine";
  72068. /**
  72069. * This represents the different options available for the video capture.
  72070. */
  72071. export interface VideoRecorderOptions {
  72072. /** Defines the mime type of the video. */
  72073. mimeType: string;
  72074. /** Defines the FPS the video should be recorded at. */
  72075. fps: number;
  72076. /** Defines the chunk size for the recording data. */
  72077. recordChunckSize: number;
  72078. /** The audio tracks to attach to the recording. */
  72079. audioTracks?: MediaStreamTrack[];
  72080. }
  72081. /**
  72082. * This can help with recording videos from BabylonJS.
  72083. * This is based on the available WebRTC functionalities of the browser.
  72084. *
  72085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72086. */
  72087. export class VideoRecorder {
  72088. private static readonly _defaultOptions;
  72089. /**
  72090. * Returns whether or not the VideoRecorder is available in your browser.
  72091. * @param engine Defines the Babylon Engine.
  72092. * @returns true if supported otherwise false.
  72093. */
  72094. static IsSupported(engine: Engine): boolean;
  72095. private readonly _options;
  72096. private _canvas;
  72097. private _mediaRecorder;
  72098. private _recordedChunks;
  72099. private _fileName;
  72100. private _resolve;
  72101. private _reject;
  72102. /**
  72103. * True when a recording is already in progress.
  72104. */
  72105. get isRecording(): boolean;
  72106. /**
  72107. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72108. * @param engine Defines the BabylonJS Engine you wish to record.
  72109. * @param options Defines options that can be used to customize the capture.
  72110. */
  72111. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72112. /**
  72113. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72114. */
  72115. stopRecording(): void;
  72116. /**
  72117. * Starts recording the canvas for a max duration specified in parameters.
  72118. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72119. * If null no automatic download will start and you can rely on the promise to get the data back.
  72120. * @param maxDuration Defines the maximum recording time in seconds.
  72121. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72122. * @return A promise callback at the end of the recording with the video data in Blob.
  72123. */
  72124. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72125. /**
  72126. * Releases internal resources used during the recording.
  72127. */
  72128. dispose(): void;
  72129. private _handleDataAvailable;
  72130. private _handleError;
  72131. private _handleStop;
  72132. }
  72133. }
  72134. declare module "babylonjs/Misc/screenshotTools" {
  72135. import { Camera } from "babylonjs/Cameras/camera";
  72136. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72137. import { Engine } from "babylonjs/Engines/engine";
  72138. /**
  72139. * Class containing a set of static utilities functions for screenshots
  72140. */
  72141. export class ScreenshotTools {
  72142. /**
  72143. * Captures a screenshot of the current rendering
  72144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72145. * @param engine defines the rendering engine
  72146. * @param camera defines the source camera
  72147. * @param size This parameter can be set to a single number or to an object with the
  72148. * following (optional) properties: precision, width, height. If a single number is passed,
  72149. * it will be used for both width and height. If an object is passed, the screenshot size
  72150. * will be derived from the parameters. The precision property is a multiplier allowing
  72151. * rendering at a higher or lower resolution
  72152. * @param successCallback defines the callback receives a single parameter which contains the
  72153. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72154. * src parameter of an <img> to display it
  72155. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72156. * Check your browser for supported MIME types
  72157. */
  72158. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72159. /**
  72160. * Captures a screenshot of the current rendering
  72161. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72162. * @param engine defines the rendering engine
  72163. * @param camera defines the source camera
  72164. * @param size This parameter can be set to a single number or to an object with the
  72165. * following (optional) properties: precision, width, height. If a single number is passed,
  72166. * it will be used for both width and height. If an object is passed, the screenshot size
  72167. * will be derived from the parameters. The precision property is a multiplier allowing
  72168. * rendering at a higher or lower resolution
  72169. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72170. * Check your browser for supported MIME types
  72171. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72172. * to the src parameter of an <img> to display it
  72173. */
  72174. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72175. /**
  72176. * Generates an image screenshot from the specified camera.
  72177. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72178. * @param engine The engine to use for rendering
  72179. * @param camera The camera to use for rendering
  72180. * @param size This parameter can be set to a single number or to an object with the
  72181. * following (optional) properties: precision, width, height. If a single number is passed,
  72182. * it will be used for both width and height. If an object is passed, the screenshot size
  72183. * will be derived from the parameters. The precision property is a multiplier allowing
  72184. * rendering at a higher or lower resolution
  72185. * @param successCallback The callback receives a single parameter which contains the
  72186. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72187. * src parameter of an <img> to display it
  72188. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72189. * Check your browser for supported MIME types
  72190. * @param samples Texture samples (default: 1)
  72191. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72192. * @param fileName A name for for the downloaded file.
  72193. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72194. */
  72195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72196. /**
  72197. * Generates an image screenshot from the specified camera.
  72198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72199. * @param engine The engine to use for rendering
  72200. * @param camera The camera to use for rendering
  72201. * @param size This parameter can be set to a single number or to an object with the
  72202. * following (optional) properties: precision, width, height. If a single number is passed,
  72203. * it will be used for both width and height. If an object is passed, the screenshot size
  72204. * will be derived from the parameters. The precision property is a multiplier allowing
  72205. * rendering at a higher or lower resolution
  72206. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72207. * Check your browser for supported MIME types
  72208. * @param samples Texture samples (default: 1)
  72209. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72210. * @param fileName A name for for the downloaded file.
  72211. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72212. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72213. * to the src parameter of an <img> to display it
  72214. */
  72215. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72216. /**
  72217. * Gets height and width for screenshot size
  72218. * @private
  72219. */
  72220. private static _getScreenshotSize;
  72221. }
  72222. }
  72223. declare module "babylonjs/Misc/dataReader" {
  72224. /**
  72225. * Interface for a data buffer
  72226. */
  72227. export interface IDataBuffer {
  72228. /**
  72229. * Reads bytes from the data buffer.
  72230. * @param byteOffset The byte offset to read
  72231. * @param byteLength The byte length to read
  72232. * @returns A promise that resolves when the bytes are read
  72233. */
  72234. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72235. /**
  72236. * The byte length of the buffer.
  72237. */
  72238. readonly byteLength: number;
  72239. }
  72240. /**
  72241. * Utility class for reading from a data buffer
  72242. */
  72243. export class DataReader {
  72244. /**
  72245. * The data buffer associated with this data reader.
  72246. */
  72247. readonly buffer: IDataBuffer;
  72248. /**
  72249. * The current byte offset from the beginning of the data buffer.
  72250. */
  72251. byteOffset: number;
  72252. private _dataView;
  72253. private _dataByteOffset;
  72254. /**
  72255. * Constructor
  72256. * @param buffer The buffer to read
  72257. */
  72258. constructor(buffer: IDataBuffer);
  72259. /**
  72260. * Loads the given byte length.
  72261. * @param byteLength The byte length to load
  72262. * @returns A promise that resolves when the load is complete
  72263. */
  72264. loadAsync(byteLength: number): Promise<void>;
  72265. /**
  72266. * Read a unsigned 32-bit integer from the currently loaded data range.
  72267. * @returns The 32-bit integer read
  72268. */
  72269. readUint32(): number;
  72270. /**
  72271. * Read a byte array from the currently loaded data range.
  72272. * @param byteLength The byte length to read
  72273. * @returns The byte array read
  72274. */
  72275. readUint8Array(byteLength: number): Uint8Array;
  72276. /**
  72277. * Read a string from the currently loaded data range.
  72278. * @param byteLength The byte length to read
  72279. * @returns The string read
  72280. */
  72281. readString(byteLength: number): string;
  72282. /**
  72283. * Skips the given byte length the currently loaded data range.
  72284. * @param byteLength The byte length to skip
  72285. */
  72286. skipBytes(byteLength: number): void;
  72287. }
  72288. }
  72289. declare module "babylonjs/Misc/index" {
  72290. export * from "babylonjs/Misc/andOrNotEvaluator";
  72291. export * from "babylonjs/Misc/assetsManager";
  72292. export * from "babylonjs/Misc/basis";
  72293. export * from "babylonjs/Misc/dds";
  72294. export * from "babylonjs/Misc/decorators";
  72295. export * from "babylonjs/Misc/deferred";
  72296. export * from "babylonjs/Misc/environmentTextureTools";
  72297. export * from "babylonjs/Misc/meshExploder";
  72298. export * from "babylonjs/Misc/filesInput";
  72299. export * from "babylonjs/Misc/HighDynamicRange/index";
  72300. export * from "babylonjs/Misc/khronosTextureContainer";
  72301. export * from "babylonjs/Misc/observable";
  72302. export * from "babylonjs/Misc/performanceMonitor";
  72303. export * from "babylonjs/Misc/promise";
  72304. export * from "babylonjs/Misc/sceneOptimizer";
  72305. export * from "babylonjs/Misc/sceneSerializer";
  72306. export * from "babylonjs/Misc/smartArray";
  72307. export * from "babylonjs/Misc/stringDictionary";
  72308. export * from "babylonjs/Misc/tags";
  72309. export * from "babylonjs/Misc/textureTools";
  72310. export * from "babylonjs/Misc/tga";
  72311. export * from "babylonjs/Misc/tools";
  72312. export * from "babylonjs/Misc/videoRecorder";
  72313. export * from "babylonjs/Misc/virtualJoystick";
  72314. export * from "babylonjs/Misc/workerPool";
  72315. export * from "babylonjs/Misc/logger";
  72316. export * from "babylonjs/Misc/typeStore";
  72317. export * from "babylonjs/Misc/filesInputStore";
  72318. export * from "babylonjs/Misc/deepCopier";
  72319. export * from "babylonjs/Misc/pivotTools";
  72320. export * from "babylonjs/Misc/precisionDate";
  72321. export * from "babylonjs/Misc/screenshotTools";
  72322. export * from "babylonjs/Misc/typeStore";
  72323. export * from "babylonjs/Misc/webRequest";
  72324. export * from "babylonjs/Misc/iInspectable";
  72325. export * from "babylonjs/Misc/brdfTextureTools";
  72326. export * from "babylonjs/Misc/rgbdTextureTools";
  72327. export * from "babylonjs/Misc/gradients";
  72328. export * from "babylonjs/Misc/perfCounter";
  72329. export * from "babylonjs/Misc/fileRequest";
  72330. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72331. export * from "babylonjs/Misc/retryStrategy";
  72332. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72333. export * from "babylonjs/Misc/canvasGenerator";
  72334. export * from "babylonjs/Misc/fileTools";
  72335. export * from "babylonjs/Misc/stringTools";
  72336. export * from "babylonjs/Misc/dataReader";
  72337. export * from "babylonjs/Misc/minMaxReducer";
  72338. export * from "babylonjs/Misc/depthReducer";
  72339. }
  72340. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72341. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72342. import { Observable } from "babylonjs/Misc/observable";
  72343. import { Matrix } from "babylonjs/Maths/math.vector";
  72344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72345. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72346. /**
  72347. * Options used for hit testing
  72348. */
  72349. export interface IWebXRHitTestOptions {
  72350. /**
  72351. * Only test when user interacted with the scene. Default - hit test every frame
  72352. */
  72353. testOnPointerDownOnly?: boolean;
  72354. /**
  72355. * The node to use to transform the local results to world coordinates
  72356. */
  72357. worldParentNode?: TransformNode;
  72358. }
  72359. /**
  72360. * Interface defining the babylon result of raycasting/hit-test
  72361. */
  72362. export interface IWebXRHitResult {
  72363. /**
  72364. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72365. */
  72366. transformationMatrix: Matrix;
  72367. /**
  72368. * The native hit test result
  72369. */
  72370. xrHitResult: XRHitResult;
  72371. }
  72372. /**
  72373. * The currently-working hit-test module.
  72374. * Hit test (or Ray-casting) is used to interact with the real world.
  72375. * For further information read here - https://github.com/immersive-web/hit-test
  72376. */
  72377. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72378. /**
  72379. * options to use when constructing this feature
  72380. */
  72381. readonly options: IWebXRHitTestOptions;
  72382. private _direction;
  72383. private _mat;
  72384. private _onSelectEnabled;
  72385. private _origin;
  72386. /**
  72387. * The module's name
  72388. */
  72389. static readonly Name: string;
  72390. /**
  72391. * The (Babylon) version of this module.
  72392. * This is an integer representing the implementation version.
  72393. * This number does not correspond to the WebXR specs version
  72394. */
  72395. static readonly Version: number;
  72396. /**
  72397. * Populated with the last native XR Hit Results
  72398. */
  72399. lastNativeXRHitResults: XRHitResult[];
  72400. /**
  72401. * Triggered when new babylon (transformed) hit test results are available
  72402. */
  72403. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72404. /**
  72405. * Creates a new instance of the (legacy version) hit test feature
  72406. * @param _xrSessionManager an instance of WebXRSessionManager
  72407. * @param options options to use when constructing this feature
  72408. */
  72409. constructor(_xrSessionManager: WebXRSessionManager,
  72410. /**
  72411. * options to use when constructing this feature
  72412. */
  72413. options?: IWebXRHitTestOptions);
  72414. /**
  72415. * execute a hit test with an XR Ray
  72416. *
  72417. * @param xrSession a native xrSession that will execute this hit test
  72418. * @param xrRay the ray (position and direction) to use for ray-casting
  72419. * @param referenceSpace native XR reference space to use for the hit-test
  72420. * @param filter filter function that will filter the results
  72421. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72422. */
  72423. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72424. /**
  72425. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72426. * @param event the (select) event to use to select with
  72427. * @param referenceSpace the reference space to use for this hit test
  72428. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72429. */
  72430. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72431. /**
  72432. * attach this feature
  72433. * Will usually be called by the features manager
  72434. *
  72435. * @returns true if successful.
  72436. */
  72437. attach(): boolean;
  72438. /**
  72439. * detach this feature.
  72440. * Will usually be called by the features manager
  72441. *
  72442. * @returns true if successful.
  72443. */
  72444. detach(): boolean;
  72445. /**
  72446. * Dispose this feature and all of the resources attached
  72447. */
  72448. dispose(): void;
  72449. protected _onXRFrame(frame: XRFrame): void;
  72450. private _onHitTestResults;
  72451. private _onSelect;
  72452. }
  72453. }
  72454. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72455. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72456. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72457. import { Observable } from "babylonjs/Misc/observable";
  72458. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72459. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72460. /**
  72461. * Options used in the plane detector module
  72462. */
  72463. export interface IWebXRPlaneDetectorOptions {
  72464. /**
  72465. * The node to use to transform the local results to world coordinates
  72466. */
  72467. worldParentNode?: TransformNode;
  72468. }
  72469. /**
  72470. * A babylon interface for a WebXR plane.
  72471. * A Plane is actually a polygon, built from N points in space
  72472. *
  72473. * Supported in chrome 79, not supported in canary 81 ATM
  72474. */
  72475. export interface IWebXRPlane {
  72476. /**
  72477. * a babylon-assigned ID for this polygon
  72478. */
  72479. id: number;
  72480. /**
  72481. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72482. */
  72483. polygonDefinition: Array<Vector3>;
  72484. /**
  72485. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72486. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72487. */
  72488. transformationMatrix: Matrix;
  72489. /**
  72490. * the native xr-plane object
  72491. */
  72492. xrPlane: XRPlane;
  72493. }
  72494. /**
  72495. * The plane detector is used to detect planes in the real world when in AR
  72496. * For more information see https://github.com/immersive-web/real-world-geometry/
  72497. */
  72498. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72499. private _options;
  72500. private _detectedPlanes;
  72501. private _enabled;
  72502. private _lastFrameDetected;
  72503. /**
  72504. * The module's name
  72505. */
  72506. static readonly Name: string;
  72507. /**
  72508. * The (Babylon) version of this module.
  72509. * This is an integer representing the implementation version.
  72510. * This number does not correspond to the WebXR specs version
  72511. */
  72512. static readonly Version: number;
  72513. /**
  72514. * Observers registered here will be executed when a new plane was added to the session
  72515. */
  72516. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72517. /**
  72518. * Observers registered here will be executed when a plane is no longer detected in the session
  72519. */
  72520. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72521. /**
  72522. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72523. * This can execute N times every frame
  72524. */
  72525. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72526. /**
  72527. * construct a new Plane Detector
  72528. * @param _xrSessionManager an instance of xr Session manager
  72529. * @param _options configuration to use when constructing this feature
  72530. */
  72531. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72532. /**
  72533. * Dispose this feature and all of the resources attached
  72534. */
  72535. dispose(): void;
  72536. protected _onXRFrame(frame: XRFrame): void;
  72537. private _init;
  72538. private _updatePlaneWithXRPlane;
  72539. /**
  72540. * avoiding using Array.find for global support.
  72541. * @param xrPlane the plane to find in the array
  72542. */
  72543. private findIndexInPlaneArray;
  72544. }
  72545. }
  72546. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72547. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72548. import { Observable } from "babylonjs/Misc/observable";
  72549. import { Matrix } from "babylonjs/Maths/math.vector";
  72550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72551. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72552. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72553. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72554. /**
  72555. * Configuration options of the anchor system
  72556. */
  72557. export interface IWebXRAnchorSystemOptions {
  72558. /**
  72559. * Should a new anchor be added every time a select event is triggered
  72560. */
  72561. addAnchorOnSelect?: boolean;
  72562. /**
  72563. * should the anchor system use plane detection.
  72564. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72565. */
  72566. usePlaneDetection?: boolean;
  72567. /**
  72568. * a node that will be used to convert local to world coordinates
  72569. */
  72570. worldParentNode?: TransformNode;
  72571. }
  72572. /**
  72573. * A babylon container for an XR Anchor
  72574. */
  72575. export interface IWebXRAnchor {
  72576. /**
  72577. * A babylon-assigned ID for this anchor
  72578. */
  72579. id: number;
  72580. /**
  72581. * Transformation matrix to apply to an object attached to this anchor
  72582. */
  72583. transformationMatrix: Matrix;
  72584. /**
  72585. * The native anchor object
  72586. */
  72587. xrAnchor: XRAnchor;
  72588. }
  72589. /**
  72590. * An implementation of the anchor system of WebXR.
  72591. * Note that the current documented implementation is not available in any browser. Future implementations
  72592. * will use the frame to create an anchor and not the session or a detected plane
  72593. * For further information see https://github.com/immersive-web/anchors/
  72594. */
  72595. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72596. private _options;
  72597. private _enabled;
  72598. private _hitTestModule;
  72599. private _lastFrameDetected;
  72600. private _onSelect;
  72601. private _planeDetector;
  72602. private _trackedAnchors;
  72603. /**
  72604. * The module's name
  72605. */
  72606. static readonly Name: string;
  72607. /**
  72608. * The (Babylon) version of this module.
  72609. * This is an integer representing the implementation version.
  72610. * This number does not correspond to the WebXR specs version
  72611. */
  72612. static readonly Version: number;
  72613. /**
  72614. * Observers registered here will be executed when a new anchor was added to the session
  72615. */
  72616. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72617. /**
  72618. * Observers registered here will be executed when an anchor was removed from the session
  72619. */
  72620. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72621. /**
  72622. * Observers registered here will be executed when an existing anchor updates
  72623. * This can execute N times every frame
  72624. */
  72625. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72626. /**
  72627. * constructs a new anchor system
  72628. * @param _xrSessionManager an instance of WebXRSessionManager
  72629. * @param _options configuration object for this feature
  72630. */
  72631. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72632. /**
  72633. * Add anchor at a specific XR point.
  72634. *
  72635. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72636. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72637. * @returns a promise the fulfills when the anchor was created
  72638. */
  72639. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72640. /**
  72641. * attach this feature
  72642. * Will usually be called by the features manager
  72643. *
  72644. * @returns true if successful.
  72645. */
  72646. attach(): boolean;
  72647. /**
  72648. * detach this feature.
  72649. * Will usually be called by the features manager
  72650. *
  72651. * @returns true if successful.
  72652. */
  72653. detach(): boolean;
  72654. /**
  72655. * Dispose this feature and all of the resources attached
  72656. */
  72657. dispose(): void;
  72658. /**
  72659. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72660. * @param hitTestModule the hit-test module to use.
  72661. */
  72662. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72663. /**
  72664. * set the plane detector to use in order to create anchors from frames
  72665. * @param planeDetector the plane-detector module to use
  72666. * @param enable enable plane-anchors. default is true
  72667. */
  72668. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72669. protected _onXRFrame(frame: XRFrame): void;
  72670. /**
  72671. * avoiding using Array.find for global support.
  72672. * @param xrAnchor the plane to find in the array
  72673. */
  72674. private _findIndexInAnchorArray;
  72675. private _updateAnchorWithXRFrame;
  72676. }
  72677. }
  72678. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72679. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72681. import { Observable } from "babylonjs/Misc/observable";
  72682. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72683. /**
  72684. * Options interface for the background remover plugin
  72685. */
  72686. export interface IWebXRBackgroundRemoverOptions {
  72687. /**
  72688. * Further background meshes to disable when entering AR
  72689. */
  72690. backgroundMeshes?: AbstractMesh[];
  72691. /**
  72692. * flags to configure the removal of the environment helper.
  72693. * If not set, the entire background will be removed. If set, flags should be set as well.
  72694. */
  72695. environmentHelperRemovalFlags?: {
  72696. /**
  72697. * Should the skybox be removed (default false)
  72698. */
  72699. skyBox?: boolean;
  72700. /**
  72701. * Should the ground be removed (default false)
  72702. */
  72703. ground?: boolean;
  72704. };
  72705. /**
  72706. * don't disable the environment helper
  72707. */
  72708. ignoreEnvironmentHelper?: boolean;
  72709. }
  72710. /**
  72711. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72712. */
  72713. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72714. /**
  72715. * read-only options to be used in this module
  72716. */
  72717. readonly options: IWebXRBackgroundRemoverOptions;
  72718. /**
  72719. * The module's name
  72720. */
  72721. static readonly Name: string;
  72722. /**
  72723. * The (Babylon) version of this module.
  72724. * This is an integer representing the implementation version.
  72725. * This number does not correspond to the WebXR specs version
  72726. */
  72727. static readonly Version: number;
  72728. /**
  72729. * registered observers will be triggered when the background state changes
  72730. */
  72731. onBackgroundStateChangedObservable: Observable<boolean>;
  72732. /**
  72733. * constructs a new background remover module
  72734. * @param _xrSessionManager the session manager for this module
  72735. * @param options read-only options to be used in this module
  72736. */
  72737. constructor(_xrSessionManager: WebXRSessionManager,
  72738. /**
  72739. * read-only options to be used in this module
  72740. */
  72741. options?: IWebXRBackgroundRemoverOptions);
  72742. /**
  72743. * attach this feature
  72744. * Will usually be called by the features manager
  72745. *
  72746. * @returns true if successful.
  72747. */
  72748. attach(): boolean;
  72749. /**
  72750. * detach this feature.
  72751. * Will usually be called by the features manager
  72752. *
  72753. * @returns true if successful.
  72754. */
  72755. detach(): boolean;
  72756. /**
  72757. * Dispose this feature and all of the resources attached
  72758. */
  72759. dispose(): void;
  72760. protected _onXRFrame(_xrFrame: XRFrame): void;
  72761. private _setBackgroundState;
  72762. }
  72763. }
  72764. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72765. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72766. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72767. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72768. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72769. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72770. import { Nullable } from "babylonjs/types";
  72771. /**
  72772. * Options for the controller physics feature
  72773. */
  72774. export class IWebXRControllerPhysicsOptions {
  72775. /**
  72776. * Should the headset get its own impostor
  72777. */
  72778. enableHeadsetImpostor?: boolean;
  72779. /**
  72780. * Optional parameters for the headset impostor
  72781. */
  72782. headsetImpostorParams?: {
  72783. /**
  72784. * The type of impostor to create. Default is sphere
  72785. */
  72786. impostorType: number;
  72787. /**
  72788. * the size of the impostor. Defaults to 10cm
  72789. */
  72790. impostorSize?: number | {
  72791. width: number;
  72792. height: number;
  72793. depth: number;
  72794. };
  72795. /**
  72796. * Friction definitions
  72797. */
  72798. friction?: number;
  72799. /**
  72800. * Restitution
  72801. */
  72802. restitution?: number;
  72803. };
  72804. /**
  72805. * The physics properties of the future impostors
  72806. */
  72807. physicsProperties?: {
  72808. /**
  72809. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72810. * Note that this requires a physics engine that supports mesh impostors!
  72811. */
  72812. useControllerMesh?: boolean;
  72813. /**
  72814. * The type of impostor to create. Default is sphere
  72815. */
  72816. impostorType?: number;
  72817. /**
  72818. * the size of the impostor. Defaults to 10cm
  72819. */
  72820. impostorSize?: number | {
  72821. width: number;
  72822. height: number;
  72823. depth: number;
  72824. };
  72825. /**
  72826. * Friction definitions
  72827. */
  72828. friction?: number;
  72829. /**
  72830. * Restitution
  72831. */
  72832. restitution?: number;
  72833. };
  72834. /**
  72835. * the xr input to use with this pointer selection
  72836. */
  72837. xrInput: WebXRInput;
  72838. }
  72839. /**
  72840. * Add physics impostor to your webxr controllers,
  72841. * including naive calculation of their linear and angular velocity
  72842. */
  72843. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72844. private readonly _options;
  72845. private _attachController;
  72846. private _controllers;
  72847. private _debugMode;
  72848. private _delta;
  72849. private _headsetImpostor?;
  72850. private _headsetMesh?;
  72851. private _lastTimestamp;
  72852. private _tmpQuaternion;
  72853. private _tmpVector;
  72854. /**
  72855. * The module's name
  72856. */
  72857. static readonly Name: string;
  72858. /**
  72859. * The (Babylon) version of this module.
  72860. * This is an integer representing the implementation version.
  72861. * This number does not correspond to the webxr specs version
  72862. */
  72863. static readonly Version: number;
  72864. /**
  72865. * Construct a new Controller Physics Feature
  72866. * @param _xrSessionManager the corresponding xr session manager
  72867. * @param _options options to create this feature with
  72868. */
  72869. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72870. /**
  72871. * @hidden
  72872. * enable debugging - will show console outputs and the impostor mesh
  72873. */
  72874. _enablePhysicsDebug(): void;
  72875. /**
  72876. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72877. * @param xrController the controller to add
  72878. */
  72879. addController(xrController: WebXRInputSource): void;
  72880. /**
  72881. * attach this feature
  72882. * Will usually be called by the features manager
  72883. *
  72884. * @returns true if successful.
  72885. */
  72886. attach(): boolean;
  72887. /**
  72888. * detach this feature.
  72889. * Will usually be called by the features manager
  72890. *
  72891. * @returns true if successful.
  72892. */
  72893. detach(): boolean;
  72894. /**
  72895. * Get the headset impostor, if enabled
  72896. * @returns the impostor
  72897. */
  72898. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72899. /**
  72900. * Get the physics impostor of a specific controller.
  72901. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72902. * @param controller the controller or the controller id of which to get the impostor
  72903. * @returns the impostor or null
  72904. */
  72905. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72906. /**
  72907. * Update the physics properties provided in the constructor
  72908. * @param newProperties the new properties object
  72909. */
  72910. setPhysicsProperties(newProperties: {
  72911. impostorType?: number;
  72912. impostorSize?: number | {
  72913. width: number;
  72914. height: number;
  72915. depth: number;
  72916. };
  72917. friction?: number;
  72918. restitution?: number;
  72919. }): void;
  72920. protected _onXRFrame(_xrFrame: any): void;
  72921. private _detachController;
  72922. }
  72923. }
  72924. declare module "babylonjs/XR/features/index" {
  72925. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72926. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72927. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72928. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72929. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72930. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72931. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72932. }
  72933. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72934. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72936. import { Scene } from "babylonjs/scene";
  72937. /**
  72938. * The motion controller class for all microsoft mixed reality controllers
  72939. */
  72940. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72941. protected readonly _mapping: {
  72942. defaultButton: {
  72943. "valueNodeName": string;
  72944. "unpressedNodeName": string;
  72945. "pressedNodeName": string;
  72946. };
  72947. defaultAxis: {
  72948. "valueNodeName": string;
  72949. "minNodeName": string;
  72950. "maxNodeName": string;
  72951. };
  72952. buttons: {
  72953. "xr-standard-trigger": {
  72954. "rootNodeName": string;
  72955. "componentProperty": string;
  72956. "states": string[];
  72957. };
  72958. "xr-standard-squeeze": {
  72959. "rootNodeName": string;
  72960. "componentProperty": string;
  72961. "states": string[];
  72962. };
  72963. "xr-standard-touchpad": {
  72964. "rootNodeName": string;
  72965. "labelAnchorNodeName": string;
  72966. "touchPointNodeName": string;
  72967. };
  72968. "xr-standard-thumbstick": {
  72969. "rootNodeName": string;
  72970. "componentProperty": string;
  72971. "states": string[];
  72972. };
  72973. };
  72974. axes: {
  72975. "xr-standard-touchpad": {
  72976. "x-axis": {
  72977. "rootNodeName": string;
  72978. };
  72979. "y-axis": {
  72980. "rootNodeName": string;
  72981. };
  72982. };
  72983. "xr-standard-thumbstick": {
  72984. "x-axis": {
  72985. "rootNodeName": string;
  72986. };
  72987. "y-axis": {
  72988. "rootNodeName": string;
  72989. };
  72990. };
  72991. };
  72992. };
  72993. /**
  72994. * The base url used to load the left and right controller models
  72995. */
  72996. static MODEL_BASE_URL: string;
  72997. /**
  72998. * The name of the left controller model file
  72999. */
  73000. static MODEL_LEFT_FILENAME: string;
  73001. /**
  73002. * The name of the right controller model file
  73003. */
  73004. static MODEL_RIGHT_FILENAME: string;
  73005. profileId: string;
  73006. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73007. protected _getFilenameAndPath(): {
  73008. filename: string;
  73009. path: string;
  73010. };
  73011. protected _getModelLoadingConstraints(): boolean;
  73012. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73013. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73014. protected _updateModel(): void;
  73015. }
  73016. }
  73017. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73018. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73020. import { Scene } from "babylonjs/scene";
  73021. /**
  73022. * The motion controller class for oculus touch (quest, rift).
  73023. * This class supports legacy mapping as well the standard xr mapping
  73024. */
  73025. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73026. private _forceLegacyControllers;
  73027. private _modelRootNode;
  73028. /**
  73029. * The base url used to load the left and right controller models
  73030. */
  73031. static MODEL_BASE_URL: string;
  73032. /**
  73033. * The name of the left controller model file
  73034. */
  73035. static MODEL_LEFT_FILENAME: string;
  73036. /**
  73037. * The name of the right controller model file
  73038. */
  73039. static MODEL_RIGHT_FILENAME: string;
  73040. /**
  73041. * Base Url for the Quest controller model.
  73042. */
  73043. static QUEST_MODEL_BASE_URL: string;
  73044. profileId: string;
  73045. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73046. protected _getFilenameAndPath(): {
  73047. filename: string;
  73048. path: string;
  73049. };
  73050. protected _getModelLoadingConstraints(): boolean;
  73051. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73053. protected _updateModel(): void;
  73054. /**
  73055. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73056. * between the touch and touch 2.
  73057. */
  73058. private _isQuest;
  73059. }
  73060. }
  73061. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73062. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73063. import { Scene } from "babylonjs/scene";
  73064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73065. /**
  73066. * The motion controller class for the standard HTC-Vive controllers
  73067. */
  73068. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73069. private _modelRootNode;
  73070. /**
  73071. * The base url used to load the left and right controller models
  73072. */
  73073. static MODEL_BASE_URL: string;
  73074. /**
  73075. * File name for the controller model.
  73076. */
  73077. static MODEL_FILENAME: string;
  73078. profileId: string;
  73079. /**
  73080. * Create a new Vive motion controller object
  73081. * @param scene the scene to use to create this controller
  73082. * @param gamepadObject the corresponding gamepad object
  73083. * @param handness the handness of the controller
  73084. */
  73085. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73086. protected _getFilenameAndPath(): {
  73087. filename: string;
  73088. path: string;
  73089. };
  73090. protected _getModelLoadingConstraints(): boolean;
  73091. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73092. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73093. protected _updateModel(): void;
  73094. }
  73095. }
  73096. declare module "babylonjs/XR/motionController/index" {
  73097. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73098. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73099. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73100. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73101. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73102. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73103. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73104. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73105. }
  73106. declare module "babylonjs/XR/index" {
  73107. export * from "babylonjs/XR/webXRCamera";
  73108. export * from "babylonjs/XR/webXREnterExitUI";
  73109. export * from "babylonjs/XR/webXRExperienceHelper";
  73110. export * from "babylonjs/XR/webXRInput";
  73111. export * from "babylonjs/XR/webXRInputSource";
  73112. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73113. export * from "babylonjs/XR/webXRTypes";
  73114. export * from "babylonjs/XR/webXRSessionManager";
  73115. export * from "babylonjs/XR/webXRDefaultExperience";
  73116. export * from "babylonjs/XR/webXRFeaturesManager";
  73117. export * from "babylonjs/XR/features/index";
  73118. export * from "babylonjs/XR/motionController/index";
  73119. }
  73120. declare module "babylonjs/index" {
  73121. export * from "babylonjs/abstractScene";
  73122. export * from "babylonjs/Actions/index";
  73123. export * from "babylonjs/Animations/index";
  73124. export * from "babylonjs/assetContainer";
  73125. export * from "babylonjs/Audio/index";
  73126. export * from "babylonjs/Behaviors/index";
  73127. export * from "babylonjs/Bones/index";
  73128. export * from "babylonjs/Cameras/index";
  73129. export * from "babylonjs/Collisions/index";
  73130. export * from "babylonjs/Culling/index";
  73131. export * from "babylonjs/Debug/index";
  73132. export * from "babylonjs/Engines/index";
  73133. export * from "babylonjs/Events/index";
  73134. export * from "babylonjs/Gamepads/index";
  73135. export * from "babylonjs/Gizmos/index";
  73136. export * from "babylonjs/Helpers/index";
  73137. export * from "babylonjs/Instrumentation/index";
  73138. export * from "babylonjs/Layers/index";
  73139. export * from "babylonjs/LensFlares/index";
  73140. export * from "babylonjs/Lights/index";
  73141. export * from "babylonjs/Loading/index";
  73142. export * from "babylonjs/Materials/index";
  73143. export * from "babylonjs/Maths/index";
  73144. export * from "babylonjs/Meshes/index";
  73145. export * from "babylonjs/Morph/index";
  73146. export * from "babylonjs/Navigation/index";
  73147. export * from "babylonjs/node";
  73148. export * from "babylonjs/Offline/index";
  73149. export * from "babylonjs/Particles/index";
  73150. export * from "babylonjs/Physics/index";
  73151. export * from "babylonjs/PostProcesses/index";
  73152. export * from "babylonjs/Probes/index";
  73153. export * from "babylonjs/Rendering/index";
  73154. export * from "babylonjs/scene";
  73155. export * from "babylonjs/sceneComponent";
  73156. export * from "babylonjs/Sprites/index";
  73157. export * from "babylonjs/States/index";
  73158. export * from "babylonjs/Misc/index";
  73159. export * from "babylonjs/XR/index";
  73160. export * from "babylonjs/types";
  73161. }
  73162. declare module "babylonjs/Animations/pathCursor" {
  73163. import { Vector3 } from "babylonjs/Maths/math.vector";
  73164. import { Path2 } from "babylonjs/Maths/math.path";
  73165. /**
  73166. * A cursor which tracks a point on a path
  73167. */
  73168. export class PathCursor {
  73169. private path;
  73170. /**
  73171. * Stores path cursor callbacks for when an onchange event is triggered
  73172. */
  73173. private _onchange;
  73174. /**
  73175. * The value of the path cursor
  73176. */
  73177. value: number;
  73178. /**
  73179. * The animation array of the path cursor
  73180. */
  73181. animations: Animation[];
  73182. /**
  73183. * Initializes the path cursor
  73184. * @param path The path to track
  73185. */
  73186. constructor(path: Path2);
  73187. /**
  73188. * Gets the cursor point on the path
  73189. * @returns A point on the path cursor at the cursor location
  73190. */
  73191. getPoint(): Vector3;
  73192. /**
  73193. * Moves the cursor ahead by the step amount
  73194. * @param step The amount to move the cursor forward
  73195. * @returns This path cursor
  73196. */
  73197. moveAhead(step?: number): PathCursor;
  73198. /**
  73199. * Moves the cursor behind by the step amount
  73200. * @param step The amount to move the cursor back
  73201. * @returns This path cursor
  73202. */
  73203. moveBack(step?: number): PathCursor;
  73204. /**
  73205. * Moves the cursor by the step amount
  73206. * If the step amount is greater than one, an exception is thrown
  73207. * @param step The amount to move the cursor
  73208. * @returns This path cursor
  73209. */
  73210. move(step: number): PathCursor;
  73211. /**
  73212. * Ensures that the value is limited between zero and one
  73213. * @returns This path cursor
  73214. */
  73215. private ensureLimits;
  73216. /**
  73217. * Runs onchange callbacks on change (used by the animation engine)
  73218. * @returns This path cursor
  73219. */
  73220. private raiseOnChange;
  73221. /**
  73222. * Executes a function on change
  73223. * @param f A path cursor onchange callback
  73224. * @returns This path cursor
  73225. */
  73226. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73227. }
  73228. }
  73229. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73230. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73231. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73232. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73233. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73234. }
  73235. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73236. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73237. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73238. }
  73239. declare module "babylonjs/Engines/Processors/index" {
  73240. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73241. export * from "babylonjs/Engines/Processors/Expressions/index";
  73242. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73243. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73244. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73245. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73246. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73247. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73248. }
  73249. declare module "babylonjs/Legacy/legacy" {
  73250. import * as Babylon from "babylonjs/index";
  73251. export * from "babylonjs/index";
  73252. }
  73253. declare module "babylonjs/Shaders/blur.fragment" {
  73254. /** @hidden */
  73255. export var blurPixelShader: {
  73256. name: string;
  73257. shader: string;
  73258. };
  73259. }
  73260. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73261. /** @hidden */
  73262. export var pointCloudVertexDeclaration: {
  73263. name: string;
  73264. shader: string;
  73265. };
  73266. }
  73267. declare module "babylonjs" {
  73268. export * from "babylonjs/Legacy/legacy";
  73269. }
  73270. declare module BABYLON {
  73271. /** Alias type for value that can be null */
  73272. export type Nullable<T> = T | null;
  73273. /**
  73274. * Alias type for number that are floats
  73275. * @ignorenaming
  73276. */
  73277. export type float = number;
  73278. /**
  73279. * Alias type for number that are doubles.
  73280. * @ignorenaming
  73281. */
  73282. export type double = number;
  73283. /**
  73284. * Alias type for number that are integer
  73285. * @ignorenaming
  73286. */
  73287. export type int = number;
  73288. /** Alias type for number array or Float32Array */
  73289. export type FloatArray = number[] | Float32Array;
  73290. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73291. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73292. /**
  73293. * Alias for types that can be used by a Buffer or VertexBuffer.
  73294. */
  73295. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73296. /**
  73297. * Alias type for primitive types
  73298. * @ignorenaming
  73299. */
  73300. type Primitive = undefined | null | boolean | string | number | Function;
  73301. /**
  73302. * Type modifier to make all the properties of an object Readonly
  73303. */
  73304. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73305. /**
  73306. * Type modifier to make all the properties of an object Readonly recursively
  73307. */
  73308. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73309. /**
  73310. * Type modifier to make object properties readonly.
  73311. */
  73312. export type DeepImmutableObject<T> = {
  73313. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73314. };
  73315. /** @hidden */
  73316. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * A class serves as a medium between the observable and its observers
  73322. */
  73323. export class EventState {
  73324. /**
  73325. * Create a new EventState
  73326. * @param mask defines the mask associated with this state
  73327. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73328. * @param target defines the original target of the state
  73329. * @param currentTarget defines the current target of the state
  73330. */
  73331. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73332. /**
  73333. * Initialize the current event state
  73334. * @param mask defines the mask associated with this state
  73335. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73336. * @param target defines the original target of the state
  73337. * @param currentTarget defines the current target of the state
  73338. * @returns the current event state
  73339. */
  73340. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73341. /**
  73342. * An Observer can set this property to true to prevent subsequent observers of being notified
  73343. */
  73344. skipNextObservers: boolean;
  73345. /**
  73346. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73347. */
  73348. mask: number;
  73349. /**
  73350. * The object that originally notified the event
  73351. */
  73352. target?: any;
  73353. /**
  73354. * The current object in the bubbling phase
  73355. */
  73356. currentTarget?: any;
  73357. /**
  73358. * This will be populated with the return value of the last function that was executed.
  73359. * If it is the first function in the callback chain it will be the event data.
  73360. */
  73361. lastReturnValue?: any;
  73362. }
  73363. /**
  73364. * Represent an Observer registered to a given Observable object.
  73365. */
  73366. export class Observer<T> {
  73367. /**
  73368. * Defines the callback to call when the observer is notified
  73369. */
  73370. callback: (eventData: T, eventState: EventState) => void;
  73371. /**
  73372. * Defines the mask of the observer (used to filter notifications)
  73373. */
  73374. mask: number;
  73375. /**
  73376. * Defines the current scope used to restore the JS context
  73377. */
  73378. scope: any;
  73379. /** @hidden */
  73380. _willBeUnregistered: boolean;
  73381. /**
  73382. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73383. */
  73384. unregisterOnNextCall: boolean;
  73385. /**
  73386. * Creates a new observer
  73387. * @param callback defines the callback to call when the observer is notified
  73388. * @param mask defines the mask of the observer (used to filter notifications)
  73389. * @param scope defines the current scope used to restore the JS context
  73390. */
  73391. constructor(
  73392. /**
  73393. * Defines the callback to call when the observer is notified
  73394. */
  73395. callback: (eventData: T, eventState: EventState) => void,
  73396. /**
  73397. * Defines the mask of the observer (used to filter notifications)
  73398. */
  73399. mask: number,
  73400. /**
  73401. * Defines the current scope used to restore the JS context
  73402. */
  73403. scope?: any);
  73404. }
  73405. /**
  73406. * Represent a list of observers registered to multiple Observables object.
  73407. */
  73408. export class MultiObserver<T> {
  73409. private _observers;
  73410. private _observables;
  73411. /**
  73412. * Release associated resources
  73413. */
  73414. dispose(): void;
  73415. /**
  73416. * Raise a callback when one of the observable will notify
  73417. * @param observables defines a list of observables to watch
  73418. * @param callback defines the callback to call on notification
  73419. * @param mask defines the mask used to filter notifications
  73420. * @param scope defines the current scope used to restore the JS context
  73421. * @returns the new MultiObserver
  73422. */
  73423. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73424. }
  73425. /**
  73426. * The Observable class is a simple implementation of the Observable pattern.
  73427. *
  73428. * 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.
  73429. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73430. * 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).
  73431. * 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.
  73432. */
  73433. export class Observable<T> {
  73434. private _observers;
  73435. private _eventState;
  73436. private _onObserverAdded;
  73437. /**
  73438. * Gets the list of observers
  73439. */
  73440. get observers(): Array<Observer<T>>;
  73441. /**
  73442. * Creates a new observable
  73443. * @param onObserverAdded defines a callback to call when a new observer is added
  73444. */
  73445. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73446. /**
  73447. * Create a new Observer with the specified callback
  73448. * @param callback the callback that will be executed for that Observer
  73449. * @param mask the mask used to filter observers
  73450. * @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.
  73451. * @param scope optional scope for the callback to be called from
  73452. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73453. * @returns the new observer created for the callback
  73454. */
  73455. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73456. /**
  73457. * Create a new Observer with the specified callback and unregisters after the next notification
  73458. * @param callback the callback that will be executed for that Observer
  73459. * @returns the new observer created for the callback
  73460. */
  73461. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73462. /**
  73463. * Remove an Observer from the Observable object
  73464. * @param observer the instance of the Observer to remove
  73465. * @returns false if it doesn't belong to this Observable
  73466. */
  73467. remove(observer: Nullable<Observer<T>>): boolean;
  73468. /**
  73469. * Remove a callback from the Observable object
  73470. * @param callback the callback to remove
  73471. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73472. * @returns false if it doesn't belong to this Observable
  73473. */
  73474. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73475. private _deferUnregister;
  73476. private _remove;
  73477. /**
  73478. * Moves the observable to the top of the observer list making it get called first when notified
  73479. * @param observer the observer to move
  73480. */
  73481. makeObserverTopPriority(observer: Observer<T>): void;
  73482. /**
  73483. * Moves the observable to the bottom of the observer list making it get called last when notified
  73484. * @param observer the observer to move
  73485. */
  73486. makeObserverBottomPriority(observer: Observer<T>): void;
  73487. /**
  73488. * Notify all Observers by calling their respective callback with the given data
  73489. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73490. * @param eventData defines the data to send to all observers
  73491. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73492. * @param target defines the original target of the state
  73493. * @param currentTarget defines the current target of the state
  73494. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73495. */
  73496. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73497. /**
  73498. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73499. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73500. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73501. * and it is crucial that all callbacks will be executed.
  73502. * The order of the callbacks is kept, callbacks are not executed parallel.
  73503. *
  73504. * @param eventData The data to be sent to each callback
  73505. * @param mask is used to filter observers defaults to -1
  73506. * @param target defines the callback target (see EventState)
  73507. * @param currentTarget defines he current object in the bubbling phase
  73508. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73509. */
  73510. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73511. /**
  73512. * Notify a specific observer
  73513. * @param observer defines the observer to notify
  73514. * @param eventData defines the data to be sent to each callback
  73515. * @param mask is used to filter observers defaults to -1
  73516. */
  73517. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73518. /**
  73519. * Gets a boolean indicating if the observable has at least one observer
  73520. * @returns true is the Observable has at least one Observer registered
  73521. */
  73522. hasObservers(): boolean;
  73523. /**
  73524. * Clear the list of observers
  73525. */
  73526. clear(): void;
  73527. /**
  73528. * Clone the current observable
  73529. * @returns a new observable
  73530. */
  73531. clone(): Observable<T>;
  73532. /**
  73533. * Does this observable handles observer registered with a given mask
  73534. * @param mask defines the mask to be tested
  73535. * @return whether or not one observer registered with the given mask is handeled
  73536. **/
  73537. hasSpecificMask(mask?: number): boolean;
  73538. }
  73539. }
  73540. declare module BABYLON {
  73541. /**
  73542. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73543. * Babylon.js
  73544. */
  73545. export class DomManagement {
  73546. /**
  73547. * Checks if the window object exists
  73548. * @returns true if the window object exists
  73549. */
  73550. static IsWindowObjectExist(): boolean;
  73551. /**
  73552. * Checks if the navigator object exists
  73553. * @returns true if the navigator object exists
  73554. */
  73555. static IsNavigatorAvailable(): boolean;
  73556. /**
  73557. * Extracts text content from a DOM element hierarchy
  73558. * @param element defines the root element
  73559. * @returns a string
  73560. */
  73561. static GetDOMTextContent(element: HTMLElement): string;
  73562. }
  73563. }
  73564. declare module BABYLON {
  73565. /**
  73566. * Logger used througouht the application to allow configuration of
  73567. * the log level required for the messages.
  73568. */
  73569. export class Logger {
  73570. /**
  73571. * No log
  73572. */
  73573. static readonly NoneLogLevel: number;
  73574. /**
  73575. * Only message logs
  73576. */
  73577. static readonly MessageLogLevel: number;
  73578. /**
  73579. * Only warning logs
  73580. */
  73581. static readonly WarningLogLevel: number;
  73582. /**
  73583. * Only error logs
  73584. */
  73585. static readonly ErrorLogLevel: number;
  73586. /**
  73587. * All logs
  73588. */
  73589. static readonly AllLogLevel: number;
  73590. private static _LogCache;
  73591. /**
  73592. * Gets a value indicating the number of loading errors
  73593. * @ignorenaming
  73594. */
  73595. static errorsCount: number;
  73596. /**
  73597. * Callback called when a new log is added
  73598. */
  73599. static OnNewCacheEntry: (entry: string) => void;
  73600. private static _AddLogEntry;
  73601. private static _FormatMessage;
  73602. private static _LogDisabled;
  73603. private static _LogEnabled;
  73604. private static _WarnDisabled;
  73605. private static _WarnEnabled;
  73606. private static _ErrorDisabled;
  73607. private static _ErrorEnabled;
  73608. /**
  73609. * Log a message to the console
  73610. */
  73611. static Log: (message: string) => void;
  73612. /**
  73613. * Write a warning message to the console
  73614. */
  73615. static Warn: (message: string) => void;
  73616. /**
  73617. * Write an error message to the console
  73618. */
  73619. static Error: (message: string) => void;
  73620. /**
  73621. * Gets current log cache (list of logs)
  73622. */
  73623. static get LogCache(): string;
  73624. /**
  73625. * Clears the log cache
  73626. */
  73627. static ClearLogCache(): void;
  73628. /**
  73629. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73630. */
  73631. static set LogLevels(level: number);
  73632. }
  73633. }
  73634. declare module BABYLON {
  73635. /** @hidden */
  73636. export class _TypeStore {
  73637. /** @hidden */
  73638. static RegisteredTypes: {
  73639. [key: string]: Object;
  73640. };
  73641. /** @hidden */
  73642. static GetClass(fqdn: string): any;
  73643. }
  73644. }
  73645. declare module BABYLON {
  73646. /**
  73647. * Helper to manipulate strings
  73648. */
  73649. export class StringTools {
  73650. /**
  73651. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73652. * @param str Source string
  73653. * @param suffix Suffix to search for in the source string
  73654. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73655. */
  73656. static EndsWith(str: string, suffix: string): boolean;
  73657. /**
  73658. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73659. * @param str Source string
  73660. * @param suffix Suffix to search for in the source string
  73661. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73662. */
  73663. static StartsWith(str: string, suffix: string): boolean;
  73664. /**
  73665. * Decodes a buffer into a string
  73666. * @param buffer The buffer to decode
  73667. * @returns The decoded string
  73668. */
  73669. static Decode(buffer: Uint8Array | Uint16Array): string;
  73670. /**
  73671. * Encode a buffer to a base64 string
  73672. * @param buffer defines the buffer to encode
  73673. * @returns the encoded string
  73674. */
  73675. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73676. }
  73677. }
  73678. declare module BABYLON {
  73679. /**
  73680. * Class containing a set of static utilities functions for deep copy.
  73681. */
  73682. export class DeepCopier {
  73683. /**
  73684. * Tries to copy an object by duplicating every property
  73685. * @param source defines the source object
  73686. * @param destination defines the target object
  73687. * @param doNotCopyList defines a list of properties to avoid
  73688. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73689. */
  73690. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73691. }
  73692. }
  73693. declare module BABYLON {
  73694. /**
  73695. * Class containing a set of static utilities functions for precision date
  73696. */
  73697. export class PrecisionDate {
  73698. /**
  73699. * Gets either window.performance.now() if supported or Date.now() else
  73700. */
  73701. static get Now(): number;
  73702. }
  73703. }
  73704. declare module BABYLON {
  73705. /** @hidden */
  73706. export class _DevTools {
  73707. static WarnImport(name: string): string;
  73708. }
  73709. }
  73710. declare module BABYLON {
  73711. /**
  73712. * Interface used to define the mechanism to get data from the network
  73713. */
  73714. export interface IWebRequest {
  73715. /**
  73716. * Returns client's response url
  73717. */
  73718. responseURL: string;
  73719. /**
  73720. * Returns client's status
  73721. */
  73722. status: number;
  73723. /**
  73724. * Returns client's status as a text
  73725. */
  73726. statusText: string;
  73727. }
  73728. }
  73729. declare module BABYLON {
  73730. /**
  73731. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73732. */
  73733. export class WebRequest implements IWebRequest {
  73734. private _xhr;
  73735. /**
  73736. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73737. * i.e. when loading files, where the server/service expects an Authorization header
  73738. */
  73739. static CustomRequestHeaders: {
  73740. [key: string]: string;
  73741. };
  73742. /**
  73743. * Add callback functions in this array to update all the requests before they get sent to the network
  73744. */
  73745. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73746. private _injectCustomRequestHeaders;
  73747. /**
  73748. * Gets or sets a function to be called when loading progress changes
  73749. */
  73750. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73751. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73752. /**
  73753. * Returns client's state
  73754. */
  73755. get readyState(): number;
  73756. /**
  73757. * Returns client's status
  73758. */
  73759. get status(): number;
  73760. /**
  73761. * Returns client's status as a text
  73762. */
  73763. get statusText(): string;
  73764. /**
  73765. * Returns client's response
  73766. */
  73767. get response(): any;
  73768. /**
  73769. * Returns client's response url
  73770. */
  73771. get responseURL(): string;
  73772. /**
  73773. * Returns client's response as text
  73774. */
  73775. get responseText(): string;
  73776. /**
  73777. * Gets or sets the expected response type
  73778. */
  73779. get responseType(): XMLHttpRequestResponseType;
  73780. set responseType(value: XMLHttpRequestResponseType);
  73781. /** @hidden */
  73782. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73783. /** @hidden */
  73784. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73785. /**
  73786. * Cancels any network activity
  73787. */
  73788. abort(): void;
  73789. /**
  73790. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73791. * @param body defines an optional request body
  73792. */
  73793. send(body?: Document | BodyInit | null): void;
  73794. /**
  73795. * Sets the request method, request URL
  73796. * @param method defines the method to use (GET, POST, etc..)
  73797. * @param url defines the url to connect with
  73798. */
  73799. open(method: string, url: string): void;
  73800. /**
  73801. * Sets the value of a request header.
  73802. * @param name The name of the header whose value is to be set
  73803. * @param value The value to set as the body of the header
  73804. */
  73805. setRequestHeader(name: string, value: string): void;
  73806. /**
  73807. * Get the string containing the text of a particular header's value.
  73808. * @param name The name of the header
  73809. * @returns The string containing the text of the given header name
  73810. */
  73811. getResponseHeader(name: string): Nullable<string>;
  73812. }
  73813. }
  73814. declare module BABYLON {
  73815. /**
  73816. * File request interface
  73817. */
  73818. export interface IFileRequest {
  73819. /**
  73820. * Raised when the request is complete (success or error).
  73821. */
  73822. onCompleteObservable: Observable<IFileRequest>;
  73823. /**
  73824. * Aborts the request for a file.
  73825. */
  73826. abort: () => void;
  73827. }
  73828. }
  73829. declare module BABYLON {
  73830. /**
  73831. * Define options used to create a render target texture
  73832. */
  73833. export class RenderTargetCreationOptions {
  73834. /**
  73835. * Specifies is mipmaps must be generated
  73836. */
  73837. generateMipMaps?: boolean;
  73838. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73839. generateDepthBuffer?: boolean;
  73840. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73841. generateStencilBuffer?: boolean;
  73842. /** Defines texture type (int by default) */
  73843. type?: number;
  73844. /** Defines sampling mode (trilinear by default) */
  73845. samplingMode?: number;
  73846. /** Defines format (RGBA by default) */
  73847. format?: number;
  73848. }
  73849. }
  73850. declare module BABYLON {
  73851. /** Defines the cross module used constants to avoid circular dependncies */
  73852. export class Constants {
  73853. /** Defines that alpha blending is disabled */
  73854. static readonly ALPHA_DISABLE: number;
  73855. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73856. static readonly ALPHA_ADD: number;
  73857. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73858. static readonly ALPHA_COMBINE: number;
  73859. /** Defines that alpha blending is DEST - SRC * DEST */
  73860. static readonly ALPHA_SUBTRACT: number;
  73861. /** Defines that alpha blending is SRC * DEST */
  73862. static readonly ALPHA_MULTIPLY: number;
  73863. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73864. static readonly ALPHA_MAXIMIZED: number;
  73865. /** Defines that alpha blending is SRC + DEST */
  73866. static readonly ALPHA_ONEONE: number;
  73867. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73868. static readonly ALPHA_PREMULTIPLIED: number;
  73869. /**
  73870. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73871. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73872. */
  73873. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73874. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73875. static readonly ALPHA_INTERPOLATE: number;
  73876. /**
  73877. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73878. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73879. */
  73880. static readonly ALPHA_SCREENMODE: number;
  73881. /**
  73882. * Defines that alpha blending is SRC + DST
  73883. * Alpha will be set to SRC ALPHA + DST ALPHA
  73884. */
  73885. static readonly ALPHA_ONEONE_ONEONE: number;
  73886. /**
  73887. * Defines that alpha blending is SRC * DST ALPHA + DST
  73888. * Alpha will be set to 0
  73889. */
  73890. static readonly ALPHA_ALPHATOCOLOR: number;
  73891. /**
  73892. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73893. */
  73894. static readonly ALPHA_REVERSEONEMINUS: number;
  73895. /**
  73896. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73897. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73898. */
  73899. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73900. /**
  73901. * Defines that alpha blending is SRC + DST
  73902. * Alpha will be set to SRC ALPHA
  73903. */
  73904. static readonly ALPHA_ONEONE_ONEZERO: number;
  73905. /**
  73906. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73907. * Alpha will be set to DST ALPHA
  73908. */
  73909. static readonly ALPHA_EXCLUSION: number;
  73910. /** Defines that alpha blending equation a SUM */
  73911. static readonly ALPHA_EQUATION_ADD: number;
  73912. /** Defines that alpha blending equation a SUBSTRACTION */
  73913. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73914. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73915. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73916. /** Defines that alpha blending equation a MAX operation */
  73917. static readonly ALPHA_EQUATION_MAX: number;
  73918. /** Defines that alpha blending equation a MIN operation */
  73919. static readonly ALPHA_EQUATION_MIN: number;
  73920. /**
  73921. * Defines that alpha blending equation a DARKEN operation:
  73922. * It takes the min of the src and sums the alpha channels.
  73923. */
  73924. static readonly ALPHA_EQUATION_DARKEN: number;
  73925. /** Defines that the ressource is not delayed*/
  73926. static readonly DELAYLOADSTATE_NONE: number;
  73927. /** Defines that the ressource was successfully delay loaded */
  73928. static readonly DELAYLOADSTATE_LOADED: number;
  73929. /** Defines that the ressource is currently delay loading */
  73930. static readonly DELAYLOADSTATE_LOADING: number;
  73931. /** Defines that the ressource is delayed and has not started loading */
  73932. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73934. static readonly NEVER: number;
  73935. /** 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 */
  73936. static readonly ALWAYS: number;
  73937. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73938. static readonly LESS: number;
  73939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73940. static readonly EQUAL: number;
  73941. /** 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 */
  73942. static readonly LEQUAL: number;
  73943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73944. static readonly GREATER: number;
  73945. /** 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 */
  73946. static readonly GEQUAL: number;
  73947. /** 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 */
  73948. static readonly NOTEQUAL: number;
  73949. /** Passed to stencilOperation to specify that stencil value must be kept */
  73950. static readonly KEEP: number;
  73951. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73952. static readonly REPLACE: number;
  73953. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73954. static readonly INCR: number;
  73955. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73956. static readonly DECR: number;
  73957. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73958. static readonly INVERT: number;
  73959. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73960. static readonly INCR_WRAP: number;
  73961. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73962. static readonly DECR_WRAP: number;
  73963. /** Texture is not repeating outside of 0..1 UVs */
  73964. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73965. /** Texture is repeating outside of 0..1 UVs */
  73966. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73967. /** Texture is repeating and mirrored */
  73968. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73969. /** ALPHA */
  73970. static readonly TEXTUREFORMAT_ALPHA: number;
  73971. /** LUMINANCE */
  73972. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73973. /** LUMINANCE_ALPHA */
  73974. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73975. /** RGB */
  73976. static readonly TEXTUREFORMAT_RGB: number;
  73977. /** RGBA */
  73978. static readonly TEXTUREFORMAT_RGBA: number;
  73979. /** RED */
  73980. static readonly TEXTUREFORMAT_RED: number;
  73981. /** RED (2nd reference) */
  73982. static readonly TEXTUREFORMAT_R: number;
  73983. /** RG */
  73984. static readonly TEXTUREFORMAT_RG: number;
  73985. /** RED_INTEGER */
  73986. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73987. /** RED_INTEGER (2nd reference) */
  73988. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73989. /** RG_INTEGER */
  73990. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73991. /** RGB_INTEGER */
  73992. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73993. /** RGBA_INTEGER */
  73994. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73995. /** UNSIGNED_BYTE */
  73996. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73997. /** UNSIGNED_BYTE (2nd reference) */
  73998. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73999. /** FLOAT */
  74000. static readonly TEXTURETYPE_FLOAT: number;
  74001. /** HALF_FLOAT */
  74002. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74003. /** BYTE */
  74004. static readonly TEXTURETYPE_BYTE: number;
  74005. /** SHORT */
  74006. static readonly TEXTURETYPE_SHORT: number;
  74007. /** UNSIGNED_SHORT */
  74008. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74009. /** INT */
  74010. static readonly TEXTURETYPE_INT: number;
  74011. /** UNSIGNED_INT */
  74012. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74013. /** UNSIGNED_SHORT_4_4_4_4 */
  74014. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74015. /** UNSIGNED_SHORT_5_5_5_1 */
  74016. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74017. /** UNSIGNED_SHORT_5_6_5 */
  74018. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74019. /** UNSIGNED_INT_2_10_10_10_REV */
  74020. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74021. /** UNSIGNED_INT_24_8 */
  74022. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74023. /** UNSIGNED_INT_10F_11F_11F_REV */
  74024. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74025. /** UNSIGNED_INT_5_9_9_9_REV */
  74026. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74027. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74028. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74029. /** nearest is mag = nearest and min = nearest and no mip */
  74030. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74031. /** mag = nearest and min = nearest and mip = none */
  74032. static readonly TEXTURE_NEAREST_NEAREST: number;
  74033. /** Bilinear is mag = linear and min = linear and no mip */
  74034. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74035. /** mag = linear and min = linear and mip = none */
  74036. static readonly TEXTURE_LINEAR_LINEAR: number;
  74037. /** Trilinear is mag = linear and min = linear and mip = linear */
  74038. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74039. /** Trilinear is mag = linear and min = linear and mip = linear */
  74040. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74041. /** mag = nearest and min = nearest and mip = nearest */
  74042. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74043. /** mag = nearest and min = linear and mip = nearest */
  74044. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74045. /** mag = nearest and min = linear and mip = linear */
  74046. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74047. /** mag = nearest and min = linear and mip = none */
  74048. static readonly TEXTURE_NEAREST_LINEAR: number;
  74049. /** nearest is mag = nearest and min = nearest and mip = linear */
  74050. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74051. /** mag = linear and min = nearest and mip = nearest */
  74052. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74053. /** mag = linear and min = nearest and mip = linear */
  74054. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74055. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74056. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74057. /** mag = linear and min = nearest and mip = none */
  74058. static readonly TEXTURE_LINEAR_NEAREST: number;
  74059. /** Explicit coordinates mode */
  74060. static readonly TEXTURE_EXPLICIT_MODE: number;
  74061. /** Spherical coordinates mode */
  74062. static readonly TEXTURE_SPHERICAL_MODE: number;
  74063. /** Planar coordinates mode */
  74064. static readonly TEXTURE_PLANAR_MODE: number;
  74065. /** Cubic coordinates mode */
  74066. static readonly TEXTURE_CUBIC_MODE: number;
  74067. /** Projection coordinates mode */
  74068. static readonly TEXTURE_PROJECTION_MODE: number;
  74069. /** Skybox coordinates mode */
  74070. static readonly TEXTURE_SKYBOX_MODE: number;
  74071. /** Inverse Cubic coordinates mode */
  74072. static readonly TEXTURE_INVCUBIC_MODE: number;
  74073. /** Equirectangular coordinates mode */
  74074. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74075. /** Equirectangular Fixed coordinates mode */
  74076. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74077. /** Equirectangular Fixed Mirrored coordinates mode */
  74078. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74079. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74080. static readonly SCALEMODE_FLOOR: number;
  74081. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74082. static readonly SCALEMODE_NEAREST: number;
  74083. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74084. static readonly SCALEMODE_CEILING: number;
  74085. /**
  74086. * The dirty texture flag value
  74087. */
  74088. static readonly MATERIAL_TextureDirtyFlag: number;
  74089. /**
  74090. * The dirty light flag value
  74091. */
  74092. static readonly MATERIAL_LightDirtyFlag: number;
  74093. /**
  74094. * The dirty fresnel flag value
  74095. */
  74096. static readonly MATERIAL_FresnelDirtyFlag: number;
  74097. /**
  74098. * The dirty attribute flag value
  74099. */
  74100. static readonly MATERIAL_AttributesDirtyFlag: number;
  74101. /**
  74102. * The dirty misc flag value
  74103. */
  74104. static readonly MATERIAL_MiscDirtyFlag: number;
  74105. /**
  74106. * The all dirty flag value
  74107. */
  74108. static readonly MATERIAL_AllDirtyFlag: number;
  74109. /**
  74110. * Returns the triangle fill mode
  74111. */
  74112. static readonly MATERIAL_TriangleFillMode: number;
  74113. /**
  74114. * Returns the wireframe mode
  74115. */
  74116. static readonly MATERIAL_WireFrameFillMode: number;
  74117. /**
  74118. * Returns the point fill mode
  74119. */
  74120. static readonly MATERIAL_PointFillMode: number;
  74121. /**
  74122. * Returns the point list draw mode
  74123. */
  74124. static readonly MATERIAL_PointListDrawMode: number;
  74125. /**
  74126. * Returns the line list draw mode
  74127. */
  74128. static readonly MATERIAL_LineListDrawMode: number;
  74129. /**
  74130. * Returns the line loop draw mode
  74131. */
  74132. static readonly MATERIAL_LineLoopDrawMode: number;
  74133. /**
  74134. * Returns the line strip draw mode
  74135. */
  74136. static readonly MATERIAL_LineStripDrawMode: number;
  74137. /**
  74138. * Returns the triangle strip draw mode
  74139. */
  74140. static readonly MATERIAL_TriangleStripDrawMode: number;
  74141. /**
  74142. * Returns the triangle fan draw mode
  74143. */
  74144. static readonly MATERIAL_TriangleFanDrawMode: number;
  74145. /**
  74146. * Stores the clock-wise side orientation
  74147. */
  74148. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74149. /**
  74150. * Stores the counter clock-wise side orientation
  74151. */
  74152. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74153. /**
  74154. * Nothing
  74155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74156. */
  74157. static readonly ACTION_NothingTrigger: number;
  74158. /**
  74159. * On pick
  74160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74161. */
  74162. static readonly ACTION_OnPickTrigger: number;
  74163. /**
  74164. * On left pick
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74166. */
  74167. static readonly ACTION_OnLeftPickTrigger: number;
  74168. /**
  74169. * On right pick
  74170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74171. */
  74172. static readonly ACTION_OnRightPickTrigger: number;
  74173. /**
  74174. * On center pick
  74175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74176. */
  74177. static readonly ACTION_OnCenterPickTrigger: number;
  74178. /**
  74179. * On pick down
  74180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74181. */
  74182. static readonly ACTION_OnPickDownTrigger: number;
  74183. /**
  74184. * On double pick
  74185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74186. */
  74187. static readonly ACTION_OnDoublePickTrigger: number;
  74188. /**
  74189. * On pick up
  74190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74191. */
  74192. static readonly ACTION_OnPickUpTrigger: number;
  74193. /**
  74194. * On pick out.
  74195. * This trigger will only be raised if you also declared a OnPickDown
  74196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74197. */
  74198. static readonly ACTION_OnPickOutTrigger: number;
  74199. /**
  74200. * On long press
  74201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74202. */
  74203. static readonly ACTION_OnLongPressTrigger: number;
  74204. /**
  74205. * On pointer over
  74206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74207. */
  74208. static readonly ACTION_OnPointerOverTrigger: number;
  74209. /**
  74210. * On pointer out
  74211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74212. */
  74213. static readonly ACTION_OnPointerOutTrigger: number;
  74214. /**
  74215. * On every frame
  74216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74217. */
  74218. static readonly ACTION_OnEveryFrameTrigger: number;
  74219. /**
  74220. * On intersection enter
  74221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74222. */
  74223. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74224. /**
  74225. * On intersection exit
  74226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74227. */
  74228. static readonly ACTION_OnIntersectionExitTrigger: number;
  74229. /**
  74230. * On key down
  74231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74232. */
  74233. static readonly ACTION_OnKeyDownTrigger: number;
  74234. /**
  74235. * On key up
  74236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74237. */
  74238. static readonly ACTION_OnKeyUpTrigger: number;
  74239. /**
  74240. * Billboard mode will only apply to Y axis
  74241. */
  74242. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74243. /**
  74244. * Billboard mode will apply to all axes
  74245. */
  74246. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74247. /**
  74248. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74249. */
  74250. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74251. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74252. * Test order :
  74253. * Is the bounding sphere outside the frustum ?
  74254. * If not, are the bounding box vertices outside the frustum ?
  74255. * It not, then the cullable object is in the frustum.
  74256. */
  74257. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74258. /** Culling strategy : Bounding Sphere Only.
  74259. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74260. * It's also less accurate than the standard because some not visible objects can still be selected.
  74261. * Test : is the bounding sphere outside the frustum ?
  74262. * If not, then the cullable object is in the frustum.
  74263. */
  74264. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74265. /** Culling strategy : Optimistic Inclusion.
  74266. * This in an inclusion test first, then the standard exclusion test.
  74267. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74268. * 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.
  74269. * Anyway, it's as accurate as the standard strategy.
  74270. * Test :
  74271. * Is the cullable object bounding sphere center in the frustum ?
  74272. * If not, apply the default culling strategy.
  74273. */
  74274. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74275. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74276. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74277. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74278. * 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.
  74279. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74280. * Test :
  74281. * Is the cullable object bounding sphere center in the frustum ?
  74282. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74283. */
  74284. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74285. /**
  74286. * No logging while loading
  74287. */
  74288. static readonly SCENELOADER_NO_LOGGING: number;
  74289. /**
  74290. * Minimal logging while loading
  74291. */
  74292. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74293. /**
  74294. * Summary logging while loading
  74295. */
  74296. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74297. /**
  74298. * Detailled logging while loading
  74299. */
  74300. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74301. }
  74302. }
  74303. declare module BABYLON {
  74304. /**
  74305. * This represents the required contract to create a new type of texture loader.
  74306. */
  74307. export interface IInternalTextureLoader {
  74308. /**
  74309. * Defines wether the loader supports cascade loading the different faces.
  74310. */
  74311. supportCascades: boolean;
  74312. /**
  74313. * This returns if the loader support the current file information.
  74314. * @param extension defines the file extension of the file being loaded
  74315. * @returns true if the loader can load the specified file
  74316. */
  74317. canLoad(extension: string): boolean;
  74318. /**
  74319. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74320. * @param data contains the texture data
  74321. * @param texture defines the BabylonJS internal texture
  74322. * @param createPolynomials will be true if polynomials have been requested
  74323. * @param onLoad defines the callback to trigger once the texture is ready
  74324. * @param onError defines the callback to trigger in case of error
  74325. */
  74326. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74327. /**
  74328. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74329. * @param data contains the texture data
  74330. * @param texture defines the BabylonJS internal texture
  74331. * @param callback defines the method to call once ready to upload
  74332. */
  74333. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74334. }
  74335. }
  74336. declare module BABYLON {
  74337. /**
  74338. * Class used to store and describe the pipeline context associated with an effect
  74339. */
  74340. export interface IPipelineContext {
  74341. /**
  74342. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74343. */
  74344. isAsync: boolean;
  74345. /**
  74346. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74347. */
  74348. isReady: boolean;
  74349. /** @hidden */
  74350. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74351. }
  74352. }
  74353. declare module BABYLON {
  74354. /**
  74355. * Class used to store gfx data (like WebGLBuffer)
  74356. */
  74357. export class DataBuffer {
  74358. /**
  74359. * Gets or sets the number of objects referencing this buffer
  74360. */
  74361. references: number;
  74362. /** Gets or sets the size of the underlying buffer */
  74363. capacity: number;
  74364. /**
  74365. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74366. */
  74367. is32Bits: boolean;
  74368. /**
  74369. * Gets the underlying buffer
  74370. */
  74371. get underlyingResource(): any;
  74372. }
  74373. }
  74374. declare module BABYLON {
  74375. /** @hidden */
  74376. export interface IShaderProcessor {
  74377. attributeProcessor?: (attribute: string) => string;
  74378. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74379. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74380. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74381. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74382. lineProcessor?: (line: string, isFragment: boolean) => string;
  74383. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74384. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74385. }
  74386. }
  74387. declare module BABYLON {
  74388. /** @hidden */
  74389. export interface ProcessingOptions {
  74390. defines: string[];
  74391. indexParameters: any;
  74392. isFragment: boolean;
  74393. shouldUseHighPrecisionShader: boolean;
  74394. supportsUniformBuffers: boolean;
  74395. shadersRepository: string;
  74396. includesShadersStore: {
  74397. [key: string]: string;
  74398. };
  74399. processor?: IShaderProcessor;
  74400. version: string;
  74401. platformName: string;
  74402. lookForClosingBracketForUniformBuffer?: boolean;
  74403. }
  74404. }
  74405. declare module BABYLON {
  74406. /** @hidden */
  74407. export class ShaderCodeNode {
  74408. line: string;
  74409. children: ShaderCodeNode[];
  74410. additionalDefineKey?: string;
  74411. additionalDefineValue?: string;
  74412. isValid(preprocessors: {
  74413. [key: string]: string;
  74414. }): boolean;
  74415. process(preprocessors: {
  74416. [key: string]: string;
  74417. }, options: ProcessingOptions): string;
  74418. }
  74419. }
  74420. declare module BABYLON {
  74421. /** @hidden */
  74422. export class ShaderCodeCursor {
  74423. private _lines;
  74424. lineIndex: number;
  74425. get currentLine(): string;
  74426. get canRead(): boolean;
  74427. set lines(value: string[]);
  74428. }
  74429. }
  74430. declare module BABYLON {
  74431. /** @hidden */
  74432. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74433. process(preprocessors: {
  74434. [key: string]: string;
  74435. }, options: ProcessingOptions): string;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /** @hidden */
  74440. export class ShaderDefineExpression {
  74441. isTrue(preprocessors: {
  74442. [key: string]: string;
  74443. }): boolean;
  74444. }
  74445. }
  74446. declare module BABYLON {
  74447. /** @hidden */
  74448. export class ShaderCodeTestNode extends ShaderCodeNode {
  74449. testExpression: ShaderDefineExpression;
  74450. isValid(preprocessors: {
  74451. [key: string]: string;
  74452. }): boolean;
  74453. }
  74454. }
  74455. declare module BABYLON {
  74456. /** @hidden */
  74457. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74458. define: string;
  74459. not: boolean;
  74460. constructor(define: string, not?: boolean);
  74461. isTrue(preprocessors: {
  74462. [key: string]: string;
  74463. }): boolean;
  74464. }
  74465. }
  74466. declare module BABYLON {
  74467. /** @hidden */
  74468. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74469. leftOperand: ShaderDefineExpression;
  74470. rightOperand: ShaderDefineExpression;
  74471. isTrue(preprocessors: {
  74472. [key: string]: string;
  74473. }): boolean;
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. /** @hidden */
  74478. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74479. leftOperand: ShaderDefineExpression;
  74480. rightOperand: ShaderDefineExpression;
  74481. isTrue(preprocessors: {
  74482. [key: string]: string;
  74483. }): boolean;
  74484. }
  74485. }
  74486. declare module BABYLON {
  74487. /** @hidden */
  74488. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74489. define: string;
  74490. operand: string;
  74491. testValue: string;
  74492. constructor(define: string, operand: string, testValue: string);
  74493. isTrue(preprocessors: {
  74494. [key: string]: string;
  74495. }): boolean;
  74496. }
  74497. }
  74498. declare module BABYLON {
  74499. /**
  74500. * Class used to enable access to offline support
  74501. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74502. */
  74503. export interface IOfflineProvider {
  74504. /**
  74505. * Gets a boolean indicating if scene must be saved in the database
  74506. */
  74507. enableSceneOffline: boolean;
  74508. /**
  74509. * Gets a boolean indicating if textures must be saved in the database
  74510. */
  74511. enableTexturesOffline: boolean;
  74512. /**
  74513. * Open the offline support and make it available
  74514. * @param successCallback defines the callback to call on success
  74515. * @param errorCallback defines the callback to call on error
  74516. */
  74517. open(successCallback: () => void, errorCallback: () => void): void;
  74518. /**
  74519. * Loads an image from the offline support
  74520. * @param url defines the url to load from
  74521. * @param image defines the target DOM image
  74522. */
  74523. loadImage(url: string, image: HTMLImageElement): void;
  74524. /**
  74525. * Loads a file from offline support
  74526. * @param url defines the URL to load from
  74527. * @param sceneLoaded defines a callback to call on success
  74528. * @param progressCallBack defines a callback to call when progress changed
  74529. * @param errorCallback defines a callback to call on error
  74530. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74531. */
  74532. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /**
  74537. * Class used to help managing file picking and drag'n'drop
  74538. * File Storage
  74539. */
  74540. export class FilesInputStore {
  74541. /**
  74542. * List of files ready to be loaded
  74543. */
  74544. static FilesToLoad: {
  74545. [key: string]: File;
  74546. };
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /**
  74551. * Class used to define a retry strategy when error happens while loading assets
  74552. */
  74553. export class RetryStrategy {
  74554. /**
  74555. * Function used to defines an exponential back off strategy
  74556. * @param maxRetries defines the maximum number of retries (3 by default)
  74557. * @param baseInterval defines the interval between retries
  74558. * @returns the strategy function to use
  74559. */
  74560. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74561. }
  74562. }
  74563. declare module BABYLON {
  74564. /**
  74565. * @ignore
  74566. * Application error to support additional information when loading a file
  74567. */
  74568. export abstract class BaseError extends Error {
  74569. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /** @ignore */
  74574. export class LoadFileError extends BaseError {
  74575. request?: WebRequest;
  74576. file?: File;
  74577. /**
  74578. * Creates a new LoadFileError
  74579. * @param message defines the message of the error
  74580. * @param request defines the optional web request
  74581. * @param file defines the optional file
  74582. */
  74583. constructor(message: string, object?: WebRequest | File);
  74584. }
  74585. /** @ignore */
  74586. export class RequestFileError extends BaseError {
  74587. request: WebRequest;
  74588. /**
  74589. * Creates a new LoadFileError
  74590. * @param message defines the message of the error
  74591. * @param request defines the optional web request
  74592. */
  74593. constructor(message: string, request: WebRequest);
  74594. }
  74595. /** @ignore */
  74596. export class ReadFileError extends BaseError {
  74597. file: File;
  74598. /**
  74599. * Creates a new ReadFileError
  74600. * @param message defines the message of the error
  74601. * @param file defines the optional file
  74602. */
  74603. constructor(message: string, file: File);
  74604. }
  74605. /**
  74606. * @hidden
  74607. */
  74608. export class FileTools {
  74609. /**
  74610. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74611. */
  74612. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74613. /**
  74614. * Gets or sets the base URL to use to load assets
  74615. */
  74616. static BaseUrl: string;
  74617. /**
  74618. * Default behaviour for cors in the application.
  74619. * It can be a string if the expected behavior is identical in the entire app.
  74620. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74621. */
  74622. static CorsBehavior: string | ((url: string | string[]) => string);
  74623. /**
  74624. * Gets or sets a function used to pre-process url before using them to load assets
  74625. */
  74626. static PreprocessUrl: (url: string) => string;
  74627. /**
  74628. * Removes unwanted characters from an url
  74629. * @param url defines the url to clean
  74630. * @returns the cleaned url
  74631. */
  74632. private static _CleanUrl;
  74633. /**
  74634. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74635. * @param url define the url we are trying
  74636. * @param element define the dom element where to configure the cors policy
  74637. */
  74638. static SetCorsBehavior(url: string | string[], element: {
  74639. crossOrigin: string | null;
  74640. }): void;
  74641. /**
  74642. * Loads an image as an HTMLImageElement.
  74643. * @param input url string, ArrayBuffer, or Blob to load
  74644. * @param onLoad callback called when the image successfully loads
  74645. * @param onError callback called when the image fails to load
  74646. * @param offlineProvider offline provider for caching
  74647. * @param mimeType optional mime type
  74648. * @returns the HTMLImageElement of the loaded image
  74649. */
  74650. 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>;
  74651. /**
  74652. * Reads a file from a File object
  74653. * @param file defines the file to load
  74654. * @param onSuccess defines the callback to call when data is loaded
  74655. * @param onProgress defines the callback to call during loading process
  74656. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74657. * @param onError defines the callback to call when an error occurs
  74658. * @returns a file request object
  74659. */
  74660. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74661. /**
  74662. * Loads a file from a url
  74663. * @param url url to load
  74664. * @param onSuccess callback called when the file successfully loads
  74665. * @param onProgress callback called while file is loading (if the server supports this mode)
  74666. * @param offlineProvider defines the offline provider for caching
  74667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74668. * @param onError callback called when the file fails to load
  74669. * @returns a file request object
  74670. */
  74671. 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;
  74672. /**
  74673. * Loads a file
  74674. * @param url url to load
  74675. * @param onSuccess callback called when the file successfully loads
  74676. * @param onProgress callback called while file is loading (if the server supports this mode)
  74677. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74678. * @param onError callback called when the file fails to load
  74679. * @param onOpened callback called when the web request is opened
  74680. * @returns a file request object
  74681. */
  74682. 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;
  74683. /**
  74684. * Checks if the loaded document was accessed via `file:`-Protocol.
  74685. * @returns boolean
  74686. */
  74687. static IsFileURL(): boolean;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /** @hidden */
  74692. export class ShaderProcessor {
  74693. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74694. private static _ProcessPrecision;
  74695. private static _ExtractOperation;
  74696. private static _BuildSubExpression;
  74697. private static _BuildExpression;
  74698. private static _MoveCursorWithinIf;
  74699. private static _MoveCursor;
  74700. private static _EvaluatePreProcessors;
  74701. private static _PreparePreProcessors;
  74702. private static _ProcessShaderConversion;
  74703. private static _ProcessIncludes;
  74704. /**
  74705. * Loads a file from a url
  74706. * @param url url to load
  74707. * @param onSuccess callback called when the file successfully loads
  74708. * @param onProgress callback called while file is loading (if the server supports this mode)
  74709. * @param offlineProvider defines the offline provider for caching
  74710. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74711. * @param onError callback called when the file fails to load
  74712. * @returns a file request object
  74713. * @hidden
  74714. */
  74715. 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;
  74716. }
  74717. }
  74718. declare module BABYLON {
  74719. /**
  74720. * @hidden
  74721. */
  74722. export interface IColor4Like {
  74723. r: float;
  74724. g: float;
  74725. b: float;
  74726. a: float;
  74727. }
  74728. /**
  74729. * @hidden
  74730. */
  74731. export interface IColor3Like {
  74732. r: float;
  74733. g: float;
  74734. b: float;
  74735. }
  74736. /**
  74737. * @hidden
  74738. */
  74739. export interface IVector4Like {
  74740. x: float;
  74741. y: float;
  74742. z: float;
  74743. w: float;
  74744. }
  74745. /**
  74746. * @hidden
  74747. */
  74748. export interface IVector3Like {
  74749. x: float;
  74750. y: float;
  74751. z: float;
  74752. }
  74753. /**
  74754. * @hidden
  74755. */
  74756. export interface IVector2Like {
  74757. x: float;
  74758. y: float;
  74759. }
  74760. /**
  74761. * @hidden
  74762. */
  74763. export interface IMatrixLike {
  74764. toArray(): DeepImmutable<Float32Array>;
  74765. updateFlag: int;
  74766. }
  74767. /**
  74768. * @hidden
  74769. */
  74770. export interface IViewportLike {
  74771. x: float;
  74772. y: float;
  74773. width: float;
  74774. height: float;
  74775. }
  74776. /**
  74777. * @hidden
  74778. */
  74779. export interface IPlaneLike {
  74780. normal: IVector3Like;
  74781. d: float;
  74782. normalize(): void;
  74783. }
  74784. }
  74785. declare module BABYLON {
  74786. /**
  74787. * Interface used to define common properties for effect fallbacks
  74788. */
  74789. export interface IEffectFallbacks {
  74790. /**
  74791. * Removes the defines that should be removed when falling back.
  74792. * @param currentDefines defines the current define statements for the shader.
  74793. * @param effect defines the current effect we try to compile
  74794. * @returns The resulting defines with defines of the current rank removed.
  74795. */
  74796. reduce(currentDefines: string, effect: Effect): string;
  74797. /**
  74798. * Removes the fallback from the bound mesh.
  74799. */
  74800. unBindMesh(): void;
  74801. /**
  74802. * Checks to see if more fallbacks are still availible.
  74803. */
  74804. hasMoreFallbacks: boolean;
  74805. }
  74806. }
  74807. declare module BABYLON {
  74808. /**
  74809. * Class used to evalaute queries containing `and` and `or` operators
  74810. */
  74811. export class AndOrNotEvaluator {
  74812. /**
  74813. * Evaluate a query
  74814. * @param query defines the query to evaluate
  74815. * @param evaluateCallback defines the callback used to filter result
  74816. * @returns true if the query matches
  74817. */
  74818. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74819. private static _HandleParenthesisContent;
  74820. private static _SimplifyNegation;
  74821. }
  74822. }
  74823. declare module BABYLON {
  74824. /**
  74825. * Class used to store custom tags
  74826. */
  74827. export class Tags {
  74828. /**
  74829. * Adds support for tags on the given object
  74830. * @param obj defines the object to use
  74831. */
  74832. static EnableFor(obj: any): void;
  74833. /**
  74834. * Removes tags support
  74835. * @param obj defines the object to use
  74836. */
  74837. static DisableFor(obj: any): void;
  74838. /**
  74839. * Gets a boolean indicating if the given object has tags
  74840. * @param obj defines the object to use
  74841. * @returns a boolean
  74842. */
  74843. static HasTags(obj: any): boolean;
  74844. /**
  74845. * Gets the tags available on a given object
  74846. * @param obj defines the object to use
  74847. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74848. * @returns the tags
  74849. */
  74850. static GetTags(obj: any, asString?: boolean): any;
  74851. /**
  74852. * Adds tags to an object
  74853. * @param obj defines the object to use
  74854. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74855. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74856. */
  74857. static AddTagsTo(obj: any, tagsString: string): void;
  74858. /**
  74859. * @hidden
  74860. */
  74861. static _AddTagTo(obj: any, tag: string): void;
  74862. /**
  74863. * Removes specific tags from a specific object
  74864. * @param obj defines the object to use
  74865. * @param tagsString defines the tags to remove
  74866. */
  74867. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74868. /**
  74869. * @hidden
  74870. */
  74871. static _RemoveTagFrom(obj: any, tag: string): void;
  74872. /**
  74873. * Defines if tags hosted on an object match a given query
  74874. * @param obj defines the object to use
  74875. * @param tagsQuery defines the tag query
  74876. * @returns a boolean
  74877. */
  74878. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74879. }
  74880. }
  74881. declare module BABYLON {
  74882. /**
  74883. * Scalar computation library
  74884. */
  74885. export class Scalar {
  74886. /**
  74887. * Two pi constants convenient for computation.
  74888. */
  74889. static TwoPi: number;
  74890. /**
  74891. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74892. * @param a number
  74893. * @param b number
  74894. * @param epsilon (default = 1.401298E-45)
  74895. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74896. */
  74897. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74898. /**
  74899. * Returns a string : the upper case translation of the number i to hexadecimal.
  74900. * @param i number
  74901. * @returns the upper case translation of the number i to hexadecimal.
  74902. */
  74903. static ToHex(i: number): string;
  74904. /**
  74905. * Returns -1 if value is negative and +1 is value is positive.
  74906. * @param value the value
  74907. * @returns the value itself if it's equal to zero.
  74908. */
  74909. static Sign(value: number): number;
  74910. /**
  74911. * Returns the value itself if it's between min and max.
  74912. * Returns min if the value is lower than min.
  74913. * Returns max if the value is greater than max.
  74914. * @param value the value to clmap
  74915. * @param min the min value to clamp to (default: 0)
  74916. * @param max the max value to clamp to (default: 1)
  74917. * @returns the clamped value
  74918. */
  74919. static Clamp(value: number, min?: number, max?: number): number;
  74920. /**
  74921. * the log2 of value.
  74922. * @param value the value to compute log2 of
  74923. * @returns the log2 of value.
  74924. */
  74925. static Log2(value: number): number;
  74926. /**
  74927. * Loops the value, so that it is never larger than length and never smaller than 0.
  74928. *
  74929. * This is similar to the modulo operator but it works with floating point numbers.
  74930. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74931. * With t = 5 and length = 2.5, the result would be 0.0.
  74932. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74933. * @param value the value
  74934. * @param length the length
  74935. * @returns the looped value
  74936. */
  74937. static Repeat(value: number, length: number): number;
  74938. /**
  74939. * Normalize the value between 0.0 and 1.0 using min and max values
  74940. * @param value value to normalize
  74941. * @param min max to normalize between
  74942. * @param max min to normalize between
  74943. * @returns the normalized value
  74944. */
  74945. static Normalize(value: number, min: number, max: number): number;
  74946. /**
  74947. * Denormalize the value from 0.0 and 1.0 using min and max values
  74948. * @param normalized value to denormalize
  74949. * @param min max to denormalize between
  74950. * @param max min to denormalize between
  74951. * @returns the denormalized value
  74952. */
  74953. static Denormalize(normalized: number, min: number, max: number): number;
  74954. /**
  74955. * Calculates the shortest difference between two given angles given in degrees.
  74956. * @param current current angle in degrees
  74957. * @param target target angle in degrees
  74958. * @returns the delta
  74959. */
  74960. static DeltaAngle(current: number, target: number): number;
  74961. /**
  74962. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74963. * @param tx value
  74964. * @param length length
  74965. * @returns The returned value will move back and forth between 0 and length
  74966. */
  74967. static PingPong(tx: number, length: number): number;
  74968. /**
  74969. * Interpolates between min and max with smoothing at the limits.
  74970. *
  74971. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74972. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74973. * @param from from
  74974. * @param to to
  74975. * @param tx value
  74976. * @returns the smooth stepped value
  74977. */
  74978. static SmoothStep(from: number, to: number, tx: number): number;
  74979. /**
  74980. * Moves a value current towards target.
  74981. *
  74982. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74983. * Negative values of maxDelta pushes the value away from target.
  74984. * @param current current value
  74985. * @param target target value
  74986. * @param maxDelta max distance to move
  74987. * @returns resulting value
  74988. */
  74989. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74990. /**
  74991. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74992. *
  74993. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74994. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74995. * @param current current value
  74996. * @param target target value
  74997. * @param maxDelta max distance to move
  74998. * @returns resulting angle
  74999. */
  75000. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75001. /**
  75002. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75003. * @param start start value
  75004. * @param end target value
  75005. * @param amount amount to lerp between
  75006. * @returns the lerped value
  75007. */
  75008. static Lerp(start: number, end: number, amount: number): number;
  75009. /**
  75010. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75011. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75012. * @param start start value
  75013. * @param end target value
  75014. * @param amount amount to lerp between
  75015. * @returns the lerped value
  75016. */
  75017. static LerpAngle(start: number, end: number, amount: number): number;
  75018. /**
  75019. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75020. * @param a start value
  75021. * @param b target value
  75022. * @param value value between a and b
  75023. * @returns the inverseLerp value
  75024. */
  75025. static InverseLerp(a: number, b: number, value: number): number;
  75026. /**
  75027. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75028. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75029. * @param value1 spline value
  75030. * @param tangent1 spline value
  75031. * @param value2 spline value
  75032. * @param tangent2 spline value
  75033. * @param amount input value
  75034. * @returns hermite result
  75035. */
  75036. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75037. /**
  75038. * Returns a random float number between and min and max values
  75039. * @param min min value of random
  75040. * @param max max value of random
  75041. * @returns random value
  75042. */
  75043. static RandomRange(min: number, max: number): number;
  75044. /**
  75045. * This function returns percentage of a number in a given range.
  75046. *
  75047. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75048. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75049. * @param number to convert to percentage
  75050. * @param min min range
  75051. * @param max max range
  75052. * @returns the percentage
  75053. */
  75054. static RangeToPercent(number: number, min: number, max: number): number;
  75055. /**
  75056. * This function returns number that corresponds to the percentage in a given range.
  75057. *
  75058. * PercentToRange(0.34,0,100) will return 34.
  75059. * @param percent to convert to number
  75060. * @param min min range
  75061. * @param max max range
  75062. * @returns the number
  75063. */
  75064. static PercentToRange(percent: number, min: number, max: number): number;
  75065. /**
  75066. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75067. * @param angle The angle to normalize in radian.
  75068. * @return The converted angle.
  75069. */
  75070. static NormalizeRadians(angle: number): number;
  75071. }
  75072. }
  75073. declare module BABYLON {
  75074. /**
  75075. * Constant used to convert a value to gamma space
  75076. * @ignorenaming
  75077. */
  75078. export const ToGammaSpace: number;
  75079. /**
  75080. * Constant used to convert a value to linear space
  75081. * @ignorenaming
  75082. */
  75083. export const ToLinearSpace = 2.2;
  75084. /**
  75085. * Constant used to define the minimal number value in Babylon.js
  75086. * @ignorenaming
  75087. */
  75088. let Epsilon: number;
  75089. }
  75090. declare module BABYLON {
  75091. /**
  75092. * Class used to represent a viewport on screen
  75093. */
  75094. export class Viewport {
  75095. /** viewport left coordinate */
  75096. x: number;
  75097. /** viewport top coordinate */
  75098. y: number;
  75099. /**viewport width */
  75100. width: number;
  75101. /** viewport height */
  75102. height: number;
  75103. /**
  75104. * Creates a Viewport object located at (x, y) and sized (width, height)
  75105. * @param x defines viewport left coordinate
  75106. * @param y defines viewport top coordinate
  75107. * @param width defines the viewport width
  75108. * @param height defines the viewport height
  75109. */
  75110. constructor(
  75111. /** viewport left coordinate */
  75112. x: number,
  75113. /** viewport top coordinate */
  75114. y: number,
  75115. /**viewport width */
  75116. width: number,
  75117. /** viewport height */
  75118. height: number);
  75119. /**
  75120. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75121. * @param renderWidth defines the rendering width
  75122. * @param renderHeight defines the rendering height
  75123. * @returns a new Viewport
  75124. */
  75125. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75126. /**
  75127. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75128. * @param renderWidth defines the rendering width
  75129. * @param renderHeight defines the rendering height
  75130. * @param ref defines the target viewport
  75131. * @returns the current viewport
  75132. */
  75133. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75134. /**
  75135. * Returns a new Viewport copied from the current one
  75136. * @returns a new Viewport
  75137. */
  75138. clone(): Viewport;
  75139. }
  75140. }
  75141. declare module BABYLON {
  75142. /**
  75143. * Class containing a set of static utilities functions for arrays.
  75144. */
  75145. export class ArrayTools {
  75146. /**
  75147. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75148. * @param size the number of element to construct and put in the array
  75149. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75150. * @returns a new array filled with new objects
  75151. */
  75152. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75153. }
  75154. }
  75155. declare module BABYLON {
  75156. /**
  75157. * Class representing a vector containing 2 coordinates
  75158. */
  75159. export class Vector2 {
  75160. /** defines the first coordinate */
  75161. x: number;
  75162. /** defines the second coordinate */
  75163. y: number;
  75164. /**
  75165. * Creates a new Vector2 from the given x and y coordinates
  75166. * @param x defines the first coordinate
  75167. * @param y defines the second coordinate
  75168. */
  75169. constructor(
  75170. /** defines the first coordinate */
  75171. x?: number,
  75172. /** defines the second coordinate */
  75173. y?: number);
  75174. /**
  75175. * Gets a string with the Vector2 coordinates
  75176. * @returns a string with the Vector2 coordinates
  75177. */
  75178. toString(): string;
  75179. /**
  75180. * Gets class name
  75181. * @returns the string "Vector2"
  75182. */
  75183. getClassName(): string;
  75184. /**
  75185. * Gets current vector hash code
  75186. * @returns the Vector2 hash code as a number
  75187. */
  75188. getHashCode(): number;
  75189. /**
  75190. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75191. * @param array defines the source array
  75192. * @param index defines the offset in source array
  75193. * @returns the current Vector2
  75194. */
  75195. toArray(array: FloatArray, index?: number): Vector2;
  75196. /**
  75197. * Copy the current vector to an array
  75198. * @returns a new array with 2 elements: the Vector2 coordinates.
  75199. */
  75200. asArray(): number[];
  75201. /**
  75202. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75203. * @param source defines the source Vector2
  75204. * @returns the current updated Vector2
  75205. */
  75206. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75207. /**
  75208. * Sets the Vector2 coordinates with the given floats
  75209. * @param x defines the first coordinate
  75210. * @param y defines the second coordinate
  75211. * @returns the current updated Vector2
  75212. */
  75213. copyFromFloats(x: number, y: number): Vector2;
  75214. /**
  75215. * Sets the Vector2 coordinates with the given floats
  75216. * @param x defines the first coordinate
  75217. * @param y defines the second coordinate
  75218. * @returns the current updated Vector2
  75219. */
  75220. set(x: number, y: number): Vector2;
  75221. /**
  75222. * Add another vector with the current one
  75223. * @param otherVector defines the other vector
  75224. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75225. */
  75226. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75227. /**
  75228. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75229. * @param otherVector defines the other vector
  75230. * @param result defines the target vector
  75231. * @returns the unmodified current Vector2
  75232. */
  75233. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75234. /**
  75235. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75236. * @param otherVector defines the other vector
  75237. * @returns the current updated Vector2
  75238. */
  75239. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75240. /**
  75241. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75242. * @param otherVector defines the other vector
  75243. * @returns a new Vector2
  75244. */
  75245. addVector3(otherVector: Vector3): Vector2;
  75246. /**
  75247. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75248. * @param otherVector defines the other vector
  75249. * @returns a new Vector2
  75250. */
  75251. subtract(otherVector: Vector2): Vector2;
  75252. /**
  75253. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75254. * @param otherVector defines the other vector
  75255. * @param result defines the target vector
  75256. * @returns the unmodified current Vector2
  75257. */
  75258. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75259. /**
  75260. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75261. * @param otherVector defines the other vector
  75262. * @returns the current updated Vector2
  75263. */
  75264. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75265. /**
  75266. * Multiplies in place the current Vector2 coordinates by the given ones
  75267. * @param otherVector defines the other vector
  75268. * @returns the current updated Vector2
  75269. */
  75270. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75271. /**
  75272. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75273. * @param otherVector defines the other vector
  75274. * @returns a new Vector2
  75275. */
  75276. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75277. /**
  75278. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75279. * @param otherVector defines the other vector
  75280. * @param result defines the target vector
  75281. * @returns the unmodified current Vector2
  75282. */
  75283. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75284. /**
  75285. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75286. * @param x defines the first coordinate
  75287. * @param y defines the second coordinate
  75288. * @returns a new Vector2
  75289. */
  75290. multiplyByFloats(x: number, y: number): Vector2;
  75291. /**
  75292. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75293. * @param otherVector defines the other vector
  75294. * @returns a new Vector2
  75295. */
  75296. divide(otherVector: Vector2): Vector2;
  75297. /**
  75298. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75299. * @param otherVector defines the other vector
  75300. * @param result defines the target vector
  75301. * @returns the unmodified current Vector2
  75302. */
  75303. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75304. /**
  75305. * Divides the current Vector2 coordinates by the given ones
  75306. * @param otherVector defines the other vector
  75307. * @returns the current updated Vector2
  75308. */
  75309. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75310. /**
  75311. * Gets a new Vector2 with current Vector2 negated coordinates
  75312. * @returns a new Vector2
  75313. */
  75314. negate(): Vector2;
  75315. /**
  75316. * Negate this vector in place
  75317. * @returns this
  75318. */
  75319. negateInPlace(): Vector2;
  75320. /**
  75321. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75322. * @param result defines the Vector3 object where to store the result
  75323. * @returns the current Vector2
  75324. */
  75325. negateToRef(result: Vector2): Vector2;
  75326. /**
  75327. * Multiply the Vector2 coordinates by scale
  75328. * @param scale defines the scaling factor
  75329. * @returns the current updated Vector2
  75330. */
  75331. scaleInPlace(scale: number): Vector2;
  75332. /**
  75333. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75334. * @param scale defines the scaling factor
  75335. * @returns a new Vector2
  75336. */
  75337. scale(scale: number): Vector2;
  75338. /**
  75339. * Scale the current Vector2 values by a factor to a given Vector2
  75340. * @param scale defines the scale factor
  75341. * @param result defines the Vector2 object where to store the result
  75342. * @returns the unmodified current Vector2
  75343. */
  75344. scaleToRef(scale: number, result: Vector2): Vector2;
  75345. /**
  75346. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75347. * @param scale defines the scale factor
  75348. * @param result defines the Vector2 object where to store the result
  75349. * @returns the unmodified current Vector2
  75350. */
  75351. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75352. /**
  75353. * Gets a boolean if two vectors are equals
  75354. * @param otherVector defines the other vector
  75355. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75356. */
  75357. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75358. /**
  75359. * Gets a boolean if two vectors are equals (using an epsilon value)
  75360. * @param otherVector defines the other vector
  75361. * @param epsilon defines the minimal distance to consider equality
  75362. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75363. */
  75364. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75365. /**
  75366. * Gets a new Vector2 from current Vector2 floored values
  75367. * @returns a new Vector2
  75368. */
  75369. floor(): Vector2;
  75370. /**
  75371. * Gets a new Vector2 from current Vector2 floored values
  75372. * @returns a new Vector2
  75373. */
  75374. fract(): Vector2;
  75375. /**
  75376. * Gets the length of the vector
  75377. * @returns the vector length (float)
  75378. */
  75379. length(): number;
  75380. /**
  75381. * Gets the vector squared length
  75382. * @returns the vector squared length (float)
  75383. */
  75384. lengthSquared(): number;
  75385. /**
  75386. * Normalize the vector
  75387. * @returns the current updated Vector2
  75388. */
  75389. normalize(): Vector2;
  75390. /**
  75391. * Gets a new Vector2 copied from the Vector2
  75392. * @returns a new Vector2
  75393. */
  75394. clone(): Vector2;
  75395. /**
  75396. * Gets a new Vector2(0, 0)
  75397. * @returns a new Vector2
  75398. */
  75399. static Zero(): Vector2;
  75400. /**
  75401. * Gets a new Vector2(1, 1)
  75402. * @returns a new Vector2
  75403. */
  75404. static One(): Vector2;
  75405. /**
  75406. * Gets a new Vector2 set from the given index element of the given array
  75407. * @param array defines the data source
  75408. * @param offset defines the offset in the data source
  75409. * @returns a new Vector2
  75410. */
  75411. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75412. /**
  75413. * Sets "result" from the given index element of the given array
  75414. * @param array defines the data source
  75415. * @param offset defines the offset in the data source
  75416. * @param result defines the target vector
  75417. */
  75418. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75419. /**
  75420. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75421. * @param value1 defines 1st point of control
  75422. * @param value2 defines 2nd point of control
  75423. * @param value3 defines 3rd point of control
  75424. * @param value4 defines 4th point of control
  75425. * @param amount defines the interpolation factor
  75426. * @returns a new Vector2
  75427. */
  75428. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75429. /**
  75430. * 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".
  75431. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75432. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75433. * @param value defines the value to clamp
  75434. * @param min defines the lower limit
  75435. * @param max defines the upper limit
  75436. * @returns a new Vector2
  75437. */
  75438. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75439. /**
  75440. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75441. * @param value1 defines the 1st control point
  75442. * @param tangent1 defines the outgoing tangent
  75443. * @param value2 defines the 2nd control point
  75444. * @param tangent2 defines the incoming tangent
  75445. * @param amount defines the interpolation factor
  75446. * @returns a new Vector2
  75447. */
  75448. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75449. /**
  75450. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75451. * @param start defines the start vector
  75452. * @param end defines the end vector
  75453. * @param amount defines the interpolation factor
  75454. * @returns a new Vector2
  75455. */
  75456. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75457. /**
  75458. * Gets the dot product of the vector "left" and the vector "right"
  75459. * @param left defines first vector
  75460. * @param right defines second vector
  75461. * @returns the dot product (float)
  75462. */
  75463. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75464. /**
  75465. * Returns a new Vector2 equal to the normalized given vector
  75466. * @param vector defines the vector to normalize
  75467. * @returns a new Vector2
  75468. */
  75469. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75470. /**
  75471. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75472. * @param left defines 1st vector
  75473. * @param right defines 2nd vector
  75474. * @returns a new Vector2
  75475. */
  75476. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75477. /**
  75478. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75479. * @param left defines 1st vector
  75480. * @param right defines 2nd vector
  75481. * @returns a new Vector2
  75482. */
  75483. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75484. /**
  75485. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75486. * @param vector defines the vector to transform
  75487. * @param transformation defines the matrix to apply
  75488. * @returns a new Vector2
  75489. */
  75490. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75491. /**
  75492. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75493. * @param vector defines the vector to transform
  75494. * @param transformation defines the matrix to apply
  75495. * @param result defines the target vector
  75496. */
  75497. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75498. /**
  75499. * Determines if a given vector is included in a triangle
  75500. * @param p defines the vector to test
  75501. * @param p0 defines 1st triangle point
  75502. * @param p1 defines 2nd triangle point
  75503. * @param p2 defines 3rd triangle point
  75504. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75505. */
  75506. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75507. /**
  75508. * Gets the distance between the vectors "value1" and "value2"
  75509. * @param value1 defines first vector
  75510. * @param value2 defines second vector
  75511. * @returns the distance between vectors
  75512. */
  75513. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75514. /**
  75515. * Returns the squared distance between the vectors "value1" and "value2"
  75516. * @param value1 defines first vector
  75517. * @param value2 defines second vector
  75518. * @returns the squared distance between vectors
  75519. */
  75520. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75521. /**
  75522. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75523. * @param value1 defines first vector
  75524. * @param value2 defines second vector
  75525. * @returns a new Vector2
  75526. */
  75527. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75528. /**
  75529. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75530. * @param p defines the middle point
  75531. * @param segA defines one point of the segment
  75532. * @param segB defines the other point of the segment
  75533. * @returns the shortest distance
  75534. */
  75535. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75536. }
  75537. /**
  75538. * Class used to store (x,y,z) vector representation
  75539. * A Vector3 is the main object used in 3D geometry
  75540. * It can represent etiher the coordinates of a point the space, either a direction
  75541. * Reminder: js uses a left handed forward facing system
  75542. */
  75543. export class Vector3 {
  75544. /**
  75545. * Defines the first coordinates (on X axis)
  75546. */
  75547. x: number;
  75548. /**
  75549. * Defines the second coordinates (on Y axis)
  75550. */
  75551. y: number;
  75552. /**
  75553. * Defines the third coordinates (on Z axis)
  75554. */
  75555. z: number;
  75556. private static _UpReadOnly;
  75557. private static _ZeroReadOnly;
  75558. /**
  75559. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75560. * @param x defines the first coordinates (on X axis)
  75561. * @param y defines the second coordinates (on Y axis)
  75562. * @param z defines the third coordinates (on Z axis)
  75563. */
  75564. constructor(
  75565. /**
  75566. * Defines the first coordinates (on X axis)
  75567. */
  75568. x?: number,
  75569. /**
  75570. * Defines the second coordinates (on Y axis)
  75571. */
  75572. y?: number,
  75573. /**
  75574. * Defines the third coordinates (on Z axis)
  75575. */
  75576. z?: number);
  75577. /**
  75578. * Creates a string representation of the Vector3
  75579. * @returns a string with the Vector3 coordinates.
  75580. */
  75581. toString(): string;
  75582. /**
  75583. * Gets the class name
  75584. * @returns the string "Vector3"
  75585. */
  75586. getClassName(): string;
  75587. /**
  75588. * Creates the Vector3 hash code
  75589. * @returns a number which tends to be unique between Vector3 instances
  75590. */
  75591. getHashCode(): number;
  75592. /**
  75593. * Creates an array containing three elements : the coordinates of the Vector3
  75594. * @returns a new array of numbers
  75595. */
  75596. asArray(): number[];
  75597. /**
  75598. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75599. * @param array defines the destination array
  75600. * @param index defines the offset in the destination array
  75601. * @returns the current Vector3
  75602. */
  75603. toArray(array: FloatArray, index?: number): Vector3;
  75604. /**
  75605. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75606. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75607. */
  75608. toQuaternion(): Quaternion;
  75609. /**
  75610. * Adds the given vector to the current Vector3
  75611. * @param otherVector defines the second operand
  75612. * @returns the current updated Vector3
  75613. */
  75614. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75615. /**
  75616. * Adds the given coordinates to the current Vector3
  75617. * @param x defines the x coordinate of the operand
  75618. * @param y defines the y coordinate of the operand
  75619. * @param z defines the z coordinate of the operand
  75620. * @returns the current updated Vector3
  75621. */
  75622. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75623. /**
  75624. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75625. * @param otherVector defines the second operand
  75626. * @returns the resulting Vector3
  75627. */
  75628. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75629. /**
  75630. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75631. * @param otherVector defines the second operand
  75632. * @param result defines the Vector3 object where to store the result
  75633. * @returns the current Vector3
  75634. */
  75635. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75636. /**
  75637. * Subtract the given vector from the current Vector3
  75638. * @param otherVector defines the second operand
  75639. * @returns the current updated Vector3
  75640. */
  75641. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75642. /**
  75643. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75644. * @param otherVector defines the second operand
  75645. * @returns the resulting Vector3
  75646. */
  75647. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75648. /**
  75649. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75650. * @param otherVector defines the second operand
  75651. * @param result defines the Vector3 object where to store the result
  75652. * @returns the current Vector3
  75653. */
  75654. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75655. /**
  75656. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75657. * @param x defines the x coordinate of the operand
  75658. * @param y defines the y coordinate of the operand
  75659. * @param z defines the z coordinate of the operand
  75660. * @returns the resulting Vector3
  75661. */
  75662. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75663. /**
  75664. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75665. * @param x defines the x coordinate of the operand
  75666. * @param y defines the y coordinate of the operand
  75667. * @param z defines the z coordinate of the operand
  75668. * @param result defines the Vector3 object where to store the result
  75669. * @returns the current Vector3
  75670. */
  75671. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75672. /**
  75673. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75674. * @returns a new Vector3
  75675. */
  75676. negate(): Vector3;
  75677. /**
  75678. * Negate this vector in place
  75679. * @returns this
  75680. */
  75681. negateInPlace(): Vector3;
  75682. /**
  75683. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75684. * @param result defines the Vector3 object where to store the result
  75685. * @returns the current Vector3
  75686. */
  75687. negateToRef(result: Vector3): Vector3;
  75688. /**
  75689. * Multiplies the Vector3 coordinates by the float "scale"
  75690. * @param scale defines the multiplier factor
  75691. * @returns the current updated Vector3
  75692. */
  75693. scaleInPlace(scale: number): Vector3;
  75694. /**
  75695. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75696. * @param scale defines the multiplier factor
  75697. * @returns a new Vector3
  75698. */
  75699. scale(scale: number): Vector3;
  75700. /**
  75701. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75702. * @param scale defines the multiplier factor
  75703. * @param result defines the Vector3 object where to store the result
  75704. * @returns the current Vector3
  75705. */
  75706. scaleToRef(scale: number, result: Vector3): Vector3;
  75707. /**
  75708. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75709. * @param scale defines the scale factor
  75710. * @param result defines the Vector3 object where to store the result
  75711. * @returns the unmodified current Vector3
  75712. */
  75713. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75714. /**
  75715. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75716. * @param otherVector defines the second operand
  75717. * @returns true if both vectors are equals
  75718. */
  75719. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75720. /**
  75721. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75722. * @param otherVector defines the second operand
  75723. * @param epsilon defines the minimal distance to define values as equals
  75724. * @returns true if both vectors are distant less than epsilon
  75725. */
  75726. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75727. /**
  75728. * Returns true if the current Vector3 coordinates equals the given floats
  75729. * @param x defines the x coordinate of the operand
  75730. * @param y defines the y coordinate of the operand
  75731. * @param z defines the z coordinate of the operand
  75732. * @returns true if both vectors are equals
  75733. */
  75734. equalsToFloats(x: number, y: number, z: number): boolean;
  75735. /**
  75736. * Multiplies the current Vector3 coordinates by the given ones
  75737. * @param otherVector defines the second operand
  75738. * @returns the current updated Vector3
  75739. */
  75740. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75741. /**
  75742. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75743. * @param otherVector defines the second operand
  75744. * @returns the new Vector3
  75745. */
  75746. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75747. /**
  75748. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75749. * @param otherVector defines the second operand
  75750. * @param result defines the Vector3 object where to store the result
  75751. * @returns the current Vector3
  75752. */
  75753. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75754. /**
  75755. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75756. * @param x defines the x coordinate of the operand
  75757. * @param y defines the y coordinate of the operand
  75758. * @param z defines the z coordinate of the operand
  75759. * @returns the new Vector3
  75760. */
  75761. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75762. /**
  75763. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75764. * @param otherVector defines the second operand
  75765. * @returns the new Vector3
  75766. */
  75767. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75768. /**
  75769. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75770. * @param otherVector defines the second operand
  75771. * @param result defines the Vector3 object where to store the result
  75772. * @returns the current Vector3
  75773. */
  75774. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75775. /**
  75776. * Divides the current Vector3 coordinates by the given ones.
  75777. * @param otherVector defines the second operand
  75778. * @returns the current updated Vector3
  75779. */
  75780. divideInPlace(otherVector: Vector3): Vector3;
  75781. /**
  75782. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75783. * @param other defines the second operand
  75784. * @returns the current updated Vector3
  75785. */
  75786. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75787. /**
  75788. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75789. * @param other defines the second operand
  75790. * @returns the current updated Vector3
  75791. */
  75792. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75793. /**
  75794. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75795. * @param x defines the x coordinate of the operand
  75796. * @param y defines the y coordinate of the operand
  75797. * @param z defines the z coordinate of the operand
  75798. * @returns the current updated Vector3
  75799. */
  75800. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75801. /**
  75802. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75803. * @param x defines the x coordinate of the operand
  75804. * @param y defines the y coordinate of the operand
  75805. * @param z defines the z coordinate of the operand
  75806. * @returns the current updated Vector3
  75807. */
  75808. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75809. /**
  75810. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75811. * Check if is non uniform within a certain amount of decimal places to account for this
  75812. * @param epsilon the amount the values can differ
  75813. * @returns if the the vector is non uniform to a certain number of decimal places
  75814. */
  75815. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75816. /**
  75817. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75818. */
  75819. get isNonUniform(): boolean;
  75820. /**
  75821. * Gets a new Vector3 from current Vector3 floored values
  75822. * @returns a new Vector3
  75823. */
  75824. floor(): Vector3;
  75825. /**
  75826. * Gets a new Vector3 from current Vector3 floored values
  75827. * @returns a new Vector3
  75828. */
  75829. fract(): Vector3;
  75830. /**
  75831. * Gets the length of the Vector3
  75832. * @returns the length of the Vector3
  75833. */
  75834. length(): number;
  75835. /**
  75836. * Gets the squared length of the Vector3
  75837. * @returns squared length of the Vector3
  75838. */
  75839. lengthSquared(): number;
  75840. /**
  75841. * Normalize the current Vector3.
  75842. * Please note that this is an in place operation.
  75843. * @returns the current updated Vector3
  75844. */
  75845. normalize(): Vector3;
  75846. /**
  75847. * Reorders the x y z properties of the vector in place
  75848. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75849. * @returns the current updated vector
  75850. */
  75851. reorderInPlace(order: string): this;
  75852. /**
  75853. * Rotates the vector around 0,0,0 by a quaternion
  75854. * @param quaternion the rotation quaternion
  75855. * @param result vector to store the result
  75856. * @returns the resulting vector
  75857. */
  75858. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75859. /**
  75860. * Rotates a vector around a given point
  75861. * @param quaternion the rotation quaternion
  75862. * @param point the point to rotate around
  75863. * @param result vector to store the result
  75864. * @returns the resulting vector
  75865. */
  75866. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75867. /**
  75868. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75869. * The cross product is then orthogonal to both current and "other"
  75870. * @param other defines the right operand
  75871. * @returns the cross product
  75872. */
  75873. cross(other: Vector3): Vector3;
  75874. /**
  75875. * Normalize the current Vector3 with the given input length.
  75876. * Please note that this is an in place operation.
  75877. * @param len the length of the vector
  75878. * @returns the current updated Vector3
  75879. */
  75880. normalizeFromLength(len: number): Vector3;
  75881. /**
  75882. * Normalize the current Vector3 to a new vector
  75883. * @returns the new Vector3
  75884. */
  75885. normalizeToNew(): Vector3;
  75886. /**
  75887. * Normalize the current Vector3 to the reference
  75888. * @param reference define the Vector3 to update
  75889. * @returns the updated Vector3
  75890. */
  75891. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75892. /**
  75893. * Creates a new Vector3 copied from the current Vector3
  75894. * @returns the new Vector3
  75895. */
  75896. clone(): Vector3;
  75897. /**
  75898. * Copies the given vector coordinates to the current Vector3 ones
  75899. * @param source defines the source Vector3
  75900. * @returns the current updated Vector3
  75901. */
  75902. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75903. /**
  75904. * Copies the given floats to the current Vector3 coordinates
  75905. * @param x defines the x coordinate of the operand
  75906. * @param y defines the y coordinate of the operand
  75907. * @param z defines the z coordinate of the operand
  75908. * @returns the current updated Vector3
  75909. */
  75910. copyFromFloats(x: number, y: number, z: number): Vector3;
  75911. /**
  75912. * Copies the given floats to the current Vector3 coordinates
  75913. * @param x defines the x coordinate of the operand
  75914. * @param y defines the y coordinate of the operand
  75915. * @param z defines the z coordinate of the operand
  75916. * @returns the current updated Vector3
  75917. */
  75918. set(x: number, y: number, z: number): Vector3;
  75919. /**
  75920. * Copies the given float to the current Vector3 coordinates
  75921. * @param v defines the x, y and z coordinates of the operand
  75922. * @returns the current updated Vector3
  75923. */
  75924. setAll(v: number): Vector3;
  75925. /**
  75926. * Get the clip factor between two vectors
  75927. * @param vector0 defines the first operand
  75928. * @param vector1 defines the second operand
  75929. * @param axis defines the axis to use
  75930. * @param size defines the size along the axis
  75931. * @returns the clip factor
  75932. */
  75933. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75934. /**
  75935. * Get angle between two vectors
  75936. * @param vector0 angle between vector0 and vector1
  75937. * @param vector1 angle between vector0 and vector1
  75938. * @param normal direction of the normal
  75939. * @return the angle between vector0 and vector1
  75940. */
  75941. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75942. /**
  75943. * Returns a new Vector3 set from the index "offset" of the given array
  75944. * @param array defines the source array
  75945. * @param offset defines the offset in the source array
  75946. * @returns the new Vector3
  75947. */
  75948. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75949. /**
  75950. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75951. * @param array defines the source array
  75952. * @param offset defines the offset in the source array
  75953. * @returns the new Vector3
  75954. * @deprecated Please use FromArray instead.
  75955. */
  75956. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75957. /**
  75958. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75959. * @param array defines the source array
  75960. * @param offset defines the offset in the source array
  75961. * @param result defines the Vector3 where to store the result
  75962. */
  75963. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75964. /**
  75965. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75966. * @param array defines the source array
  75967. * @param offset defines the offset in the source array
  75968. * @param result defines the Vector3 where to store the result
  75969. * @deprecated Please use FromArrayToRef instead.
  75970. */
  75971. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75972. /**
  75973. * Sets the given vector "result" with the given floats.
  75974. * @param x defines the x coordinate of the source
  75975. * @param y defines the y coordinate of the source
  75976. * @param z defines the z coordinate of the source
  75977. * @param result defines the Vector3 where to store the result
  75978. */
  75979. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75980. /**
  75981. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75982. * @returns a new empty Vector3
  75983. */
  75984. static Zero(): Vector3;
  75985. /**
  75986. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75987. * @returns a new unit Vector3
  75988. */
  75989. static One(): Vector3;
  75990. /**
  75991. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75992. * @returns a new up Vector3
  75993. */
  75994. static Up(): Vector3;
  75995. /**
  75996. * Gets a up Vector3 that must not be updated
  75997. */
  75998. static get UpReadOnly(): DeepImmutable<Vector3>;
  75999. /**
  76000. * Gets a zero Vector3 that must not be updated
  76001. */
  76002. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76003. /**
  76004. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76005. * @returns a new down Vector3
  76006. */
  76007. static Down(): Vector3;
  76008. /**
  76009. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76010. * @returns a new forward Vector3
  76011. */
  76012. static Forward(): Vector3;
  76013. /**
  76014. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76015. * @returns a new forward Vector3
  76016. */
  76017. static Backward(): Vector3;
  76018. /**
  76019. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76020. * @returns a new right Vector3
  76021. */
  76022. static Right(): Vector3;
  76023. /**
  76024. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76025. * @returns a new left Vector3
  76026. */
  76027. static Left(): Vector3;
  76028. /**
  76029. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76030. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76031. * @param vector defines the Vector3 to transform
  76032. * @param transformation defines the transformation matrix
  76033. * @returns the transformed Vector3
  76034. */
  76035. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76036. /**
  76037. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76038. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76039. * @param vector defines the Vector3 to transform
  76040. * @param transformation defines the transformation matrix
  76041. * @param result defines the Vector3 where to store the result
  76042. */
  76043. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76044. /**
  76045. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76046. * This method computes tranformed coordinates only, not transformed direction vectors
  76047. * @param x define the x coordinate of the source vector
  76048. * @param y define the y coordinate of the source vector
  76049. * @param z define the z coordinate of the source vector
  76050. * @param transformation defines the transformation matrix
  76051. * @param result defines the Vector3 where to store the result
  76052. */
  76053. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76054. /**
  76055. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76056. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76057. * @param vector defines the Vector3 to transform
  76058. * @param transformation defines the transformation matrix
  76059. * @returns the new Vector3
  76060. */
  76061. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76062. /**
  76063. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76064. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76065. * @param vector defines the Vector3 to transform
  76066. * @param transformation defines the transformation matrix
  76067. * @param result defines the Vector3 where to store the result
  76068. */
  76069. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76070. /**
  76071. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76072. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76073. * @param x define the x coordinate of the source vector
  76074. * @param y define the y coordinate of the source vector
  76075. * @param z define the z coordinate of the source vector
  76076. * @param transformation defines the transformation matrix
  76077. * @param result defines the Vector3 where to store the result
  76078. */
  76079. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76080. /**
  76081. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76082. * @param value1 defines the first control point
  76083. * @param value2 defines the second control point
  76084. * @param value3 defines the third control point
  76085. * @param value4 defines the fourth control point
  76086. * @param amount defines the amount on the spline to use
  76087. * @returns the new Vector3
  76088. */
  76089. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76090. /**
  76091. * 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"
  76092. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76093. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76094. * @param value defines the current value
  76095. * @param min defines the lower range value
  76096. * @param max defines the upper range value
  76097. * @returns the new Vector3
  76098. */
  76099. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76100. /**
  76101. * 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"
  76102. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76103. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76104. * @param value defines the current value
  76105. * @param min defines the lower range value
  76106. * @param max defines the upper range value
  76107. * @param result defines the Vector3 where to store the result
  76108. */
  76109. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76110. /**
  76111. * Checks if a given vector is inside a specific range
  76112. * @param v defines the vector to test
  76113. * @param min defines the minimum range
  76114. * @param max defines the maximum range
  76115. */
  76116. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76117. /**
  76118. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76119. * @param value1 defines the first control point
  76120. * @param tangent1 defines the first tangent vector
  76121. * @param value2 defines the second control point
  76122. * @param tangent2 defines the second tangent vector
  76123. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76124. * @returns the new Vector3
  76125. */
  76126. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76127. /**
  76128. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76129. * @param start defines the start value
  76130. * @param end defines the end value
  76131. * @param amount max defines amount between both (between 0 and 1)
  76132. * @returns the new Vector3
  76133. */
  76134. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76135. /**
  76136. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76137. * @param start defines the start value
  76138. * @param end defines the end value
  76139. * @param amount max defines amount between both (between 0 and 1)
  76140. * @param result defines the Vector3 where to store the result
  76141. */
  76142. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76143. /**
  76144. * Returns the dot product (float) between the vectors "left" and "right"
  76145. * @param left defines the left operand
  76146. * @param right defines the right operand
  76147. * @returns the dot product
  76148. */
  76149. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76150. /**
  76151. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76152. * The cross product is then orthogonal to both "left" and "right"
  76153. * @param left defines the left operand
  76154. * @param right defines the right operand
  76155. * @returns the cross product
  76156. */
  76157. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76158. /**
  76159. * Sets the given vector "result" with the cross product of "left" and "right"
  76160. * The cross product is then orthogonal to both "left" and "right"
  76161. * @param left defines the left operand
  76162. * @param right defines the right operand
  76163. * @param result defines the Vector3 where to store the result
  76164. */
  76165. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76166. /**
  76167. * Returns a new Vector3 as the normalization of the given vector
  76168. * @param vector defines the Vector3 to normalize
  76169. * @returns the new Vector3
  76170. */
  76171. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76172. /**
  76173. * Sets the given vector "result" with the normalization of the given first vector
  76174. * @param vector defines the Vector3 to normalize
  76175. * @param result defines the Vector3 where to store the result
  76176. */
  76177. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76178. /**
  76179. * Project a Vector3 onto screen space
  76180. * @param vector defines the Vector3 to project
  76181. * @param world defines the world matrix to use
  76182. * @param transform defines the transform (view x projection) matrix to use
  76183. * @param viewport defines the screen viewport to use
  76184. * @returns the new Vector3
  76185. */
  76186. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76187. /** @hidden */
  76188. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76189. /**
  76190. * Unproject from screen space to object space
  76191. * @param source defines the screen space Vector3 to use
  76192. * @param viewportWidth defines the current width of the viewport
  76193. * @param viewportHeight defines the current height of the viewport
  76194. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76195. * @param transform defines the transform (view x projection) matrix to use
  76196. * @returns the new Vector3
  76197. */
  76198. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76199. /**
  76200. * Unproject from screen space to object space
  76201. * @param source defines the screen space Vector3 to use
  76202. * @param viewportWidth defines the current width of the viewport
  76203. * @param viewportHeight defines the current height of the viewport
  76204. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76205. * @param view defines the view matrix to use
  76206. * @param projection defines the projection matrix to use
  76207. * @returns the new Vector3
  76208. */
  76209. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76210. /**
  76211. * Unproject from screen space to object space
  76212. * @param source defines the screen space Vector3 to use
  76213. * @param viewportWidth defines the current width of the viewport
  76214. * @param viewportHeight defines the current height of the viewport
  76215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76216. * @param view defines the view matrix to use
  76217. * @param projection defines the projection matrix to use
  76218. * @param result defines the Vector3 where to store the result
  76219. */
  76220. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76221. /**
  76222. * Unproject from screen space to object space
  76223. * @param sourceX defines the screen space x coordinate to use
  76224. * @param sourceY defines the screen space y coordinate to use
  76225. * @param sourceZ defines the screen space z coordinate to use
  76226. * @param viewportWidth defines the current width of the viewport
  76227. * @param viewportHeight defines the current height of the viewport
  76228. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76229. * @param view defines the view matrix to use
  76230. * @param projection defines the projection matrix to use
  76231. * @param result defines the Vector3 where to store the result
  76232. */
  76233. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76234. /**
  76235. * Gets the minimal coordinate values between two Vector3
  76236. * @param left defines the first operand
  76237. * @param right defines the second operand
  76238. * @returns the new Vector3
  76239. */
  76240. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76241. /**
  76242. * Gets the maximal coordinate values between two Vector3
  76243. * @param left defines the first operand
  76244. * @param right defines the second operand
  76245. * @returns the new Vector3
  76246. */
  76247. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76248. /**
  76249. * Returns the distance between the vectors "value1" and "value2"
  76250. * @param value1 defines the first operand
  76251. * @param value2 defines the second operand
  76252. * @returns the distance
  76253. */
  76254. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76255. /**
  76256. * Returns the squared distance between the vectors "value1" and "value2"
  76257. * @param value1 defines the first operand
  76258. * @param value2 defines the second operand
  76259. * @returns the squared distance
  76260. */
  76261. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76262. /**
  76263. * Returns a new Vector3 located at the center between "value1" and "value2"
  76264. * @param value1 defines the first operand
  76265. * @param value2 defines the second operand
  76266. * @returns the new Vector3
  76267. */
  76268. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76269. /**
  76270. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76271. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76272. * to something in order to rotate it from its local system to the given target system
  76273. * Note: axis1, axis2 and axis3 are normalized during this operation
  76274. * @param axis1 defines the first axis
  76275. * @param axis2 defines the second axis
  76276. * @param axis3 defines the third axis
  76277. * @returns a new Vector3
  76278. */
  76279. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76280. /**
  76281. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76282. * @param axis1 defines the first axis
  76283. * @param axis2 defines the second axis
  76284. * @param axis3 defines the third axis
  76285. * @param ref defines the Vector3 where to store the result
  76286. */
  76287. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76288. }
  76289. /**
  76290. * Vector4 class created for EulerAngle class conversion to Quaternion
  76291. */
  76292. export class Vector4 {
  76293. /** x value of the vector */
  76294. x: number;
  76295. /** y value of the vector */
  76296. y: number;
  76297. /** z value of the vector */
  76298. z: number;
  76299. /** w value of the vector */
  76300. w: number;
  76301. /**
  76302. * Creates a Vector4 object from the given floats.
  76303. * @param x x value of the vector
  76304. * @param y y value of the vector
  76305. * @param z z value of the vector
  76306. * @param w w value of the vector
  76307. */
  76308. constructor(
  76309. /** x value of the vector */
  76310. x: number,
  76311. /** y value of the vector */
  76312. y: number,
  76313. /** z value of the vector */
  76314. z: number,
  76315. /** w value of the vector */
  76316. w: number);
  76317. /**
  76318. * Returns the string with the Vector4 coordinates.
  76319. * @returns a string containing all the vector values
  76320. */
  76321. toString(): string;
  76322. /**
  76323. * Returns the string "Vector4".
  76324. * @returns "Vector4"
  76325. */
  76326. getClassName(): string;
  76327. /**
  76328. * Returns the Vector4 hash code.
  76329. * @returns a unique hash code
  76330. */
  76331. getHashCode(): number;
  76332. /**
  76333. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76334. * @returns the resulting array
  76335. */
  76336. asArray(): number[];
  76337. /**
  76338. * Populates the given array from the given index with the Vector4 coordinates.
  76339. * @param array array to populate
  76340. * @param index index of the array to start at (default: 0)
  76341. * @returns the Vector4.
  76342. */
  76343. toArray(array: FloatArray, index?: number): Vector4;
  76344. /**
  76345. * Adds the given vector to the current Vector4.
  76346. * @param otherVector the vector to add
  76347. * @returns the updated Vector4.
  76348. */
  76349. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76350. /**
  76351. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76352. * @param otherVector the vector to add
  76353. * @returns the resulting vector
  76354. */
  76355. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76356. /**
  76357. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76358. * @param otherVector the vector to add
  76359. * @param result the vector to store the result
  76360. * @returns the current Vector4.
  76361. */
  76362. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76363. /**
  76364. * Subtract in place the given vector from the current Vector4.
  76365. * @param otherVector the vector to subtract
  76366. * @returns the updated Vector4.
  76367. */
  76368. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76369. /**
  76370. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76371. * @param otherVector the vector to add
  76372. * @returns the new vector with the result
  76373. */
  76374. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76375. /**
  76376. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76377. * @param otherVector the vector to subtract
  76378. * @param result the vector to store the result
  76379. * @returns the current Vector4.
  76380. */
  76381. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76382. /**
  76383. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76384. */
  76385. /**
  76386. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76387. * @param x value to subtract
  76388. * @param y value to subtract
  76389. * @param z value to subtract
  76390. * @param w value to subtract
  76391. * @returns new vector containing the result
  76392. */
  76393. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76394. /**
  76395. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76396. * @param x value to subtract
  76397. * @param y value to subtract
  76398. * @param z value to subtract
  76399. * @param w value to subtract
  76400. * @param result the vector to store the result in
  76401. * @returns the current Vector4.
  76402. */
  76403. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76404. /**
  76405. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76406. * @returns a new vector with the negated values
  76407. */
  76408. negate(): Vector4;
  76409. /**
  76410. * Negate this vector in place
  76411. * @returns this
  76412. */
  76413. negateInPlace(): Vector4;
  76414. /**
  76415. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76416. * @param result defines the Vector3 object where to store the result
  76417. * @returns the current Vector4
  76418. */
  76419. negateToRef(result: Vector4): Vector4;
  76420. /**
  76421. * Multiplies the current Vector4 coordinates by scale (float).
  76422. * @param scale the number to scale with
  76423. * @returns the updated Vector4.
  76424. */
  76425. scaleInPlace(scale: number): Vector4;
  76426. /**
  76427. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76428. * @param scale the number to scale with
  76429. * @returns a new vector with the result
  76430. */
  76431. scale(scale: number): Vector4;
  76432. /**
  76433. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76434. * @param scale the number to scale with
  76435. * @param result a vector to store the result in
  76436. * @returns the current Vector4.
  76437. */
  76438. scaleToRef(scale: number, result: Vector4): Vector4;
  76439. /**
  76440. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76441. * @param scale defines the scale factor
  76442. * @param result defines the Vector4 object where to store the result
  76443. * @returns the unmodified current Vector4
  76444. */
  76445. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76446. /**
  76447. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76448. * @param otherVector the vector to compare against
  76449. * @returns true if they are equal
  76450. */
  76451. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76452. /**
  76453. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76454. * @param otherVector vector to compare against
  76455. * @param epsilon (Default: very small number)
  76456. * @returns true if they are equal
  76457. */
  76458. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76459. /**
  76460. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76461. * @param x x value to compare against
  76462. * @param y y value to compare against
  76463. * @param z z value to compare against
  76464. * @param w w value to compare against
  76465. * @returns true if equal
  76466. */
  76467. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76468. /**
  76469. * Multiplies in place the current Vector4 by the given one.
  76470. * @param otherVector vector to multiple with
  76471. * @returns the updated Vector4.
  76472. */
  76473. multiplyInPlace(otherVector: Vector4): Vector4;
  76474. /**
  76475. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76476. * @param otherVector vector to multiple with
  76477. * @returns resulting new vector
  76478. */
  76479. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76480. /**
  76481. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76482. * @param otherVector vector to multiple with
  76483. * @param result vector to store the result
  76484. * @returns the current Vector4.
  76485. */
  76486. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76487. /**
  76488. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76489. * @param x x value multiply with
  76490. * @param y y value multiply with
  76491. * @param z z value multiply with
  76492. * @param w w value multiply with
  76493. * @returns resulting new vector
  76494. */
  76495. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76496. /**
  76497. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76498. * @param otherVector vector to devide with
  76499. * @returns resulting new vector
  76500. */
  76501. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76502. /**
  76503. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76504. * @param otherVector vector to devide with
  76505. * @param result vector to store the result
  76506. * @returns the current Vector4.
  76507. */
  76508. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76509. /**
  76510. * Divides the current Vector3 coordinates by the given ones.
  76511. * @param otherVector vector to devide with
  76512. * @returns the updated Vector3.
  76513. */
  76514. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76515. /**
  76516. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76517. * @param other defines the second operand
  76518. * @returns the current updated Vector4
  76519. */
  76520. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76521. /**
  76522. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76523. * @param other defines the second operand
  76524. * @returns the current updated Vector4
  76525. */
  76526. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76527. /**
  76528. * Gets a new Vector4 from current Vector4 floored values
  76529. * @returns a new Vector4
  76530. */
  76531. floor(): Vector4;
  76532. /**
  76533. * Gets a new Vector4 from current Vector3 floored values
  76534. * @returns a new Vector4
  76535. */
  76536. fract(): Vector4;
  76537. /**
  76538. * Returns the Vector4 length (float).
  76539. * @returns the length
  76540. */
  76541. length(): number;
  76542. /**
  76543. * Returns the Vector4 squared length (float).
  76544. * @returns the length squared
  76545. */
  76546. lengthSquared(): number;
  76547. /**
  76548. * Normalizes in place the Vector4.
  76549. * @returns the updated Vector4.
  76550. */
  76551. normalize(): Vector4;
  76552. /**
  76553. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76554. * @returns this converted to a new vector3
  76555. */
  76556. toVector3(): Vector3;
  76557. /**
  76558. * Returns a new Vector4 copied from the current one.
  76559. * @returns the new cloned vector
  76560. */
  76561. clone(): Vector4;
  76562. /**
  76563. * Updates the current Vector4 with the given one coordinates.
  76564. * @param source the source vector to copy from
  76565. * @returns the updated Vector4.
  76566. */
  76567. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76568. /**
  76569. * Updates the current Vector4 coordinates with the given floats.
  76570. * @param x float to copy from
  76571. * @param y float to copy from
  76572. * @param z float to copy from
  76573. * @param w float to copy from
  76574. * @returns the updated Vector4.
  76575. */
  76576. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76577. /**
  76578. * Updates the current Vector4 coordinates with the given floats.
  76579. * @param x float to set from
  76580. * @param y float to set from
  76581. * @param z float to set from
  76582. * @param w float to set from
  76583. * @returns the updated Vector4.
  76584. */
  76585. set(x: number, y: number, z: number, w: number): Vector4;
  76586. /**
  76587. * Copies the given float to the current Vector3 coordinates
  76588. * @param v defines the x, y, z and w coordinates of the operand
  76589. * @returns the current updated Vector3
  76590. */
  76591. setAll(v: number): Vector4;
  76592. /**
  76593. * Returns a new Vector4 set from the starting index of the given array.
  76594. * @param array the array to pull values from
  76595. * @param offset the offset into the array to start at
  76596. * @returns the new vector
  76597. */
  76598. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76599. /**
  76600. * Updates the given vector "result" from the starting index of the given array.
  76601. * @param array the array to pull values from
  76602. * @param offset the offset into the array to start at
  76603. * @param result the vector to store the result in
  76604. */
  76605. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76606. /**
  76607. * Updates the given vector "result" from the starting index of the given Float32Array.
  76608. * @param array the array to pull values from
  76609. * @param offset the offset into the array to start at
  76610. * @param result the vector to store the result in
  76611. */
  76612. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76613. /**
  76614. * Updates the given vector "result" coordinates from the given floats.
  76615. * @param x float to set from
  76616. * @param y float to set from
  76617. * @param z float to set from
  76618. * @param w float to set from
  76619. * @param result the vector to the floats in
  76620. */
  76621. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76622. /**
  76623. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76624. * @returns the new vector
  76625. */
  76626. static Zero(): Vector4;
  76627. /**
  76628. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76629. * @returns the new vector
  76630. */
  76631. static One(): Vector4;
  76632. /**
  76633. * Returns a new normalized Vector4 from the given one.
  76634. * @param vector the vector to normalize
  76635. * @returns the vector
  76636. */
  76637. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76638. /**
  76639. * Updates the given vector "result" from the normalization of the given one.
  76640. * @param vector the vector to normalize
  76641. * @param result the vector to store the result in
  76642. */
  76643. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76644. /**
  76645. * Returns a vector with the minimum values from the left and right vectors
  76646. * @param left left vector to minimize
  76647. * @param right right vector to minimize
  76648. * @returns a new vector with the minimum of the left and right vector values
  76649. */
  76650. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76651. /**
  76652. * Returns a vector with the maximum values from the left and right vectors
  76653. * @param left left vector to maximize
  76654. * @param right right vector to maximize
  76655. * @returns a new vector with the maximum of the left and right vector values
  76656. */
  76657. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76658. /**
  76659. * Returns the distance (float) between the vectors "value1" and "value2".
  76660. * @param value1 value to calulate the distance between
  76661. * @param value2 value to calulate the distance between
  76662. * @return the distance between the two vectors
  76663. */
  76664. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76665. /**
  76666. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76667. * @param value1 value to calulate the distance between
  76668. * @param value2 value to calulate the distance between
  76669. * @return the distance between the two vectors squared
  76670. */
  76671. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76672. /**
  76673. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76674. * @param value1 value to calulate the center between
  76675. * @param value2 value to calulate the center between
  76676. * @return the center between the two vectors
  76677. */
  76678. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76679. /**
  76680. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76681. * This methods computes transformed normalized direction vectors only.
  76682. * @param vector the vector to transform
  76683. * @param transformation the transformation matrix to apply
  76684. * @returns the new vector
  76685. */
  76686. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76687. /**
  76688. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76689. * This methods computes transformed normalized direction vectors only.
  76690. * @param vector the vector to transform
  76691. * @param transformation the transformation matrix to apply
  76692. * @param result the vector to store the result in
  76693. */
  76694. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76695. /**
  76696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76697. * This methods computes transformed normalized direction vectors only.
  76698. * @param x value to transform
  76699. * @param y value to transform
  76700. * @param z value to transform
  76701. * @param w value to transform
  76702. * @param transformation the transformation matrix to apply
  76703. * @param result the vector to store the results in
  76704. */
  76705. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76706. /**
  76707. * Creates a new Vector4 from a Vector3
  76708. * @param source defines the source data
  76709. * @param w defines the 4th component (default is 0)
  76710. * @returns a new Vector4
  76711. */
  76712. static FromVector3(source: Vector3, w?: number): Vector4;
  76713. }
  76714. /**
  76715. * Class used to store quaternion data
  76716. * @see https://en.wikipedia.org/wiki/Quaternion
  76717. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76718. */
  76719. export class Quaternion {
  76720. /** defines the first component (0 by default) */
  76721. x: number;
  76722. /** defines the second component (0 by default) */
  76723. y: number;
  76724. /** defines the third component (0 by default) */
  76725. z: number;
  76726. /** defines the fourth component (1.0 by default) */
  76727. w: number;
  76728. /**
  76729. * Creates a new Quaternion from the given floats
  76730. * @param x defines the first component (0 by default)
  76731. * @param y defines the second component (0 by default)
  76732. * @param z defines the third component (0 by default)
  76733. * @param w defines the fourth component (1.0 by default)
  76734. */
  76735. constructor(
  76736. /** defines the first component (0 by default) */
  76737. x?: number,
  76738. /** defines the second component (0 by default) */
  76739. y?: number,
  76740. /** defines the third component (0 by default) */
  76741. z?: number,
  76742. /** defines the fourth component (1.0 by default) */
  76743. w?: number);
  76744. /**
  76745. * Gets a string representation for the current quaternion
  76746. * @returns a string with the Quaternion coordinates
  76747. */
  76748. toString(): string;
  76749. /**
  76750. * Gets the class name of the quaternion
  76751. * @returns the string "Quaternion"
  76752. */
  76753. getClassName(): string;
  76754. /**
  76755. * Gets a hash code for this quaternion
  76756. * @returns the quaternion hash code
  76757. */
  76758. getHashCode(): number;
  76759. /**
  76760. * Copy the quaternion to an array
  76761. * @returns a new array populated with 4 elements from the quaternion coordinates
  76762. */
  76763. asArray(): number[];
  76764. /**
  76765. * Check if two quaternions are equals
  76766. * @param otherQuaternion defines the second operand
  76767. * @return true if the current quaternion and the given one coordinates are strictly equals
  76768. */
  76769. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76770. /**
  76771. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76772. * @param otherQuaternion defines the other quaternion
  76773. * @param epsilon defines the minimal distance to consider equality
  76774. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76775. */
  76776. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76777. /**
  76778. * Clone the current quaternion
  76779. * @returns a new quaternion copied from the current one
  76780. */
  76781. clone(): Quaternion;
  76782. /**
  76783. * Copy a quaternion to the current one
  76784. * @param other defines the other quaternion
  76785. * @returns the updated current quaternion
  76786. */
  76787. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76788. /**
  76789. * Updates the current quaternion with the given float coordinates
  76790. * @param x defines the x coordinate
  76791. * @param y defines the y coordinate
  76792. * @param z defines the z coordinate
  76793. * @param w defines the w coordinate
  76794. * @returns the updated current quaternion
  76795. */
  76796. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76797. /**
  76798. * Updates the current quaternion from the given float coordinates
  76799. * @param x defines the x coordinate
  76800. * @param y defines the y coordinate
  76801. * @param z defines the z coordinate
  76802. * @param w defines the w coordinate
  76803. * @returns the updated current quaternion
  76804. */
  76805. set(x: number, y: number, z: number, w: number): Quaternion;
  76806. /**
  76807. * Adds two quaternions
  76808. * @param other defines the second operand
  76809. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76810. */
  76811. add(other: DeepImmutable<Quaternion>): Quaternion;
  76812. /**
  76813. * Add a quaternion to the current one
  76814. * @param other defines the quaternion to add
  76815. * @returns the current quaternion
  76816. */
  76817. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76818. /**
  76819. * Subtract two quaternions
  76820. * @param other defines the second operand
  76821. * @returns a new quaternion as the subtraction result of the given one from the current one
  76822. */
  76823. subtract(other: Quaternion): Quaternion;
  76824. /**
  76825. * Multiplies the current quaternion by a scale factor
  76826. * @param value defines the scale factor
  76827. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76828. */
  76829. scale(value: number): Quaternion;
  76830. /**
  76831. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76832. * @param scale defines the scale factor
  76833. * @param result defines the Quaternion object where to store the result
  76834. * @returns the unmodified current quaternion
  76835. */
  76836. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76837. /**
  76838. * Multiplies in place the current quaternion by a scale factor
  76839. * @param value defines the scale factor
  76840. * @returns the current modified quaternion
  76841. */
  76842. scaleInPlace(value: number): Quaternion;
  76843. /**
  76844. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76845. * @param scale defines the scale factor
  76846. * @param result defines the Quaternion object where to store the result
  76847. * @returns the unmodified current quaternion
  76848. */
  76849. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76850. /**
  76851. * Multiplies two quaternions
  76852. * @param q1 defines the second operand
  76853. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76854. */
  76855. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76856. /**
  76857. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76858. * @param q1 defines the second operand
  76859. * @param result defines the target quaternion
  76860. * @returns the current quaternion
  76861. */
  76862. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76863. /**
  76864. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76865. * @param q1 defines the second operand
  76866. * @returns the currentupdated quaternion
  76867. */
  76868. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76869. /**
  76870. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76871. * @param ref defines the target quaternion
  76872. * @returns the current quaternion
  76873. */
  76874. conjugateToRef(ref: Quaternion): Quaternion;
  76875. /**
  76876. * Conjugates in place (1-q) the current quaternion
  76877. * @returns the current updated quaternion
  76878. */
  76879. conjugateInPlace(): Quaternion;
  76880. /**
  76881. * Conjugates in place (1-q) the current quaternion
  76882. * @returns a new quaternion
  76883. */
  76884. conjugate(): Quaternion;
  76885. /**
  76886. * Gets length of current quaternion
  76887. * @returns the quaternion length (float)
  76888. */
  76889. length(): number;
  76890. /**
  76891. * Normalize in place the current quaternion
  76892. * @returns the current updated quaternion
  76893. */
  76894. normalize(): Quaternion;
  76895. /**
  76896. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76897. * @param order is a reserved parameter and is ignore for now
  76898. * @returns a new Vector3 containing the Euler angles
  76899. */
  76900. toEulerAngles(order?: string): Vector3;
  76901. /**
  76902. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76903. * @param result defines the vector which will be filled with the Euler angles
  76904. * @param order is a reserved parameter and is ignore for now
  76905. * @returns the current unchanged quaternion
  76906. */
  76907. toEulerAnglesToRef(result: Vector3): Quaternion;
  76908. /**
  76909. * Updates the given rotation matrix with the current quaternion values
  76910. * @param result defines the target matrix
  76911. * @returns the current unchanged quaternion
  76912. */
  76913. toRotationMatrix(result: Matrix): Quaternion;
  76914. /**
  76915. * Updates the current quaternion from the given rotation matrix values
  76916. * @param matrix defines the source matrix
  76917. * @returns the current updated quaternion
  76918. */
  76919. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76920. /**
  76921. * Creates a new quaternion from a rotation matrix
  76922. * @param matrix defines the source matrix
  76923. * @returns a new quaternion created from the given rotation matrix values
  76924. */
  76925. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76926. /**
  76927. * Updates the given quaternion with the given rotation matrix values
  76928. * @param matrix defines the source matrix
  76929. * @param result defines the target quaternion
  76930. */
  76931. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76932. /**
  76933. * Returns the dot product (float) between the quaternions "left" and "right"
  76934. * @param left defines the left operand
  76935. * @param right defines the right operand
  76936. * @returns the dot product
  76937. */
  76938. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76939. /**
  76940. * Checks if the two quaternions are close to each other
  76941. * @param quat0 defines the first quaternion to check
  76942. * @param quat1 defines the second quaternion to check
  76943. * @returns true if the two quaternions are close to each other
  76944. */
  76945. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76946. /**
  76947. * Creates an empty quaternion
  76948. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76949. */
  76950. static Zero(): Quaternion;
  76951. /**
  76952. * Inverse a given quaternion
  76953. * @param q defines the source quaternion
  76954. * @returns a new quaternion as the inverted current quaternion
  76955. */
  76956. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76957. /**
  76958. * Inverse a given quaternion
  76959. * @param q defines the source quaternion
  76960. * @param result the quaternion the result will be stored in
  76961. * @returns the result quaternion
  76962. */
  76963. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76964. /**
  76965. * Creates an identity quaternion
  76966. * @returns the identity quaternion
  76967. */
  76968. static Identity(): Quaternion;
  76969. /**
  76970. * Gets a boolean indicating if the given quaternion is identity
  76971. * @param quaternion defines the quaternion to check
  76972. * @returns true if the quaternion is identity
  76973. */
  76974. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76975. /**
  76976. * Creates a quaternion from a rotation around an axis
  76977. * @param axis defines the axis to use
  76978. * @param angle defines the angle to use
  76979. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76980. */
  76981. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76982. /**
  76983. * Creates a rotation around an axis and stores it into the given quaternion
  76984. * @param axis defines the axis to use
  76985. * @param angle defines the angle to use
  76986. * @param result defines the target quaternion
  76987. * @returns the target quaternion
  76988. */
  76989. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76990. /**
  76991. * Creates a new quaternion from data stored into an array
  76992. * @param array defines the data source
  76993. * @param offset defines the offset in the source array where the data starts
  76994. * @returns a new quaternion
  76995. */
  76996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76997. /**
  76998. * Create a quaternion from Euler rotation angles
  76999. * @param x Pitch
  77000. * @param y Yaw
  77001. * @param z Roll
  77002. * @returns the new Quaternion
  77003. */
  77004. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77005. /**
  77006. * Updates a quaternion from Euler rotation angles
  77007. * @param x Pitch
  77008. * @param y Yaw
  77009. * @param z Roll
  77010. * @param result the quaternion to store the result
  77011. * @returns the updated quaternion
  77012. */
  77013. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77014. /**
  77015. * Create a quaternion from Euler rotation vector
  77016. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77017. * @returns the new Quaternion
  77018. */
  77019. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77020. /**
  77021. * Updates a quaternion from Euler rotation vector
  77022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77023. * @param result the quaternion to store the result
  77024. * @returns the updated quaternion
  77025. */
  77026. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77027. /**
  77028. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77029. * @param yaw defines the rotation around Y axis
  77030. * @param pitch defines the rotation around X axis
  77031. * @param roll defines the rotation around Z axis
  77032. * @returns the new quaternion
  77033. */
  77034. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77035. /**
  77036. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77037. * @param yaw defines the rotation around Y axis
  77038. * @param pitch defines the rotation around X axis
  77039. * @param roll defines the rotation around Z axis
  77040. * @param result defines the target quaternion
  77041. */
  77042. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77043. /**
  77044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77045. * @param alpha defines the rotation around first axis
  77046. * @param beta defines the rotation around second axis
  77047. * @param gamma defines the rotation around third axis
  77048. * @returns the new quaternion
  77049. */
  77050. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77051. /**
  77052. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77053. * @param alpha defines the rotation around first axis
  77054. * @param beta defines the rotation around second axis
  77055. * @param gamma defines the rotation around third axis
  77056. * @param result defines the target quaternion
  77057. */
  77058. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77059. /**
  77060. * 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)
  77061. * @param axis1 defines the first axis
  77062. * @param axis2 defines the second axis
  77063. * @param axis3 defines the third axis
  77064. * @returns the new quaternion
  77065. */
  77066. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77067. /**
  77068. * 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
  77069. * @param axis1 defines the first axis
  77070. * @param axis2 defines the second axis
  77071. * @param axis3 defines the third axis
  77072. * @param ref defines the target quaternion
  77073. */
  77074. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77075. /**
  77076. * Interpolates between two quaternions
  77077. * @param left defines first quaternion
  77078. * @param right defines second quaternion
  77079. * @param amount defines the gradient to use
  77080. * @returns the new interpolated quaternion
  77081. */
  77082. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77083. /**
  77084. * Interpolates between two quaternions and stores it into a target quaternion
  77085. * @param left defines first quaternion
  77086. * @param right defines second quaternion
  77087. * @param amount defines the gradient to use
  77088. * @param result defines the target quaternion
  77089. */
  77090. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77091. /**
  77092. * Interpolate between two quaternions using Hermite interpolation
  77093. * @param value1 defines first quaternion
  77094. * @param tangent1 defines the incoming tangent
  77095. * @param value2 defines second quaternion
  77096. * @param tangent2 defines the outgoing tangent
  77097. * @param amount defines the target quaternion
  77098. * @returns the new interpolated quaternion
  77099. */
  77100. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77101. }
  77102. /**
  77103. * Class used to store matrix data (4x4)
  77104. */
  77105. export class Matrix {
  77106. private static _updateFlagSeed;
  77107. private static _identityReadOnly;
  77108. private _isIdentity;
  77109. private _isIdentityDirty;
  77110. private _isIdentity3x2;
  77111. private _isIdentity3x2Dirty;
  77112. /**
  77113. * Gets the update flag of the matrix which is an unique number for the matrix.
  77114. * It will be incremented every time the matrix data change.
  77115. * You can use it to speed the comparison between two versions of the same matrix.
  77116. */
  77117. updateFlag: number;
  77118. private readonly _m;
  77119. /**
  77120. * Gets the internal data of the matrix
  77121. */
  77122. get m(): DeepImmutable<Float32Array>;
  77123. /** @hidden */
  77124. _markAsUpdated(): void;
  77125. /** @hidden */
  77126. private _updateIdentityStatus;
  77127. /**
  77128. * Creates an empty matrix (filled with zeros)
  77129. */
  77130. constructor();
  77131. /**
  77132. * Check if the current matrix is identity
  77133. * @returns true is the matrix is the identity matrix
  77134. */
  77135. isIdentity(): boolean;
  77136. /**
  77137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77138. * @returns true is the matrix is the identity matrix
  77139. */
  77140. isIdentityAs3x2(): boolean;
  77141. /**
  77142. * Gets the determinant of the matrix
  77143. * @returns the matrix determinant
  77144. */
  77145. determinant(): number;
  77146. /**
  77147. * Returns the matrix as a Float32Array
  77148. * @returns the matrix underlying array
  77149. */
  77150. toArray(): DeepImmutable<Float32Array>;
  77151. /**
  77152. * Returns the matrix as a Float32Array
  77153. * @returns the matrix underlying array.
  77154. */
  77155. asArray(): DeepImmutable<Float32Array>;
  77156. /**
  77157. * Inverts the current matrix in place
  77158. * @returns the current inverted matrix
  77159. */
  77160. invert(): Matrix;
  77161. /**
  77162. * Sets all the matrix elements to zero
  77163. * @returns the current matrix
  77164. */
  77165. reset(): Matrix;
  77166. /**
  77167. * Adds the current matrix with a second one
  77168. * @param other defines the matrix to add
  77169. * @returns a new matrix as the addition of the current matrix and the given one
  77170. */
  77171. add(other: DeepImmutable<Matrix>): Matrix;
  77172. /**
  77173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77174. * @param other defines the matrix to add
  77175. * @param result defines the target matrix
  77176. * @returns the current matrix
  77177. */
  77178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77179. /**
  77180. * Adds in place the given matrix to the current matrix
  77181. * @param other defines the second operand
  77182. * @returns the current updated matrix
  77183. */
  77184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77185. /**
  77186. * Sets the given matrix to the current inverted Matrix
  77187. * @param other defines the target matrix
  77188. * @returns the unmodified current matrix
  77189. */
  77190. invertToRef(other: Matrix): Matrix;
  77191. /**
  77192. * add a value at the specified position in the current Matrix
  77193. * @param index the index of the value within the matrix. between 0 and 15.
  77194. * @param value the value to be added
  77195. * @returns the current updated matrix
  77196. */
  77197. addAtIndex(index: number, value: number): Matrix;
  77198. /**
  77199. * mutiply the specified position in the current Matrix by a value
  77200. * @param index the index of the value within the matrix. between 0 and 15.
  77201. * @param value the value to be added
  77202. * @returns the current updated matrix
  77203. */
  77204. multiplyAtIndex(index: number, value: number): Matrix;
  77205. /**
  77206. * Inserts the translation vector (using 3 floats) in the current matrix
  77207. * @param x defines the 1st component of the translation
  77208. * @param y defines the 2nd component of the translation
  77209. * @param z defines the 3rd component of the translation
  77210. * @returns the current updated matrix
  77211. */
  77212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77213. /**
  77214. * Adds the translation vector (using 3 floats) in the current matrix
  77215. * @param x defines the 1st component of the translation
  77216. * @param y defines the 2nd component of the translation
  77217. * @param z defines the 3rd component of the translation
  77218. * @returns the current updated matrix
  77219. */
  77220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77221. /**
  77222. * Inserts the translation vector in the current matrix
  77223. * @param vector3 defines the translation to insert
  77224. * @returns the current updated matrix
  77225. */
  77226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77227. /**
  77228. * Gets the translation value of the current matrix
  77229. * @returns a new Vector3 as the extracted translation from the matrix
  77230. */
  77231. getTranslation(): Vector3;
  77232. /**
  77233. * Fill a Vector3 with the extracted translation from the matrix
  77234. * @param result defines the Vector3 where to store the translation
  77235. * @returns the current matrix
  77236. */
  77237. getTranslationToRef(result: Vector3): Matrix;
  77238. /**
  77239. * Remove rotation and scaling part from the matrix
  77240. * @returns the updated matrix
  77241. */
  77242. removeRotationAndScaling(): Matrix;
  77243. /**
  77244. * Multiply two matrices
  77245. * @param other defines the second operand
  77246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77247. */
  77248. multiply(other: DeepImmutable<Matrix>): Matrix;
  77249. /**
  77250. * Copy the current matrix from the given one
  77251. * @param other defines the source matrix
  77252. * @returns the current updated matrix
  77253. */
  77254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77255. /**
  77256. * Populates the given array from the starting index with the current matrix values
  77257. * @param array defines the target array
  77258. * @param offset defines the offset in the target array where to start storing values
  77259. * @returns the current matrix
  77260. */
  77261. copyToArray(array: Float32Array, offset?: number): Matrix;
  77262. /**
  77263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77264. * @param other defines the second operand
  77265. * @param result defines the matrix where to store the multiplication
  77266. * @returns the current matrix
  77267. */
  77268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77269. /**
  77270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77271. * @param other defines the second operand
  77272. * @param result defines the array where to store the multiplication
  77273. * @param offset defines the offset in the target array where to start storing values
  77274. * @returns the current matrix
  77275. */
  77276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77277. /**
  77278. * Check equality between this matrix and a second one
  77279. * @param value defines the second matrix to compare
  77280. * @returns true is the current matrix and the given one values are strictly equal
  77281. */
  77282. equals(value: DeepImmutable<Matrix>): boolean;
  77283. /**
  77284. * Clone the current matrix
  77285. * @returns a new matrix from the current matrix
  77286. */
  77287. clone(): Matrix;
  77288. /**
  77289. * Returns the name of the current matrix class
  77290. * @returns the string "Matrix"
  77291. */
  77292. getClassName(): string;
  77293. /**
  77294. * Gets the hash code of the current matrix
  77295. * @returns the hash code
  77296. */
  77297. getHashCode(): number;
  77298. /**
  77299. * Decomposes the current Matrix into a translation, rotation and scaling components
  77300. * @param scale defines the scale vector3 given as a reference to update
  77301. * @param rotation defines the rotation quaternion given as a reference to update
  77302. * @param translation defines the translation vector3 given as a reference to update
  77303. * @returns true if operation was successful
  77304. */
  77305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77306. /**
  77307. * Gets specific row of the matrix
  77308. * @param index defines the number of the row to get
  77309. * @returns the index-th row of the current matrix as a new Vector4
  77310. */
  77311. getRow(index: number): Nullable<Vector4>;
  77312. /**
  77313. * Sets the index-th row of the current matrix to the vector4 values
  77314. * @param index defines the number of the row to set
  77315. * @param row defines the target vector4
  77316. * @returns the updated current matrix
  77317. */
  77318. setRow(index: number, row: Vector4): Matrix;
  77319. /**
  77320. * Compute the transpose of the matrix
  77321. * @returns the new transposed matrix
  77322. */
  77323. transpose(): Matrix;
  77324. /**
  77325. * Compute the transpose of the matrix and store it in a given matrix
  77326. * @param result defines the target matrix
  77327. * @returns the current matrix
  77328. */
  77329. transposeToRef(result: Matrix): Matrix;
  77330. /**
  77331. * Sets the index-th row of the current matrix with the given 4 x float values
  77332. * @param index defines the row index
  77333. * @param x defines the x component to set
  77334. * @param y defines the y component to set
  77335. * @param z defines the z component to set
  77336. * @param w defines the w component to set
  77337. * @returns the updated current matrix
  77338. */
  77339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77340. /**
  77341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77342. * @param scale defines the scale factor
  77343. * @returns a new matrix
  77344. */
  77345. scale(scale: number): Matrix;
  77346. /**
  77347. * Scale the current matrix values by a factor to a given result matrix
  77348. * @param scale defines the scale factor
  77349. * @param result defines the matrix to store the result
  77350. * @returns the current matrix
  77351. */
  77352. scaleToRef(scale: number, result: Matrix): Matrix;
  77353. /**
  77354. * Scale the current matrix values by a factor and add the result to a given matrix
  77355. * @param scale defines the scale factor
  77356. * @param result defines the Matrix to store the result
  77357. * @returns the current matrix
  77358. */
  77359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77360. /**
  77361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77362. * @param ref matrix to store the result
  77363. */
  77364. toNormalMatrix(ref: Matrix): void;
  77365. /**
  77366. * Gets only rotation part of the current matrix
  77367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77368. */
  77369. getRotationMatrix(): Matrix;
  77370. /**
  77371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77372. * @param result defines the target matrix to store data to
  77373. * @returns the current matrix
  77374. */
  77375. getRotationMatrixToRef(result: Matrix): Matrix;
  77376. /**
  77377. * Toggles model matrix from being right handed to left handed in place and vice versa
  77378. */
  77379. toggleModelMatrixHandInPlace(): void;
  77380. /**
  77381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77382. */
  77383. toggleProjectionMatrixHandInPlace(): void;
  77384. /**
  77385. * Creates a matrix from an array
  77386. * @param array defines the source array
  77387. * @param offset defines an offset in the source array
  77388. * @returns a new Matrix set from the starting index of the given array
  77389. */
  77390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77391. /**
  77392. * Copy the content of an array into a given matrix
  77393. * @param array defines the source array
  77394. * @param offset defines an offset in the source array
  77395. * @param result defines the target matrix
  77396. */
  77397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77398. /**
  77399. * Stores an array into a matrix after having multiplied each component by a given factor
  77400. * @param array defines the source array
  77401. * @param offset defines the offset in the source array
  77402. * @param scale defines the scaling factor
  77403. * @param result defines the target matrix
  77404. */
  77405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77406. /**
  77407. * Gets an identity matrix that must not be updated
  77408. */
  77409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77410. /**
  77411. * Stores a list of values (16) inside a given matrix
  77412. * @param initialM11 defines 1st value of 1st row
  77413. * @param initialM12 defines 2nd value of 1st row
  77414. * @param initialM13 defines 3rd value of 1st row
  77415. * @param initialM14 defines 4th value of 1st row
  77416. * @param initialM21 defines 1st value of 2nd row
  77417. * @param initialM22 defines 2nd value of 2nd row
  77418. * @param initialM23 defines 3rd value of 2nd row
  77419. * @param initialM24 defines 4th value of 2nd row
  77420. * @param initialM31 defines 1st value of 3rd row
  77421. * @param initialM32 defines 2nd value of 3rd row
  77422. * @param initialM33 defines 3rd value of 3rd row
  77423. * @param initialM34 defines 4th value of 3rd row
  77424. * @param initialM41 defines 1st value of 4th row
  77425. * @param initialM42 defines 2nd value of 4th row
  77426. * @param initialM43 defines 3rd value of 4th row
  77427. * @param initialM44 defines 4th value of 4th row
  77428. * @param result defines the target matrix
  77429. */
  77430. 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;
  77431. /**
  77432. * Creates new matrix from a list of values (16)
  77433. * @param initialM11 defines 1st value of 1st row
  77434. * @param initialM12 defines 2nd value of 1st row
  77435. * @param initialM13 defines 3rd value of 1st row
  77436. * @param initialM14 defines 4th value of 1st row
  77437. * @param initialM21 defines 1st value of 2nd row
  77438. * @param initialM22 defines 2nd value of 2nd row
  77439. * @param initialM23 defines 3rd value of 2nd row
  77440. * @param initialM24 defines 4th value of 2nd row
  77441. * @param initialM31 defines 1st value of 3rd row
  77442. * @param initialM32 defines 2nd value of 3rd row
  77443. * @param initialM33 defines 3rd value of 3rd row
  77444. * @param initialM34 defines 4th value of 3rd row
  77445. * @param initialM41 defines 1st value of 4th row
  77446. * @param initialM42 defines 2nd value of 4th row
  77447. * @param initialM43 defines 3rd value of 4th row
  77448. * @param initialM44 defines 4th value of 4th row
  77449. * @returns the new matrix
  77450. */
  77451. 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;
  77452. /**
  77453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77454. * @param scale defines the scale vector3
  77455. * @param rotation defines the rotation quaternion
  77456. * @param translation defines the translation vector3
  77457. * @returns a new matrix
  77458. */
  77459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77460. /**
  77461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77462. * @param scale defines the scale vector3
  77463. * @param rotation defines the rotation quaternion
  77464. * @param translation defines the translation vector3
  77465. * @param result defines the target matrix
  77466. */
  77467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77468. /**
  77469. * Creates a new identity matrix
  77470. * @returns a new identity matrix
  77471. */
  77472. static Identity(): Matrix;
  77473. /**
  77474. * Creates a new identity matrix and stores the result in a given matrix
  77475. * @param result defines the target matrix
  77476. */
  77477. static IdentityToRef(result: Matrix): void;
  77478. /**
  77479. * Creates a new zero matrix
  77480. * @returns a new zero matrix
  77481. */
  77482. static Zero(): Matrix;
  77483. /**
  77484. * Creates a new rotation matrix for "angle" radians around the X axis
  77485. * @param angle defines the angle (in radians) to use
  77486. * @return the new matrix
  77487. */
  77488. static RotationX(angle: number): Matrix;
  77489. /**
  77490. * Creates a new matrix as the invert of a given matrix
  77491. * @param source defines the source matrix
  77492. * @returns the new matrix
  77493. */
  77494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77495. /**
  77496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77497. * @param angle defines the angle (in radians) to use
  77498. * @param result defines the target matrix
  77499. */
  77500. static RotationXToRef(angle: number, result: Matrix): void;
  77501. /**
  77502. * Creates a new rotation matrix for "angle" radians around the Y axis
  77503. * @param angle defines the angle (in radians) to use
  77504. * @return the new matrix
  77505. */
  77506. static RotationY(angle: number): Matrix;
  77507. /**
  77508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77509. * @param angle defines the angle (in radians) to use
  77510. * @param result defines the target matrix
  77511. */
  77512. static RotationYToRef(angle: number, result: Matrix): void;
  77513. /**
  77514. * Creates a new rotation matrix for "angle" radians around the Z axis
  77515. * @param angle defines the angle (in radians) to use
  77516. * @return the new matrix
  77517. */
  77518. static RotationZ(angle: number): Matrix;
  77519. /**
  77520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77521. * @param angle defines the angle (in radians) to use
  77522. * @param result defines the target matrix
  77523. */
  77524. static RotationZToRef(angle: number, result: Matrix): void;
  77525. /**
  77526. * Creates a new rotation matrix for "angle" radians around the given axis
  77527. * @param axis defines the axis to use
  77528. * @param angle defines the angle (in radians) to use
  77529. * @return the new matrix
  77530. */
  77531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77532. /**
  77533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77534. * @param axis defines the axis to use
  77535. * @param angle defines the angle (in radians) to use
  77536. * @param result defines the target matrix
  77537. */
  77538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77539. /**
  77540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77542. * @param from defines the vector to align
  77543. * @param to defines the vector to align to
  77544. * @param result defines the target matrix
  77545. */
  77546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77547. /**
  77548. * Creates a rotation matrix
  77549. * @param yaw defines the yaw angle in radians (Y axis)
  77550. * @param pitch defines the pitch angle in radians (X axis)
  77551. * @param roll defines the roll angle in radians (X axis)
  77552. * @returns the new rotation matrix
  77553. */
  77554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77555. /**
  77556. * Creates a rotation matrix and stores it in a given matrix
  77557. * @param yaw defines the yaw angle in radians (Y axis)
  77558. * @param pitch defines the pitch angle in radians (X axis)
  77559. * @param roll defines the roll angle in radians (X axis)
  77560. * @param result defines the target matrix
  77561. */
  77562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77563. /**
  77564. * Creates a scaling matrix
  77565. * @param x defines the scale factor on X axis
  77566. * @param y defines the scale factor on Y axis
  77567. * @param z defines the scale factor on Z axis
  77568. * @returns the new matrix
  77569. */
  77570. static Scaling(x: number, y: number, z: number): Matrix;
  77571. /**
  77572. * Creates a scaling matrix and stores it in a given matrix
  77573. * @param x defines the scale factor on X axis
  77574. * @param y defines the scale factor on Y axis
  77575. * @param z defines the scale factor on Z axis
  77576. * @param result defines the target matrix
  77577. */
  77578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77579. /**
  77580. * Creates a translation matrix
  77581. * @param x defines the translation on X axis
  77582. * @param y defines the translation on Y axis
  77583. * @param z defines the translationon Z axis
  77584. * @returns the new matrix
  77585. */
  77586. static Translation(x: number, y: number, z: number): Matrix;
  77587. /**
  77588. * Creates a translation matrix and stores it in a given matrix
  77589. * @param x defines the translation on X axis
  77590. * @param y defines the translation on Y axis
  77591. * @param z defines the translationon Z axis
  77592. * @param result defines the target matrix
  77593. */
  77594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77595. /**
  77596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77597. * @param startValue defines the start value
  77598. * @param endValue defines the end value
  77599. * @param gradient defines the gradient factor
  77600. * @returns the new matrix
  77601. */
  77602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77603. /**
  77604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77605. * @param startValue defines the start value
  77606. * @param endValue defines the end value
  77607. * @param gradient defines the gradient factor
  77608. * @param result defines the Matrix object where to store data
  77609. */
  77610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77611. /**
  77612. * Builds a new matrix whose values are computed by:
  77613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77616. * @param startValue defines the first matrix
  77617. * @param endValue defines the second matrix
  77618. * @param gradient defines the gradient between the two matrices
  77619. * @returns the new matrix
  77620. */
  77621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77622. /**
  77623. * Update a matrix to values which are computed by:
  77624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77627. * @param startValue defines the first matrix
  77628. * @param endValue defines the second matrix
  77629. * @param gradient defines the gradient between the two matrices
  77630. * @param result defines the target matrix
  77631. */
  77632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77633. /**
  77634. * 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"
  77635. * This function works in left handed mode
  77636. * @param eye defines the final position of the entity
  77637. * @param target defines where the entity should look at
  77638. * @param up defines the up vector for the entity
  77639. * @returns the new matrix
  77640. */
  77641. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77642. /**
  77643. * 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".
  77644. * This function works in left handed mode
  77645. * @param eye defines the final position of the entity
  77646. * @param target defines where the entity should look at
  77647. * @param up defines the up vector for the entity
  77648. * @param result defines the target matrix
  77649. */
  77650. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77651. /**
  77652. * 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"
  77653. * This function works in right handed mode
  77654. * @param eye defines the final position of the entity
  77655. * @param target defines where the entity should look at
  77656. * @param up defines the up vector for the entity
  77657. * @returns the new matrix
  77658. */
  77659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77660. /**
  77661. * 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".
  77662. * This function works in right handed mode
  77663. * @param eye defines the final position of the entity
  77664. * @param target defines where the entity should look at
  77665. * @param up defines the up vector for the entity
  77666. * @param result defines the target matrix
  77667. */
  77668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77669. /**
  77670. * Create a left-handed orthographic projection matrix
  77671. * @param width defines the viewport width
  77672. * @param height defines the viewport height
  77673. * @param znear defines the near clip plane
  77674. * @param zfar defines the far clip plane
  77675. * @returns a new matrix as a left-handed orthographic projection matrix
  77676. */
  77677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77678. /**
  77679. * Store a left-handed orthographic projection to a given matrix
  77680. * @param width defines the viewport width
  77681. * @param height defines the viewport height
  77682. * @param znear defines the near clip plane
  77683. * @param zfar defines the far clip plane
  77684. * @param result defines the target matrix
  77685. */
  77686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77687. /**
  77688. * Create a left-handed orthographic projection matrix
  77689. * @param left defines the viewport left coordinate
  77690. * @param right defines the viewport right coordinate
  77691. * @param bottom defines the viewport bottom coordinate
  77692. * @param top defines the viewport top coordinate
  77693. * @param znear defines the near clip plane
  77694. * @param zfar defines the far clip plane
  77695. * @returns a new matrix as a left-handed orthographic projection matrix
  77696. */
  77697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77698. /**
  77699. * Stores a left-handed orthographic projection into a given matrix
  77700. * @param left defines the viewport left coordinate
  77701. * @param right defines the viewport right coordinate
  77702. * @param bottom defines the viewport bottom coordinate
  77703. * @param top defines the viewport top coordinate
  77704. * @param znear defines the near clip plane
  77705. * @param zfar defines the far clip plane
  77706. * @param result defines the target matrix
  77707. */
  77708. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77709. /**
  77710. * Creates a right-handed orthographic projection matrix
  77711. * @param left defines the viewport left coordinate
  77712. * @param right defines the viewport right coordinate
  77713. * @param bottom defines the viewport bottom coordinate
  77714. * @param top defines the viewport top coordinate
  77715. * @param znear defines the near clip plane
  77716. * @param zfar defines the far clip plane
  77717. * @returns a new matrix as a right-handed orthographic projection matrix
  77718. */
  77719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77720. /**
  77721. * Stores a right-handed orthographic projection into a given matrix
  77722. * @param left defines the viewport left coordinate
  77723. * @param right defines the viewport right coordinate
  77724. * @param bottom defines the viewport bottom coordinate
  77725. * @param top defines the viewport top coordinate
  77726. * @param znear defines the near clip plane
  77727. * @param zfar defines the far clip plane
  77728. * @param result defines the target matrix
  77729. */
  77730. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77731. /**
  77732. * Creates a left-handed perspective projection matrix
  77733. * @param width defines the viewport width
  77734. * @param height defines the viewport height
  77735. * @param znear defines the near clip plane
  77736. * @param zfar defines the far clip plane
  77737. * @returns a new matrix as a left-handed perspective projection matrix
  77738. */
  77739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77740. /**
  77741. * Creates a left-handed perspective projection matrix
  77742. * @param fov defines the horizontal field of view
  77743. * @param aspect defines the aspect ratio
  77744. * @param znear defines the near clip plane
  77745. * @param zfar defines the far clip plane
  77746. * @returns a new matrix as a left-handed perspective projection matrix
  77747. */
  77748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77749. /**
  77750. * Stores a left-handed perspective projection into a given matrix
  77751. * @param fov defines the horizontal field of view
  77752. * @param aspect defines the aspect ratio
  77753. * @param znear defines the near clip plane
  77754. * @param zfar defines the far clip plane
  77755. * @param result defines the target matrix
  77756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77757. */
  77758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77759. /**
  77760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77761. * @param fov defines the horizontal field of view
  77762. * @param aspect defines the aspect ratio
  77763. * @param znear defines the near clip plane
  77764. * @param zfar not used as infinity is used as far clip
  77765. * @param result defines the target matrix
  77766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77767. */
  77768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77769. /**
  77770. * Creates a right-handed perspective projection matrix
  77771. * @param fov defines the horizontal field of view
  77772. * @param aspect defines the aspect ratio
  77773. * @param znear defines the near clip plane
  77774. * @param zfar defines the far clip plane
  77775. * @returns a new matrix as a right-handed perspective projection matrix
  77776. */
  77777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77778. /**
  77779. * Stores a right-handed perspective projection into a given matrix
  77780. * @param fov defines the horizontal field of view
  77781. * @param aspect defines the aspect ratio
  77782. * @param znear defines the near clip plane
  77783. * @param zfar defines the far clip plane
  77784. * @param result defines the target matrix
  77785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77786. */
  77787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77788. /**
  77789. * Stores a right-handed perspective projection into a given matrix
  77790. * @param fov defines the horizontal field of view
  77791. * @param aspect defines the aspect ratio
  77792. * @param znear defines the near clip plane
  77793. * @param zfar not used as infinity is used as far clip
  77794. * @param result defines the target matrix
  77795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77796. */
  77797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77798. /**
  77799. * Stores a perspective projection for WebVR info a given matrix
  77800. * @param fov defines the field of view
  77801. * @param znear defines the near clip plane
  77802. * @param zfar defines the far clip plane
  77803. * @param result defines the target matrix
  77804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77805. */
  77806. static PerspectiveFovWebVRToRef(fov: {
  77807. upDegrees: number;
  77808. downDegrees: number;
  77809. leftDegrees: number;
  77810. rightDegrees: number;
  77811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77812. /**
  77813. * Computes a complete transformation matrix
  77814. * @param viewport defines the viewport to use
  77815. * @param world defines the world matrix
  77816. * @param view defines the view matrix
  77817. * @param projection defines the projection matrix
  77818. * @param zmin defines the near clip plane
  77819. * @param zmax defines the far clip plane
  77820. * @returns the transformation matrix
  77821. */
  77822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77823. /**
  77824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77825. * @param matrix defines the matrix to use
  77826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77827. */
  77828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77829. /**
  77830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77831. * @param matrix defines the matrix to use
  77832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77833. */
  77834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77835. /**
  77836. * Compute the transpose of a given matrix
  77837. * @param matrix defines the matrix to transpose
  77838. * @returns the new matrix
  77839. */
  77840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77841. /**
  77842. * Compute the transpose of a matrix and store it in a target matrix
  77843. * @param matrix defines the matrix to transpose
  77844. * @param result defines the target matrix
  77845. */
  77846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77847. /**
  77848. * Computes a reflection matrix from a plane
  77849. * @param plane defines the reflection plane
  77850. * @returns a new matrix
  77851. */
  77852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77853. /**
  77854. * Computes a reflection matrix from a plane
  77855. * @param plane defines the reflection plane
  77856. * @param result defines the target matrix
  77857. */
  77858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77859. /**
  77860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77861. * @param xaxis defines the value of the 1st axis
  77862. * @param yaxis defines the value of the 2nd axis
  77863. * @param zaxis defines the value of the 3rd axis
  77864. * @param result defines the target matrix
  77865. */
  77866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77867. /**
  77868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77869. * @param quat defines the quaternion to use
  77870. * @param result defines the target matrix
  77871. */
  77872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77873. }
  77874. /**
  77875. * @hidden
  77876. */
  77877. export class TmpVectors {
  77878. static Vector2: Vector2[];
  77879. static Vector3: Vector3[];
  77880. static Vector4: Vector4[];
  77881. static Quaternion: Quaternion[];
  77882. static Matrix: Matrix[];
  77883. }
  77884. }
  77885. declare module BABYLON {
  77886. /**
  77887. * Defines potential orientation for back face culling
  77888. */
  77889. export enum Orientation {
  77890. /**
  77891. * Clockwise
  77892. */
  77893. CW = 0,
  77894. /** Counter clockwise */
  77895. CCW = 1
  77896. }
  77897. /** Class used to represent a Bezier curve */
  77898. export class BezierCurve {
  77899. /**
  77900. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77901. * @param t defines the time
  77902. * @param x1 defines the left coordinate on X axis
  77903. * @param y1 defines the left coordinate on Y axis
  77904. * @param x2 defines the right coordinate on X axis
  77905. * @param y2 defines the right coordinate on Y axis
  77906. * @returns the interpolated value
  77907. */
  77908. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77909. }
  77910. /**
  77911. * Defines angle representation
  77912. */
  77913. export class Angle {
  77914. private _radians;
  77915. /**
  77916. * Creates an Angle object of "radians" radians (float).
  77917. * @param radians the angle in radians
  77918. */
  77919. constructor(radians: number);
  77920. /**
  77921. * Get value in degrees
  77922. * @returns the Angle value in degrees (float)
  77923. */
  77924. degrees(): number;
  77925. /**
  77926. * Get value in radians
  77927. * @returns the Angle value in radians (float)
  77928. */
  77929. radians(): number;
  77930. /**
  77931. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77932. * @param a defines first vector
  77933. * @param b defines second vector
  77934. * @returns a new Angle
  77935. */
  77936. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77937. /**
  77938. * Gets a new Angle object from the given float in radians
  77939. * @param radians defines the angle value in radians
  77940. * @returns a new Angle
  77941. */
  77942. static FromRadians(radians: number): Angle;
  77943. /**
  77944. * Gets a new Angle object from the given float in degrees
  77945. * @param degrees defines the angle value in degrees
  77946. * @returns a new Angle
  77947. */
  77948. static FromDegrees(degrees: number): Angle;
  77949. }
  77950. /**
  77951. * This represents an arc in a 2d space.
  77952. */
  77953. export class Arc2 {
  77954. /** Defines the start point of the arc */
  77955. startPoint: Vector2;
  77956. /** Defines the mid point of the arc */
  77957. midPoint: Vector2;
  77958. /** Defines the end point of the arc */
  77959. endPoint: Vector2;
  77960. /**
  77961. * Defines the center point of the arc.
  77962. */
  77963. centerPoint: Vector2;
  77964. /**
  77965. * Defines the radius of the arc.
  77966. */
  77967. radius: number;
  77968. /**
  77969. * Defines the angle of the arc (from mid point to end point).
  77970. */
  77971. angle: Angle;
  77972. /**
  77973. * Defines the start angle of the arc (from start point to middle point).
  77974. */
  77975. startAngle: Angle;
  77976. /**
  77977. * Defines the orientation of the arc (clock wise/counter clock wise).
  77978. */
  77979. orientation: Orientation;
  77980. /**
  77981. * Creates an Arc object from the three given points : start, middle and end.
  77982. * @param startPoint Defines the start point of the arc
  77983. * @param midPoint Defines the midlle point of the arc
  77984. * @param endPoint Defines the end point of the arc
  77985. */
  77986. constructor(
  77987. /** Defines the start point of the arc */
  77988. startPoint: Vector2,
  77989. /** Defines the mid point of the arc */
  77990. midPoint: Vector2,
  77991. /** Defines the end point of the arc */
  77992. endPoint: Vector2);
  77993. }
  77994. /**
  77995. * Represents a 2D path made up of multiple 2D points
  77996. */
  77997. export class Path2 {
  77998. private _points;
  77999. private _length;
  78000. /**
  78001. * If the path start and end point are the same
  78002. */
  78003. closed: boolean;
  78004. /**
  78005. * Creates a Path2 object from the starting 2D coordinates x and y.
  78006. * @param x the starting points x value
  78007. * @param y the starting points y value
  78008. */
  78009. constructor(x: number, y: number);
  78010. /**
  78011. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78012. * @param x the added points x value
  78013. * @param y the added points y value
  78014. * @returns the updated Path2.
  78015. */
  78016. addLineTo(x: number, y: number): Path2;
  78017. /**
  78018. * 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.
  78019. * @param midX middle point x value
  78020. * @param midY middle point y value
  78021. * @param endX end point x value
  78022. * @param endY end point y value
  78023. * @param numberOfSegments (default: 36)
  78024. * @returns the updated Path2.
  78025. */
  78026. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78027. /**
  78028. * Closes the Path2.
  78029. * @returns the Path2.
  78030. */
  78031. close(): Path2;
  78032. /**
  78033. * Gets the sum of the distance between each sequential point in the path
  78034. * @returns the Path2 total length (float).
  78035. */
  78036. length(): number;
  78037. /**
  78038. * Gets the points which construct the path
  78039. * @returns the Path2 internal array of points.
  78040. */
  78041. getPoints(): Vector2[];
  78042. /**
  78043. * Retreives the point at the distance aways from the starting point
  78044. * @param normalizedLengthPosition the length along the path to retreive the point from
  78045. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78046. */
  78047. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78048. /**
  78049. * Creates a new path starting from an x and y position
  78050. * @param x starting x value
  78051. * @param y starting y value
  78052. * @returns a new Path2 starting at the coordinates (x, y).
  78053. */
  78054. static StartingAt(x: number, y: number): Path2;
  78055. }
  78056. /**
  78057. * Represents a 3D path made up of multiple 3D points
  78058. */
  78059. export class Path3D {
  78060. /**
  78061. * an array of Vector3, the curve axis of the Path3D
  78062. */
  78063. path: Vector3[];
  78064. private _curve;
  78065. private _distances;
  78066. private _tangents;
  78067. private _normals;
  78068. private _binormals;
  78069. private _raw;
  78070. private _alignTangentsWithPath;
  78071. private readonly _pointAtData;
  78072. /**
  78073. * new Path3D(path, normal, raw)
  78074. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78075. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78076. * @param path an array of Vector3, the curve axis of the Path3D
  78077. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78078. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78079. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78080. */
  78081. constructor(
  78082. /**
  78083. * an array of Vector3, the curve axis of the Path3D
  78084. */
  78085. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78086. /**
  78087. * Returns the Path3D array of successive Vector3 designing its curve.
  78088. * @returns the Path3D array of successive Vector3 designing its curve.
  78089. */
  78090. getCurve(): Vector3[];
  78091. /**
  78092. * Returns the Path3D array of successive Vector3 designing its curve.
  78093. * @returns the Path3D array of successive Vector3 designing its curve.
  78094. */
  78095. getPoints(): Vector3[];
  78096. /**
  78097. * @returns the computed length (float) of the path.
  78098. */
  78099. length(): number;
  78100. /**
  78101. * Returns an array populated with tangent vectors on each Path3D curve point.
  78102. * @returns an array populated with tangent vectors on each Path3D curve point.
  78103. */
  78104. getTangents(): Vector3[];
  78105. /**
  78106. * Returns an array populated with normal vectors on each Path3D curve point.
  78107. * @returns an array populated with normal vectors on each Path3D curve point.
  78108. */
  78109. getNormals(): Vector3[];
  78110. /**
  78111. * Returns an array populated with binormal vectors on each Path3D curve point.
  78112. * @returns an array populated with binormal vectors on each Path3D curve point.
  78113. */
  78114. getBinormals(): Vector3[];
  78115. /**
  78116. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78117. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78118. */
  78119. getDistances(): number[];
  78120. /**
  78121. * Returns an interpolated point along this path
  78122. * @param position the position of the point along this path, from 0.0 to 1.0
  78123. * @returns a new Vector3 as the point
  78124. */
  78125. getPointAt(position: number): Vector3;
  78126. /**
  78127. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78128. * @param position the position of the point along this path, from 0.0 to 1.0
  78129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78130. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78131. */
  78132. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78133. /**
  78134. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78135. * @param position the position of the point along this path, from 0.0 to 1.0
  78136. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78137. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78138. */
  78139. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78140. /**
  78141. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78142. * @param position the position of the point along this path, from 0.0 to 1.0
  78143. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78144. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78145. */
  78146. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78147. /**
  78148. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78149. * @param position the position of the point along this path, from 0.0 to 1.0
  78150. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78151. */
  78152. getDistanceAt(position: number): number;
  78153. /**
  78154. * Returns the array index of the previous point of an interpolated point along this path
  78155. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78156. * @returns the array index
  78157. */
  78158. getPreviousPointIndexAt(position: number): number;
  78159. /**
  78160. * 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)
  78161. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78162. * @returns the sub position
  78163. */
  78164. getSubPositionAt(position: number): number;
  78165. /**
  78166. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78167. * @param target the vector of which to get the closest position to
  78168. * @returns the position of the closest virtual point on this path to the target vector
  78169. */
  78170. getClosestPositionTo(target: Vector3): number;
  78171. /**
  78172. * Returns a sub path (slice) of this path
  78173. * @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
  78174. * @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
  78175. * @returns a sub path (slice) of this path
  78176. */
  78177. slice(start?: number, end?: number): Path3D;
  78178. /**
  78179. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78180. * @param path path which all values are copied into the curves points
  78181. * @param firstNormal which should be projected onto the curve
  78182. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78183. * @returns the same object updated.
  78184. */
  78185. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78186. private _compute;
  78187. private _getFirstNonNullVector;
  78188. private _getLastNonNullVector;
  78189. private _normalVector;
  78190. /**
  78191. * Updates the point at data for an interpolated point along this curve
  78192. * @param position the position of the point along this curve, from 0.0 to 1.0
  78193. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78194. * @returns the (updated) point at data
  78195. */
  78196. private _updatePointAtData;
  78197. /**
  78198. * Updates the point at data from the specified parameters
  78199. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78200. * @param point the interpolated point
  78201. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78202. */
  78203. private _setPointAtData;
  78204. /**
  78205. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78206. */
  78207. private _updateInterpolationMatrix;
  78208. }
  78209. /**
  78210. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78211. * A Curve3 is designed from a series of successive Vector3.
  78212. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78213. */
  78214. export class Curve3 {
  78215. private _points;
  78216. private _length;
  78217. /**
  78218. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78219. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78220. * @param v1 (Vector3) the control point
  78221. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78222. * @param nbPoints (integer) the wanted number of points in the curve
  78223. * @returns the created Curve3
  78224. */
  78225. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78226. /**
  78227. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78228. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78229. * @param v1 (Vector3) the first control point
  78230. * @param v2 (Vector3) the second control point
  78231. * @param v3 (Vector3) the end point of the Cubic Bezier
  78232. * @param nbPoints (integer) the wanted number of points in the curve
  78233. * @returns the created Curve3
  78234. */
  78235. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78236. /**
  78237. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78238. * @param p1 (Vector3) the origin point of the Hermite Spline
  78239. * @param t1 (Vector3) the tangent vector at the origin point
  78240. * @param p2 (Vector3) the end point of the Hermite Spline
  78241. * @param t2 (Vector3) the tangent vector at the end point
  78242. * @param nbPoints (integer) the wanted number of points in the curve
  78243. * @returns the created Curve3
  78244. */
  78245. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78246. /**
  78247. * Returns a Curve3 object along a CatmullRom Spline curve :
  78248. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78249. * @param nbPoints (integer) the wanted number of points between each curve control points
  78250. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78251. * @returns the created Curve3
  78252. */
  78253. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78254. /**
  78255. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78256. * A Curve3 is designed from a series of successive Vector3.
  78257. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78258. * @param points points which make up the curve
  78259. */
  78260. constructor(points: Vector3[]);
  78261. /**
  78262. * @returns the Curve3 stored array of successive Vector3
  78263. */
  78264. getPoints(): Vector3[];
  78265. /**
  78266. * @returns the computed length (float) of the curve.
  78267. */
  78268. length(): number;
  78269. /**
  78270. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78271. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78272. * curveA and curveB keep unchanged.
  78273. * @param curve the curve to continue from this curve
  78274. * @returns the newly constructed curve
  78275. */
  78276. continue(curve: DeepImmutable<Curve3>): Curve3;
  78277. private _computeLength;
  78278. }
  78279. }
  78280. declare module BABYLON {
  78281. /**
  78282. * This represents the main contract an easing function should follow.
  78283. * Easing functions are used throughout the animation system.
  78284. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78285. */
  78286. export interface IEasingFunction {
  78287. /**
  78288. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78289. * of the easing function.
  78290. * The link below provides some of the most common examples of easing functions.
  78291. * @see https://easings.net/
  78292. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78293. * @returns the corresponding value on the curve defined by the easing function
  78294. */
  78295. ease(gradient: number): number;
  78296. }
  78297. /**
  78298. * Base class used for every default easing function.
  78299. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78300. */
  78301. export class EasingFunction implements IEasingFunction {
  78302. /**
  78303. * Interpolation follows the mathematical formula associated with the easing function.
  78304. */
  78305. static readonly EASINGMODE_EASEIN: number;
  78306. /**
  78307. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78308. */
  78309. static readonly EASINGMODE_EASEOUT: number;
  78310. /**
  78311. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78312. */
  78313. static readonly EASINGMODE_EASEINOUT: number;
  78314. private _easingMode;
  78315. /**
  78316. * Sets the easing mode of the current function.
  78317. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78318. */
  78319. setEasingMode(easingMode: number): void;
  78320. /**
  78321. * Gets the current easing mode.
  78322. * @returns the easing mode
  78323. */
  78324. getEasingMode(): number;
  78325. /**
  78326. * @hidden
  78327. */
  78328. easeInCore(gradient: number): number;
  78329. /**
  78330. * Given an input gradient between 0 and 1, this returns the corresponding value
  78331. * of the easing function.
  78332. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78333. * @returns the corresponding value on the curve defined by the easing function
  78334. */
  78335. ease(gradient: number): number;
  78336. }
  78337. /**
  78338. * Easing function with a circle shape (see link below).
  78339. * @see https://easings.net/#easeInCirc
  78340. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78341. */
  78342. export class CircleEase extends EasingFunction implements IEasingFunction {
  78343. /** @hidden */
  78344. easeInCore(gradient: number): number;
  78345. }
  78346. /**
  78347. * Easing function with a ease back shape (see link below).
  78348. * @see https://easings.net/#easeInBack
  78349. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78350. */
  78351. export class BackEase extends EasingFunction implements IEasingFunction {
  78352. /** Defines the amplitude of the function */
  78353. amplitude: number;
  78354. /**
  78355. * Instantiates a back ease easing
  78356. * @see https://easings.net/#easeInBack
  78357. * @param amplitude Defines the amplitude of the function
  78358. */
  78359. constructor(
  78360. /** Defines the amplitude of the function */
  78361. amplitude?: number);
  78362. /** @hidden */
  78363. easeInCore(gradient: number): number;
  78364. }
  78365. /**
  78366. * Easing function with a bouncing shape (see link below).
  78367. * @see https://easings.net/#easeInBounce
  78368. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78369. */
  78370. export class BounceEase extends EasingFunction implements IEasingFunction {
  78371. /** Defines the number of bounces */
  78372. bounces: number;
  78373. /** Defines the amplitude of the bounce */
  78374. bounciness: number;
  78375. /**
  78376. * Instantiates a bounce easing
  78377. * @see https://easings.net/#easeInBounce
  78378. * @param bounces Defines the number of bounces
  78379. * @param bounciness Defines the amplitude of the bounce
  78380. */
  78381. constructor(
  78382. /** Defines the number of bounces */
  78383. bounces?: number,
  78384. /** Defines the amplitude of the bounce */
  78385. bounciness?: number);
  78386. /** @hidden */
  78387. easeInCore(gradient: number): number;
  78388. }
  78389. /**
  78390. * Easing function with a power of 3 shape (see link below).
  78391. * @see https://easings.net/#easeInCubic
  78392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78393. */
  78394. export class CubicEase extends EasingFunction implements IEasingFunction {
  78395. /** @hidden */
  78396. easeInCore(gradient: number): number;
  78397. }
  78398. /**
  78399. * Easing function with an elastic shape (see link below).
  78400. * @see https://easings.net/#easeInElastic
  78401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78402. */
  78403. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78404. /** Defines the number of oscillations*/
  78405. oscillations: number;
  78406. /** Defines the amplitude of the oscillations*/
  78407. springiness: number;
  78408. /**
  78409. * Instantiates an elastic easing function
  78410. * @see https://easings.net/#easeInElastic
  78411. * @param oscillations Defines the number of oscillations
  78412. * @param springiness Defines the amplitude of the oscillations
  78413. */
  78414. constructor(
  78415. /** Defines the number of oscillations*/
  78416. oscillations?: number,
  78417. /** Defines the amplitude of the oscillations*/
  78418. springiness?: number);
  78419. /** @hidden */
  78420. easeInCore(gradient: number): number;
  78421. }
  78422. /**
  78423. * Easing function with an exponential shape (see link below).
  78424. * @see https://easings.net/#easeInExpo
  78425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78426. */
  78427. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78428. /** Defines the exponent of the function */
  78429. exponent: number;
  78430. /**
  78431. * Instantiates an exponential easing function
  78432. * @see https://easings.net/#easeInExpo
  78433. * @param exponent Defines the exponent of the function
  78434. */
  78435. constructor(
  78436. /** Defines the exponent of the function */
  78437. exponent?: number);
  78438. /** @hidden */
  78439. easeInCore(gradient: number): number;
  78440. }
  78441. /**
  78442. * Easing function with a power shape (see link below).
  78443. * @see https://easings.net/#easeInQuad
  78444. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78445. */
  78446. export class PowerEase extends EasingFunction implements IEasingFunction {
  78447. /** Defines the power of the function */
  78448. power: number;
  78449. /**
  78450. * Instantiates an power base easing function
  78451. * @see https://easings.net/#easeInQuad
  78452. * @param power Defines the power of the function
  78453. */
  78454. constructor(
  78455. /** Defines the power of the function */
  78456. power?: number);
  78457. /** @hidden */
  78458. easeInCore(gradient: number): number;
  78459. }
  78460. /**
  78461. * Easing function with a power of 2 shape (see link below).
  78462. * @see https://easings.net/#easeInQuad
  78463. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78464. */
  78465. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78466. /** @hidden */
  78467. easeInCore(gradient: number): number;
  78468. }
  78469. /**
  78470. * Easing function with a power of 4 shape (see link below).
  78471. * @see https://easings.net/#easeInQuart
  78472. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78473. */
  78474. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78475. /** @hidden */
  78476. easeInCore(gradient: number): number;
  78477. }
  78478. /**
  78479. * Easing function with a power of 5 shape (see link below).
  78480. * @see https://easings.net/#easeInQuint
  78481. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78482. */
  78483. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78484. /** @hidden */
  78485. easeInCore(gradient: number): number;
  78486. }
  78487. /**
  78488. * Easing function with a sin shape (see link below).
  78489. * @see https://easings.net/#easeInSine
  78490. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78491. */
  78492. export class SineEase extends EasingFunction implements IEasingFunction {
  78493. /** @hidden */
  78494. easeInCore(gradient: number): number;
  78495. }
  78496. /**
  78497. * Easing function with a bezier shape (see link below).
  78498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78500. */
  78501. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78502. /** Defines the x component of the start tangent in the bezier curve */
  78503. x1: number;
  78504. /** Defines the y component of the start tangent in the bezier curve */
  78505. y1: number;
  78506. /** Defines the x component of the end tangent in the bezier curve */
  78507. x2: number;
  78508. /** Defines the y component of the end tangent in the bezier curve */
  78509. y2: number;
  78510. /**
  78511. * Instantiates a bezier function
  78512. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78513. * @param x1 Defines the x component of the start tangent in the bezier curve
  78514. * @param y1 Defines the y component of the start tangent in the bezier curve
  78515. * @param x2 Defines the x component of the end tangent in the bezier curve
  78516. * @param y2 Defines the y component of the end tangent in the bezier curve
  78517. */
  78518. constructor(
  78519. /** Defines the x component of the start tangent in the bezier curve */
  78520. x1?: number,
  78521. /** Defines the y component of the start tangent in the bezier curve */
  78522. y1?: number,
  78523. /** Defines the x component of the end tangent in the bezier curve */
  78524. x2?: number,
  78525. /** Defines the y component of the end tangent in the bezier curve */
  78526. y2?: number);
  78527. /** @hidden */
  78528. easeInCore(gradient: number): number;
  78529. }
  78530. }
  78531. declare module BABYLON {
  78532. /**
  78533. * Class used to hold a RBG color
  78534. */
  78535. export class Color3 {
  78536. /**
  78537. * Defines the red component (between 0 and 1, default is 0)
  78538. */
  78539. r: number;
  78540. /**
  78541. * Defines the green component (between 0 and 1, default is 0)
  78542. */
  78543. g: number;
  78544. /**
  78545. * Defines the blue component (between 0 and 1, default is 0)
  78546. */
  78547. b: number;
  78548. /**
  78549. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78550. * @param r defines the red component (between 0 and 1, default is 0)
  78551. * @param g defines the green component (between 0 and 1, default is 0)
  78552. * @param b defines the blue component (between 0 and 1, default is 0)
  78553. */
  78554. constructor(
  78555. /**
  78556. * Defines the red component (between 0 and 1, default is 0)
  78557. */
  78558. r?: number,
  78559. /**
  78560. * Defines the green component (between 0 and 1, default is 0)
  78561. */
  78562. g?: number,
  78563. /**
  78564. * Defines the blue component (between 0 and 1, default is 0)
  78565. */
  78566. b?: number);
  78567. /**
  78568. * Creates a string with the Color3 current values
  78569. * @returns the string representation of the Color3 object
  78570. */
  78571. toString(): string;
  78572. /**
  78573. * Returns the string "Color3"
  78574. * @returns "Color3"
  78575. */
  78576. getClassName(): string;
  78577. /**
  78578. * Compute the Color3 hash code
  78579. * @returns an unique number that can be used to hash Color3 objects
  78580. */
  78581. getHashCode(): number;
  78582. /**
  78583. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78584. * @param array defines the array where to store the r,g,b components
  78585. * @param index defines an optional index in the target array to define where to start storing values
  78586. * @returns the current Color3 object
  78587. */
  78588. toArray(array: FloatArray, index?: number): Color3;
  78589. /**
  78590. * Returns a new Color4 object from the current Color3 and the given alpha
  78591. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78592. * @returns a new Color4 object
  78593. */
  78594. toColor4(alpha?: number): Color4;
  78595. /**
  78596. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78597. * @returns the new array
  78598. */
  78599. asArray(): number[];
  78600. /**
  78601. * Returns the luminance value
  78602. * @returns a float value
  78603. */
  78604. toLuminance(): number;
  78605. /**
  78606. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78607. * @param otherColor defines the second operand
  78608. * @returns the new Color3 object
  78609. */
  78610. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78611. /**
  78612. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78613. * @param otherColor defines the second operand
  78614. * @param result defines the Color3 object where to store the result
  78615. * @returns the current Color3
  78616. */
  78617. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78618. /**
  78619. * Determines equality between Color3 objects
  78620. * @param otherColor defines the second operand
  78621. * @returns true if the rgb values are equal to the given ones
  78622. */
  78623. equals(otherColor: DeepImmutable<Color3>): boolean;
  78624. /**
  78625. * Determines equality between the current Color3 object and a set of r,b,g values
  78626. * @param r defines the red component to check
  78627. * @param g defines the green component to check
  78628. * @param b defines the blue component to check
  78629. * @returns true if the rgb values are equal to the given ones
  78630. */
  78631. equalsFloats(r: number, g: number, b: number): boolean;
  78632. /**
  78633. * Multiplies in place each rgb value by scale
  78634. * @param scale defines the scaling factor
  78635. * @returns the updated Color3
  78636. */
  78637. scale(scale: number): Color3;
  78638. /**
  78639. * Multiplies the rgb values by scale and stores the result into "result"
  78640. * @param scale defines the scaling factor
  78641. * @param result defines the Color3 object where to store the result
  78642. * @returns the unmodified current Color3
  78643. */
  78644. scaleToRef(scale: number, result: Color3): Color3;
  78645. /**
  78646. * Scale the current Color3 values by a factor and add the result to a given Color3
  78647. * @param scale defines the scale factor
  78648. * @param result defines color to store the result into
  78649. * @returns the unmodified current Color3
  78650. */
  78651. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78652. /**
  78653. * Clamps the rgb values by the min and max values and stores the result into "result"
  78654. * @param min defines minimum clamping value (default is 0)
  78655. * @param max defines maximum clamping value (default is 1)
  78656. * @param result defines color to store the result into
  78657. * @returns the original Color3
  78658. */
  78659. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78660. /**
  78661. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78662. * @param otherColor defines the second operand
  78663. * @returns the new Color3
  78664. */
  78665. add(otherColor: DeepImmutable<Color3>): Color3;
  78666. /**
  78667. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78668. * @param otherColor defines the second operand
  78669. * @param result defines Color3 object to store the result into
  78670. * @returns the unmodified current Color3
  78671. */
  78672. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78673. /**
  78674. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78675. * @param otherColor defines the second operand
  78676. * @returns the new Color3
  78677. */
  78678. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78679. /**
  78680. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78681. * @param otherColor defines the second operand
  78682. * @param result defines Color3 object to store the result into
  78683. * @returns the unmodified current Color3
  78684. */
  78685. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78686. /**
  78687. * Copy the current object
  78688. * @returns a new Color3 copied the current one
  78689. */
  78690. clone(): Color3;
  78691. /**
  78692. * Copies the rgb values from the source in the current Color3
  78693. * @param source defines the source Color3 object
  78694. * @returns the updated Color3 object
  78695. */
  78696. copyFrom(source: DeepImmutable<Color3>): Color3;
  78697. /**
  78698. * Updates the Color3 rgb values from the given floats
  78699. * @param r defines the red component to read from
  78700. * @param g defines the green component to read from
  78701. * @param b defines the blue component to read from
  78702. * @returns the current Color3 object
  78703. */
  78704. copyFromFloats(r: number, g: number, b: number): Color3;
  78705. /**
  78706. * Updates the Color3 rgb values from the given floats
  78707. * @param r defines the red component to read from
  78708. * @param g defines the green component to read from
  78709. * @param b defines the blue component to read from
  78710. * @returns the current Color3 object
  78711. */
  78712. set(r: number, g: number, b: number): Color3;
  78713. /**
  78714. * Compute the Color3 hexadecimal code as a string
  78715. * @returns a string containing the hexadecimal representation of the Color3 object
  78716. */
  78717. toHexString(): string;
  78718. /**
  78719. * Computes a new Color3 converted from the current one to linear space
  78720. * @returns a new Color3 object
  78721. */
  78722. toLinearSpace(): Color3;
  78723. /**
  78724. * Converts current color in rgb space to HSV values
  78725. * @returns a new color3 representing the HSV values
  78726. */
  78727. toHSV(): Color3;
  78728. /**
  78729. * Converts current color in rgb space to HSV values
  78730. * @param result defines the Color3 where to store the HSV values
  78731. */
  78732. toHSVToRef(result: Color3): void;
  78733. /**
  78734. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78735. * @param convertedColor defines the Color3 object where to store the linear space version
  78736. * @returns the unmodified Color3
  78737. */
  78738. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78739. /**
  78740. * Computes a new Color3 converted from the current one to gamma space
  78741. * @returns a new Color3 object
  78742. */
  78743. toGammaSpace(): Color3;
  78744. /**
  78745. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78746. * @param convertedColor defines the Color3 object where to store the gamma space version
  78747. * @returns the unmodified Color3
  78748. */
  78749. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78750. private static _BlackReadOnly;
  78751. /**
  78752. * Convert Hue, saturation and value to a Color3 (RGB)
  78753. * @param hue defines the hue
  78754. * @param saturation defines the saturation
  78755. * @param value defines the value
  78756. * @param result defines the Color3 where to store the RGB values
  78757. */
  78758. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78759. /**
  78760. * Creates a new Color3 from the string containing valid hexadecimal values
  78761. * @param hex defines a string containing valid hexadecimal values
  78762. * @returns a new Color3 object
  78763. */
  78764. static FromHexString(hex: string): Color3;
  78765. /**
  78766. * Creates a new Color3 from the starting index of the given array
  78767. * @param array defines the source array
  78768. * @param offset defines an offset in the source array
  78769. * @returns a new Color3 object
  78770. */
  78771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78772. /**
  78773. * Creates a new Color3 from integer values (< 256)
  78774. * @param r defines the red component to read from (value between 0 and 255)
  78775. * @param g defines the green component to read from (value between 0 and 255)
  78776. * @param b defines the blue component to read from (value between 0 and 255)
  78777. * @returns a new Color3 object
  78778. */
  78779. static FromInts(r: number, g: number, b: number): Color3;
  78780. /**
  78781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78782. * @param start defines the start Color3 value
  78783. * @param end defines the end Color3 value
  78784. * @param amount defines the gradient value between start and end
  78785. * @returns a new Color3 object
  78786. */
  78787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78788. /**
  78789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78790. * @param left defines the start value
  78791. * @param right defines the end value
  78792. * @param amount defines the gradient factor
  78793. * @param result defines the Color3 object where to store the result
  78794. */
  78795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78796. /**
  78797. * Returns a Color3 value containing a red color
  78798. * @returns a new Color3 object
  78799. */
  78800. static Red(): Color3;
  78801. /**
  78802. * Returns a Color3 value containing a green color
  78803. * @returns a new Color3 object
  78804. */
  78805. static Green(): Color3;
  78806. /**
  78807. * Returns a Color3 value containing a blue color
  78808. * @returns a new Color3 object
  78809. */
  78810. static Blue(): Color3;
  78811. /**
  78812. * Returns a Color3 value containing a black color
  78813. * @returns a new Color3 object
  78814. */
  78815. static Black(): Color3;
  78816. /**
  78817. * Gets a Color3 value containing a black color that must not be updated
  78818. */
  78819. static get BlackReadOnly(): DeepImmutable<Color3>;
  78820. /**
  78821. * Returns a Color3 value containing a white color
  78822. * @returns a new Color3 object
  78823. */
  78824. static White(): Color3;
  78825. /**
  78826. * Returns a Color3 value containing a purple color
  78827. * @returns a new Color3 object
  78828. */
  78829. static Purple(): Color3;
  78830. /**
  78831. * Returns a Color3 value containing a magenta color
  78832. * @returns a new Color3 object
  78833. */
  78834. static Magenta(): Color3;
  78835. /**
  78836. * Returns a Color3 value containing a yellow color
  78837. * @returns a new Color3 object
  78838. */
  78839. static Yellow(): Color3;
  78840. /**
  78841. * Returns a Color3 value containing a gray color
  78842. * @returns a new Color3 object
  78843. */
  78844. static Gray(): Color3;
  78845. /**
  78846. * Returns a Color3 value containing a teal color
  78847. * @returns a new Color3 object
  78848. */
  78849. static Teal(): Color3;
  78850. /**
  78851. * Returns a Color3 value containing a random color
  78852. * @returns a new Color3 object
  78853. */
  78854. static Random(): Color3;
  78855. }
  78856. /**
  78857. * Class used to hold a RBGA color
  78858. */
  78859. export class Color4 {
  78860. /**
  78861. * Defines the red component (between 0 and 1, default is 0)
  78862. */
  78863. r: number;
  78864. /**
  78865. * Defines the green component (between 0 and 1, default is 0)
  78866. */
  78867. g: number;
  78868. /**
  78869. * Defines the blue component (between 0 and 1, default is 0)
  78870. */
  78871. b: number;
  78872. /**
  78873. * Defines the alpha component (between 0 and 1, default is 1)
  78874. */
  78875. a: number;
  78876. /**
  78877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78878. * @param r defines the red component (between 0 and 1, default is 0)
  78879. * @param g defines the green component (between 0 and 1, default is 0)
  78880. * @param b defines the blue component (between 0 and 1, default is 0)
  78881. * @param a defines the alpha component (between 0 and 1, default is 1)
  78882. */
  78883. constructor(
  78884. /**
  78885. * Defines the red component (between 0 and 1, default is 0)
  78886. */
  78887. r?: number,
  78888. /**
  78889. * Defines the green component (between 0 and 1, default is 0)
  78890. */
  78891. g?: number,
  78892. /**
  78893. * Defines the blue component (between 0 and 1, default is 0)
  78894. */
  78895. b?: number,
  78896. /**
  78897. * Defines the alpha component (between 0 and 1, default is 1)
  78898. */
  78899. a?: number);
  78900. /**
  78901. * Adds in place the given Color4 values to the current Color4 object
  78902. * @param right defines the second operand
  78903. * @returns the current updated Color4 object
  78904. */
  78905. addInPlace(right: DeepImmutable<Color4>): Color4;
  78906. /**
  78907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78908. * @returns the new array
  78909. */
  78910. asArray(): number[];
  78911. /**
  78912. * Stores from the starting index in the given array the Color4 successive values
  78913. * @param array defines the array where to store the r,g,b components
  78914. * @param index defines an optional index in the target array to define where to start storing values
  78915. * @returns the current Color4 object
  78916. */
  78917. toArray(array: number[], index?: number): Color4;
  78918. /**
  78919. * Determines equality between Color4 objects
  78920. * @param otherColor defines the second operand
  78921. * @returns true if the rgba values are equal to the given ones
  78922. */
  78923. equals(otherColor: DeepImmutable<Color4>): boolean;
  78924. /**
  78925. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78926. * @param right defines the second operand
  78927. * @returns a new Color4 object
  78928. */
  78929. add(right: DeepImmutable<Color4>): Color4;
  78930. /**
  78931. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78932. * @param right defines the second operand
  78933. * @returns a new Color4 object
  78934. */
  78935. subtract(right: DeepImmutable<Color4>): Color4;
  78936. /**
  78937. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78938. * @param right defines the second operand
  78939. * @param result defines the Color4 object where to store the result
  78940. * @returns the current Color4 object
  78941. */
  78942. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78943. /**
  78944. * Creates a new Color4 with the current Color4 values multiplied by scale
  78945. * @param scale defines the scaling factor to apply
  78946. * @returns a new Color4 object
  78947. */
  78948. scale(scale: number): Color4;
  78949. /**
  78950. * Multiplies the current Color4 values by scale and stores the result in "result"
  78951. * @param scale defines the scaling factor to apply
  78952. * @param result defines the Color4 object where to store the result
  78953. * @returns the current unmodified Color4
  78954. */
  78955. scaleToRef(scale: number, result: Color4): Color4;
  78956. /**
  78957. * Scale the current Color4 values by a factor and add the result to a given Color4
  78958. * @param scale defines the scale factor
  78959. * @param result defines the Color4 object where to store the result
  78960. * @returns the unmodified current Color4
  78961. */
  78962. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78963. /**
  78964. * Clamps the rgb values by the min and max values and stores the result into "result"
  78965. * @param min defines minimum clamping value (default is 0)
  78966. * @param max defines maximum clamping value (default is 1)
  78967. * @param result defines color to store the result into.
  78968. * @returns the cuurent Color4
  78969. */
  78970. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78971. /**
  78972. * Multipy an Color4 value by another and return a new Color4 object
  78973. * @param color defines the Color4 value to multiply by
  78974. * @returns a new Color4 object
  78975. */
  78976. multiply(color: Color4): Color4;
  78977. /**
  78978. * Multipy a Color4 value by another and push the result in a reference value
  78979. * @param color defines the Color4 value to multiply by
  78980. * @param result defines the Color4 to fill the result in
  78981. * @returns the result Color4
  78982. */
  78983. multiplyToRef(color: Color4, result: Color4): Color4;
  78984. /**
  78985. * Creates a string with the Color4 current values
  78986. * @returns the string representation of the Color4 object
  78987. */
  78988. toString(): string;
  78989. /**
  78990. * Returns the string "Color4"
  78991. * @returns "Color4"
  78992. */
  78993. getClassName(): string;
  78994. /**
  78995. * Compute the Color4 hash code
  78996. * @returns an unique number that can be used to hash Color4 objects
  78997. */
  78998. getHashCode(): number;
  78999. /**
  79000. * Creates a new Color4 copied from the current one
  79001. * @returns a new Color4 object
  79002. */
  79003. clone(): Color4;
  79004. /**
  79005. * Copies the given Color4 values into the current one
  79006. * @param source defines the source Color4 object
  79007. * @returns the current updated Color4 object
  79008. */
  79009. copyFrom(source: Color4): Color4;
  79010. /**
  79011. * Copies the given float values into the current one
  79012. * @param r defines the red component to read from
  79013. * @param g defines the green component to read from
  79014. * @param b defines the blue component to read from
  79015. * @param a defines the alpha component to read from
  79016. * @returns the current updated Color4 object
  79017. */
  79018. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79019. /**
  79020. * Copies the given float values into the current one
  79021. * @param r defines the red component to read from
  79022. * @param g defines the green component to read from
  79023. * @param b defines the blue component to read from
  79024. * @param a defines the alpha component to read from
  79025. * @returns the current updated Color4 object
  79026. */
  79027. set(r: number, g: number, b: number, a: number): Color4;
  79028. /**
  79029. * Compute the Color4 hexadecimal code as a string
  79030. * @returns a string containing the hexadecimal representation of the Color4 object
  79031. */
  79032. toHexString(): string;
  79033. /**
  79034. * Computes a new Color4 converted from the current one to linear space
  79035. * @returns a new Color4 object
  79036. */
  79037. toLinearSpace(): Color4;
  79038. /**
  79039. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79040. * @param convertedColor defines the Color4 object where to store the linear space version
  79041. * @returns the unmodified Color4
  79042. */
  79043. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79044. /**
  79045. * Computes a new Color4 converted from the current one to gamma space
  79046. * @returns a new Color4 object
  79047. */
  79048. toGammaSpace(): Color4;
  79049. /**
  79050. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79051. * @param convertedColor defines the Color4 object where to store the gamma space version
  79052. * @returns the unmodified Color4
  79053. */
  79054. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79055. /**
  79056. * Creates a new Color4 from the string containing valid hexadecimal values
  79057. * @param hex defines a string containing valid hexadecimal values
  79058. * @returns a new Color4 object
  79059. */
  79060. static FromHexString(hex: string): Color4;
  79061. /**
  79062. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79063. * @param left defines the start value
  79064. * @param right defines the end value
  79065. * @param amount defines the gradient factor
  79066. * @returns a new Color4 object
  79067. */
  79068. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79069. /**
  79070. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79071. * @param left defines the start value
  79072. * @param right defines the end value
  79073. * @param amount defines the gradient factor
  79074. * @param result defines the Color4 object where to store data
  79075. */
  79076. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79077. /**
  79078. * Creates a new Color4 from a Color3 and an alpha value
  79079. * @param color3 defines the source Color3 to read from
  79080. * @param alpha defines the alpha component (1.0 by default)
  79081. * @returns a new Color4 object
  79082. */
  79083. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79084. /**
  79085. * Creates a new Color4 from the starting index element of the given array
  79086. * @param array defines the source array to read from
  79087. * @param offset defines the offset in the source array
  79088. * @returns a new Color4 object
  79089. */
  79090. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79091. /**
  79092. * Creates a new Color3 from integer values (< 256)
  79093. * @param r defines the red component to read from (value between 0 and 255)
  79094. * @param g defines the green component to read from (value between 0 and 255)
  79095. * @param b defines the blue component to read from (value between 0 and 255)
  79096. * @param a defines the alpha component to read from (value between 0 and 255)
  79097. * @returns a new Color3 object
  79098. */
  79099. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79100. /**
  79101. * Check the content of a given array and convert it to an array containing RGBA data
  79102. * If the original array was already containing count * 4 values then it is returned directly
  79103. * @param colors defines the array to check
  79104. * @param count defines the number of RGBA data to expect
  79105. * @returns an array containing count * 4 values (RGBA)
  79106. */
  79107. static CheckColors4(colors: number[], count: number): number[];
  79108. }
  79109. /**
  79110. * @hidden
  79111. */
  79112. export class TmpColors {
  79113. static Color3: Color3[];
  79114. static Color4: Color4[];
  79115. }
  79116. }
  79117. declare module BABYLON {
  79118. /**
  79119. * Defines an interface which represents an animation key frame
  79120. */
  79121. export interface IAnimationKey {
  79122. /**
  79123. * Frame of the key frame
  79124. */
  79125. frame: number;
  79126. /**
  79127. * Value at the specifies key frame
  79128. */
  79129. value: any;
  79130. /**
  79131. * The input tangent for the cubic hermite spline
  79132. */
  79133. inTangent?: any;
  79134. /**
  79135. * The output tangent for the cubic hermite spline
  79136. */
  79137. outTangent?: any;
  79138. /**
  79139. * The animation interpolation type
  79140. */
  79141. interpolation?: AnimationKeyInterpolation;
  79142. }
  79143. /**
  79144. * Enum for the animation key frame interpolation type
  79145. */
  79146. export enum AnimationKeyInterpolation {
  79147. /**
  79148. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79149. */
  79150. STEP = 1
  79151. }
  79152. }
  79153. declare module BABYLON {
  79154. /**
  79155. * Represents the range of an animation
  79156. */
  79157. export class AnimationRange {
  79158. /**The name of the animation range**/
  79159. name: string;
  79160. /**The starting frame of the animation */
  79161. from: number;
  79162. /**The ending frame of the animation*/
  79163. to: number;
  79164. /**
  79165. * Initializes the range of an animation
  79166. * @param name The name of the animation range
  79167. * @param from The starting frame of the animation
  79168. * @param to The ending frame of the animation
  79169. */
  79170. constructor(
  79171. /**The name of the animation range**/
  79172. name: string,
  79173. /**The starting frame of the animation */
  79174. from: number,
  79175. /**The ending frame of the animation*/
  79176. to: number);
  79177. /**
  79178. * Makes a copy of the animation range
  79179. * @returns A copy of the animation range
  79180. */
  79181. clone(): AnimationRange;
  79182. }
  79183. }
  79184. declare module BABYLON {
  79185. /**
  79186. * Composed of a frame, and an action function
  79187. */
  79188. export class AnimationEvent {
  79189. /** The frame for which the event is triggered **/
  79190. frame: number;
  79191. /** The event to perform when triggered **/
  79192. action: (currentFrame: number) => void;
  79193. /** Specifies if the event should be triggered only once**/
  79194. onlyOnce?: boolean | undefined;
  79195. /**
  79196. * Specifies if the animation event is done
  79197. */
  79198. isDone: boolean;
  79199. /**
  79200. * Initializes the animation event
  79201. * @param frame The frame for which the event is triggered
  79202. * @param action The event to perform when triggered
  79203. * @param onlyOnce Specifies if the event should be triggered only once
  79204. */
  79205. constructor(
  79206. /** The frame for which the event is triggered **/
  79207. frame: number,
  79208. /** The event to perform when triggered **/
  79209. action: (currentFrame: number) => void,
  79210. /** Specifies if the event should be triggered only once**/
  79211. onlyOnce?: boolean | undefined);
  79212. /** @hidden */
  79213. _clone(): AnimationEvent;
  79214. }
  79215. }
  79216. declare module BABYLON {
  79217. /**
  79218. * Interface used to define a behavior
  79219. */
  79220. export interface Behavior<T> {
  79221. /** gets or sets behavior's name */
  79222. name: string;
  79223. /**
  79224. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79225. */
  79226. init(): void;
  79227. /**
  79228. * Called when the behavior is attached to a target
  79229. * @param target defines the target where the behavior is attached to
  79230. */
  79231. attach(target: T): void;
  79232. /**
  79233. * Called when the behavior is detached from its target
  79234. */
  79235. detach(): void;
  79236. }
  79237. /**
  79238. * Interface implemented by classes supporting behaviors
  79239. */
  79240. export interface IBehaviorAware<T> {
  79241. /**
  79242. * Attach a behavior
  79243. * @param behavior defines the behavior to attach
  79244. * @returns the current host
  79245. */
  79246. addBehavior(behavior: Behavior<T>): T;
  79247. /**
  79248. * Remove a behavior from the current object
  79249. * @param behavior defines the behavior to detach
  79250. * @returns the current host
  79251. */
  79252. removeBehavior(behavior: Behavior<T>): T;
  79253. /**
  79254. * Gets a behavior using its name to search
  79255. * @param name defines the name to search
  79256. * @returns the behavior or null if not found
  79257. */
  79258. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79259. }
  79260. }
  79261. declare module BABYLON {
  79262. /**
  79263. * Defines an array and its length.
  79264. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79265. */
  79266. export interface ISmartArrayLike<T> {
  79267. /**
  79268. * The data of the array.
  79269. */
  79270. data: Array<T>;
  79271. /**
  79272. * The active length of the array.
  79273. */
  79274. length: number;
  79275. }
  79276. /**
  79277. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79278. */
  79279. export class SmartArray<T> implements ISmartArrayLike<T> {
  79280. /**
  79281. * The full set of data from the array.
  79282. */
  79283. data: Array<T>;
  79284. /**
  79285. * The active length of the array.
  79286. */
  79287. length: number;
  79288. protected _id: number;
  79289. /**
  79290. * Instantiates a Smart Array.
  79291. * @param capacity defines the default capacity of the array.
  79292. */
  79293. constructor(capacity: number);
  79294. /**
  79295. * Pushes a value at the end of the active data.
  79296. * @param value defines the object to push in the array.
  79297. */
  79298. push(value: T): void;
  79299. /**
  79300. * Iterates over the active data and apply the lambda to them.
  79301. * @param func defines the action to apply on each value.
  79302. */
  79303. forEach(func: (content: T) => void): void;
  79304. /**
  79305. * Sorts the full sets of data.
  79306. * @param compareFn defines the comparison function to apply.
  79307. */
  79308. sort(compareFn: (a: T, b: T) => number): void;
  79309. /**
  79310. * Resets the active data to an empty array.
  79311. */
  79312. reset(): void;
  79313. /**
  79314. * Releases all the data from the array as well as the array.
  79315. */
  79316. dispose(): void;
  79317. /**
  79318. * Concats the active data with a given array.
  79319. * @param array defines the data to concatenate with.
  79320. */
  79321. concat(array: any): void;
  79322. /**
  79323. * Returns the position of a value in the active data.
  79324. * @param value defines the value to find the index for
  79325. * @returns the index if found in the active data otherwise -1
  79326. */
  79327. indexOf(value: T): number;
  79328. /**
  79329. * Returns whether an element is part of the active data.
  79330. * @param value defines the value to look for
  79331. * @returns true if found in the active data otherwise false
  79332. */
  79333. contains(value: T): boolean;
  79334. private static _GlobalId;
  79335. }
  79336. /**
  79337. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79338. * The data in this array can only be present once
  79339. */
  79340. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79341. private _duplicateId;
  79342. /**
  79343. * Pushes a value at the end of the active data.
  79344. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79345. * @param value defines the object to push in the array.
  79346. */
  79347. push(value: T): void;
  79348. /**
  79349. * Pushes a value at the end of the active data.
  79350. * If the data is already present, it won t be added again
  79351. * @param value defines the object to push in the array.
  79352. * @returns true if added false if it was already present
  79353. */
  79354. pushNoDuplicate(value: T): boolean;
  79355. /**
  79356. * Resets the active data to an empty array.
  79357. */
  79358. reset(): void;
  79359. /**
  79360. * Concats the active data with a given array.
  79361. * This ensures no dupplicate will be present in the result.
  79362. * @param array defines the data to concatenate with.
  79363. */
  79364. concatWithNoDuplicate(array: any): void;
  79365. }
  79366. }
  79367. declare module BABYLON {
  79368. /**
  79369. * @ignore
  79370. * This is a list of all the different input types that are available in the application.
  79371. * Fo instance: ArcRotateCameraGamepadInput...
  79372. */
  79373. export var CameraInputTypes: {};
  79374. /**
  79375. * This is the contract to implement in order to create a new input class.
  79376. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79377. */
  79378. export interface ICameraInput<TCamera extends Camera> {
  79379. /**
  79380. * Defines the camera the input is attached to.
  79381. */
  79382. camera: Nullable<TCamera>;
  79383. /**
  79384. * Gets the class name of the current intput.
  79385. * @returns the class name
  79386. */
  79387. getClassName(): string;
  79388. /**
  79389. * Get the friendly name associated with the input class.
  79390. * @returns the input friendly name
  79391. */
  79392. getSimpleName(): string;
  79393. /**
  79394. * Attach the input controls to a specific dom element to get the input from.
  79395. * @param element Defines the element the controls should be listened from
  79396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79397. */
  79398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79399. /**
  79400. * Detach the current controls from the specified dom element.
  79401. * @param element Defines the element to stop listening the inputs from
  79402. */
  79403. detachControl(element: Nullable<HTMLElement>): void;
  79404. /**
  79405. * Update the current camera state depending on the inputs that have been used this frame.
  79406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79407. */
  79408. checkInputs?: () => void;
  79409. }
  79410. /**
  79411. * Represents a map of input types to input instance or input index to input instance.
  79412. */
  79413. export interface CameraInputsMap<TCamera extends Camera> {
  79414. /**
  79415. * Accessor to the input by input type.
  79416. */
  79417. [name: string]: ICameraInput<TCamera>;
  79418. /**
  79419. * Accessor to the input by input index.
  79420. */
  79421. [idx: number]: ICameraInput<TCamera>;
  79422. }
  79423. /**
  79424. * This represents the input manager used within a camera.
  79425. * It helps dealing with all the different kind of input attached to a camera.
  79426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79427. */
  79428. export class CameraInputsManager<TCamera extends Camera> {
  79429. /**
  79430. * Defines the list of inputs attahed to the camera.
  79431. */
  79432. attached: CameraInputsMap<TCamera>;
  79433. /**
  79434. * Defines the dom element the camera is collecting inputs from.
  79435. * This is null if the controls have not been attached.
  79436. */
  79437. attachedElement: Nullable<HTMLElement>;
  79438. /**
  79439. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79440. */
  79441. noPreventDefault: boolean;
  79442. /**
  79443. * Defined the camera the input manager belongs to.
  79444. */
  79445. camera: TCamera;
  79446. /**
  79447. * Update the current camera state depending on the inputs that have been used this frame.
  79448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79449. */
  79450. checkInputs: () => void;
  79451. /**
  79452. * Instantiate a new Camera Input Manager.
  79453. * @param camera Defines the camera the input manager blongs to
  79454. */
  79455. constructor(camera: TCamera);
  79456. /**
  79457. * Add an input method to a camera
  79458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79459. * @param input camera input method
  79460. */
  79461. add(input: ICameraInput<TCamera>): void;
  79462. /**
  79463. * Remove a specific input method from a camera
  79464. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79465. * @param inputToRemove camera input method
  79466. */
  79467. remove(inputToRemove: ICameraInput<TCamera>): void;
  79468. /**
  79469. * Remove a specific input type from a camera
  79470. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79471. * @param inputType the type of the input to remove
  79472. */
  79473. removeByType(inputType: string): void;
  79474. private _addCheckInputs;
  79475. /**
  79476. * Attach the input controls to the currently attached dom element to listen the events from.
  79477. * @param input Defines the input to attach
  79478. */
  79479. attachInput(input: ICameraInput<TCamera>): void;
  79480. /**
  79481. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79482. * @param element Defines the dom element to collect the events from
  79483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79484. */
  79485. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79486. /**
  79487. * Detach the current manager inputs controls from a specific dom element.
  79488. * @param element Defines the dom element to collect the events from
  79489. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79490. */
  79491. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79492. /**
  79493. * Rebuild the dynamic inputCheck function from the current list of
  79494. * defined inputs in the manager.
  79495. */
  79496. rebuildInputCheck(): void;
  79497. /**
  79498. * Remove all attached input methods from a camera
  79499. */
  79500. clear(): void;
  79501. /**
  79502. * Serialize the current input manager attached to a camera.
  79503. * This ensures than once parsed,
  79504. * the input associated to the camera will be identical to the current ones
  79505. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79506. */
  79507. serialize(serializedCamera: any): void;
  79508. /**
  79509. * Parses an input manager serialized JSON to restore the previous list of inputs
  79510. * and states associated to a camera.
  79511. * @param parsedCamera Defines the JSON to parse
  79512. */
  79513. parse(parsedCamera: any): void;
  79514. }
  79515. }
  79516. declare module BABYLON {
  79517. /**
  79518. * Class used to store data that will be store in GPU memory
  79519. */
  79520. export class Buffer {
  79521. private _engine;
  79522. private _buffer;
  79523. /** @hidden */
  79524. _data: Nullable<DataArray>;
  79525. private _updatable;
  79526. private _instanced;
  79527. private _divisor;
  79528. /**
  79529. * Gets the byte stride.
  79530. */
  79531. readonly byteStride: number;
  79532. /**
  79533. * Constructor
  79534. * @param engine the engine
  79535. * @param data the data to use for this buffer
  79536. * @param updatable whether the data is updatable
  79537. * @param stride the stride (optional)
  79538. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79539. * @param instanced whether the buffer is instanced (optional)
  79540. * @param useBytes set to true if the stride in in bytes (optional)
  79541. * @param divisor sets an optional divisor for instances (1 by default)
  79542. */
  79543. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79544. /**
  79545. * Create a new VertexBuffer based on the current buffer
  79546. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79547. * @param offset defines offset in the buffer (0 by default)
  79548. * @param size defines the size in floats of attributes (position is 3 for instance)
  79549. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79550. * @param instanced defines if the vertex buffer contains indexed data
  79551. * @param useBytes defines if the offset and stride are in bytes *
  79552. * @param divisor sets an optional divisor for instances (1 by default)
  79553. * @returns the new vertex buffer
  79554. */
  79555. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79556. /**
  79557. * Gets a boolean indicating if the Buffer is updatable?
  79558. * @returns true if the buffer is updatable
  79559. */
  79560. isUpdatable(): boolean;
  79561. /**
  79562. * Gets current buffer's data
  79563. * @returns a DataArray or null
  79564. */
  79565. getData(): Nullable<DataArray>;
  79566. /**
  79567. * Gets underlying native buffer
  79568. * @returns underlying native buffer
  79569. */
  79570. getBuffer(): Nullable<DataBuffer>;
  79571. /**
  79572. * Gets the stride in float32 units (i.e. byte stride / 4).
  79573. * May not be an integer if the byte stride is not divisible by 4.
  79574. * @returns the stride in float32 units
  79575. * @deprecated Please use byteStride instead.
  79576. */
  79577. getStrideSize(): number;
  79578. /**
  79579. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79580. * @param data defines the data to store
  79581. */
  79582. create(data?: Nullable<DataArray>): void;
  79583. /** @hidden */
  79584. _rebuild(): void;
  79585. /**
  79586. * Update current buffer data
  79587. * @param data defines the data to store
  79588. */
  79589. update(data: DataArray): void;
  79590. /**
  79591. * Updates the data directly.
  79592. * @param data the new data
  79593. * @param offset the new offset
  79594. * @param vertexCount the vertex count (optional)
  79595. * @param useBytes set to true if the offset is in bytes
  79596. */
  79597. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79598. /**
  79599. * Release all resources
  79600. */
  79601. dispose(): void;
  79602. }
  79603. /**
  79604. * Specialized buffer used to store vertex data
  79605. */
  79606. export class VertexBuffer {
  79607. /** @hidden */
  79608. _buffer: Buffer;
  79609. private _kind;
  79610. private _size;
  79611. private _ownsBuffer;
  79612. private _instanced;
  79613. private _instanceDivisor;
  79614. /**
  79615. * The byte type.
  79616. */
  79617. static readonly BYTE: number;
  79618. /**
  79619. * The unsigned byte type.
  79620. */
  79621. static readonly UNSIGNED_BYTE: number;
  79622. /**
  79623. * The short type.
  79624. */
  79625. static readonly SHORT: number;
  79626. /**
  79627. * The unsigned short type.
  79628. */
  79629. static readonly UNSIGNED_SHORT: number;
  79630. /**
  79631. * The integer type.
  79632. */
  79633. static readonly INT: number;
  79634. /**
  79635. * The unsigned integer type.
  79636. */
  79637. static readonly UNSIGNED_INT: number;
  79638. /**
  79639. * The float type.
  79640. */
  79641. static readonly FLOAT: number;
  79642. /**
  79643. * Gets or sets the instance divisor when in instanced mode
  79644. */
  79645. get instanceDivisor(): number;
  79646. set instanceDivisor(value: number);
  79647. /**
  79648. * Gets the byte stride.
  79649. */
  79650. readonly byteStride: number;
  79651. /**
  79652. * Gets the byte offset.
  79653. */
  79654. readonly byteOffset: number;
  79655. /**
  79656. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79657. */
  79658. readonly normalized: boolean;
  79659. /**
  79660. * Gets the data type of each component in the array.
  79661. */
  79662. readonly type: number;
  79663. /**
  79664. * Constructor
  79665. * @param engine the engine
  79666. * @param data the data to use for this vertex buffer
  79667. * @param kind the vertex buffer kind
  79668. * @param updatable whether the data is updatable
  79669. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79670. * @param stride the stride (optional)
  79671. * @param instanced whether the buffer is instanced (optional)
  79672. * @param offset the offset of the data (optional)
  79673. * @param size the number of components (optional)
  79674. * @param type the type of the component (optional)
  79675. * @param normalized whether the data contains normalized data (optional)
  79676. * @param useBytes set to true if stride and offset are in bytes (optional)
  79677. * @param divisor defines the instance divisor to use (1 by default)
  79678. */
  79679. 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);
  79680. /** @hidden */
  79681. _rebuild(): void;
  79682. /**
  79683. * Returns the kind of the VertexBuffer (string)
  79684. * @returns a string
  79685. */
  79686. getKind(): string;
  79687. /**
  79688. * Gets a boolean indicating if the VertexBuffer is updatable?
  79689. * @returns true if the buffer is updatable
  79690. */
  79691. isUpdatable(): boolean;
  79692. /**
  79693. * Gets current buffer's data
  79694. * @returns a DataArray or null
  79695. */
  79696. getData(): Nullable<DataArray>;
  79697. /**
  79698. * Gets underlying native buffer
  79699. * @returns underlying native buffer
  79700. */
  79701. getBuffer(): Nullable<DataBuffer>;
  79702. /**
  79703. * Gets the stride in float32 units (i.e. byte stride / 4).
  79704. * May not be an integer if the byte stride is not divisible by 4.
  79705. * @returns the stride in float32 units
  79706. * @deprecated Please use byteStride instead.
  79707. */
  79708. getStrideSize(): number;
  79709. /**
  79710. * Returns the offset as a multiple of the type byte length.
  79711. * @returns the offset in bytes
  79712. * @deprecated Please use byteOffset instead.
  79713. */
  79714. getOffset(): number;
  79715. /**
  79716. * Returns the number of components per vertex attribute (integer)
  79717. * @returns the size in float
  79718. */
  79719. getSize(): number;
  79720. /**
  79721. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79722. * @returns true if this buffer is instanced
  79723. */
  79724. getIsInstanced(): boolean;
  79725. /**
  79726. * Returns the instancing divisor, zero for non-instanced (integer).
  79727. * @returns a number
  79728. */
  79729. getInstanceDivisor(): number;
  79730. /**
  79731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79732. * @param data defines the data to store
  79733. */
  79734. create(data?: DataArray): void;
  79735. /**
  79736. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79737. * This function will create a new buffer if the current one is not updatable
  79738. * @param data defines the data to store
  79739. */
  79740. update(data: DataArray): void;
  79741. /**
  79742. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79743. * Returns the directly updated WebGLBuffer.
  79744. * @param data the new data
  79745. * @param offset the new offset
  79746. * @param useBytes set to true if the offset is in bytes
  79747. */
  79748. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79749. /**
  79750. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79751. */
  79752. dispose(): void;
  79753. /**
  79754. * Enumerates each value of this vertex buffer as numbers.
  79755. * @param count the number of values to enumerate
  79756. * @param callback the callback function called for each value
  79757. */
  79758. forEach(count: number, callback: (value: number, index: number) => void): void;
  79759. /**
  79760. * Positions
  79761. */
  79762. static readonly PositionKind: string;
  79763. /**
  79764. * Normals
  79765. */
  79766. static readonly NormalKind: string;
  79767. /**
  79768. * Tangents
  79769. */
  79770. static readonly TangentKind: string;
  79771. /**
  79772. * Texture coordinates
  79773. */
  79774. static readonly UVKind: string;
  79775. /**
  79776. * Texture coordinates 2
  79777. */
  79778. static readonly UV2Kind: string;
  79779. /**
  79780. * Texture coordinates 3
  79781. */
  79782. static readonly UV3Kind: string;
  79783. /**
  79784. * Texture coordinates 4
  79785. */
  79786. static readonly UV4Kind: string;
  79787. /**
  79788. * Texture coordinates 5
  79789. */
  79790. static readonly UV5Kind: string;
  79791. /**
  79792. * Texture coordinates 6
  79793. */
  79794. static readonly UV6Kind: string;
  79795. /**
  79796. * Colors
  79797. */
  79798. static readonly ColorKind: string;
  79799. /**
  79800. * Matrix indices (for bones)
  79801. */
  79802. static readonly MatricesIndicesKind: string;
  79803. /**
  79804. * Matrix weights (for bones)
  79805. */
  79806. static readonly MatricesWeightsKind: string;
  79807. /**
  79808. * Additional matrix indices (for bones)
  79809. */
  79810. static readonly MatricesIndicesExtraKind: string;
  79811. /**
  79812. * Additional matrix weights (for bones)
  79813. */
  79814. static readonly MatricesWeightsExtraKind: string;
  79815. /**
  79816. * Deduces the stride given a kind.
  79817. * @param kind The kind string to deduce
  79818. * @returns The deduced stride
  79819. */
  79820. static DeduceStride(kind: string): number;
  79821. /**
  79822. * Gets the byte length of the given type.
  79823. * @param type the type
  79824. * @returns the number of bytes
  79825. */
  79826. static GetTypeByteLength(type: number): number;
  79827. /**
  79828. * Enumerates each value of the given parameters as numbers.
  79829. * @param data the data to enumerate
  79830. * @param byteOffset the byte offset of the data
  79831. * @param byteStride the byte stride of the data
  79832. * @param componentCount the number of components per element
  79833. * @param componentType the type of the component
  79834. * @param count the number of values to enumerate
  79835. * @param normalized whether the data is normalized
  79836. * @param callback the callback function called for each value
  79837. */
  79838. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79839. private static _GetFloatValue;
  79840. }
  79841. }
  79842. declare module BABYLON {
  79843. /**
  79844. * @hidden
  79845. */
  79846. export class IntersectionInfo {
  79847. bu: Nullable<number>;
  79848. bv: Nullable<number>;
  79849. distance: number;
  79850. faceId: number;
  79851. subMeshId: number;
  79852. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /**
  79857. * Represens a plane by the equation ax + by + cz + d = 0
  79858. */
  79859. export class Plane {
  79860. private static _TmpMatrix;
  79861. /**
  79862. * Normal of the plane (a,b,c)
  79863. */
  79864. normal: Vector3;
  79865. /**
  79866. * d component of the plane
  79867. */
  79868. d: number;
  79869. /**
  79870. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79871. * @param a a component of the plane
  79872. * @param b b component of the plane
  79873. * @param c c component of the plane
  79874. * @param d d component of the plane
  79875. */
  79876. constructor(a: number, b: number, c: number, d: number);
  79877. /**
  79878. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79879. */
  79880. asArray(): number[];
  79881. /**
  79882. * @returns a new plane copied from the current Plane.
  79883. */
  79884. clone(): Plane;
  79885. /**
  79886. * @returns the string "Plane".
  79887. */
  79888. getClassName(): string;
  79889. /**
  79890. * @returns the Plane hash code.
  79891. */
  79892. getHashCode(): number;
  79893. /**
  79894. * Normalize the current Plane in place.
  79895. * @returns the updated Plane.
  79896. */
  79897. normalize(): Plane;
  79898. /**
  79899. * Applies a transformation the plane and returns the result
  79900. * @param transformation the transformation matrix to be applied to the plane
  79901. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79902. */
  79903. transform(transformation: DeepImmutable<Matrix>): Plane;
  79904. /**
  79905. * Calcualtte the dot product between the point and the plane normal
  79906. * @param point point to calculate the dot product with
  79907. * @returns the dot product (float) of the point coordinates and the plane normal.
  79908. */
  79909. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79910. /**
  79911. * Updates the current Plane from the plane defined by the three given points.
  79912. * @param point1 one of the points used to contruct the plane
  79913. * @param point2 one of the points used to contruct the plane
  79914. * @param point3 one of the points used to contruct the plane
  79915. * @returns the updated Plane.
  79916. */
  79917. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79918. /**
  79919. * Checks if the plane is facing a given direction
  79920. * @param direction the direction to check if the plane is facing
  79921. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79922. * @returns True is the vector "direction" is the same side than the plane normal.
  79923. */
  79924. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79925. /**
  79926. * Calculates the distance to a point
  79927. * @param point point to calculate distance to
  79928. * @returns the signed distance (float) from the given point to the Plane.
  79929. */
  79930. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79931. /**
  79932. * Creates a plane from an array
  79933. * @param array the array to create a plane from
  79934. * @returns a new Plane from the given array.
  79935. */
  79936. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79937. /**
  79938. * Creates a plane from three points
  79939. * @param point1 point used to create the plane
  79940. * @param point2 point used to create the plane
  79941. * @param point3 point used to create the plane
  79942. * @returns a new Plane defined by the three given points.
  79943. */
  79944. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79945. /**
  79946. * Creates a plane from an origin point and a normal
  79947. * @param origin origin of the plane to be constructed
  79948. * @param normal normal of the plane to be constructed
  79949. * @returns a new Plane the normal vector to this plane at the given origin point.
  79950. * Note : the vector "normal" is updated because normalized.
  79951. */
  79952. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79953. /**
  79954. * Calculates the distance from a plane and a point
  79955. * @param origin origin of the plane to be constructed
  79956. * @param normal normal of the plane to be constructed
  79957. * @param point point to calculate distance to
  79958. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79959. */
  79960. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79961. }
  79962. }
  79963. declare module BABYLON {
  79964. /**
  79965. * Class used to store bounding sphere information
  79966. */
  79967. export class BoundingSphere {
  79968. /**
  79969. * Gets the center of the bounding sphere in local space
  79970. */
  79971. readonly center: Vector3;
  79972. /**
  79973. * Radius of the bounding sphere in local space
  79974. */
  79975. radius: number;
  79976. /**
  79977. * Gets the center of the bounding sphere in world space
  79978. */
  79979. readonly centerWorld: Vector3;
  79980. /**
  79981. * Radius of the bounding sphere in world space
  79982. */
  79983. radiusWorld: number;
  79984. /**
  79985. * Gets the minimum vector in local space
  79986. */
  79987. readonly minimum: Vector3;
  79988. /**
  79989. * Gets the maximum vector in local space
  79990. */
  79991. readonly maximum: Vector3;
  79992. private _worldMatrix;
  79993. private static readonly TmpVector3;
  79994. /**
  79995. * Creates a new bounding sphere
  79996. * @param min defines the minimum vector (in local space)
  79997. * @param max defines the maximum vector (in local space)
  79998. * @param worldMatrix defines the new world matrix
  79999. */
  80000. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80001. /**
  80002. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80003. * @param min defines the new minimum vector (in local space)
  80004. * @param max defines the new maximum vector (in local space)
  80005. * @param worldMatrix defines the new world matrix
  80006. */
  80007. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80008. /**
  80009. * Scale the current bounding sphere by applying a scale factor
  80010. * @param factor defines the scale factor to apply
  80011. * @returns the current bounding box
  80012. */
  80013. scale(factor: number): BoundingSphere;
  80014. /**
  80015. * Gets the world matrix of the bounding box
  80016. * @returns a matrix
  80017. */
  80018. getWorldMatrix(): DeepImmutable<Matrix>;
  80019. /** @hidden */
  80020. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80021. /**
  80022. * Tests if the bounding sphere is intersecting the frustum planes
  80023. * @param frustumPlanes defines the frustum planes to test
  80024. * @returns true if there is an intersection
  80025. */
  80026. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80027. /**
  80028. * Tests if the bounding sphere center is in between the frustum planes.
  80029. * Used for optimistic fast inclusion.
  80030. * @param frustumPlanes defines the frustum planes to test
  80031. * @returns true if the sphere center is in between the frustum planes
  80032. */
  80033. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80034. /**
  80035. * Tests if a point is inside the bounding sphere
  80036. * @param point defines the point to test
  80037. * @returns true if the point is inside the bounding sphere
  80038. */
  80039. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80040. /**
  80041. * Checks if two sphere intersct
  80042. * @param sphere0 sphere 0
  80043. * @param sphere1 sphere 1
  80044. * @returns true if the speres intersect
  80045. */
  80046. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80047. }
  80048. }
  80049. declare module BABYLON {
  80050. /**
  80051. * Class used to store bounding box information
  80052. */
  80053. export class BoundingBox implements ICullable {
  80054. /**
  80055. * Gets the 8 vectors representing the bounding box in local space
  80056. */
  80057. readonly vectors: Vector3[];
  80058. /**
  80059. * Gets the center of the bounding box in local space
  80060. */
  80061. readonly center: Vector3;
  80062. /**
  80063. * Gets the center of the bounding box in world space
  80064. */
  80065. readonly centerWorld: Vector3;
  80066. /**
  80067. * Gets the extend size in local space
  80068. */
  80069. readonly extendSize: Vector3;
  80070. /**
  80071. * Gets the extend size in world space
  80072. */
  80073. readonly extendSizeWorld: Vector3;
  80074. /**
  80075. * Gets the OBB (object bounding box) directions
  80076. */
  80077. readonly directions: Vector3[];
  80078. /**
  80079. * Gets the 8 vectors representing the bounding box in world space
  80080. */
  80081. readonly vectorsWorld: Vector3[];
  80082. /**
  80083. * Gets the minimum vector in world space
  80084. */
  80085. readonly minimumWorld: Vector3;
  80086. /**
  80087. * Gets the maximum vector in world space
  80088. */
  80089. readonly maximumWorld: Vector3;
  80090. /**
  80091. * Gets the minimum vector in local space
  80092. */
  80093. readonly minimum: Vector3;
  80094. /**
  80095. * Gets the maximum vector in local space
  80096. */
  80097. readonly maximum: Vector3;
  80098. private _worldMatrix;
  80099. private static readonly TmpVector3;
  80100. /**
  80101. * @hidden
  80102. */
  80103. _tag: number;
  80104. /**
  80105. * Creates a new bounding box
  80106. * @param min defines the minimum vector (in local space)
  80107. * @param max defines the maximum vector (in local space)
  80108. * @param worldMatrix defines the new world matrix
  80109. */
  80110. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80111. /**
  80112. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80113. * @param min defines the new minimum vector (in local space)
  80114. * @param max defines the new maximum vector (in local space)
  80115. * @param worldMatrix defines the new world matrix
  80116. */
  80117. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80118. /**
  80119. * Scale the current bounding box by applying a scale factor
  80120. * @param factor defines the scale factor to apply
  80121. * @returns the current bounding box
  80122. */
  80123. scale(factor: number): BoundingBox;
  80124. /**
  80125. * Gets the world matrix of the bounding box
  80126. * @returns a matrix
  80127. */
  80128. getWorldMatrix(): DeepImmutable<Matrix>;
  80129. /** @hidden */
  80130. _update(world: DeepImmutable<Matrix>): void;
  80131. /**
  80132. * Tests if the bounding box is intersecting the frustum planes
  80133. * @param frustumPlanes defines the frustum planes to test
  80134. * @returns true if there is an intersection
  80135. */
  80136. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80137. /**
  80138. * Tests if the bounding box is entirely inside the frustum planes
  80139. * @param frustumPlanes defines the frustum planes to test
  80140. * @returns true if there is an inclusion
  80141. */
  80142. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80143. /**
  80144. * Tests if a point is inside the bounding box
  80145. * @param point defines the point to test
  80146. * @returns true if the point is inside the bounding box
  80147. */
  80148. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80149. /**
  80150. * Tests if the bounding box intersects with a bounding sphere
  80151. * @param sphere defines the sphere to test
  80152. * @returns true if there is an intersection
  80153. */
  80154. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80155. /**
  80156. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80157. * @param min defines the min vector to use
  80158. * @param max defines the max vector to use
  80159. * @returns true if there is an intersection
  80160. */
  80161. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80162. /**
  80163. * Tests if two bounding boxes are intersections
  80164. * @param box0 defines the first box to test
  80165. * @param box1 defines the second box to test
  80166. * @returns true if there is an intersection
  80167. */
  80168. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80169. /**
  80170. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80171. * @param minPoint defines the minimum vector of the bounding box
  80172. * @param maxPoint defines the maximum vector of the bounding box
  80173. * @param sphereCenter defines the sphere center
  80174. * @param sphereRadius defines the sphere radius
  80175. * @returns true if there is an intersection
  80176. */
  80177. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80178. /**
  80179. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80180. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80181. * @param frustumPlanes defines the frustum planes to test
  80182. * @return true if there is an inclusion
  80183. */
  80184. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80185. /**
  80186. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80188. * @param frustumPlanes defines the frustum planes to test
  80189. * @return true if there is an intersection
  80190. */
  80191. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80192. }
  80193. }
  80194. declare module BABYLON {
  80195. /** @hidden */
  80196. export class Collider {
  80197. /** Define if a collision was found */
  80198. collisionFound: boolean;
  80199. /**
  80200. * Define last intersection point in local space
  80201. */
  80202. intersectionPoint: Vector3;
  80203. /**
  80204. * Define last collided mesh
  80205. */
  80206. collidedMesh: Nullable<AbstractMesh>;
  80207. private _collisionPoint;
  80208. private _planeIntersectionPoint;
  80209. private _tempVector;
  80210. private _tempVector2;
  80211. private _tempVector3;
  80212. private _tempVector4;
  80213. private _edge;
  80214. private _baseToVertex;
  80215. private _destinationPoint;
  80216. private _slidePlaneNormal;
  80217. private _displacementVector;
  80218. /** @hidden */
  80219. _radius: Vector3;
  80220. /** @hidden */
  80221. _retry: number;
  80222. private _velocity;
  80223. private _basePoint;
  80224. private _epsilon;
  80225. /** @hidden */
  80226. _velocityWorldLength: number;
  80227. /** @hidden */
  80228. _basePointWorld: Vector3;
  80229. private _velocityWorld;
  80230. private _normalizedVelocity;
  80231. /** @hidden */
  80232. _initialVelocity: Vector3;
  80233. /** @hidden */
  80234. _initialPosition: Vector3;
  80235. private _nearestDistance;
  80236. private _collisionMask;
  80237. get collisionMask(): number;
  80238. set collisionMask(mask: number);
  80239. /**
  80240. * Gets the plane normal used to compute the sliding response (in local space)
  80241. */
  80242. get slidePlaneNormal(): Vector3;
  80243. /** @hidden */
  80244. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80245. /** @hidden */
  80246. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80247. /** @hidden */
  80248. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80249. /** @hidden */
  80250. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80251. /** @hidden */
  80252. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80253. /** @hidden */
  80254. _getResponse(pos: Vector3, vel: Vector3): void;
  80255. }
  80256. }
  80257. declare module BABYLON {
  80258. /**
  80259. * Interface for cullable objects
  80260. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80261. */
  80262. export interface ICullable {
  80263. /**
  80264. * Checks if the object or part of the object is in the frustum
  80265. * @param frustumPlanes Camera near/planes
  80266. * @returns true if the object is in frustum otherwise false
  80267. */
  80268. isInFrustum(frustumPlanes: Plane[]): boolean;
  80269. /**
  80270. * Checks if a cullable object (mesh...) is in the camera frustum
  80271. * Unlike isInFrustum this cheks the full bounding box
  80272. * @param frustumPlanes Camera near/planes
  80273. * @returns true if the object is in frustum otherwise false
  80274. */
  80275. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80276. }
  80277. /**
  80278. * Info for a bounding data of a mesh
  80279. */
  80280. export class BoundingInfo implements ICullable {
  80281. /**
  80282. * Bounding box for the mesh
  80283. */
  80284. readonly boundingBox: BoundingBox;
  80285. /**
  80286. * Bounding sphere for the mesh
  80287. */
  80288. readonly boundingSphere: BoundingSphere;
  80289. private _isLocked;
  80290. private static readonly TmpVector3;
  80291. /**
  80292. * Constructs bounding info
  80293. * @param minimum min vector of the bounding box/sphere
  80294. * @param maximum max vector of the bounding box/sphere
  80295. * @param worldMatrix defines the new world matrix
  80296. */
  80297. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80298. /**
  80299. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80300. * @param min defines the new minimum vector (in local space)
  80301. * @param max defines the new maximum vector (in local space)
  80302. * @param worldMatrix defines the new world matrix
  80303. */
  80304. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80305. /**
  80306. * min vector of the bounding box/sphere
  80307. */
  80308. get minimum(): Vector3;
  80309. /**
  80310. * max vector of the bounding box/sphere
  80311. */
  80312. get maximum(): Vector3;
  80313. /**
  80314. * If the info is locked and won't be updated to avoid perf overhead
  80315. */
  80316. get isLocked(): boolean;
  80317. set isLocked(value: boolean);
  80318. /**
  80319. * Updates the bounding sphere and box
  80320. * @param world world matrix to be used to update
  80321. */
  80322. update(world: DeepImmutable<Matrix>): void;
  80323. /**
  80324. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80325. * @param center New center of the bounding info
  80326. * @param extend New extend of the bounding info
  80327. * @returns the current bounding info
  80328. */
  80329. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80330. /**
  80331. * Scale the current bounding info by applying a scale factor
  80332. * @param factor defines the scale factor to apply
  80333. * @returns the current bounding info
  80334. */
  80335. scale(factor: number): BoundingInfo;
  80336. /**
  80337. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80338. * @param frustumPlanes defines the frustum to test
  80339. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80340. * @returns true if the bounding info is in the frustum planes
  80341. */
  80342. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80343. /**
  80344. * Gets the world distance between the min and max points of the bounding box
  80345. */
  80346. get diagonalLength(): number;
  80347. /**
  80348. * Checks if a cullable object (mesh...) is in the camera frustum
  80349. * Unlike isInFrustum this cheks the full bounding box
  80350. * @param frustumPlanes Camera near/planes
  80351. * @returns true if the object is in frustum otherwise false
  80352. */
  80353. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80354. /** @hidden */
  80355. _checkCollision(collider: Collider): boolean;
  80356. /**
  80357. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80358. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80359. * @param point the point to check intersection with
  80360. * @returns if the point intersects
  80361. */
  80362. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80363. /**
  80364. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80365. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80366. * @param boundingInfo the bounding info to check intersection with
  80367. * @param precise if the intersection should be done using OBB
  80368. * @returns if the bounding info intersects
  80369. */
  80370. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80371. }
  80372. }
  80373. declare module BABYLON {
  80374. /**
  80375. * Extracts minimum and maximum values from a list of indexed positions
  80376. * @param positions defines the positions to use
  80377. * @param indices defines the indices to the positions
  80378. * @param indexStart defines the start index
  80379. * @param indexCount defines the end index
  80380. * @param bias defines bias value to add to the result
  80381. * @return minimum and maximum values
  80382. */
  80383. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80384. minimum: Vector3;
  80385. maximum: Vector3;
  80386. };
  80387. /**
  80388. * Extracts minimum and maximum values from a list of positions
  80389. * @param positions defines the positions to use
  80390. * @param start defines the start index in the positions array
  80391. * @param count defines the number of positions to handle
  80392. * @param bias defines bias value to add to the result
  80393. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80394. * @return minimum and maximum values
  80395. */
  80396. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80397. minimum: Vector3;
  80398. maximum: Vector3;
  80399. };
  80400. }
  80401. declare module BABYLON {
  80402. /** @hidden */
  80403. export class WebGLDataBuffer extends DataBuffer {
  80404. private _buffer;
  80405. constructor(resource: WebGLBuffer);
  80406. get underlyingResource(): any;
  80407. }
  80408. }
  80409. declare module BABYLON {
  80410. /** @hidden */
  80411. export class WebGLPipelineContext implements IPipelineContext {
  80412. engine: ThinEngine;
  80413. program: Nullable<WebGLProgram>;
  80414. context?: WebGLRenderingContext;
  80415. vertexShader?: WebGLShader;
  80416. fragmentShader?: WebGLShader;
  80417. isParallelCompiled: boolean;
  80418. onCompiled?: () => void;
  80419. transformFeedback?: WebGLTransformFeedback | null;
  80420. vertexCompilationError: Nullable<string>;
  80421. fragmentCompilationError: Nullable<string>;
  80422. programLinkError: Nullable<string>;
  80423. programValidationError: Nullable<string>;
  80424. get isAsync(): boolean;
  80425. get isReady(): boolean;
  80426. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80427. }
  80428. }
  80429. declare module BABYLON {
  80430. interface ThinEngine {
  80431. /**
  80432. * Create an uniform buffer
  80433. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80434. * @param elements defines the content of the uniform buffer
  80435. * @returns the webGL uniform buffer
  80436. */
  80437. createUniformBuffer(elements: FloatArray): DataBuffer;
  80438. /**
  80439. * Create a dynamic uniform buffer
  80440. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80441. * @param elements defines the content of the uniform buffer
  80442. * @returns the webGL uniform buffer
  80443. */
  80444. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80445. /**
  80446. * Update an existing uniform buffer
  80447. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80448. * @param uniformBuffer defines the target uniform buffer
  80449. * @param elements defines the content to update
  80450. * @param offset defines the offset in the uniform buffer where update should start
  80451. * @param count defines the size of the data to update
  80452. */
  80453. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80454. /**
  80455. * Bind an uniform buffer to the current webGL context
  80456. * @param buffer defines the buffer to bind
  80457. */
  80458. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80459. /**
  80460. * Bind a buffer to the current webGL context at a given location
  80461. * @param buffer defines the buffer to bind
  80462. * @param location defines the index where to bind the buffer
  80463. */
  80464. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80465. /**
  80466. * Bind a specific block at a given index in a specific shader program
  80467. * @param pipelineContext defines the pipeline context to use
  80468. * @param blockName defines the block name
  80469. * @param index defines the index where to bind the block
  80470. */
  80471. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80472. }
  80473. }
  80474. declare module BABYLON {
  80475. /**
  80476. * Uniform buffer objects.
  80477. *
  80478. * Handles blocks of uniform on the GPU.
  80479. *
  80480. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80481. *
  80482. * For more information, please refer to :
  80483. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80484. */
  80485. export class UniformBuffer {
  80486. private _engine;
  80487. private _buffer;
  80488. private _data;
  80489. private _bufferData;
  80490. private _dynamic?;
  80491. private _uniformLocations;
  80492. private _uniformSizes;
  80493. private _uniformLocationPointer;
  80494. private _needSync;
  80495. private _noUBO;
  80496. private _currentEffect;
  80497. /** @hidden */
  80498. _alreadyBound: boolean;
  80499. private static _MAX_UNIFORM_SIZE;
  80500. private static _tempBuffer;
  80501. /**
  80502. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80503. * This is dynamic to allow compat with webgl 1 and 2.
  80504. * You will need to pass the name of the uniform as well as the value.
  80505. */
  80506. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80507. /**
  80508. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80509. * This is dynamic to allow compat with webgl 1 and 2.
  80510. * You will need to pass the name of the uniform as well as the value.
  80511. */
  80512. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80513. /**
  80514. * Lambda to Update a single float in a uniform buffer.
  80515. * This is dynamic to allow compat with webgl 1 and 2.
  80516. * You will need to pass the name of the uniform as well as the value.
  80517. */
  80518. updateFloat: (name: string, x: number) => void;
  80519. /**
  80520. * Lambda to Update a vec2 of float in a uniform buffer.
  80521. * This is dynamic to allow compat with webgl 1 and 2.
  80522. * You will need to pass the name of the uniform as well as the value.
  80523. */
  80524. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80525. /**
  80526. * Lambda to Update a vec3 of float in a uniform buffer.
  80527. * This is dynamic to allow compat with webgl 1 and 2.
  80528. * You will need to pass the name of the uniform as well as the value.
  80529. */
  80530. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80531. /**
  80532. * Lambda to Update a vec4 of float in a uniform buffer.
  80533. * This is dynamic to allow compat with webgl 1 and 2.
  80534. * You will need to pass the name of the uniform as well as the value.
  80535. */
  80536. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80537. /**
  80538. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80539. * This is dynamic to allow compat with webgl 1 and 2.
  80540. * You will need to pass the name of the uniform as well as the value.
  80541. */
  80542. updateMatrix: (name: string, mat: Matrix) => void;
  80543. /**
  80544. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80545. * This is dynamic to allow compat with webgl 1 and 2.
  80546. * You will need to pass the name of the uniform as well as the value.
  80547. */
  80548. updateVector3: (name: string, vector: Vector3) => void;
  80549. /**
  80550. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80551. * This is dynamic to allow compat with webgl 1 and 2.
  80552. * You will need to pass the name of the uniform as well as the value.
  80553. */
  80554. updateVector4: (name: string, vector: Vector4) => void;
  80555. /**
  80556. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80557. * This is dynamic to allow compat with webgl 1 and 2.
  80558. * You will need to pass the name of the uniform as well as the value.
  80559. */
  80560. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80561. /**
  80562. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80563. * This is dynamic to allow compat with webgl 1 and 2.
  80564. * You will need to pass the name of the uniform as well as the value.
  80565. */
  80566. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80567. /**
  80568. * Instantiates a new Uniform buffer objects.
  80569. *
  80570. * Handles blocks of uniform on the GPU.
  80571. *
  80572. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80573. *
  80574. * For more information, please refer to :
  80575. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80576. * @param engine Define the engine the buffer is associated with
  80577. * @param data Define the data contained in the buffer
  80578. * @param dynamic Define if the buffer is updatable
  80579. */
  80580. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80581. /**
  80582. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80583. * or just falling back on setUniformXXX calls.
  80584. */
  80585. get useUbo(): boolean;
  80586. /**
  80587. * Indicates if the WebGL underlying uniform buffer is in sync
  80588. * with the javascript cache data.
  80589. */
  80590. get isSync(): boolean;
  80591. /**
  80592. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80593. * Also, a dynamic UniformBuffer will disable cache verification and always
  80594. * update the underlying WebGL uniform buffer to the GPU.
  80595. * @returns if Dynamic, otherwise false
  80596. */
  80597. isDynamic(): boolean;
  80598. /**
  80599. * The data cache on JS side.
  80600. * @returns the underlying data as a float array
  80601. */
  80602. getData(): Float32Array;
  80603. /**
  80604. * The underlying WebGL Uniform buffer.
  80605. * @returns the webgl buffer
  80606. */
  80607. getBuffer(): Nullable<DataBuffer>;
  80608. /**
  80609. * std140 layout specifies how to align data within an UBO structure.
  80610. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80611. * for specs.
  80612. */
  80613. private _fillAlignment;
  80614. /**
  80615. * Adds an uniform in the buffer.
  80616. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80617. * for the layout to be correct !
  80618. * @param name Name of the uniform, as used in the uniform block in the shader.
  80619. * @param size Data size, or data directly.
  80620. */
  80621. addUniform(name: string, size: number | number[]): void;
  80622. /**
  80623. * Adds a Matrix 4x4 to the uniform buffer.
  80624. * @param name Name of the uniform, as used in the uniform block in the shader.
  80625. * @param mat A 4x4 matrix.
  80626. */
  80627. addMatrix(name: string, mat: Matrix): void;
  80628. /**
  80629. * Adds a vec2 to the uniform buffer.
  80630. * @param name Name of the uniform, as used in the uniform block in the shader.
  80631. * @param x Define the x component value of the vec2
  80632. * @param y Define the y component value of the vec2
  80633. */
  80634. addFloat2(name: string, x: number, y: number): void;
  80635. /**
  80636. * Adds a vec3 to the uniform buffer.
  80637. * @param name Name of the uniform, as used in the uniform block in the shader.
  80638. * @param x Define the x component value of the vec3
  80639. * @param y Define the y component value of the vec3
  80640. * @param z Define the z component value of the vec3
  80641. */
  80642. addFloat3(name: string, x: number, y: number, z: number): void;
  80643. /**
  80644. * Adds a vec3 to the uniform buffer.
  80645. * @param name Name of the uniform, as used in the uniform block in the shader.
  80646. * @param color Define the vec3 from a Color
  80647. */
  80648. addColor3(name: string, color: Color3): void;
  80649. /**
  80650. * Adds a vec4 to the uniform buffer.
  80651. * @param name Name of the uniform, as used in the uniform block in the shader.
  80652. * @param color Define the rgb components from a Color
  80653. * @param alpha Define the a component of the vec4
  80654. */
  80655. addColor4(name: string, color: Color3, alpha: number): void;
  80656. /**
  80657. * Adds a vec3 to the uniform buffer.
  80658. * @param name Name of the uniform, as used in the uniform block in the shader.
  80659. * @param vector Define the vec3 components from a Vector
  80660. */
  80661. addVector3(name: string, vector: Vector3): void;
  80662. /**
  80663. * Adds a Matrix 3x3 to the uniform buffer.
  80664. * @param name Name of the uniform, as used in the uniform block in the shader.
  80665. */
  80666. addMatrix3x3(name: string): void;
  80667. /**
  80668. * Adds a Matrix 2x2 to the uniform buffer.
  80669. * @param name Name of the uniform, as used in the uniform block in the shader.
  80670. */
  80671. addMatrix2x2(name: string): void;
  80672. /**
  80673. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80674. */
  80675. create(): void;
  80676. /** @hidden */
  80677. _rebuild(): void;
  80678. /**
  80679. * Updates the WebGL Uniform Buffer on the GPU.
  80680. * If the `dynamic` flag is set to true, no cache comparison is done.
  80681. * Otherwise, the buffer will be updated only if the cache differs.
  80682. */
  80683. update(): void;
  80684. /**
  80685. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80686. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80687. * @param data Define the flattened data
  80688. * @param size Define the size of the data.
  80689. */
  80690. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80691. private _valueCache;
  80692. private _cacheMatrix;
  80693. private _updateMatrix3x3ForUniform;
  80694. private _updateMatrix3x3ForEffect;
  80695. private _updateMatrix2x2ForEffect;
  80696. private _updateMatrix2x2ForUniform;
  80697. private _updateFloatForEffect;
  80698. private _updateFloatForUniform;
  80699. private _updateFloat2ForEffect;
  80700. private _updateFloat2ForUniform;
  80701. private _updateFloat3ForEffect;
  80702. private _updateFloat3ForUniform;
  80703. private _updateFloat4ForEffect;
  80704. private _updateFloat4ForUniform;
  80705. private _updateMatrixForEffect;
  80706. private _updateMatrixForUniform;
  80707. private _updateVector3ForEffect;
  80708. private _updateVector3ForUniform;
  80709. private _updateVector4ForEffect;
  80710. private _updateVector4ForUniform;
  80711. private _updateColor3ForEffect;
  80712. private _updateColor3ForUniform;
  80713. private _updateColor4ForEffect;
  80714. private _updateColor4ForUniform;
  80715. /**
  80716. * Sets a sampler uniform on the effect.
  80717. * @param name Define the name of the sampler.
  80718. * @param texture Define the texture to set in the sampler
  80719. */
  80720. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80721. /**
  80722. * Directly updates the value of the uniform in the cache AND on the GPU.
  80723. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80724. * @param data Define the flattened data
  80725. */
  80726. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80727. /**
  80728. * Binds this uniform buffer to an effect.
  80729. * @param effect Define the effect to bind the buffer to
  80730. * @param name Name of the uniform block in the shader.
  80731. */
  80732. bindToEffect(effect: Effect, name: string): void;
  80733. /**
  80734. * Disposes the uniform buffer.
  80735. */
  80736. dispose(): void;
  80737. }
  80738. }
  80739. declare module BABYLON {
  80740. /**
  80741. * Enum that determines the text-wrapping mode to use.
  80742. */
  80743. export enum InspectableType {
  80744. /**
  80745. * Checkbox for booleans
  80746. */
  80747. Checkbox = 0,
  80748. /**
  80749. * Sliders for numbers
  80750. */
  80751. Slider = 1,
  80752. /**
  80753. * Vector3
  80754. */
  80755. Vector3 = 2,
  80756. /**
  80757. * Quaternions
  80758. */
  80759. Quaternion = 3,
  80760. /**
  80761. * Color3
  80762. */
  80763. Color3 = 4,
  80764. /**
  80765. * String
  80766. */
  80767. String = 5
  80768. }
  80769. /**
  80770. * Interface used to define custom inspectable properties.
  80771. * This interface is used by the inspector to display custom property grids
  80772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80773. */
  80774. export interface IInspectable {
  80775. /**
  80776. * Gets the label to display
  80777. */
  80778. label: string;
  80779. /**
  80780. * Gets the name of the property to edit
  80781. */
  80782. propertyName: string;
  80783. /**
  80784. * Gets the type of the editor to use
  80785. */
  80786. type: InspectableType;
  80787. /**
  80788. * Gets the minimum value of the property when using in "slider" mode
  80789. */
  80790. min?: number;
  80791. /**
  80792. * Gets the maximum value of the property when using in "slider" mode
  80793. */
  80794. max?: number;
  80795. /**
  80796. * Gets the setp to use when using in "slider" mode
  80797. */
  80798. step?: number;
  80799. }
  80800. }
  80801. declare module BABYLON {
  80802. /**
  80803. * Class used to provide helper for timing
  80804. */
  80805. export class TimingTools {
  80806. /**
  80807. * Polyfill for setImmediate
  80808. * @param action defines the action to execute after the current execution block
  80809. */
  80810. static SetImmediate(action: () => void): void;
  80811. }
  80812. }
  80813. declare module BABYLON {
  80814. /**
  80815. * Class used to enable instatition of objects by class name
  80816. */
  80817. export class InstantiationTools {
  80818. /**
  80819. * Use this object to register external classes like custom textures or material
  80820. * to allow the laoders to instantiate them
  80821. */
  80822. static RegisteredExternalClasses: {
  80823. [key: string]: Object;
  80824. };
  80825. /**
  80826. * Tries to instantiate a new object from a given class name
  80827. * @param className defines the class name to instantiate
  80828. * @returns the new object or null if the system was not able to do the instantiation
  80829. */
  80830. static Instantiate(className: string): any;
  80831. }
  80832. }
  80833. declare module BABYLON {
  80834. /**
  80835. * Define options used to create a depth texture
  80836. */
  80837. export class DepthTextureCreationOptions {
  80838. /** Specifies whether or not a stencil should be allocated in the texture */
  80839. generateStencil?: boolean;
  80840. /** Specifies whether or not bilinear filtering is enable on the texture */
  80841. bilinearFiltering?: boolean;
  80842. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80843. comparisonFunction?: number;
  80844. /** Specifies if the created texture is a cube texture */
  80845. isCube?: boolean;
  80846. }
  80847. }
  80848. declare module BABYLON {
  80849. interface ThinEngine {
  80850. /**
  80851. * Creates a depth stencil cube texture.
  80852. * This is only available in WebGL 2.
  80853. * @param size The size of face edge in the cube texture.
  80854. * @param options The options defining the cube texture.
  80855. * @returns The cube texture
  80856. */
  80857. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80858. /**
  80859. * Creates a cube texture
  80860. * @param rootUrl defines the url where the files to load is located
  80861. * @param scene defines the current scene
  80862. * @param files defines the list of files to load (1 per face)
  80863. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80864. * @param onLoad defines an optional callback raised when the texture is loaded
  80865. * @param onError defines an optional callback raised if there is an issue to load the texture
  80866. * @param format defines the format of the data
  80867. * @param forcedExtension defines the extension to use to pick the right loader
  80868. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80869. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80870. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80871. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80872. * @returns the cube texture as an InternalTexture
  80873. */
  80874. 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;
  80875. /**
  80876. * Creates a cube texture
  80877. * @param rootUrl defines the url where the files to load is located
  80878. * @param scene defines the current scene
  80879. * @param files defines the list of files to load (1 per face)
  80880. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80881. * @param onLoad defines an optional callback raised when the texture is loaded
  80882. * @param onError defines an optional callback raised if there is an issue to load the texture
  80883. * @param format defines the format of the data
  80884. * @param forcedExtension defines the extension to use to pick the right loader
  80885. * @returns the cube texture as an InternalTexture
  80886. */
  80887. 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;
  80888. /**
  80889. * Creates a cube texture
  80890. * @param rootUrl defines the url where the files to load is located
  80891. * @param scene defines the current scene
  80892. * @param files defines the list of files to load (1 per face)
  80893. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80894. * @param onLoad defines an optional callback raised when the texture is loaded
  80895. * @param onError defines an optional callback raised if there is an issue to load the texture
  80896. * @param format defines the format of the data
  80897. * @param forcedExtension defines the extension to use to pick the right loader
  80898. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80899. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80900. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80901. * @returns the cube texture as an InternalTexture
  80902. */
  80903. 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;
  80904. /** @hidden */
  80905. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80906. /** @hidden */
  80907. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80908. /** @hidden */
  80909. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80910. /** @hidden */
  80911. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80912. /**
  80913. * @hidden
  80914. */
  80915. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80916. }
  80917. }
  80918. declare module BABYLON {
  80919. /**
  80920. * Class for creating a cube texture
  80921. */
  80922. export class CubeTexture extends BaseTexture {
  80923. private _delayedOnLoad;
  80924. /**
  80925. * Observable triggered once the texture has been loaded.
  80926. */
  80927. onLoadObservable: Observable<CubeTexture>;
  80928. /**
  80929. * The url of the texture
  80930. */
  80931. url: string;
  80932. /**
  80933. * Gets or sets the center of the bounding box associated with the cube texture.
  80934. * It must define where the camera used to render the texture was set
  80935. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80936. */
  80937. boundingBoxPosition: Vector3;
  80938. private _boundingBoxSize;
  80939. /**
  80940. * Gets or sets the size of the bounding box associated with the cube texture
  80941. * When defined, the cubemap will switch to local mode
  80942. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80943. * @example https://www.babylonjs-playground.com/#RNASML
  80944. */
  80945. set boundingBoxSize(value: Vector3);
  80946. /**
  80947. * Returns the bounding box size
  80948. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80949. */
  80950. get boundingBoxSize(): Vector3;
  80951. protected _rotationY: number;
  80952. /**
  80953. * Sets texture matrix rotation angle around Y axis in radians.
  80954. */
  80955. set rotationY(value: number);
  80956. /**
  80957. * Gets texture matrix rotation angle around Y axis radians.
  80958. */
  80959. get rotationY(): number;
  80960. /**
  80961. * Are mip maps generated for this texture or not.
  80962. */
  80963. get noMipmap(): boolean;
  80964. private _noMipmap;
  80965. private _files;
  80966. protected _forcedExtension: Nullable<string>;
  80967. private _extensions;
  80968. private _textureMatrix;
  80969. private _format;
  80970. private _createPolynomials;
  80971. /** @hidden */
  80972. _prefiltered: boolean;
  80973. /**
  80974. * Creates a cube texture from an array of image urls
  80975. * @param files defines an array of image urls
  80976. * @param scene defines the hosting scene
  80977. * @param noMipmap specifies if mip maps are not used
  80978. * @returns a cube texture
  80979. */
  80980. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80981. /**
  80982. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80983. * @param url defines the url of the prefiltered texture
  80984. * @param scene defines the scene the texture is attached to
  80985. * @param forcedExtension defines the extension of the file if different from the url
  80986. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80987. * @return the prefiltered texture
  80988. */
  80989. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80990. /**
  80991. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80992. * as prefiltered data.
  80993. * @param rootUrl defines the url of the texture or the root name of the six images
  80994. * @param scene defines the scene the texture is attached to
  80995. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80996. * @param noMipmap defines if mipmaps should be created or not
  80997. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80998. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80999. * @param onError defines a callback triggered in case of error during load
  81000. * @param format defines the internal format to use for the texture once loaded
  81001. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81002. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81003. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81004. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81005. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81006. * @return the cube texture
  81007. */
  81008. 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);
  81009. /**
  81010. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81011. */
  81012. get isPrefiltered(): boolean;
  81013. /**
  81014. * Get the current class name of the texture useful for serialization or dynamic coding.
  81015. * @returns "CubeTexture"
  81016. */
  81017. getClassName(): string;
  81018. /**
  81019. * Update the url (and optional buffer) of this texture if url was null during construction.
  81020. * @param url the url of the texture
  81021. * @param forcedExtension defines the extension to use
  81022. * @param onLoad callback called when the texture is loaded (defaults to null)
  81023. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81024. */
  81025. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81026. /**
  81027. * Delays loading of the cube texture
  81028. * @param forcedExtension defines the extension to use
  81029. */
  81030. delayLoad(forcedExtension?: string): void;
  81031. /**
  81032. * Returns the reflection texture matrix
  81033. * @returns the reflection texture matrix
  81034. */
  81035. getReflectionTextureMatrix(): Matrix;
  81036. /**
  81037. * Sets the reflection texture matrix
  81038. * @param value Reflection texture matrix
  81039. */
  81040. setReflectionTextureMatrix(value: Matrix): void;
  81041. /**
  81042. * Parses text to create a cube texture
  81043. * @param parsedTexture define the serialized text to read from
  81044. * @param scene defines the hosting scene
  81045. * @param rootUrl defines the root url of the cube texture
  81046. * @returns a cube texture
  81047. */
  81048. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81049. /**
  81050. * Makes a clone, or deep copy, of the cube texture
  81051. * @returns a new cube texture
  81052. */
  81053. clone(): CubeTexture;
  81054. }
  81055. }
  81056. declare module BABYLON {
  81057. /**
  81058. * Manages the defines for the Material
  81059. */
  81060. export class MaterialDefines {
  81061. /** @hidden */
  81062. protected _keys: string[];
  81063. private _isDirty;
  81064. /** @hidden */
  81065. _renderId: number;
  81066. /** @hidden */
  81067. _areLightsDirty: boolean;
  81068. /** @hidden */
  81069. _areLightsDisposed: boolean;
  81070. /** @hidden */
  81071. _areAttributesDirty: boolean;
  81072. /** @hidden */
  81073. _areTexturesDirty: boolean;
  81074. /** @hidden */
  81075. _areFresnelDirty: boolean;
  81076. /** @hidden */
  81077. _areMiscDirty: boolean;
  81078. /** @hidden */
  81079. _areImageProcessingDirty: boolean;
  81080. /** @hidden */
  81081. _normals: boolean;
  81082. /** @hidden */
  81083. _uvs: boolean;
  81084. /** @hidden */
  81085. _needNormals: boolean;
  81086. /** @hidden */
  81087. _needUVs: boolean;
  81088. [id: string]: any;
  81089. /**
  81090. * Specifies if the material needs to be re-calculated
  81091. */
  81092. get isDirty(): boolean;
  81093. /**
  81094. * Marks the material to indicate that it has been re-calculated
  81095. */
  81096. markAsProcessed(): void;
  81097. /**
  81098. * Marks the material to indicate that it needs to be re-calculated
  81099. */
  81100. markAsUnprocessed(): void;
  81101. /**
  81102. * Marks the material to indicate all of its defines need to be re-calculated
  81103. */
  81104. markAllAsDirty(): void;
  81105. /**
  81106. * Marks the material to indicate that image processing needs to be re-calculated
  81107. */
  81108. markAsImageProcessingDirty(): void;
  81109. /**
  81110. * Marks the material to indicate the lights need to be re-calculated
  81111. * @param disposed Defines whether the light is dirty due to dispose or not
  81112. */
  81113. markAsLightDirty(disposed?: boolean): void;
  81114. /**
  81115. * Marks the attribute state as changed
  81116. */
  81117. markAsAttributesDirty(): void;
  81118. /**
  81119. * Marks the texture state as changed
  81120. */
  81121. markAsTexturesDirty(): void;
  81122. /**
  81123. * Marks the fresnel state as changed
  81124. */
  81125. markAsFresnelDirty(): void;
  81126. /**
  81127. * Marks the misc state as changed
  81128. */
  81129. markAsMiscDirty(): void;
  81130. /**
  81131. * Rebuilds the material defines
  81132. */
  81133. rebuild(): void;
  81134. /**
  81135. * Specifies if two material defines are equal
  81136. * @param other - A material define instance to compare to
  81137. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81138. */
  81139. isEqual(other: MaterialDefines): boolean;
  81140. /**
  81141. * Clones this instance's defines to another instance
  81142. * @param other - material defines to clone values to
  81143. */
  81144. cloneTo(other: MaterialDefines): void;
  81145. /**
  81146. * Resets the material define values
  81147. */
  81148. reset(): void;
  81149. /**
  81150. * Converts the material define values to a string
  81151. * @returns - String of material define information
  81152. */
  81153. toString(): string;
  81154. }
  81155. }
  81156. declare module BABYLON {
  81157. /**
  81158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81160. * 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;
  81161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81162. */
  81163. export class ColorCurves {
  81164. private _dirty;
  81165. private _tempColor;
  81166. private _globalCurve;
  81167. private _highlightsCurve;
  81168. private _midtonesCurve;
  81169. private _shadowsCurve;
  81170. private _positiveCurve;
  81171. private _negativeCurve;
  81172. private _globalHue;
  81173. private _globalDensity;
  81174. private _globalSaturation;
  81175. private _globalExposure;
  81176. /**
  81177. * Gets the global Hue value.
  81178. * 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).
  81179. */
  81180. get globalHue(): number;
  81181. /**
  81182. * Sets the global Hue value.
  81183. * 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).
  81184. */
  81185. set globalHue(value: number);
  81186. /**
  81187. * Gets the global Density value.
  81188. * 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.
  81189. * Values less than zero provide a filter of opposite hue.
  81190. */
  81191. get globalDensity(): number;
  81192. /**
  81193. * Sets the global Density value.
  81194. * 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.
  81195. * Values less than zero provide a filter of opposite hue.
  81196. */
  81197. set globalDensity(value: number);
  81198. /**
  81199. * Gets the global Saturation value.
  81200. * 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.
  81201. */
  81202. get globalSaturation(): number;
  81203. /**
  81204. * Sets the global Saturation value.
  81205. * 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.
  81206. */
  81207. set globalSaturation(value: number);
  81208. /**
  81209. * Gets the global Exposure value.
  81210. * 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.
  81211. */
  81212. get globalExposure(): number;
  81213. /**
  81214. * Sets the global Exposure value.
  81215. * 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.
  81216. */
  81217. set globalExposure(value: number);
  81218. private _highlightsHue;
  81219. private _highlightsDensity;
  81220. private _highlightsSaturation;
  81221. private _highlightsExposure;
  81222. /**
  81223. * Gets the highlights Hue value.
  81224. * 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).
  81225. */
  81226. get highlightsHue(): number;
  81227. /**
  81228. * Sets the highlights Hue value.
  81229. * 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).
  81230. */
  81231. set highlightsHue(value: number);
  81232. /**
  81233. * Gets the highlights Density value.
  81234. * 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.
  81235. * Values less than zero provide a filter of opposite hue.
  81236. */
  81237. get highlightsDensity(): number;
  81238. /**
  81239. * Sets the highlights Density value.
  81240. * 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.
  81241. * Values less than zero provide a filter of opposite hue.
  81242. */
  81243. set highlightsDensity(value: number);
  81244. /**
  81245. * Gets the highlights Saturation value.
  81246. * 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.
  81247. */
  81248. get highlightsSaturation(): number;
  81249. /**
  81250. * Sets the highlights Saturation value.
  81251. * 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.
  81252. */
  81253. set highlightsSaturation(value: number);
  81254. /**
  81255. * Gets the highlights Exposure value.
  81256. * 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.
  81257. */
  81258. get highlightsExposure(): number;
  81259. /**
  81260. * Sets the highlights Exposure value.
  81261. * 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.
  81262. */
  81263. set highlightsExposure(value: number);
  81264. private _midtonesHue;
  81265. private _midtonesDensity;
  81266. private _midtonesSaturation;
  81267. private _midtonesExposure;
  81268. /**
  81269. * Gets the midtones Hue value.
  81270. * 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).
  81271. */
  81272. get midtonesHue(): number;
  81273. /**
  81274. * Sets the midtones Hue value.
  81275. * 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).
  81276. */
  81277. set midtonesHue(value: number);
  81278. /**
  81279. * Gets the midtones Density value.
  81280. * 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.
  81281. * Values less than zero provide a filter of opposite hue.
  81282. */
  81283. get midtonesDensity(): number;
  81284. /**
  81285. * Sets the midtones Density value.
  81286. * 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.
  81287. * Values less than zero provide a filter of opposite hue.
  81288. */
  81289. set midtonesDensity(value: number);
  81290. /**
  81291. * Gets the midtones Saturation value.
  81292. * 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.
  81293. */
  81294. get midtonesSaturation(): number;
  81295. /**
  81296. * Sets the midtones Saturation value.
  81297. * 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.
  81298. */
  81299. set midtonesSaturation(value: number);
  81300. /**
  81301. * Gets the midtones Exposure value.
  81302. * 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.
  81303. */
  81304. get midtonesExposure(): number;
  81305. /**
  81306. * Sets the midtones Exposure value.
  81307. * 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.
  81308. */
  81309. set midtonesExposure(value: number);
  81310. private _shadowsHue;
  81311. private _shadowsDensity;
  81312. private _shadowsSaturation;
  81313. private _shadowsExposure;
  81314. /**
  81315. * Gets the shadows Hue value.
  81316. * 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).
  81317. */
  81318. get shadowsHue(): number;
  81319. /**
  81320. * Sets the shadows Hue value.
  81321. * 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).
  81322. */
  81323. set shadowsHue(value: number);
  81324. /**
  81325. * Gets the shadows Density value.
  81326. * 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.
  81327. * Values less than zero provide a filter of opposite hue.
  81328. */
  81329. get shadowsDensity(): number;
  81330. /**
  81331. * Sets the shadows Density value.
  81332. * 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.
  81333. * Values less than zero provide a filter of opposite hue.
  81334. */
  81335. set shadowsDensity(value: number);
  81336. /**
  81337. * Gets the shadows Saturation value.
  81338. * 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.
  81339. */
  81340. get shadowsSaturation(): number;
  81341. /**
  81342. * Sets the shadows Saturation value.
  81343. * 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.
  81344. */
  81345. set shadowsSaturation(value: number);
  81346. /**
  81347. * Gets the shadows Exposure value.
  81348. * 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.
  81349. */
  81350. get shadowsExposure(): number;
  81351. /**
  81352. * Sets the shadows Exposure value.
  81353. * 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.
  81354. */
  81355. set shadowsExposure(value: number);
  81356. /**
  81357. * Returns the class name
  81358. * @returns The class name
  81359. */
  81360. getClassName(): string;
  81361. /**
  81362. * Binds the color curves to the shader.
  81363. * @param colorCurves The color curve to bind
  81364. * @param effect The effect to bind to
  81365. * @param positiveUniform The positive uniform shader parameter
  81366. * @param neutralUniform The neutral uniform shader parameter
  81367. * @param negativeUniform The negative uniform shader parameter
  81368. */
  81369. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81370. /**
  81371. * Prepare the list of uniforms associated with the ColorCurves effects.
  81372. * @param uniformsList The list of uniforms used in the effect
  81373. */
  81374. static PrepareUniforms(uniformsList: string[]): void;
  81375. /**
  81376. * Returns color grading data based on a hue, density, saturation and exposure value.
  81377. * @param filterHue The hue of the color filter.
  81378. * @param filterDensity The density of the color filter.
  81379. * @param saturation The saturation.
  81380. * @param exposure The exposure.
  81381. * @param result The result data container.
  81382. */
  81383. private getColorGradingDataToRef;
  81384. /**
  81385. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81386. * @param value The input slider value in range [-100,100].
  81387. * @returns Adjusted value.
  81388. */
  81389. private static applyColorGradingSliderNonlinear;
  81390. /**
  81391. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81392. * @param hue The hue (H) input.
  81393. * @param saturation The saturation (S) input.
  81394. * @param brightness The brightness (B) input.
  81395. * @result An RGBA color represented as Vector4.
  81396. */
  81397. private static fromHSBToRef;
  81398. /**
  81399. * Returns a value clamped between min and max
  81400. * @param value The value to clamp
  81401. * @param min The minimum of value
  81402. * @param max The maximum of value
  81403. * @returns The clamped value.
  81404. */
  81405. private static clamp;
  81406. /**
  81407. * Clones the current color curve instance.
  81408. * @return The cloned curves
  81409. */
  81410. clone(): ColorCurves;
  81411. /**
  81412. * Serializes the current color curve instance to a json representation.
  81413. * @return a JSON representation
  81414. */
  81415. serialize(): any;
  81416. /**
  81417. * Parses the color curve from a json representation.
  81418. * @param source the JSON source to parse
  81419. * @return The parsed curves
  81420. */
  81421. static Parse(source: any): ColorCurves;
  81422. }
  81423. }
  81424. declare module BABYLON {
  81425. /**
  81426. * Interface to follow in your material defines to integrate easily the
  81427. * Image proccessing functions.
  81428. * @hidden
  81429. */
  81430. export interface IImageProcessingConfigurationDefines {
  81431. IMAGEPROCESSING: boolean;
  81432. VIGNETTE: boolean;
  81433. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81434. VIGNETTEBLENDMODEOPAQUE: boolean;
  81435. TONEMAPPING: boolean;
  81436. TONEMAPPING_ACES: boolean;
  81437. CONTRAST: boolean;
  81438. EXPOSURE: boolean;
  81439. COLORCURVES: boolean;
  81440. COLORGRADING: boolean;
  81441. COLORGRADING3D: boolean;
  81442. SAMPLER3DGREENDEPTH: boolean;
  81443. SAMPLER3DBGRMAP: boolean;
  81444. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81445. }
  81446. /**
  81447. * @hidden
  81448. */
  81449. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81450. IMAGEPROCESSING: boolean;
  81451. VIGNETTE: boolean;
  81452. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81453. VIGNETTEBLENDMODEOPAQUE: boolean;
  81454. TONEMAPPING: boolean;
  81455. TONEMAPPING_ACES: boolean;
  81456. CONTRAST: boolean;
  81457. COLORCURVES: boolean;
  81458. COLORGRADING: boolean;
  81459. COLORGRADING3D: boolean;
  81460. SAMPLER3DGREENDEPTH: boolean;
  81461. SAMPLER3DBGRMAP: boolean;
  81462. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81463. EXPOSURE: boolean;
  81464. constructor();
  81465. }
  81466. /**
  81467. * This groups together the common properties used for image processing either in direct forward pass
  81468. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81469. * or not.
  81470. */
  81471. export class ImageProcessingConfiguration {
  81472. /**
  81473. * Default tone mapping applied in BabylonJS.
  81474. */
  81475. static readonly TONEMAPPING_STANDARD: number;
  81476. /**
  81477. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81478. * to other engines rendering to increase portability.
  81479. */
  81480. static readonly TONEMAPPING_ACES: number;
  81481. /**
  81482. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81483. */
  81484. colorCurves: Nullable<ColorCurves>;
  81485. private _colorCurvesEnabled;
  81486. /**
  81487. * Gets wether the color curves effect is enabled.
  81488. */
  81489. get colorCurvesEnabled(): boolean;
  81490. /**
  81491. * Sets wether the color curves effect is enabled.
  81492. */
  81493. set colorCurvesEnabled(value: boolean);
  81494. private _colorGradingTexture;
  81495. /**
  81496. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81497. */
  81498. get colorGradingTexture(): Nullable<BaseTexture>;
  81499. /**
  81500. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81501. */
  81502. set colorGradingTexture(value: Nullable<BaseTexture>);
  81503. private _colorGradingEnabled;
  81504. /**
  81505. * Gets wether the color grading effect is enabled.
  81506. */
  81507. get colorGradingEnabled(): boolean;
  81508. /**
  81509. * Sets wether the color grading effect is enabled.
  81510. */
  81511. set colorGradingEnabled(value: boolean);
  81512. private _colorGradingWithGreenDepth;
  81513. /**
  81514. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81515. */
  81516. get colorGradingWithGreenDepth(): boolean;
  81517. /**
  81518. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81519. */
  81520. set colorGradingWithGreenDepth(value: boolean);
  81521. private _colorGradingBGR;
  81522. /**
  81523. * Gets wether the color grading texture contains BGR values.
  81524. */
  81525. get colorGradingBGR(): boolean;
  81526. /**
  81527. * Sets wether the color grading texture contains BGR values.
  81528. */
  81529. set colorGradingBGR(value: boolean);
  81530. /** @hidden */
  81531. _exposure: number;
  81532. /**
  81533. * Gets the Exposure used in the effect.
  81534. */
  81535. get exposure(): number;
  81536. /**
  81537. * Sets the Exposure used in the effect.
  81538. */
  81539. set exposure(value: number);
  81540. private _toneMappingEnabled;
  81541. /**
  81542. * Gets wether the tone mapping effect is enabled.
  81543. */
  81544. get toneMappingEnabled(): boolean;
  81545. /**
  81546. * Sets wether the tone mapping effect is enabled.
  81547. */
  81548. set toneMappingEnabled(value: boolean);
  81549. private _toneMappingType;
  81550. /**
  81551. * Gets the type of tone mapping effect.
  81552. */
  81553. get toneMappingType(): number;
  81554. /**
  81555. * Sets the type of tone mapping effect used in BabylonJS.
  81556. */
  81557. set toneMappingType(value: number);
  81558. protected _contrast: number;
  81559. /**
  81560. * Gets the contrast used in the effect.
  81561. */
  81562. get contrast(): number;
  81563. /**
  81564. * Sets the contrast used in the effect.
  81565. */
  81566. set contrast(value: number);
  81567. /**
  81568. * Vignette stretch size.
  81569. */
  81570. vignetteStretch: number;
  81571. /**
  81572. * Vignette centre X Offset.
  81573. */
  81574. vignetteCentreX: number;
  81575. /**
  81576. * Vignette centre Y Offset.
  81577. */
  81578. vignetteCentreY: number;
  81579. /**
  81580. * Vignette weight or intensity of the vignette effect.
  81581. */
  81582. vignetteWeight: number;
  81583. /**
  81584. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81585. * if vignetteEnabled is set to true.
  81586. */
  81587. vignetteColor: Color4;
  81588. /**
  81589. * Camera field of view used by the Vignette effect.
  81590. */
  81591. vignetteCameraFov: number;
  81592. private _vignetteBlendMode;
  81593. /**
  81594. * Gets the vignette blend mode allowing different kind of effect.
  81595. */
  81596. get vignetteBlendMode(): number;
  81597. /**
  81598. * Sets the vignette blend mode allowing different kind of effect.
  81599. */
  81600. set vignetteBlendMode(value: number);
  81601. private _vignetteEnabled;
  81602. /**
  81603. * Gets wether the vignette effect is enabled.
  81604. */
  81605. get vignetteEnabled(): boolean;
  81606. /**
  81607. * Sets wether the vignette effect is enabled.
  81608. */
  81609. set vignetteEnabled(value: boolean);
  81610. private _applyByPostProcess;
  81611. /**
  81612. * Gets wether the image processing is applied through a post process or not.
  81613. */
  81614. get applyByPostProcess(): boolean;
  81615. /**
  81616. * Sets wether the image processing is applied through a post process or not.
  81617. */
  81618. set applyByPostProcess(value: boolean);
  81619. private _isEnabled;
  81620. /**
  81621. * Gets wether the image processing is enabled or not.
  81622. */
  81623. get isEnabled(): boolean;
  81624. /**
  81625. * Sets wether the image processing is enabled or not.
  81626. */
  81627. set isEnabled(value: boolean);
  81628. /**
  81629. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81630. */
  81631. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81632. /**
  81633. * Method called each time the image processing information changes requires to recompile the effect.
  81634. */
  81635. protected _updateParameters(): void;
  81636. /**
  81637. * Gets the current class name.
  81638. * @return "ImageProcessingConfiguration"
  81639. */
  81640. getClassName(): string;
  81641. /**
  81642. * Prepare the list of uniforms associated with the Image Processing effects.
  81643. * @param uniforms The list of uniforms used in the effect
  81644. * @param defines the list of defines currently in use
  81645. */
  81646. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81647. /**
  81648. * Prepare the list of samplers associated with the Image Processing effects.
  81649. * @param samplersList The list of uniforms used in the effect
  81650. * @param defines the list of defines currently in use
  81651. */
  81652. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81653. /**
  81654. * Prepare the list of defines associated to the shader.
  81655. * @param defines the list of defines to complete
  81656. * @param forPostProcess Define if we are currently in post process mode or not
  81657. */
  81658. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81659. /**
  81660. * Returns true if all the image processing information are ready.
  81661. * @returns True if ready, otherwise, false
  81662. */
  81663. isReady(): boolean;
  81664. /**
  81665. * Binds the image processing to the shader.
  81666. * @param effect The effect to bind to
  81667. * @param overrideAspectRatio Override the aspect ratio of the effect
  81668. */
  81669. bind(effect: Effect, overrideAspectRatio?: number): void;
  81670. /**
  81671. * Clones the current image processing instance.
  81672. * @return The cloned image processing
  81673. */
  81674. clone(): ImageProcessingConfiguration;
  81675. /**
  81676. * Serializes the current image processing instance to a json representation.
  81677. * @return a JSON representation
  81678. */
  81679. serialize(): any;
  81680. /**
  81681. * Parses the image processing from a json representation.
  81682. * @param source the JSON source to parse
  81683. * @return The parsed image processing
  81684. */
  81685. static Parse(source: any): ImageProcessingConfiguration;
  81686. private static _VIGNETTEMODE_MULTIPLY;
  81687. private static _VIGNETTEMODE_OPAQUE;
  81688. /**
  81689. * Used to apply the vignette as a mix with the pixel color.
  81690. */
  81691. static get VIGNETTEMODE_MULTIPLY(): number;
  81692. /**
  81693. * Used to apply the vignette as a replacement of the pixel color.
  81694. */
  81695. static get VIGNETTEMODE_OPAQUE(): number;
  81696. }
  81697. }
  81698. declare module BABYLON {
  81699. /** @hidden */
  81700. export var postprocessVertexShader: {
  81701. name: string;
  81702. shader: string;
  81703. };
  81704. }
  81705. declare module BABYLON {
  81706. interface ThinEngine {
  81707. /**
  81708. * Creates a new render target texture
  81709. * @param size defines the size of the texture
  81710. * @param options defines the options used to create the texture
  81711. * @returns a new render target texture stored in an InternalTexture
  81712. */
  81713. createRenderTargetTexture(size: number | {
  81714. width: number;
  81715. height: number;
  81716. layers?: number;
  81717. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81718. /**
  81719. * Creates a depth stencil texture.
  81720. * This is only available in WebGL 2 or with the depth texture extension available.
  81721. * @param size The size of face edge in the texture.
  81722. * @param options The options defining the texture.
  81723. * @returns The texture
  81724. */
  81725. createDepthStencilTexture(size: number | {
  81726. width: number;
  81727. height: number;
  81728. layers?: number;
  81729. }, options: DepthTextureCreationOptions): InternalTexture;
  81730. /** @hidden */
  81731. _createDepthStencilTexture(size: number | {
  81732. width: number;
  81733. height: number;
  81734. layers?: number;
  81735. }, options: DepthTextureCreationOptions): InternalTexture;
  81736. }
  81737. }
  81738. declare module BABYLON {
  81739. /** Defines supported spaces */
  81740. export enum Space {
  81741. /** Local (object) space */
  81742. LOCAL = 0,
  81743. /** World space */
  81744. WORLD = 1,
  81745. /** Bone space */
  81746. BONE = 2
  81747. }
  81748. /** Defines the 3 main axes */
  81749. export class Axis {
  81750. /** X axis */
  81751. static X: Vector3;
  81752. /** Y axis */
  81753. static Y: Vector3;
  81754. /** Z axis */
  81755. static Z: Vector3;
  81756. }
  81757. }
  81758. declare module BABYLON {
  81759. /**
  81760. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81761. * This is the base of the follow, arc rotate cameras and Free camera
  81762. * @see http://doc.babylonjs.com/features/cameras
  81763. */
  81764. export class TargetCamera extends Camera {
  81765. private static _RigCamTransformMatrix;
  81766. private static _TargetTransformMatrix;
  81767. private static _TargetFocalPoint;
  81768. /**
  81769. * Define the current direction the camera is moving to
  81770. */
  81771. cameraDirection: Vector3;
  81772. /**
  81773. * Define the current rotation the camera is rotating to
  81774. */
  81775. cameraRotation: Vector2;
  81776. /**
  81777. * When set, the up vector of the camera will be updated by the rotation of the camera
  81778. */
  81779. updateUpVectorFromRotation: boolean;
  81780. private _tmpQuaternion;
  81781. /**
  81782. * Define the current rotation of the camera
  81783. */
  81784. rotation: Vector3;
  81785. /**
  81786. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81787. */
  81788. rotationQuaternion: Quaternion;
  81789. /**
  81790. * Define the current speed of the camera
  81791. */
  81792. speed: number;
  81793. /**
  81794. * Add constraint to the camera to prevent it to move freely in all directions and
  81795. * around all axis.
  81796. */
  81797. noRotationConstraint: boolean;
  81798. /**
  81799. * Define the current target of the camera as an object or a position.
  81800. */
  81801. lockedTarget: any;
  81802. /** @hidden */
  81803. _currentTarget: Vector3;
  81804. /** @hidden */
  81805. _initialFocalDistance: number;
  81806. /** @hidden */
  81807. _viewMatrix: Matrix;
  81808. /** @hidden */
  81809. _camMatrix: Matrix;
  81810. /** @hidden */
  81811. _cameraTransformMatrix: Matrix;
  81812. /** @hidden */
  81813. _cameraRotationMatrix: Matrix;
  81814. /** @hidden */
  81815. _referencePoint: Vector3;
  81816. /** @hidden */
  81817. _transformedReferencePoint: Vector3;
  81818. protected _globalCurrentTarget: Vector3;
  81819. protected _globalCurrentUpVector: Vector3;
  81820. /** @hidden */
  81821. _reset: () => void;
  81822. private _defaultUp;
  81823. /**
  81824. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81825. * This is the base of the follow, arc rotate cameras and Free camera
  81826. * @see http://doc.babylonjs.com/features/cameras
  81827. * @param name Defines the name of the camera in the scene
  81828. * @param position Defines the start position of the camera in the scene
  81829. * @param scene Defines the scene the camera belongs to
  81830. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81831. */
  81832. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81833. /**
  81834. * Gets the position in front of the camera at a given distance.
  81835. * @param distance The distance from the camera we want the position to be
  81836. * @returns the position
  81837. */
  81838. getFrontPosition(distance: number): Vector3;
  81839. /** @hidden */
  81840. _getLockedTargetPosition(): Nullable<Vector3>;
  81841. private _storedPosition;
  81842. private _storedRotation;
  81843. private _storedRotationQuaternion;
  81844. /**
  81845. * Store current camera state of the camera (fov, position, rotation, etc..)
  81846. * @returns the camera
  81847. */
  81848. storeState(): Camera;
  81849. /**
  81850. * Restored camera state. You must call storeState() first
  81851. * @returns whether it was successful or not
  81852. * @hidden
  81853. */
  81854. _restoreStateValues(): boolean;
  81855. /** @hidden */
  81856. _initCache(): void;
  81857. /** @hidden */
  81858. _updateCache(ignoreParentClass?: boolean): void;
  81859. /** @hidden */
  81860. _isSynchronizedViewMatrix(): boolean;
  81861. /** @hidden */
  81862. _computeLocalCameraSpeed(): number;
  81863. /**
  81864. * Defines the target the camera should look at.
  81865. * @param target Defines the new target as a Vector or a mesh
  81866. */
  81867. setTarget(target: Vector3): void;
  81868. /**
  81869. * Return the current target position of the camera. This value is expressed in local space.
  81870. * @returns the target position
  81871. */
  81872. getTarget(): Vector3;
  81873. /** @hidden */
  81874. _decideIfNeedsToMove(): boolean;
  81875. /** @hidden */
  81876. _updatePosition(): void;
  81877. /** @hidden */
  81878. _checkInputs(): void;
  81879. protected _updateCameraRotationMatrix(): void;
  81880. /**
  81881. * 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)
  81882. * @returns the current camera
  81883. */
  81884. private _rotateUpVectorWithCameraRotationMatrix;
  81885. private _cachedRotationZ;
  81886. private _cachedQuaternionRotationZ;
  81887. /** @hidden */
  81888. _getViewMatrix(): Matrix;
  81889. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81890. /**
  81891. * @hidden
  81892. */
  81893. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81894. /**
  81895. * @hidden
  81896. */
  81897. _updateRigCameras(): void;
  81898. private _getRigCamPositionAndTarget;
  81899. /**
  81900. * Gets the current object class name.
  81901. * @return the class name
  81902. */
  81903. getClassName(): string;
  81904. }
  81905. }
  81906. declare module BABYLON {
  81907. /**
  81908. * Gather the list of keyboard event types as constants.
  81909. */
  81910. export class KeyboardEventTypes {
  81911. /**
  81912. * The keydown event is fired when a key becomes active (pressed).
  81913. */
  81914. static readonly KEYDOWN: number;
  81915. /**
  81916. * The keyup event is fired when a key has been released.
  81917. */
  81918. static readonly KEYUP: number;
  81919. }
  81920. /**
  81921. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81922. */
  81923. export class KeyboardInfo {
  81924. /**
  81925. * Defines the type of event (KeyboardEventTypes)
  81926. */
  81927. type: number;
  81928. /**
  81929. * Defines the related dom event
  81930. */
  81931. event: KeyboardEvent;
  81932. /**
  81933. * Instantiates a new keyboard info.
  81934. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81935. * @param type Defines the type of event (KeyboardEventTypes)
  81936. * @param event Defines the related dom event
  81937. */
  81938. constructor(
  81939. /**
  81940. * Defines the type of event (KeyboardEventTypes)
  81941. */
  81942. type: number,
  81943. /**
  81944. * Defines the related dom event
  81945. */
  81946. event: KeyboardEvent);
  81947. }
  81948. /**
  81949. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81950. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81951. */
  81952. export class KeyboardInfoPre extends KeyboardInfo {
  81953. /**
  81954. * Defines the type of event (KeyboardEventTypes)
  81955. */
  81956. type: number;
  81957. /**
  81958. * Defines the related dom event
  81959. */
  81960. event: KeyboardEvent;
  81961. /**
  81962. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81963. */
  81964. skipOnPointerObservable: boolean;
  81965. /**
  81966. * Instantiates a new keyboard pre info.
  81967. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81968. * @param type Defines the type of event (KeyboardEventTypes)
  81969. * @param event Defines the related dom event
  81970. */
  81971. constructor(
  81972. /**
  81973. * Defines the type of event (KeyboardEventTypes)
  81974. */
  81975. type: number,
  81976. /**
  81977. * Defines the related dom event
  81978. */
  81979. event: KeyboardEvent);
  81980. }
  81981. }
  81982. declare module BABYLON {
  81983. /**
  81984. * Manage the keyboard inputs to control the movement of a free camera.
  81985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81986. */
  81987. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81988. /**
  81989. * Defines the camera the input is attached to.
  81990. */
  81991. camera: FreeCamera;
  81992. /**
  81993. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81994. */
  81995. keysUp: number[];
  81996. /**
  81997. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81998. */
  81999. keysDown: number[];
  82000. /**
  82001. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82002. */
  82003. keysLeft: number[];
  82004. /**
  82005. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82006. */
  82007. keysRight: number[];
  82008. private _keys;
  82009. private _onCanvasBlurObserver;
  82010. private _onKeyboardObserver;
  82011. private _engine;
  82012. private _scene;
  82013. /**
  82014. * Attach the input controls to a specific dom element to get the input from.
  82015. * @param element Defines the element the controls should be listened from
  82016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82017. */
  82018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82019. /**
  82020. * Detach the current controls from the specified dom element.
  82021. * @param element Defines the element to stop listening the inputs from
  82022. */
  82023. detachControl(element: Nullable<HTMLElement>): void;
  82024. /**
  82025. * Update the current camera state depending on the inputs that have been used this frame.
  82026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82027. */
  82028. checkInputs(): void;
  82029. /**
  82030. * Gets the class name of the current intput.
  82031. * @returns the class name
  82032. */
  82033. getClassName(): string;
  82034. /** @hidden */
  82035. _onLostFocus(): void;
  82036. /**
  82037. * Get the friendly name associated with the input class.
  82038. * @returns the input friendly name
  82039. */
  82040. getSimpleName(): string;
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. /**
  82045. * Interface describing all the common properties and methods a shadow light needs to implement.
  82046. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82047. * as well as binding the different shadow properties to the effects.
  82048. */
  82049. export interface IShadowLight extends Light {
  82050. /**
  82051. * The light id in the scene (used in scene.findLighById for instance)
  82052. */
  82053. id: string;
  82054. /**
  82055. * The position the shdow will be casted from.
  82056. */
  82057. position: Vector3;
  82058. /**
  82059. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82060. */
  82061. direction: Vector3;
  82062. /**
  82063. * The transformed position. Position of the light in world space taking parenting in account.
  82064. */
  82065. transformedPosition: Vector3;
  82066. /**
  82067. * The transformed direction. Direction of the light in world space taking parenting in account.
  82068. */
  82069. transformedDirection: Vector3;
  82070. /**
  82071. * The friendly name of the light in the scene.
  82072. */
  82073. name: string;
  82074. /**
  82075. * Defines the shadow projection clipping minimum z value.
  82076. */
  82077. shadowMinZ: number;
  82078. /**
  82079. * Defines the shadow projection clipping maximum z value.
  82080. */
  82081. shadowMaxZ: number;
  82082. /**
  82083. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82084. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82085. */
  82086. computeTransformedInformation(): boolean;
  82087. /**
  82088. * Gets the scene the light belongs to.
  82089. * @returns The scene
  82090. */
  82091. getScene(): Scene;
  82092. /**
  82093. * Callback defining a custom Projection Matrix Builder.
  82094. * This can be used to override the default projection matrix computation.
  82095. */
  82096. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82097. /**
  82098. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82099. * @param matrix The materix to updated with the projection information
  82100. * @param viewMatrix The transform matrix of the light
  82101. * @param renderList The list of mesh to render in the map
  82102. * @returns The current light
  82103. */
  82104. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82105. /**
  82106. * Gets the current depth scale used in ESM.
  82107. * @returns The scale
  82108. */
  82109. getDepthScale(): number;
  82110. /**
  82111. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82112. * @returns true if a cube texture needs to be use
  82113. */
  82114. needCube(): boolean;
  82115. /**
  82116. * Detects if the projection matrix requires to be recomputed this frame.
  82117. * @returns true if it requires to be recomputed otherwise, false.
  82118. */
  82119. needProjectionMatrixCompute(): boolean;
  82120. /**
  82121. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82122. */
  82123. forceProjectionMatrixCompute(): void;
  82124. /**
  82125. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82126. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82127. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82128. */
  82129. getShadowDirection(faceIndex?: number): Vector3;
  82130. /**
  82131. * Gets the minZ used for shadow according to both the scene and the light.
  82132. * @param activeCamera The camera we are returning the min for
  82133. * @returns the depth min z
  82134. */
  82135. getDepthMinZ(activeCamera: Camera): number;
  82136. /**
  82137. * Gets the maxZ used for shadow according to both the scene and the light.
  82138. * @param activeCamera The camera we are returning the max for
  82139. * @returns the depth max z
  82140. */
  82141. getDepthMaxZ(activeCamera: Camera): number;
  82142. }
  82143. /**
  82144. * Base implementation IShadowLight
  82145. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82146. */
  82147. export abstract class ShadowLight extends Light implements IShadowLight {
  82148. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82149. protected _position: Vector3;
  82150. protected _setPosition(value: Vector3): void;
  82151. /**
  82152. * Sets the position the shadow will be casted from. Also use as the light position for both
  82153. * point and spot lights.
  82154. */
  82155. get position(): Vector3;
  82156. /**
  82157. * Sets the position the shadow will be casted from. Also use as the light position for both
  82158. * point and spot lights.
  82159. */
  82160. set position(value: Vector3);
  82161. protected _direction: Vector3;
  82162. protected _setDirection(value: Vector3): void;
  82163. /**
  82164. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82165. * Also use as the light direction on spot and directional lights.
  82166. */
  82167. get direction(): Vector3;
  82168. /**
  82169. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82170. * Also use as the light direction on spot and directional lights.
  82171. */
  82172. set direction(value: Vector3);
  82173. protected _shadowMinZ: number;
  82174. /**
  82175. * Gets the shadow projection clipping minimum z value.
  82176. */
  82177. get shadowMinZ(): number;
  82178. /**
  82179. * Sets the shadow projection clipping minimum z value.
  82180. */
  82181. set shadowMinZ(value: number);
  82182. protected _shadowMaxZ: number;
  82183. /**
  82184. * Sets the shadow projection clipping maximum z value.
  82185. */
  82186. get shadowMaxZ(): number;
  82187. /**
  82188. * Gets the shadow projection clipping maximum z value.
  82189. */
  82190. set shadowMaxZ(value: number);
  82191. /**
  82192. * Callback defining a custom Projection Matrix Builder.
  82193. * This can be used to override the default projection matrix computation.
  82194. */
  82195. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82196. /**
  82197. * The transformed position. Position of the light in world space taking parenting in account.
  82198. */
  82199. transformedPosition: Vector3;
  82200. /**
  82201. * The transformed direction. Direction of the light in world space taking parenting in account.
  82202. */
  82203. transformedDirection: Vector3;
  82204. private _needProjectionMatrixCompute;
  82205. /**
  82206. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82207. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82208. */
  82209. computeTransformedInformation(): boolean;
  82210. /**
  82211. * Return the depth scale used for the shadow map.
  82212. * @returns the depth scale.
  82213. */
  82214. getDepthScale(): number;
  82215. /**
  82216. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82217. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82218. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82219. */
  82220. getShadowDirection(faceIndex?: number): Vector3;
  82221. /**
  82222. * Returns the ShadowLight absolute position in the World.
  82223. * @returns the position vector in world space
  82224. */
  82225. getAbsolutePosition(): Vector3;
  82226. /**
  82227. * Sets the ShadowLight direction toward the passed target.
  82228. * @param target The point to target in local space
  82229. * @returns the updated ShadowLight direction
  82230. */
  82231. setDirectionToTarget(target: Vector3): Vector3;
  82232. /**
  82233. * Returns the light rotation in euler definition.
  82234. * @returns the x y z rotation in local space.
  82235. */
  82236. getRotation(): Vector3;
  82237. /**
  82238. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82239. * @returns true if a cube texture needs to be use
  82240. */
  82241. needCube(): boolean;
  82242. /**
  82243. * Detects if the projection matrix requires to be recomputed this frame.
  82244. * @returns true if it requires to be recomputed otherwise, false.
  82245. */
  82246. needProjectionMatrixCompute(): boolean;
  82247. /**
  82248. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82249. */
  82250. forceProjectionMatrixCompute(): void;
  82251. /** @hidden */
  82252. _initCache(): void;
  82253. /** @hidden */
  82254. _isSynchronized(): boolean;
  82255. /**
  82256. * Computes the world matrix of the node
  82257. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82258. * @returns the world matrix
  82259. */
  82260. computeWorldMatrix(force?: boolean): Matrix;
  82261. /**
  82262. * Gets the minZ used for shadow according to both the scene and the light.
  82263. * @param activeCamera The camera we are returning the min for
  82264. * @returns the depth min z
  82265. */
  82266. getDepthMinZ(activeCamera: Camera): number;
  82267. /**
  82268. * Gets the maxZ used for shadow according to both the scene and the light.
  82269. * @param activeCamera The camera we are returning the max for
  82270. * @returns the depth max z
  82271. */
  82272. getDepthMaxZ(activeCamera: Camera): number;
  82273. /**
  82274. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82275. * @param matrix The materix to updated with the projection information
  82276. * @param viewMatrix The transform matrix of the light
  82277. * @param renderList The list of mesh to render in the map
  82278. * @returns The current light
  82279. */
  82280. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82281. }
  82282. }
  82283. declare module BABYLON {
  82284. /**
  82285. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82286. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82287. */
  82288. export class EffectFallbacks implements IEffectFallbacks {
  82289. private _defines;
  82290. private _currentRank;
  82291. private _maxRank;
  82292. private _mesh;
  82293. /**
  82294. * Removes the fallback from the bound mesh.
  82295. */
  82296. unBindMesh(): void;
  82297. /**
  82298. * Adds a fallback on the specified property.
  82299. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82300. * @param define The name of the define in the shader
  82301. */
  82302. addFallback(rank: number, define: string): void;
  82303. /**
  82304. * Sets the mesh to use CPU skinning when needing to fallback.
  82305. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82306. * @param mesh The mesh to use the fallbacks.
  82307. */
  82308. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82309. /**
  82310. * Checks to see if more fallbacks are still availible.
  82311. */
  82312. get hasMoreFallbacks(): boolean;
  82313. /**
  82314. * Removes the defines that should be removed when falling back.
  82315. * @param currentDefines defines the current define statements for the shader.
  82316. * @param effect defines the current effect we try to compile
  82317. * @returns The resulting defines with defines of the current rank removed.
  82318. */
  82319. reduce(currentDefines: string, effect: Effect): string;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. /**
  82324. * "Static Class" containing the most commonly used helper while dealing with material for
  82325. * rendering purpose.
  82326. *
  82327. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82328. *
  82329. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82330. */
  82331. export class MaterialHelper {
  82332. /**
  82333. * Bind the current view position to an effect.
  82334. * @param effect The effect to be bound
  82335. * @param scene The scene the eyes position is used from
  82336. */
  82337. static BindEyePosition(effect: Effect, scene: Scene): void;
  82338. /**
  82339. * Helps preparing the defines values about the UVs in used in the effect.
  82340. * UVs are shared as much as we can accross channels in the shaders.
  82341. * @param texture The texture we are preparing the UVs for
  82342. * @param defines The defines to update
  82343. * @param key The channel key "diffuse", "specular"... used in the shader
  82344. */
  82345. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82346. /**
  82347. * Binds a texture matrix value to its corrsponding uniform
  82348. * @param texture The texture to bind the matrix for
  82349. * @param uniformBuffer The uniform buffer receivin the data
  82350. * @param key The channel key "diffuse", "specular"... used in the shader
  82351. */
  82352. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82353. /**
  82354. * Gets the current status of the fog (should it be enabled?)
  82355. * @param mesh defines the mesh to evaluate for fog support
  82356. * @param scene defines the hosting scene
  82357. * @returns true if fog must be enabled
  82358. */
  82359. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82360. /**
  82361. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82362. * @param mesh defines the current mesh
  82363. * @param scene defines the current scene
  82364. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82365. * @param pointsCloud defines if point cloud rendering has to be turned on
  82366. * @param fogEnabled defines if fog has to be turned on
  82367. * @param alphaTest defines if alpha testing has to be turned on
  82368. * @param defines defines the current list of defines
  82369. */
  82370. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82371. /**
  82372. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82373. * @param scene defines the current scene
  82374. * @param engine defines the current engine
  82375. * @param defines specifies the list of active defines
  82376. * @param useInstances defines if instances have to be turned on
  82377. * @param useClipPlane defines if clip plane have to be turned on
  82378. */
  82379. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82380. /**
  82381. * Prepares the defines for bones
  82382. * @param mesh The mesh containing the geometry data we will draw
  82383. * @param defines The defines to update
  82384. */
  82385. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82386. /**
  82387. * Prepares the defines for morph targets
  82388. * @param mesh The mesh containing the geometry data we will draw
  82389. * @param defines The defines to update
  82390. */
  82391. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82392. /**
  82393. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82394. * @param mesh The mesh containing the geometry data we will draw
  82395. * @param defines The defines to update
  82396. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82397. * @param useBones Precise whether bones should be used or not (override mesh info)
  82398. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82399. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82400. * @returns false if defines are considered not dirty and have not been checked
  82401. */
  82402. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82403. /**
  82404. * Prepares the defines related to multiview
  82405. * @param scene The scene we are intending to draw
  82406. * @param defines The defines to update
  82407. */
  82408. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82409. /**
  82410. * Prepares the defines related to the light information passed in parameter
  82411. * @param scene The scene we are intending to draw
  82412. * @param mesh The mesh the effect is compiling for
  82413. * @param light The light the effect is compiling for
  82414. * @param lightIndex The index of the light
  82415. * @param defines The defines to update
  82416. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82417. * @param state Defines the current state regarding what is needed (normals, etc...)
  82418. */
  82419. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82420. needNormals: boolean;
  82421. needRebuild: boolean;
  82422. shadowEnabled: boolean;
  82423. specularEnabled: boolean;
  82424. lightmapMode: boolean;
  82425. }): void;
  82426. /**
  82427. * Prepares the defines related to the light information passed in parameter
  82428. * @param scene The scene we are intending to draw
  82429. * @param mesh The mesh the effect is compiling for
  82430. * @param defines The defines to update
  82431. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82432. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82433. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82434. * @returns true if normals will be required for the rest of the effect
  82435. */
  82436. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82437. /**
  82438. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82439. * @param lightIndex defines the light index
  82440. * @param uniformsList The uniform list
  82441. * @param samplersList The sampler list
  82442. * @param projectedLightTexture defines if projected texture must be used
  82443. * @param uniformBuffersList defines an optional list of uniform buffers
  82444. */
  82445. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82446. /**
  82447. * Prepares the uniforms and samplers list to be used in the effect
  82448. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82449. * @param samplersList The sampler list
  82450. * @param defines The defines helping in the list generation
  82451. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82452. */
  82453. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82454. /**
  82455. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82456. * @param defines The defines to update while falling back
  82457. * @param fallbacks The authorized effect fallbacks
  82458. * @param maxSimultaneousLights The maximum number of lights allowed
  82459. * @param rank the current rank of the Effect
  82460. * @returns The newly affected rank
  82461. */
  82462. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82463. private static _TmpMorphInfluencers;
  82464. /**
  82465. * Prepares the list of attributes required for morph targets according to the effect defines.
  82466. * @param attribs The current list of supported attribs
  82467. * @param mesh The mesh to prepare the morph targets attributes for
  82468. * @param influencers The number of influencers
  82469. */
  82470. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82471. /**
  82472. * Prepares the list of attributes required for morph targets according to the effect defines.
  82473. * @param attribs The current list of supported attribs
  82474. * @param mesh The mesh to prepare the morph targets attributes for
  82475. * @param defines The current Defines of the effect
  82476. */
  82477. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82478. /**
  82479. * Prepares the list of attributes required for bones according to the effect defines.
  82480. * @param attribs The current list of supported attribs
  82481. * @param mesh The mesh to prepare the bones attributes for
  82482. * @param defines The current Defines of the effect
  82483. * @param fallbacks The current efffect fallback strategy
  82484. */
  82485. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82486. /**
  82487. * Check and prepare the list of attributes required for instances according to the effect defines.
  82488. * @param attribs The current list of supported attribs
  82489. * @param defines The current MaterialDefines of the effect
  82490. */
  82491. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82492. /**
  82493. * Add the list of attributes required for instances to the attribs array.
  82494. * @param attribs The current list of supported attribs
  82495. */
  82496. static PushAttributesForInstances(attribs: string[]): void;
  82497. /**
  82498. * Binds the light information to the effect.
  82499. * @param light The light containing the generator
  82500. * @param effect The effect we are binding the data to
  82501. * @param lightIndex The light index in the effect used to render
  82502. */
  82503. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82504. /**
  82505. * Binds the lights information from the scene to the effect for the given mesh.
  82506. * @param light Light to bind
  82507. * @param lightIndex Light index
  82508. * @param scene The scene where the light belongs to
  82509. * @param effect The effect we are binding the data to
  82510. * @param useSpecular Defines if specular is supported
  82511. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82512. */
  82513. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82514. /**
  82515. * Binds the lights information from the scene to the effect for the given mesh.
  82516. * @param scene The scene the lights belongs to
  82517. * @param mesh The mesh we are binding the information to render
  82518. * @param effect The effect we are binding the data to
  82519. * @param defines The generated defines for the effect
  82520. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82521. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82522. */
  82523. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82524. private static _tempFogColor;
  82525. /**
  82526. * Binds the fog information from the scene to the effect for the given mesh.
  82527. * @param scene The scene the lights belongs to
  82528. * @param mesh The mesh we are binding the information to render
  82529. * @param effect The effect we are binding the data to
  82530. * @param linearSpace Defines if the fog effect is applied in linear space
  82531. */
  82532. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82533. /**
  82534. * Binds the bones information from the mesh to the effect.
  82535. * @param mesh The mesh we are binding the information to render
  82536. * @param effect The effect we are binding the data to
  82537. */
  82538. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82539. /**
  82540. * Binds the morph targets information from the mesh to the effect.
  82541. * @param abstractMesh The mesh we are binding the information to render
  82542. * @param effect The effect we are binding the data to
  82543. */
  82544. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82545. /**
  82546. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82547. * @param defines The generated defines used in the effect
  82548. * @param effect The effect we are binding the data to
  82549. * @param scene The scene we are willing to render with logarithmic scale for
  82550. */
  82551. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82552. /**
  82553. * Binds the clip plane information from the scene to the effect.
  82554. * @param scene The scene the clip plane information are extracted from
  82555. * @param effect The effect we are binding the data to
  82556. */
  82557. static BindClipPlane(effect: Effect, scene: Scene): void;
  82558. }
  82559. }
  82560. declare module BABYLON {
  82561. /** @hidden */
  82562. export var packingFunctions: {
  82563. name: string;
  82564. shader: string;
  82565. };
  82566. }
  82567. declare module BABYLON {
  82568. /** @hidden */
  82569. export var clipPlaneFragmentDeclaration: {
  82570. name: string;
  82571. shader: string;
  82572. };
  82573. }
  82574. declare module BABYLON {
  82575. /** @hidden */
  82576. export var clipPlaneFragment: {
  82577. name: string;
  82578. shader: string;
  82579. };
  82580. }
  82581. declare module BABYLON {
  82582. /** @hidden */
  82583. export var shadowMapPixelShader: {
  82584. name: string;
  82585. shader: string;
  82586. };
  82587. }
  82588. declare module BABYLON {
  82589. /** @hidden */
  82590. export var bonesDeclaration: {
  82591. name: string;
  82592. shader: string;
  82593. };
  82594. }
  82595. declare module BABYLON {
  82596. /** @hidden */
  82597. export var morphTargetsVertexGlobalDeclaration: {
  82598. name: string;
  82599. shader: string;
  82600. };
  82601. }
  82602. declare module BABYLON {
  82603. /** @hidden */
  82604. export var morphTargetsVertexDeclaration: {
  82605. name: string;
  82606. shader: string;
  82607. };
  82608. }
  82609. declare module BABYLON {
  82610. /** @hidden */
  82611. export var instancesDeclaration: {
  82612. name: string;
  82613. shader: string;
  82614. };
  82615. }
  82616. declare module BABYLON {
  82617. /** @hidden */
  82618. export var helperFunctions: {
  82619. name: string;
  82620. shader: string;
  82621. };
  82622. }
  82623. declare module BABYLON {
  82624. /** @hidden */
  82625. export var clipPlaneVertexDeclaration: {
  82626. name: string;
  82627. shader: string;
  82628. };
  82629. }
  82630. declare module BABYLON {
  82631. /** @hidden */
  82632. export var morphTargetsVertex: {
  82633. name: string;
  82634. shader: string;
  82635. };
  82636. }
  82637. declare module BABYLON {
  82638. /** @hidden */
  82639. export var instancesVertex: {
  82640. name: string;
  82641. shader: string;
  82642. };
  82643. }
  82644. declare module BABYLON {
  82645. /** @hidden */
  82646. export var bonesVertex: {
  82647. name: string;
  82648. shader: string;
  82649. };
  82650. }
  82651. declare module BABYLON {
  82652. /** @hidden */
  82653. export var clipPlaneVertex: {
  82654. name: string;
  82655. shader: string;
  82656. };
  82657. }
  82658. declare module BABYLON {
  82659. /** @hidden */
  82660. export var shadowMapVertexShader: {
  82661. name: string;
  82662. shader: string;
  82663. };
  82664. }
  82665. declare module BABYLON {
  82666. /** @hidden */
  82667. export var depthBoxBlurPixelShader: {
  82668. name: string;
  82669. shader: string;
  82670. };
  82671. }
  82672. declare module BABYLON {
  82673. /**
  82674. * Class representing a ray with position and direction
  82675. */
  82676. export class Ray {
  82677. /** origin point */
  82678. origin: Vector3;
  82679. /** direction */
  82680. direction: Vector3;
  82681. /** length of the ray */
  82682. length: number;
  82683. private static readonly TmpVector3;
  82684. private _tmpRay;
  82685. /**
  82686. * Creates a new ray
  82687. * @param origin origin point
  82688. * @param direction direction
  82689. * @param length length of the ray
  82690. */
  82691. constructor(
  82692. /** origin point */
  82693. origin: Vector3,
  82694. /** direction */
  82695. direction: Vector3,
  82696. /** length of the ray */
  82697. length?: number);
  82698. /**
  82699. * Checks if the ray intersects a box
  82700. * @param minimum bound of the box
  82701. * @param maximum bound of the box
  82702. * @param intersectionTreshold extra extend to be added to the box in all direction
  82703. * @returns if the box was hit
  82704. */
  82705. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82706. /**
  82707. * Checks if the ray intersects a box
  82708. * @param box the bounding box to check
  82709. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82710. * @returns if the box was hit
  82711. */
  82712. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82713. /**
  82714. * If the ray hits a sphere
  82715. * @param sphere the bounding sphere to check
  82716. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82717. * @returns true if it hits the sphere
  82718. */
  82719. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82720. /**
  82721. * If the ray hits a triange
  82722. * @param vertex0 triangle vertex
  82723. * @param vertex1 triangle vertex
  82724. * @param vertex2 triangle vertex
  82725. * @returns intersection information if hit
  82726. */
  82727. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82728. /**
  82729. * Checks if ray intersects a plane
  82730. * @param plane the plane to check
  82731. * @returns the distance away it was hit
  82732. */
  82733. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82734. /**
  82735. * Calculate the intercept of a ray on a given axis
  82736. * @param axis to check 'x' | 'y' | 'z'
  82737. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82738. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82739. */
  82740. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82741. /**
  82742. * Checks if ray intersects a mesh
  82743. * @param mesh the mesh to check
  82744. * @param fastCheck if only the bounding box should checked
  82745. * @returns picking info of the intersecton
  82746. */
  82747. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82748. /**
  82749. * Checks if ray intersects a mesh
  82750. * @param meshes the meshes to check
  82751. * @param fastCheck if only the bounding box should checked
  82752. * @param results array to store result in
  82753. * @returns Array of picking infos
  82754. */
  82755. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82756. private _comparePickingInfo;
  82757. private static smallnum;
  82758. private static rayl;
  82759. /**
  82760. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82761. * @param sega the first point of the segment to test the intersection against
  82762. * @param segb the second point of the segment to test the intersection against
  82763. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82764. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82765. */
  82766. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82767. /**
  82768. * Update the ray from viewport position
  82769. * @param x position
  82770. * @param y y position
  82771. * @param viewportWidth viewport width
  82772. * @param viewportHeight viewport height
  82773. * @param world world matrix
  82774. * @param view view matrix
  82775. * @param projection projection matrix
  82776. * @returns this ray updated
  82777. */
  82778. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82779. /**
  82780. * Creates a ray with origin and direction of 0,0,0
  82781. * @returns the new ray
  82782. */
  82783. static Zero(): Ray;
  82784. /**
  82785. * Creates a new ray from screen space and viewport
  82786. * @param x position
  82787. * @param y y position
  82788. * @param viewportWidth viewport width
  82789. * @param viewportHeight viewport height
  82790. * @param world world matrix
  82791. * @param view view matrix
  82792. * @param projection projection matrix
  82793. * @returns new ray
  82794. */
  82795. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82796. /**
  82797. * 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
  82798. * transformed to the given world matrix.
  82799. * @param origin The origin point
  82800. * @param end The end point
  82801. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82802. * @returns the new ray
  82803. */
  82804. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82805. /**
  82806. * Transforms a ray by a matrix
  82807. * @param ray ray to transform
  82808. * @param matrix matrix to apply
  82809. * @returns the resulting new ray
  82810. */
  82811. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82812. /**
  82813. * Transforms a ray by a matrix
  82814. * @param ray ray to transform
  82815. * @param matrix matrix to apply
  82816. * @param result ray to store result in
  82817. */
  82818. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82819. /**
  82820. * Unproject a ray from screen space to object space
  82821. * @param sourceX defines the screen space x coordinate to use
  82822. * @param sourceY defines the screen space y coordinate to use
  82823. * @param viewportWidth defines the current width of the viewport
  82824. * @param viewportHeight defines the current height of the viewport
  82825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82826. * @param view defines the view matrix to use
  82827. * @param projection defines the projection matrix to use
  82828. */
  82829. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82830. }
  82831. /**
  82832. * Type used to define predicate used to select faces when a mesh intersection is detected
  82833. */
  82834. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82835. interface Scene {
  82836. /** @hidden */
  82837. _tempPickingRay: Nullable<Ray>;
  82838. /** @hidden */
  82839. _cachedRayForTransform: Ray;
  82840. /** @hidden */
  82841. _pickWithRayInverseMatrix: Matrix;
  82842. /** @hidden */
  82843. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82844. /** @hidden */
  82845. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82846. }
  82847. }
  82848. declare module BABYLON {
  82849. /**
  82850. * Groups all the scene component constants in one place to ease maintenance.
  82851. * @hidden
  82852. */
  82853. export class SceneComponentConstants {
  82854. static readonly NAME_EFFECTLAYER: string;
  82855. static readonly NAME_LAYER: string;
  82856. static readonly NAME_LENSFLARESYSTEM: string;
  82857. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82858. static readonly NAME_PARTICLESYSTEM: string;
  82859. static readonly NAME_GAMEPAD: string;
  82860. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82861. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82862. static readonly NAME_DEPTHRENDERER: string;
  82863. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82864. static readonly NAME_SPRITE: string;
  82865. static readonly NAME_OUTLINERENDERER: string;
  82866. static readonly NAME_PROCEDURALTEXTURE: string;
  82867. static readonly NAME_SHADOWGENERATOR: string;
  82868. static readonly NAME_OCTREE: string;
  82869. static readonly NAME_PHYSICSENGINE: string;
  82870. static readonly NAME_AUDIO: string;
  82871. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82872. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82873. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82874. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82875. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82876. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82877. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82878. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82879. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82880. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82881. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82882. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82883. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82884. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82885. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82886. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82887. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82888. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82889. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82890. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82891. static readonly STEP_AFTERRENDER_AUDIO: number;
  82892. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82893. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82894. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82895. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82896. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82897. static readonly STEP_POINTERMOVE_SPRITE: number;
  82898. static readonly STEP_POINTERDOWN_SPRITE: number;
  82899. static readonly STEP_POINTERUP_SPRITE: number;
  82900. }
  82901. /**
  82902. * This represents a scene component.
  82903. *
  82904. * This is used to decouple the dependency the scene is having on the different workloads like
  82905. * layers, post processes...
  82906. */
  82907. export interface ISceneComponent {
  82908. /**
  82909. * The name of the component. Each component must have a unique name.
  82910. */
  82911. name: string;
  82912. /**
  82913. * The scene the component belongs to.
  82914. */
  82915. scene: Scene;
  82916. /**
  82917. * Register the component to one instance of a scene.
  82918. */
  82919. register(): void;
  82920. /**
  82921. * Rebuilds the elements related to this component in case of
  82922. * context lost for instance.
  82923. */
  82924. rebuild(): void;
  82925. /**
  82926. * Disposes the component and the associated ressources.
  82927. */
  82928. dispose(): void;
  82929. }
  82930. /**
  82931. * This represents a SERIALIZABLE scene component.
  82932. *
  82933. * This extends Scene Component to add Serialization methods on top.
  82934. */
  82935. export interface ISceneSerializableComponent extends ISceneComponent {
  82936. /**
  82937. * Adds all the elements from the container to the scene
  82938. * @param container the container holding the elements
  82939. */
  82940. addFromContainer(container: AbstractScene): void;
  82941. /**
  82942. * Removes all the elements in the container from the scene
  82943. * @param container contains the elements to remove
  82944. * @param dispose if the removed element should be disposed (default: false)
  82945. */
  82946. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82947. /**
  82948. * Serializes the component data to the specified json object
  82949. * @param serializationObject The object to serialize to
  82950. */
  82951. serialize(serializationObject: any): void;
  82952. }
  82953. /**
  82954. * Strong typing of a Mesh related stage step action
  82955. */
  82956. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82957. /**
  82958. * Strong typing of a Evaluate Sub Mesh related stage step action
  82959. */
  82960. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82961. /**
  82962. * Strong typing of a Active Mesh related stage step action
  82963. */
  82964. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82965. /**
  82966. * Strong typing of a Camera related stage step action
  82967. */
  82968. export type CameraStageAction = (camera: Camera) => void;
  82969. /**
  82970. * Strong typing of a Camera Frame buffer related stage step action
  82971. */
  82972. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82973. /**
  82974. * Strong typing of a Render Target related stage step action
  82975. */
  82976. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82977. /**
  82978. * Strong typing of a RenderingGroup related stage step action
  82979. */
  82980. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82981. /**
  82982. * Strong typing of a Mesh Render related stage step action
  82983. */
  82984. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82985. /**
  82986. * Strong typing of a simple stage step action
  82987. */
  82988. export type SimpleStageAction = () => void;
  82989. /**
  82990. * Strong typing of a render target action.
  82991. */
  82992. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82993. /**
  82994. * Strong typing of a pointer move action.
  82995. */
  82996. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82997. /**
  82998. * Strong typing of a pointer up/down action.
  82999. */
  83000. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83001. /**
  83002. * Representation of a stage in the scene (Basically a list of ordered steps)
  83003. * @hidden
  83004. */
  83005. export class Stage<T extends Function> extends Array<{
  83006. index: number;
  83007. component: ISceneComponent;
  83008. action: T;
  83009. }> {
  83010. /**
  83011. * Hide ctor from the rest of the world.
  83012. * @param items The items to add.
  83013. */
  83014. private constructor();
  83015. /**
  83016. * Creates a new Stage.
  83017. * @returns A new instance of a Stage
  83018. */
  83019. static Create<T extends Function>(): Stage<T>;
  83020. /**
  83021. * Registers a step in an ordered way in the targeted stage.
  83022. * @param index Defines the position to register the step in
  83023. * @param component Defines the component attached to the step
  83024. * @param action Defines the action to launch during the step
  83025. */
  83026. registerStep(index: number, component: ISceneComponent, action: T): void;
  83027. /**
  83028. * Clears all the steps from the stage.
  83029. */
  83030. clear(): void;
  83031. }
  83032. }
  83033. declare module BABYLON {
  83034. interface Scene {
  83035. /** @hidden */
  83036. _pointerOverSprite: Nullable<Sprite>;
  83037. /** @hidden */
  83038. _pickedDownSprite: Nullable<Sprite>;
  83039. /** @hidden */
  83040. _tempSpritePickingRay: Nullable<Ray>;
  83041. /**
  83042. * All of the sprite managers added to this scene
  83043. * @see http://doc.babylonjs.com/babylon101/sprites
  83044. */
  83045. spriteManagers: Array<ISpriteManager>;
  83046. /**
  83047. * An event triggered when sprites rendering is about to start
  83048. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83049. */
  83050. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83051. /**
  83052. * An event triggered when sprites rendering is done
  83053. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83054. */
  83055. onAfterSpritesRenderingObservable: Observable<Scene>;
  83056. /** @hidden */
  83057. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83058. /** Launch a ray to try to pick a sprite in the scene
  83059. * @param x position on screen
  83060. * @param y position on screen
  83061. * @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
  83062. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83063. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83064. * @returns a PickingInfo
  83065. */
  83066. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83067. /** Use the given ray to pick a sprite in the scene
  83068. * @param ray The ray (in world space) to use to pick meshes
  83069. * @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
  83070. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83071. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83072. * @returns a PickingInfo
  83073. */
  83074. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83075. /** @hidden */
  83076. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83077. /** Launch a ray to try to pick sprites in the scene
  83078. * @param x position on screen
  83079. * @param y position on screen
  83080. * @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
  83081. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83082. * @returns a PickingInfo array
  83083. */
  83084. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83085. /** Use the given ray to pick sprites in the scene
  83086. * @param ray The ray (in world space) to use to pick meshes
  83087. * @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
  83088. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83089. * @returns a PickingInfo array
  83090. */
  83091. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83092. /**
  83093. * Force the sprite under the pointer
  83094. * @param sprite defines the sprite to use
  83095. */
  83096. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83097. /**
  83098. * Gets the sprite under the pointer
  83099. * @returns a Sprite or null if no sprite is under the pointer
  83100. */
  83101. getPointerOverSprite(): Nullable<Sprite>;
  83102. }
  83103. /**
  83104. * Defines the sprite scene component responsible to manage sprites
  83105. * in a given scene.
  83106. */
  83107. export class SpriteSceneComponent implements ISceneComponent {
  83108. /**
  83109. * The component name helpfull to identify the component in the list of scene components.
  83110. */
  83111. readonly name: string;
  83112. /**
  83113. * The scene the component belongs to.
  83114. */
  83115. scene: Scene;
  83116. /** @hidden */
  83117. private _spritePredicate;
  83118. /**
  83119. * Creates a new instance of the component for the given scene
  83120. * @param scene Defines the scene to register the component in
  83121. */
  83122. constructor(scene: Scene);
  83123. /**
  83124. * Registers the component in a given scene
  83125. */
  83126. register(): void;
  83127. /**
  83128. * Rebuilds the elements related to this component in case of
  83129. * context lost for instance.
  83130. */
  83131. rebuild(): void;
  83132. /**
  83133. * Disposes the component and the associated ressources.
  83134. */
  83135. dispose(): void;
  83136. private _pickSpriteButKeepRay;
  83137. private _pointerMove;
  83138. private _pointerDown;
  83139. private _pointerUp;
  83140. }
  83141. }
  83142. declare module BABYLON {
  83143. /** @hidden */
  83144. export var fogFragmentDeclaration: {
  83145. name: string;
  83146. shader: string;
  83147. };
  83148. }
  83149. declare module BABYLON {
  83150. /** @hidden */
  83151. export var fogFragment: {
  83152. name: string;
  83153. shader: string;
  83154. };
  83155. }
  83156. declare module BABYLON {
  83157. /** @hidden */
  83158. export var spritesPixelShader: {
  83159. name: string;
  83160. shader: string;
  83161. };
  83162. }
  83163. declare module BABYLON {
  83164. /** @hidden */
  83165. export var fogVertexDeclaration: {
  83166. name: string;
  83167. shader: string;
  83168. };
  83169. }
  83170. declare module BABYLON {
  83171. /** @hidden */
  83172. export var spritesVertexShader: {
  83173. name: string;
  83174. shader: string;
  83175. };
  83176. }
  83177. declare module BABYLON {
  83178. /**
  83179. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83180. */
  83181. export interface ISpriteManager extends IDisposable {
  83182. /**
  83183. * Restricts the camera to viewing objects with the same layerMask.
  83184. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83185. */
  83186. layerMask: number;
  83187. /**
  83188. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83189. */
  83190. isPickable: boolean;
  83191. /**
  83192. * Specifies the rendering group id for this mesh (0 by default)
  83193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83194. */
  83195. renderingGroupId: number;
  83196. /**
  83197. * Defines the list of sprites managed by the manager.
  83198. */
  83199. sprites: Array<Sprite>;
  83200. /**
  83201. * Tests the intersection of a sprite with a specific ray.
  83202. * @param ray The ray we are sending to test the collision
  83203. * @param camera The camera space we are sending rays in
  83204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83205. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83206. * @returns picking info or null.
  83207. */
  83208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83209. /**
  83210. * Intersects the sprites with a ray
  83211. * @param ray defines the ray to intersect with
  83212. * @param camera defines the current active camera
  83213. * @param predicate defines a predicate used to select candidate sprites
  83214. * @returns null if no hit or a PickingInfo array
  83215. */
  83216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83217. /**
  83218. * Renders the list of sprites on screen.
  83219. */
  83220. render(): void;
  83221. }
  83222. /**
  83223. * Class used to manage multiple sprites on the same spritesheet
  83224. * @see http://doc.babylonjs.com/babylon101/sprites
  83225. */
  83226. export class SpriteManager implements ISpriteManager {
  83227. /** defines the manager's name */
  83228. name: string;
  83229. /** Gets the list of sprites */
  83230. sprites: Sprite[];
  83231. /** Gets or sets the rendering group id (0 by default) */
  83232. renderingGroupId: number;
  83233. /** Gets or sets camera layer mask */
  83234. layerMask: number;
  83235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83236. fogEnabled: boolean;
  83237. /** Gets or sets a boolean indicating if the sprites are pickable */
  83238. isPickable: boolean;
  83239. /** Defines the default width of a cell in the spritesheet */
  83240. cellWidth: number;
  83241. /** Defines the default height of a cell in the spritesheet */
  83242. cellHeight: number;
  83243. /** Associative array from JSON sprite data file */
  83244. private _cellData;
  83245. /** Array of sprite names from JSON sprite data file */
  83246. private _spriteMap;
  83247. /** True when packed cell data from JSON file is ready*/
  83248. private _packedAndReady;
  83249. /**
  83250. * An event triggered when the manager is disposed.
  83251. */
  83252. onDisposeObservable: Observable<SpriteManager>;
  83253. private _onDisposeObserver;
  83254. /**
  83255. * Callback called when the manager is disposed
  83256. */
  83257. set onDispose(callback: () => void);
  83258. private _capacity;
  83259. private _fromPacked;
  83260. private _spriteTexture;
  83261. private _epsilon;
  83262. private _scene;
  83263. private _vertexData;
  83264. private _buffer;
  83265. private _vertexBuffers;
  83266. private _indexBuffer;
  83267. private _effectBase;
  83268. private _effectFog;
  83269. /**
  83270. * Gets or sets the spritesheet texture
  83271. */
  83272. get texture(): Texture;
  83273. set texture(value: Texture);
  83274. private _blendMode;
  83275. /**
  83276. * Blend mode use to render the particle, it can be any of
  83277. * the static Constants.ALPHA_x properties provided in this class.
  83278. * Default value is Constants.ALPHA_COMBINE
  83279. */
  83280. get blendMode(): number;
  83281. set blendMode(blendMode: number);
  83282. /** Disables writing to the depth buffer when rendering the sprites.
  83283. * It can be handy to disable depth writing when using textures without alpha channel
  83284. * and setting some specific blend modes.
  83285. */
  83286. disableDepthWrite: boolean;
  83287. /**
  83288. * Creates a new sprite manager
  83289. * @param name defines the manager's name
  83290. * @param imgUrl defines the sprite sheet url
  83291. * @param capacity defines the maximum allowed number of sprites
  83292. * @param cellSize defines the size of a sprite cell
  83293. * @param scene defines the hosting scene
  83294. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83295. * @param samplingMode defines the smapling mode to use with spritesheet
  83296. * @param fromPacked set to false; do not alter
  83297. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83298. */
  83299. constructor(
  83300. /** defines the manager's name */
  83301. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83302. private _makePacked;
  83303. private _appendSpriteVertex;
  83304. /**
  83305. * Intersects the sprites with a ray
  83306. * @param ray defines the ray to intersect with
  83307. * @param camera defines the current active camera
  83308. * @param predicate defines a predicate used to select candidate sprites
  83309. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83310. * @returns null if no hit or a PickingInfo
  83311. */
  83312. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83313. /**
  83314. * Intersects the sprites with a ray
  83315. * @param ray defines the ray to intersect with
  83316. * @param camera defines the current active camera
  83317. * @param predicate defines a predicate used to select candidate sprites
  83318. * @returns null if no hit or a PickingInfo array
  83319. */
  83320. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83321. /**
  83322. * Render all child sprites
  83323. */
  83324. render(): void;
  83325. /**
  83326. * Release associated resources
  83327. */
  83328. dispose(): void;
  83329. }
  83330. }
  83331. declare module BABYLON {
  83332. /** Interface used by value gradients (color, factor, ...) */
  83333. export interface IValueGradient {
  83334. /**
  83335. * Gets or sets the gradient value (between 0 and 1)
  83336. */
  83337. gradient: number;
  83338. }
  83339. /** Class used to store color4 gradient */
  83340. export class ColorGradient implements IValueGradient {
  83341. /**
  83342. * Gets or sets the gradient value (between 0 and 1)
  83343. */
  83344. gradient: number;
  83345. /**
  83346. * Gets or sets first associated color
  83347. */
  83348. color1: Color4;
  83349. /**
  83350. * Gets or sets second associated color
  83351. */
  83352. color2?: Color4;
  83353. /**
  83354. * Will get a color picked randomly between color1 and color2.
  83355. * If color2 is undefined then color1 will be used
  83356. * @param result defines the target Color4 to store the result in
  83357. */
  83358. getColorToRef(result: Color4): void;
  83359. }
  83360. /** Class used to store color 3 gradient */
  83361. export class Color3Gradient implements IValueGradient {
  83362. /**
  83363. * Gets or sets the gradient value (between 0 and 1)
  83364. */
  83365. gradient: number;
  83366. /**
  83367. * Gets or sets the associated color
  83368. */
  83369. color: Color3;
  83370. }
  83371. /** Class used to store factor gradient */
  83372. export class FactorGradient implements IValueGradient {
  83373. /**
  83374. * Gets or sets the gradient value (between 0 and 1)
  83375. */
  83376. gradient: number;
  83377. /**
  83378. * Gets or sets first associated factor
  83379. */
  83380. factor1: number;
  83381. /**
  83382. * Gets or sets second associated factor
  83383. */
  83384. factor2?: number;
  83385. /**
  83386. * Will get a number picked randomly between factor1 and factor2.
  83387. * If factor2 is undefined then factor1 will be used
  83388. * @returns the picked number
  83389. */
  83390. getFactor(): number;
  83391. }
  83392. /**
  83393. * Helper used to simplify some generic gradient tasks
  83394. */
  83395. export class GradientHelper {
  83396. /**
  83397. * Gets the current gradient from an array of IValueGradient
  83398. * @param ratio defines the current ratio to get
  83399. * @param gradients defines the array of IValueGradient
  83400. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83401. */
  83402. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83403. }
  83404. }
  83405. declare module BABYLON {
  83406. /**
  83407. * Interface for the size containing width and height
  83408. */
  83409. export interface ISize {
  83410. /**
  83411. * Width
  83412. */
  83413. width: number;
  83414. /**
  83415. * Heighht
  83416. */
  83417. height: number;
  83418. }
  83419. /**
  83420. * Size containing widht and height
  83421. */
  83422. export class Size implements ISize {
  83423. /**
  83424. * Width
  83425. */
  83426. width: number;
  83427. /**
  83428. * Height
  83429. */
  83430. height: number;
  83431. /**
  83432. * Creates a Size object from the given width and height (floats).
  83433. * @param width width of the new size
  83434. * @param height height of the new size
  83435. */
  83436. constructor(width: number, height: number);
  83437. /**
  83438. * Returns a string with the Size width and height
  83439. * @returns a string with the Size width and height
  83440. */
  83441. toString(): string;
  83442. /**
  83443. * "Size"
  83444. * @returns the string "Size"
  83445. */
  83446. getClassName(): string;
  83447. /**
  83448. * Returns the Size hash code.
  83449. * @returns a hash code for a unique width and height
  83450. */
  83451. getHashCode(): number;
  83452. /**
  83453. * Updates the current size from the given one.
  83454. * @param src the given size
  83455. */
  83456. copyFrom(src: Size): void;
  83457. /**
  83458. * Updates in place the current Size from the given floats.
  83459. * @param width width of the new size
  83460. * @param height height of the new size
  83461. * @returns the updated Size.
  83462. */
  83463. copyFromFloats(width: number, height: number): Size;
  83464. /**
  83465. * Updates in place the current Size from the given floats.
  83466. * @param width width to set
  83467. * @param height height to set
  83468. * @returns the updated Size.
  83469. */
  83470. set(width: number, height: number): Size;
  83471. /**
  83472. * Multiplies the width and height by numbers
  83473. * @param w factor to multiple the width by
  83474. * @param h factor to multiple the height by
  83475. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83476. */
  83477. multiplyByFloats(w: number, h: number): Size;
  83478. /**
  83479. * Clones the size
  83480. * @returns a new Size copied from the given one.
  83481. */
  83482. clone(): Size;
  83483. /**
  83484. * True if the current Size and the given one width and height are strictly equal.
  83485. * @param other the other size to compare against
  83486. * @returns True if the current Size and the given one width and height are strictly equal.
  83487. */
  83488. equals(other: Size): boolean;
  83489. /**
  83490. * The surface of the Size : width * height (float).
  83491. */
  83492. get surface(): number;
  83493. /**
  83494. * Create a new size of zero
  83495. * @returns a new Size set to (0.0, 0.0)
  83496. */
  83497. static Zero(): Size;
  83498. /**
  83499. * Sums the width and height of two sizes
  83500. * @param otherSize size to add to this size
  83501. * @returns a new Size set as the addition result of the current Size and the given one.
  83502. */
  83503. add(otherSize: Size): Size;
  83504. /**
  83505. * Subtracts the width and height of two
  83506. * @param otherSize size to subtract to this size
  83507. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83508. */
  83509. subtract(otherSize: Size): Size;
  83510. /**
  83511. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83512. * @param start starting size to lerp between
  83513. * @param end end size to lerp between
  83514. * @param amount amount to lerp between the start and end values
  83515. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83516. */
  83517. static Lerp(start: Size, end: Size, amount: number): Size;
  83518. }
  83519. }
  83520. declare module BABYLON {
  83521. interface ThinEngine {
  83522. /**
  83523. * Creates a dynamic texture
  83524. * @param width defines the width of the texture
  83525. * @param height defines the height of the texture
  83526. * @param generateMipMaps defines if the engine should generate the mip levels
  83527. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83528. * @returns the dynamic texture inside an InternalTexture
  83529. */
  83530. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83531. /**
  83532. * Update the content of a dynamic texture
  83533. * @param texture defines the texture to update
  83534. * @param canvas defines the canvas containing the source
  83535. * @param invertY defines if data must be stored with Y axis inverted
  83536. * @param premulAlpha defines if alpha is stored as premultiplied
  83537. * @param format defines the format of the data
  83538. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83539. */
  83540. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83541. }
  83542. }
  83543. declare module BABYLON {
  83544. /**
  83545. * Helper class used to generate a canvas to manipulate images
  83546. */
  83547. export class CanvasGenerator {
  83548. /**
  83549. * Create a new canvas (or offscreen canvas depending on the context)
  83550. * @param width defines the expected width
  83551. * @param height defines the expected height
  83552. * @return a new canvas or offscreen canvas
  83553. */
  83554. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83555. }
  83556. }
  83557. declare module BABYLON {
  83558. /**
  83559. * A class extending Texture allowing drawing on a texture
  83560. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83561. */
  83562. export class DynamicTexture extends Texture {
  83563. private _generateMipMaps;
  83564. private _canvas;
  83565. private _context;
  83566. private _engine;
  83567. /**
  83568. * Creates a DynamicTexture
  83569. * @param name defines the name of the texture
  83570. * @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
  83571. * @param scene defines the scene where you want the texture
  83572. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83573. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83574. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83575. */
  83576. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83577. /**
  83578. * Get the current class name of the texture useful for serialization or dynamic coding.
  83579. * @returns "DynamicTexture"
  83580. */
  83581. getClassName(): string;
  83582. /**
  83583. * Gets the current state of canRescale
  83584. */
  83585. get canRescale(): boolean;
  83586. private _recreate;
  83587. /**
  83588. * Scales the texture
  83589. * @param ratio the scale factor to apply to both width and height
  83590. */
  83591. scale(ratio: number): void;
  83592. /**
  83593. * Resizes the texture
  83594. * @param width the new width
  83595. * @param height the new height
  83596. */
  83597. scaleTo(width: number, height: number): void;
  83598. /**
  83599. * Gets the context of the canvas used by the texture
  83600. * @returns the canvas context of the dynamic texture
  83601. */
  83602. getContext(): CanvasRenderingContext2D;
  83603. /**
  83604. * Clears the texture
  83605. */
  83606. clear(): void;
  83607. /**
  83608. * Updates the texture
  83609. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83610. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83611. */
  83612. update(invertY?: boolean, premulAlpha?: boolean): void;
  83613. /**
  83614. * Draws text onto the texture
  83615. * @param text defines the text to be drawn
  83616. * @param x defines the placement of the text from the left
  83617. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83618. * @param font defines the font to be used with font-style, font-size, font-name
  83619. * @param color defines the color used for the text
  83620. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83621. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83622. * @param update defines whether texture is immediately update (default is true)
  83623. */
  83624. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83625. /**
  83626. * Clones the texture
  83627. * @returns the clone of the texture.
  83628. */
  83629. clone(): DynamicTexture;
  83630. /**
  83631. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83632. * @returns a serialized dynamic texture object
  83633. */
  83634. serialize(): any;
  83635. /** @hidden */
  83636. _rebuild(): void;
  83637. }
  83638. }
  83639. declare module BABYLON {
  83640. interface Engine {
  83641. /**
  83642. * Creates a raw texture
  83643. * @param data defines the data to store in the texture
  83644. * @param width defines the width of the texture
  83645. * @param height defines the height of the texture
  83646. * @param format defines the format of the data
  83647. * @param generateMipMaps defines if the engine should generate the mip levels
  83648. * @param invertY defines if data must be stored with Y axis inverted
  83649. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83650. * @param compression defines the compression used (null by default)
  83651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83652. * @returns the raw texture inside an InternalTexture
  83653. */
  83654. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83655. /**
  83656. * Update a raw texture
  83657. * @param texture defines the texture to update
  83658. * @param data defines the data to store in the texture
  83659. * @param format defines the format of the data
  83660. * @param invertY defines if data must be stored with Y axis inverted
  83661. */
  83662. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83663. /**
  83664. * Update a raw texture
  83665. * @param texture defines the texture to update
  83666. * @param data defines the data to store in the texture
  83667. * @param format defines the format of the data
  83668. * @param invertY defines if data must be stored with Y axis inverted
  83669. * @param compression defines the compression used (null by default)
  83670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83671. */
  83672. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83673. /**
  83674. * Creates a new raw cube texture
  83675. * @param data defines the array of data to use to create each face
  83676. * @param size defines the size of the textures
  83677. * @param format defines the format of the data
  83678. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83679. * @param generateMipMaps defines if the engine should generate the mip levels
  83680. * @param invertY defines if data must be stored with Y axis inverted
  83681. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83682. * @param compression defines the compression used (null by default)
  83683. * @returns the cube texture as an InternalTexture
  83684. */
  83685. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83686. /**
  83687. * Update a raw cube texture
  83688. * @param texture defines the texture to udpdate
  83689. * @param data defines the data to store
  83690. * @param format defines the data format
  83691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83692. * @param invertY defines if data must be stored with Y axis inverted
  83693. */
  83694. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83695. /**
  83696. * Update a raw cube texture
  83697. * @param texture defines the texture to udpdate
  83698. * @param data defines the data to store
  83699. * @param format defines the data format
  83700. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83701. * @param invertY defines if data must be stored with Y axis inverted
  83702. * @param compression defines the compression used (null by default)
  83703. */
  83704. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83705. /**
  83706. * Update a raw cube texture
  83707. * @param texture defines the texture to udpdate
  83708. * @param data defines the data to store
  83709. * @param format defines the data format
  83710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83711. * @param invertY defines if data must be stored with Y axis inverted
  83712. * @param compression defines the compression used (null by default)
  83713. * @param level defines which level of the texture to update
  83714. */
  83715. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83716. /**
  83717. * Creates a new raw cube texture from a specified url
  83718. * @param url defines the url where the data is located
  83719. * @param scene defines the current scene
  83720. * @param size defines the size of the textures
  83721. * @param format defines the format of the data
  83722. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83723. * @param noMipmap defines if the engine should avoid generating the mip levels
  83724. * @param callback defines a callback used to extract texture data from loaded data
  83725. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83726. * @param onLoad defines a callback called when texture is loaded
  83727. * @param onError defines a callback called if there is an error
  83728. * @returns the cube texture as an InternalTexture
  83729. */
  83730. 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;
  83731. /**
  83732. * Creates a new raw cube texture from a specified url
  83733. * @param url defines the url where the data is located
  83734. * @param scene defines the current scene
  83735. * @param size defines the size of the textures
  83736. * @param format defines the format of the data
  83737. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83738. * @param noMipmap defines if the engine should avoid generating the mip levels
  83739. * @param callback defines a callback used to extract texture data from loaded data
  83740. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83741. * @param onLoad defines a callback called when texture is loaded
  83742. * @param onError defines a callback called if there is an error
  83743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83744. * @param invertY defines if data must be stored with Y axis inverted
  83745. * @returns the cube texture as an InternalTexture
  83746. */
  83747. 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;
  83748. /**
  83749. * Creates a new raw 3D texture
  83750. * @param data defines the data used to create the texture
  83751. * @param width defines the width of the texture
  83752. * @param height defines the height of the texture
  83753. * @param depth defines the depth of the texture
  83754. * @param format defines the format of the texture
  83755. * @param generateMipMaps defines if the engine must generate mip levels
  83756. * @param invertY defines if data must be stored with Y axis inverted
  83757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83758. * @param compression defines the compressed used (can be null)
  83759. * @param textureType defines the compressed used (can be null)
  83760. * @returns a new raw 3D texture (stored in an InternalTexture)
  83761. */
  83762. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83763. /**
  83764. * Update a raw 3D texture
  83765. * @param texture defines the texture to update
  83766. * @param data defines the data to store
  83767. * @param format defines the data format
  83768. * @param invertY defines if data must be stored with Y axis inverted
  83769. */
  83770. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83771. /**
  83772. * Update a raw 3D texture
  83773. * @param texture defines the texture to update
  83774. * @param data defines the data to store
  83775. * @param format defines the data format
  83776. * @param invertY defines if data must be stored with Y axis inverted
  83777. * @param compression defines the used compression (can be null)
  83778. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83779. */
  83780. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83781. /**
  83782. * Creates a new raw 2D array texture
  83783. * @param data defines the data used to create the texture
  83784. * @param width defines the width of the texture
  83785. * @param height defines the height of the texture
  83786. * @param depth defines the number of layers of the texture
  83787. * @param format defines the format of the texture
  83788. * @param generateMipMaps defines if the engine must generate mip levels
  83789. * @param invertY defines if data must be stored with Y axis inverted
  83790. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83791. * @param compression defines the compressed used (can be null)
  83792. * @param textureType defines the compressed used (can be null)
  83793. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83794. */
  83795. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83796. /**
  83797. * Update a raw 2D array texture
  83798. * @param texture defines the texture to update
  83799. * @param data defines the data to store
  83800. * @param format defines the data format
  83801. * @param invertY defines if data must be stored with Y axis inverted
  83802. */
  83803. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83804. /**
  83805. * Update a raw 2D array texture
  83806. * @param texture defines the texture to update
  83807. * @param data defines the data to store
  83808. * @param format defines the data format
  83809. * @param invertY defines if data must be stored with Y axis inverted
  83810. * @param compression defines the used compression (can be null)
  83811. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83812. */
  83813. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83814. }
  83815. }
  83816. declare module BABYLON {
  83817. /**
  83818. * Raw texture can help creating a texture directly from an array of data.
  83819. * This can be super useful if you either get the data from an uncompressed source or
  83820. * if you wish to create your texture pixel by pixel.
  83821. */
  83822. export class RawTexture extends Texture {
  83823. /**
  83824. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83825. */
  83826. format: number;
  83827. private _engine;
  83828. /**
  83829. * Instantiates a new RawTexture.
  83830. * Raw texture can help creating a texture directly from an array of data.
  83831. * This can be super useful if you either get the data from an uncompressed source or
  83832. * if you wish to create your texture pixel by pixel.
  83833. * @param data define the array of data to use to create the texture
  83834. * @param width define the width of the texture
  83835. * @param height define the height of the texture
  83836. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83837. * @param scene define the scene the texture belongs to
  83838. * @param generateMipMaps define whether mip maps should be generated or not
  83839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83841. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83842. */
  83843. constructor(data: ArrayBufferView, width: number, height: number,
  83844. /**
  83845. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83846. */
  83847. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83848. /**
  83849. * Updates the texture underlying data.
  83850. * @param data Define the new data of the texture
  83851. */
  83852. update(data: ArrayBufferView): void;
  83853. /**
  83854. * Creates a luminance texture from some data.
  83855. * @param data Define the texture data
  83856. * @param width Define the width of the texture
  83857. * @param height Define the height of the texture
  83858. * @param scene Define the scene the texture belongs to
  83859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83862. * @returns the luminance texture
  83863. */
  83864. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83865. /**
  83866. * Creates a luminance alpha texture from some data.
  83867. * @param data Define the texture data
  83868. * @param width Define the width of the texture
  83869. * @param height Define the height of the texture
  83870. * @param scene Define the scene the texture belongs to
  83871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83874. * @returns the luminance alpha texture
  83875. */
  83876. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83877. /**
  83878. * Creates an alpha texture from some data.
  83879. * @param data Define the texture data
  83880. * @param width Define the width of the texture
  83881. * @param height Define the height of the texture
  83882. * @param scene Define the scene the texture belongs to
  83883. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83884. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83885. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83886. * @returns the alpha texture
  83887. */
  83888. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83889. /**
  83890. * Creates a RGB texture from some data.
  83891. * @param data Define the texture data
  83892. * @param width Define the width of the texture
  83893. * @param height Define the height of the texture
  83894. * @param scene Define the scene the texture belongs to
  83895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83899. * @returns the RGB alpha texture
  83900. */
  83901. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83902. /**
  83903. * Creates a RGBA texture from some data.
  83904. * @param data Define the texture data
  83905. * @param width Define the width of the texture
  83906. * @param height Define the height of the texture
  83907. * @param scene Define the scene the texture belongs to
  83908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83912. * @returns the RGBA texture
  83913. */
  83914. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83915. /**
  83916. * Creates a R texture from some data.
  83917. * @param data Define the texture data
  83918. * @param width Define the width of the texture
  83919. * @param height Define the height of the texture
  83920. * @param scene Define the scene the texture belongs to
  83921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83925. * @returns the R texture
  83926. */
  83927. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83928. }
  83929. }
  83930. declare module BABYLON {
  83931. interface AbstractScene {
  83932. /**
  83933. * The list of procedural textures added to the scene
  83934. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83935. */
  83936. proceduralTextures: Array<ProceduralTexture>;
  83937. }
  83938. /**
  83939. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83940. * in a given scene.
  83941. */
  83942. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83943. /**
  83944. * The component name helpfull to identify the component in the list of scene components.
  83945. */
  83946. readonly name: string;
  83947. /**
  83948. * The scene the component belongs to.
  83949. */
  83950. scene: Scene;
  83951. /**
  83952. * Creates a new instance of the component for the given scene
  83953. * @param scene Defines the scene to register the component in
  83954. */
  83955. constructor(scene: Scene);
  83956. /**
  83957. * Registers the component in a given scene
  83958. */
  83959. register(): void;
  83960. /**
  83961. * Rebuilds the elements related to this component in case of
  83962. * context lost for instance.
  83963. */
  83964. rebuild(): void;
  83965. /**
  83966. * Disposes the component and the associated ressources.
  83967. */
  83968. dispose(): void;
  83969. private _beforeClear;
  83970. }
  83971. }
  83972. declare module BABYLON {
  83973. interface ThinEngine {
  83974. /**
  83975. * Creates a new render target cube texture
  83976. * @param size defines the size of the texture
  83977. * @param options defines the options used to create the texture
  83978. * @returns a new render target cube texture stored in an InternalTexture
  83979. */
  83980. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83981. }
  83982. }
  83983. declare module BABYLON {
  83984. /** @hidden */
  83985. export var proceduralVertexShader: {
  83986. name: string;
  83987. shader: string;
  83988. };
  83989. }
  83990. declare module BABYLON {
  83991. /**
  83992. * 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.
  83993. * This is the base class of any Procedural texture and contains most of the shareable code.
  83994. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83995. */
  83996. export class ProceduralTexture extends Texture {
  83997. isCube: boolean;
  83998. /**
  83999. * Define if the texture is enabled or not (disabled texture will not render)
  84000. */
  84001. isEnabled: boolean;
  84002. /**
  84003. * Define if the texture must be cleared before rendering (default is true)
  84004. */
  84005. autoClear: boolean;
  84006. /**
  84007. * Callback called when the texture is generated
  84008. */
  84009. onGenerated: () => void;
  84010. /**
  84011. * Event raised when the texture is generated
  84012. */
  84013. onGeneratedObservable: Observable<ProceduralTexture>;
  84014. /** @hidden */
  84015. _generateMipMaps: boolean;
  84016. /** @hidden **/
  84017. _effect: Effect;
  84018. /** @hidden */
  84019. _textures: {
  84020. [key: string]: Texture;
  84021. };
  84022. private _size;
  84023. private _currentRefreshId;
  84024. private _frameId;
  84025. private _refreshRate;
  84026. private _vertexBuffers;
  84027. private _indexBuffer;
  84028. private _uniforms;
  84029. private _samplers;
  84030. private _fragment;
  84031. private _floats;
  84032. private _ints;
  84033. private _floatsArrays;
  84034. private _colors3;
  84035. private _colors4;
  84036. private _vectors2;
  84037. private _vectors3;
  84038. private _matrices;
  84039. private _fallbackTexture;
  84040. private _fallbackTextureUsed;
  84041. private _engine;
  84042. private _cachedDefines;
  84043. private _contentUpdateId;
  84044. private _contentData;
  84045. /**
  84046. * Instantiates a new procedural texture.
  84047. * 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.
  84048. * This is the base class of any Procedural texture and contains most of the shareable code.
  84049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84050. * @param name Define the name of the texture
  84051. * @param size Define the size of the texture to create
  84052. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84053. * @param scene Define the scene the texture belongs to
  84054. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84055. * @param generateMipMaps Define if the texture should creates mip maps or not
  84056. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84057. */
  84058. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84059. /**
  84060. * The effect that is created when initializing the post process.
  84061. * @returns The created effect corresponding the the postprocess.
  84062. */
  84063. getEffect(): Effect;
  84064. /**
  84065. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84066. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84067. */
  84068. getContent(): Nullable<ArrayBufferView>;
  84069. private _createIndexBuffer;
  84070. /** @hidden */
  84071. _rebuild(): void;
  84072. /**
  84073. * Resets the texture in order to recreate its associated resources.
  84074. * This can be called in case of context loss
  84075. */
  84076. reset(): void;
  84077. protected _getDefines(): string;
  84078. /**
  84079. * Is the texture ready to be used ? (rendered at least once)
  84080. * @returns true if ready, otherwise, false.
  84081. */
  84082. isReady(): boolean;
  84083. /**
  84084. * Resets the refresh counter of the texture and start bak from scratch.
  84085. * Could be useful to regenerate the texture if it is setup to render only once.
  84086. */
  84087. resetRefreshCounter(): void;
  84088. /**
  84089. * Set the fragment shader to use in order to render the texture.
  84090. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84091. */
  84092. setFragment(fragment: any): void;
  84093. /**
  84094. * Define the refresh rate of the texture or the rendering frequency.
  84095. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84096. */
  84097. get refreshRate(): number;
  84098. set refreshRate(value: number);
  84099. /** @hidden */
  84100. _shouldRender(): boolean;
  84101. /**
  84102. * Get the size the texture is rendering at.
  84103. * @returns the size (texture is always squared)
  84104. */
  84105. getRenderSize(): number;
  84106. /**
  84107. * Resize the texture to new value.
  84108. * @param size Define the new size the texture should have
  84109. * @param generateMipMaps Define whether the new texture should create mip maps
  84110. */
  84111. resize(size: number, generateMipMaps: boolean): void;
  84112. private _checkUniform;
  84113. /**
  84114. * Set a texture in the shader program used to render.
  84115. * @param name Define the name of the uniform samplers as defined in the shader
  84116. * @param texture Define the texture to bind to this sampler
  84117. * @return the texture itself allowing "fluent" like uniform updates
  84118. */
  84119. setTexture(name: string, texture: Texture): ProceduralTexture;
  84120. /**
  84121. * Set a float in the shader.
  84122. * @param name Define the name of the uniform as defined in the shader
  84123. * @param value Define the value to give to the uniform
  84124. * @return the texture itself allowing "fluent" like uniform updates
  84125. */
  84126. setFloat(name: string, value: number): ProceduralTexture;
  84127. /**
  84128. * Set a int in the shader.
  84129. * @param name Define the name of the uniform as defined in the shader
  84130. * @param value Define the value to give to the uniform
  84131. * @return the texture itself allowing "fluent" like uniform updates
  84132. */
  84133. setInt(name: string, value: number): ProceduralTexture;
  84134. /**
  84135. * Set an array of floats in the shader.
  84136. * @param name Define the name of the uniform as defined in the shader
  84137. * @param value Define the value to give to the uniform
  84138. * @return the texture itself allowing "fluent" like uniform updates
  84139. */
  84140. setFloats(name: string, value: number[]): ProceduralTexture;
  84141. /**
  84142. * Set a vec3 in the shader from a Color3.
  84143. * @param name Define the name of the uniform as defined in the shader
  84144. * @param value Define the value to give to the uniform
  84145. * @return the texture itself allowing "fluent" like uniform updates
  84146. */
  84147. setColor3(name: string, value: Color3): ProceduralTexture;
  84148. /**
  84149. * Set a vec4 in the shader from a Color4.
  84150. * @param name Define the name of the uniform as defined in the shader
  84151. * @param value Define the value to give to the uniform
  84152. * @return the texture itself allowing "fluent" like uniform updates
  84153. */
  84154. setColor4(name: string, value: Color4): ProceduralTexture;
  84155. /**
  84156. * Set a vec2 in the shader from a Vector2.
  84157. * @param name Define the name of the uniform as defined in the shader
  84158. * @param value Define the value to give to the uniform
  84159. * @return the texture itself allowing "fluent" like uniform updates
  84160. */
  84161. setVector2(name: string, value: Vector2): ProceduralTexture;
  84162. /**
  84163. * Set a vec3 in the shader from a Vector3.
  84164. * @param name Define the name of the uniform as defined in the shader
  84165. * @param value Define the value to give to the uniform
  84166. * @return the texture itself allowing "fluent" like uniform updates
  84167. */
  84168. setVector3(name: string, value: Vector3): ProceduralTexture;
  84169. /**
  84170. * Set a mat4 in the shader from a MAtrix.
  84171. * @param name Define the name of the uniform as defined in the shader
  84172. * @param value Define the value to give to the uniform
  84173. * @return the texture itself allowing "fluent" like uniform updates
  84174. */
  84175. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84176. /**
  84177. * Render the texture to its associated render target.
  84178. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84179. */
  84180. render(useCameraPostProcess?: boolean): void;
  84181. /**
  84182. * Clone the texture.
  84183. * @returns the cloned texture
  84184. */
  84185. clone(): ProceduralTexture;
  84186. /**
  84187. * Dispose the texture and release its asoociated resources.
  84188. */
  84189. dispose(): void;
  84190. }
  84191. }
  84192. declare module BABYLON {
  84193. /**
  84194. * This represents the base class for particle system in Babylon.
  84195. * 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.
  84196. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84197. * @example https://doc.babylonjs.com/babylon101/particles
  84198. */
  84199. export class BaseParticleSystem {
  84200. /**
  84201. * Source color is added to the destination color without alpha affecting the result
  84202. */
  84203. static BLENDMODE_ONEONE: number;
  84204. /**
  84205. * Blend current color and particle color using particle’s alpha
  84206. */
  84207. static BLENDMODE_STANDARD: number;
  84208. /**
  84209. * Add current color and particle color multiplied by particle’s alpha
  84210. */
  84211. static BLENDMODE_ADD: number;
  84212. /**
  84213. * Multiply current color with particle color
  84214. */
  84215. static BLENDMODE_MULTIPLY: number;
  84216. /**
  84217. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84218. */
  84219. static BLENDMODE_MULTIPLYADD: number;
  84220. /**
  84221. * List of animations used by the particle system.
  84222. */
  84223. animations: Animation[];
  84224. /**
  84225. * The id of the Particle system.
  84226. */
  84227. id: string;
  84228. /**
  84229. * The friendly name of the Particle system.
  84230. */
  84231. name: string;
  84232. /**
  84233. * The rendering group used by the Particle system to chose when to render.
  84234. */
  84235. renderingGroupId: number;
  84236. /**
  84237. * The emitter represents the Mesh or position we are attaching the particle system to.
  84238. */
  84239. emitter: Nullable<AbstractMesh | Vector3>;
  84240. /**
  84241. * The maximum number of particles to emit per frame
  84242. */
  84243. emitRate: number;
  84244. /**
  84245. * If you want to launch only a few particles at once, that can be done, as well.
  84246. */
  84247. manualEmitCount: number;
  84248. /**
  84249. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84250. */
  84251. updateSpeed: number;
  84252. /**
  84253. * The amount of time the particle system is running (depends of the overall update speed).
  84254. */
  84255. targetStopDuration: number;
  84256. /**
  84257. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84258. */
  84259. disposeOnStop: boolean;
  84260. /**
  84261. * Minimum power of emitting particles.
  84262. */
  84263. minEmitPower: number;
  84264. /**
  84265. * Maximum power of emitting particles.
  84266. */
  84267. maxEmitPower: number;
  84268. /**
  84269. * Minimum life time of emitting particles.
  84270. */
  84271. minLifeTime: number;
  84272. /**
  84273. * Maximum life time of emitting particles.
  84274. */
  84275. maxLifeTime: number;
  84276. /**
  84277. * Minimum Size of emitting particles.
  84278. */
  84279. minSize: number;
  84280. /**
  84281. * Maximum Size of emitting particles.
  84282. */
  84283. maxSize: number;
  84284. /**
  84285. * Minimum scale of emitting particles on X axis.
  84286. */
  84287. minScaleX: number;
  84288. /**
  84289. * Maximum scale of emitting particles on X axis.
  84290. */
  84291. maxScaleX: number;
  84292. /**
  84293. * Minimum scale of emitting particles on Y axis.
  84294. */
  84295. minScaleY: number;
  84296. /**
  84297. * Maximum scale of emitting particles on Y axis.
  84298. */
  84299. maxScaleY: number;
  84300. /**
  84301. * Gets or sets the minimal initial rotation in radians.
  84302. */
  84303. minInitialRotation: number;
  84304. /**
  84305. * Gets or sets the maximal initial rotation in radians.
  84306. */
  84307. maxInitialRotation: number;
  84308. /**
  84309. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84310. */
  84311. minAngularSpeed: number;
  84312. /**
  84313. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84314. */
  84315. maxAngularSpeed: number;
  84316. /**
  84317. * The texture used to render each particle. (this can be a spritesheet)
  84318. */
  84319. particleTexture: Nullable<Texture>;
  84320. /**
  84321. * The layer mask we are rendering the particles through.
  84322. */
  84323. layerMask: number;
  84324. /**
  84325. * This can help using your own shader to render the particle system.
  84326. * The according effect will be created
  84327. */
  84328. customShader: any;
  84329. /**
  84330. * By default particle system starts as soon as they are created. This prevents the
  84331. * automatic start to happen and let you decide when to start emitting particles.
  84332. */
  84333. preventAutoStart: boolean;
  84334. private _noiseTexture;
  84335. /**
  84336. * Gets or sets a texture used to add random noise to particle positions
  84337. */
  84338. get noiseTexture(): Nullable<ProceduralTexture>;
  84339. set noiseTexture(value: Nullable<ProceduralTexture>);
  84340. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84341. noiseStrength: Vector3;
  84342. /**
  84343. * Callback triggered when the particle animation is ending.
  84344. */
  84345. onAnimationEnd: Nullable<() => void>;
  84346. /**
  84347. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84348. */
  84349. blendMode: number;
  84350. /**
  84351. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84352. * to override the particles.
  84353. */
  84354. forceDepthWrite: boolean;
  84355. /** 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 */
  84356. preWarmCycles: number;
  84357. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84358. preWarmStepOffset: number;
  84359. /**
  84360. * 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)
  84361. */
  84362. spriteCellChangeSpeed: number;
  84363. /**
  84364. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84365. */
  84366. startSpriteCellID: number;
  84367. /**
  84368. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84369. */
  84370. endSpriteCellID: number;
  84371. /**
  84372. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84373. */
  84374. spriteCellWidth: number;
  84375. /**
  84376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84377. */
  84378. spriteCellHeight: number;
  84379. /**
  84380. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84381. */
  84382. spriteRandomStartCell: boolean;
  84383. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84384. translationPivot: Vector2;
  84385. /** @hidden */
  84386. protected _isAnimationSheetEnabled: boolean;
  84387. /**
  84388. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84389. */
  84390. beginAnimationOnStart: boolean;
  84391. /**
  84392. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84393. */
  84394. beginAnimationFrom: number;
  84395. /**
  84396. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84397. */
  84398. beginAnimationTo: number;
  84399. /**
  84400. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84401. */
  84402. beginAnimationLoop: boolean;
  84403. /**
  84404. * Gets or sets a world offset applied to all particles
  84405. */
  84406. worldOffset: Vector3;
  84407. /**
  84408. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84409. */
  84410. get isAnimationSheetEnabled(): boolean;
  84411. set isAnimationSheetEnabled(value: boolean);
  84412. /**
  84413. * Get hosting scene
  84414. * @returns the scene
  84415. */
  84416. getScene(): Scene;
  84417. /**
  84418. * You can use gravity if you want to give an orientation to your particles.
  84419. */
  84420. gravity: Vector3;
  84421. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84422. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84423. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84424. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84425. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84426. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84427. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84428. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84429. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84430. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84431. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84432. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84433. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84434. /**
  84435. * Defines the delay in milliseconds before starting the system (0 by default)
  84436. */
  84437. startDelay: number;
  84438. /**
  84439. * Gets the current list of drag gradients.
  84440. * You must use addDragGradient and removeDragGradient to udpate this list
  84441. * @returns the list of drag gradients
  84442. */
  84443. getDragGradients(): Nullable<Array<FactorGradient>>;
  84444. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84445. limitVelocityDamping: number;
  84446. /**
  84447. * Gets the current list of limit velocity gradients.
  84448. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84449. * @returns the list of limit velocity gradients
  84450. */
  84451. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84452. /**
  84453. * Gets the current list of color gradients.
  84454. * You must use addColorGradient and removeColorGradient to udpate this list
  84455. * @returns the list of color gradients
  84456. */
  84457. getColorGradients(): Nullable<Array<ColorGradient>>;
  84458. /**
  84459. * Gets the current list of size gradients.
  84460. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84461. * @returns the list of size gradients
  84462. */
  84463. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84464. /**
  84465. * Gets the current list of color remap gradients.
  84466. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84467. * @returns the list of color remap gradients
  84468. */
  84469. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84470. /**
  84471. * Gets the current list of alpha remap gradients.
  84472. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84473. * @returns the list of alpha remap gradients
  84474. */
  84475. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84476. /**
  84477. * Gets the current list of life time gradients.
  84478. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84479. * @returns the list of life time gradients
  84480. */
  84481. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84482. /**
  84483. * Gets the current list of angular speed gradients.
  84484. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84485. * @returns the list of angular speed gradients
  84486. */
  84487. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84488. /**
  84489. * Gets the current list of velocity gradients.
  84490. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84491. * @returns the list of velocity gradients
  84492. */
  84493. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84494. /**
  84495. * Gets the current list of start size gradients.
  84496. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84497. * @returns the list of start size gradients
  84498. */
  84499. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84500. /**
  84501. * Gets the current list of emit rate gradients.
  84502. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84503. * @returns the list of emit rate gradients
  84504. */
  84505. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84506. /**
  84507. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84509. */
  84510. get direction1(): Vector3;
  84511. set direction1(value: Vector3);
  84512. /**
  84513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84514. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84515. */
  84516. get direction2(): Vector3;
  84517. set direction2(value: Vector3);
  84518. /**
  84519. * 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.
  84520. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84521. */
  84522. get minEmitBox(): Vector3;
  84523. set minEmitBox(value: Vector3);
  84524. /**
  84525. * 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.
  84526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84527. */
  84528. get maxEmitBox(): Vector3;
  84529. set maxEmitBox(value: Vector3);
  84530. /**
  84531. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84532. */
  84533. color1: Color4;
  84534. /**
  84535. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84536. */
  84537. color2: Color4;
  84538. /**
  84539. * Color the particle will have at the end of its lifetime
  84540. */
  84541. colorDead: Color4;
  84542. /**
  84543. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84544. */
  84545. textureMask: Color4;
  84546. /**
  84547. * The particle emitter type defines the emitter used by the particle system.
  84548. * It can be for example box, sphere, or cone...
  84549. */
  84550. particleEmitterType: IParticleEmitterType;
  84551. /** @hidden */
  84552. _isSubEmitter: boolean;
  84553. /**
  84554. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84555. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84556. */
  84557. billboardMode: number;
  84558. protected _isBillboardBased: boolean;
  84559. /**
  84560. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84561. */
  84562. get isBillboardBased(): boolean;
  84563. set isBillboardBased(value: boolean);
  84564. /**
  84565. * The scene the particle system belongs to.
  84566. */
  84567. protected _scene: Scene;
  84568. /**
  84569. * Local cache of defines for image processing.
  84570. */
  84571. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84572. /**
  84573. * Default configuration related to image processing available in the standard Material.
  84574. */
  84575. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84576. /**
  84577. * Gets the image processing configuration used either in this material.
  84578. */
  84579. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84580. /**
  84581. * Sets the Default image processing configuration used either in the this material.
  84582. *
  84583. * If sets to null, the scene one is in use.
  84584. */
  84585. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84586. /**
  84587. * Attaches a new image processing configuration to the Standard Material.
  84588. * @param configuration
  84589. */
  84590. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84591. /** @hidden */
  84592. protected _reset(): void;
  84593. /** @hidden */
  84594. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84595. /**
  84596. * Instantiates a particle system.
  84597. * 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.
  84598. * @param name The name of the particle system
  84599. */
  84600. constructor(name: string);
  84601. /**
  84602. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84605. * @returns the emitter
  84606. */
  84607. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84608. /**
  84609. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84610. * @param radius The radius of the hemisphere to emit from
  84611. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84612. * @returns the emitter
  84613. */
  84614. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84615. /**
  84616. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84617. * @param radius The radius of the sphere to emit from
  84618. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84619. * @returns the emitter
  84620. */
  84621. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84622. /**
  84623. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84624. * @param radius The radius of the sphere to emit from
  84625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84627. * @returns the emitter
  84628. */
  84629. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84630. /**
  84631. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84632. * @param radius The radius of the emission cylinder
  84633. * @param height The height of the emission cylinder
  84634. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84635. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84636. * @returns the emitter
  84637. */
  84638. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84639. /**
  84640. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84641. * @param radius The radius of the cylinder to emit from
  84642. * @param height The height of the emission cylinder
  84643. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84646. * @returns the emitter
  84647. */
  84648. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84649. /**
  84650. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84651. * @param radius The radius of the cone to emit from
  84652. * @param angle The base angle of the cone
  84653. * @returns the emitter
  84654. */
  84655. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84656. /**
  84657. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84660. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84661. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84662. * @returns the emitter
  84663. */
  84664. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84665. }
  84666. }
  84667. declare module BABYLON {
  84668. /**
  84669. * Type of sub emitter
  84670. */
  84671. export enum SubEmitterType {
  84672. /**
  84673. * Attached to the particle over it's lifetime
  84674. */
  84675. ATTACHED = 0,
  84676. /**
  84677. * Created when the particle dies
  84678. */
  84679. END = 1
  84680. }
  84681. /**
  84682. * Sub emitter class used to emit particles from an existing particle
  84683. */
  84684. export class SubEmitter {
  84685. /**
  84686. * the particle system to be used by the sub emitter
  84687. */
  84688. particleSystem: ParticleSystem;
  84689. /**
  84690. * Type of the submitter (Default: END)
  84691. */
  84692. type: SubEmitterType;
  84693. /**
  84694. * 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)
  84695. * Note: This only is supported when using an emitter of type Mesh
  84696. */
  84697. inheritDirection: boolean;
  84698. /**
  84699. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84700. */
  84701. inheritedVelocityAmount: number;
  84702. /**
  84703. * Creates a sub emitter
  84704. * @param particleSystem the particle system to be used by the sub emitter
  84705. */
  84706. constructor(
  84707. /**
  84708. * the particle system to be used by the sub emitter
  84709. */
  84710. particleSystem: ParticleSystem);
  84711. /**
  84712. * Clones the sub emitter
  84713. * @returns the cloned sub emitter
  84714. */
  84715. clone(): SubEmitter;
  84716. /**
  84717. * Serialize current object to a JSON object
  84718. * @returns the serialized object
  84719. */
  84720. serialize(): any;
  84721. /** @hidden */
  84722. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84723. /**
  84724. * Creates a new SubEmitter from a serialized JSON version
  84725. * @param serializationObject defines the JSON object to read from
  84726. * @param scene defines the hosting scene
  84727. * @param rootUrl defines the rootUrl for data loading
  84728. * @returns a new SubEmitter
  84729. */
  84730. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84731. /** Release associated resources */
  84732. dispose(): void;
  84733. }
  84734. }
  84735. declare module BABYLON {
  84736. /** @hidden */
  84737. export var imageProcessingDeclaration: {
  84738. name: string;
  84739. shader: string;
  84740. };
  84741. }
  84742. declare module BABYLON {
  84743. /** @hidden */
  84744. export var imageProcessingFunctions: {
  84745. name: string;
  84746. shader: string;
  84747. };
  84748. }
  84749. declare module BABYLON {
  84750. /** @hidden */
  84751. export var particlesPixelShader: {
  84752. name: string;
  84753. shader: string;
  84754. };
  84755. }
  84756. declare module BABYLON {
  84757. /** @hidden */
  84758. export var particlesVertexShader: {
  84759. name: string;
  84760. shader: string;
  84761. };
  84762. }
  84763. declare module BABYLON {
  84764. /**
  84765. * This represents a particle system in Babylon.
  84766. * 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.
  84767. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84768. * @example https://doc.babylonjs.com/babylon101/particles
  84769. */
  84770. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84771. /**
  84772. * Billboard mode will only apply to Y axis
  84773. */
  84774. static readonly BILLBOARDMODE_Y: number;
  84775. /**
  84776. * Billboard mode will apply to all axes
  84777. */
  84778. static readonly BILLBOARDMODE_ALL: number;
  84779. /**
  84780. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84781. */
  84782. static readonly BILLBOARDMODE_STRETCHED: number;
  84783. /**
  84784. * This function can be defined to provide custom update for active particles.
  84785. * This function will be called instead of regular update (age, position, color, etc.).
  84786. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84787. */
  84788. updateFunction: (particles: Particle[]) => void;
  84789. private _emitterWorldMatrix;
  84790. /**
  84791. * This function can be defined to specify initial direction for every new particle.
  84792. * It by default use the emitterType defined function
  84793. */
  84794. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84795. /**
  84796. * This function can be defined to specify initial position for every new particle.
  84797. * It by default use the emitterType defined function
  84798. */
  84799. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84800. /**
  84801. * @hidden
  84802. */
  84803. _inheritedVelocityOffset: Vector3;
  84804. /**
  84805. * An event triggered when the system is disposed
  84806. */
  84807. onDisposeObservable: Observable<ParticleSystem>;
  84808. private _onDisposeObserver;
  84809. /**
  84810. * Sets a callback that will be triggered when the system is disposed
  84811. */
  84812. set onDispose(callback: () => void);
  84813. private _particles;
  84814. private _epsilon;
  84815. private _capacity;
  84816. private _stockParticles;
  84817. private _newPartsExcess;
  84818. private _vertexData;
  84819. private _vertexBuffer;
  84820. private _vertexBuffers;
  84821. private _spriteBuffer;
  84822. private _indexBuffer;
  84823. private _effect;
  84824. private _customEffect;
  84825. private _cachedDefines;
  84826. private _scaledColorStep;
  84827. private _colorDiff;
  84828. private _scaledDirection;
  84829. private _scaledGravity;
  84830. private _currentRenderId;
  84831. private _alive;
  84832. private _useInstancing;
  84833. private _started;
  84834. private _stopped;
  84835. private _actualFrame;
  84836. private _scaledUpdateSpeed;
  84837. private _vertexBufferSize;
  84838. /** @hidden */
  84839. _currentEmitRateGradient: Nullable<FactorGradient>;
  84840. /** @hidden */
  84841. _currentEmitRate1: number;
  84842. /** @hidden */
  84843. _currentEmitRate2: number;
  84844. /** @hidden */
  84845. _currentStartSizeGradient: Nullable<FactorGradient>;
  84846. /** @hidden */
  84847. _currentStartSize1: number;
  84848. /** @hidden */
  84849. _currentStartSize2: number;
  84850. private readonly _rawTextureWidth;
  84851. private _rampGradientsTexture;
  84852. private _useRampGradients;
  84853. /** Gets or sets a boolean indicating that ramp gradients must be used
  84854. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84855. */
  84856. get useRampGradients(): boolean;
  84857. set useRampGradients(value: boolean);
  84858. /**
  84859. * 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.
  84860. * 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: [])
  84861. */
  84862. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84863. private _subEmitters;
  84864. /**
  84865. * @hidden
  84866. * If the particle systems emitter should be disposed when the particle system is disposed
  84867. */
  84868. _disposeEmitterOnDispose: boolean;
  84869. /**
  84870. * The current active Sub-systems, this property is used by the root particle system only.
  84871. */
  84872. activeSubSystems: Array<ParticleSystem>;
  84873. /**
  84874. * Specifies if the particles are updated in emitter local space or world space
  84875. */
  84876. isLocal: boolean;
  84877. private _rootParticleSystem;
  84878. /**
  84879. * Gets the current list of active particles
  84880. */
  84881. get particles(): Particle[];
  84882. /**
  84883. * Returns the string "ParticleSystem"
  84884. * @returns a string containing the class name
  84885. */
  84886. getClassName(): string;
  84887. /**
  84888. * Instantiates a particle system.
  84889. * 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.
  84890. * @param name The name of the particle system
  84891. * @param capacity The max number of particles alive at the same time
  84892. * @param scene The scene the particle system belongs to
  84893. * @param customEffect a custom effect used to change the way particles are rendered by default
  84894. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84895. * @param epsilon Offset used to render the particles
  84896. */
  84897. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84898. private _addFactorGradient;
  84899. private _removeFactorGradient;
  84900. /**
  84901. * Adds a new life time gradient
  84902. * @param gradient defines the gradient to use (between 0 and 1)
  84903. * @param factor defines the life time factor to affect to the specified gradient
  84904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84905. * @returns the current particle system
  84906. */
  84907. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84908. /**
  84909. * Remove a specific life time gradient
  84910. * @param gradient defines the gradient to remove
  84911. * @returns the current particle system
  84912. */
  84913. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84914. /**
  84915. * Adds a new size gradient
  84916. * @param gradient defines the gradient to use (between 0 and 1)
  84917. * @param factor defines the size factor to affect to the specified gradient
  84918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84919. * @returns the current particle system
  84920. */
  84921. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84922. /**
  84923. * Remove a specific size gradient
  84924. * @param gradient defines the gradient to remove
  84925. * @returns the current particle system
  84926. */
  84927. removeSizeGradient(gradient: number): IParticleSystem;
  84928. /**
  84929. * Adds a new color remap gradient
  84930. * @param gradient defines the gradient to use (between 0 and 1)
  84931. * @param min defines the color remap minimal range
  84932. * @param max defines the color remap maximal range
  84933. * @returns the current particle system
  84934. */
  84935. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84936. /**
  84937. * Remove a specific color remap gradient
  84938. * @param gradient defines the gradient to remove
  84939. * @returns the current particle system
  84940. */
  84941. removeColorRemapGradient(gradient: number): IParticleSystem;
  84942. /**
  84943. * Adds a new alpha remap gradient
  84944. * @param gradient defines the gradient to use (between 0 and 1)
  84945. * @param min defines the alpha remap minimal range
  84946. * @param max defines the alpha remap maximal range
  84947. * @returns the current particle system
  84948. */
  84949. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84950. /**
  84951. * Remove a specific alpha remap gradient
  84952. * @param gradient defines the gradient to remove
  84953. * @returns the current particle system
  84954. */
  84955. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84956. /**
  84957. * Adds a new angular speed gradient
  84958. * @param gradient defines the gradient to use (between 0 and 1)
  84959. * @param factor defines the angular speed to affect to the specified gradient
  84960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84961. * @returns the current particle system
  84962. */
  84963. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84964. /**
  84965. * Remove a specific angular speed gradient
  84966. * @param gradient defines the gradient to remove
  84967. * @returns the current particle system
  84968. */
  84969. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84970. /**
  84971. * Adds a new velocity gradient
  84972. * @param gradient defines the gradient to use (between 0 and 1)
  84973. * @param factor defines the velocity to affect to the specified gradient
  84974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84975. * @returns the current particle system
  84976. */
  84977. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84978. /**
  84979. * Remove a specific velocity gradient
  84980. * @param gradient defines the gradient to remove
  84981. * @returns the current particle system
  84982. */
  84983. removeVelocityGradient(gradient: number): IParticleSystem;
  84984. /**
  84985. * Adds a new limit velocity gradient
  84986. * @param gradient defines the gradient to use (between 0 and 1)
  84987. * @param factor defines the limit velocity value to affect to the specified gradient
  84988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84989. * @returns the current particle system
  84990. */
  84991. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84992. /**
  84993. * Remove a specific limit velocity gradient
  84994. * @param gradient defines the gradient to remove
  84995. * @returns the current particle system
  84996. */
  84997. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84998. /**
  84999. * Adds a new drag gradient
  85000. * @param gradient defines the gradient to use (between 0 and 1)
  85001. * @param factor defines the drag value to affect to the specified gradient
  85002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85003. * @returns the current particle system
  85004. */
  85005. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85006. /**
  85007. * Remove a specific drag gradient
  85008. * @param gradient defines the gradient to remove
  85009. * @returns the current particle system
  85010. */
  85011. removeDragGradient(gradient: number): IParticleSystem;
  85012. /**
  85013. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85014. * @param gradient defines the gradient to use (between 0 and 1)
  85015. * @param factor defines the emit rate value to affect to the specified gradient
  85016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85017. * @returns the current particle system
  85018. */
  85019. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85020. /**
  85021. * Remove a specific emit rate gradient
  85022. * @param gradient defines the gradient to remove
  85023. * @returns the current particle system
  85024. */
  85025. removeEmitRateGradient(gradient: number): IParticleSystem;
  85026. /**
  85027. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85028. * @param gradient defines the gradient to use (between 0 and 1)
  85029. * @param factor defines the start size value to affect to the specified gradient
  85030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85031. * @returns the current particle system
  85032. */
  85033. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85034. /**
  85035. * Remove a specific start size gradient
  85036. * @param gradient defines the gradient to remove
  85037. * @returns the current particle system
  85038. */
  85039. removeStartSizeGradient(gradient: number): IParticleSystem;
  85040. private _createRampGradientTexture;
  85041. /**
  85042. * Gets the current list of ramp gradients.
  85043. * You must use addRampGradient and removeRampGradient to udpate this list
  85044. * @returns the list of ramp gradients
  85045. */
  85046. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85047. /**
  85048. * Adds a new ramp gradient used to remap particle colors
  85049. * @param gradient defines the gradient to use (between 0 and 1)
  85050. * @param color defines the color to affect to the specified gradient
  85051. * @returns the current particle system
  85052. */
  85053. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85054. /**
  85055. * Remove a specific ramp gradient
  85056. * @param gradient defines the gradient to remove
  85057. * @returns the current particle system
  85058. */
  85059. removeRampGradient(gradient: number): ParticleSystem;
  85060. /**
  85061. * Adds a new color gradient
  85062. * @param gradient defines the gradient to use (between 0 and 1)
  85063. * @param color1 defines the color to affect to the specified gradient
  85064. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85065. * @returns this particle system
  85066. */
  85067. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85068. /**
  85069. * Remove a specific color gradient
  85070. * @param gradient defines the gradient to remove
  85071. * @returns this particle system
  85072. */
  85073. removeColorGradient(gradient: number): IParticleSystem;
  85074. private _fetchR;
  85075. protected _reset(): void;
  85076. private _resetEffect;
  85077. private _createVertexBuffers;
  85078. private _createIndexBuffer;
  85079. /**
  85080. * Gets the maximum number of particles active at the same time.
  85081. * @returns The max number of active particles.
  85082. */
  85083. getCapacity(): number;
  85084. /**
  85085. * Gets whether there are still active particles in the system.
  85086. * @returns True if it is alive, otherwise false.
  85087. */
  85088. isAlive(): boolean;
  85089. /**
  85090. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85091. * @returns True if it has been started, otherwise false.
  85092. */
  85093. isStarted(): boolean;
  85094. private _prepareSubEmitterInternalArray;
  85095. /**
  85096. * Starts the particle system and begins to emit
  85097. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85098. */
  85099. start(delay?: number): void;
  85100. /**
  85101. * Stops the particle system.
  85102. * @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.
  85103. */
  85104. stop(stopSubEmitters?: boolean): void;
  85105. /**
  85106. * Remove all active particles
  85107. */
  85108. reset(): void;
  85109. /**
  85110. * @hidden (for internal use only)
  85111. */
  85112. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85113. /**
  85114. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85115. * Its lifetime will start back at 0.
  85116. */
  85117. recycleParticle: (particle: Particle) => void;
  85118. private _stopSubEmitters;
  85119. private _createParticle;
  85120. private _removeFromRoot;
  85121. private _emitFromParticle;
  85122. private _update;
  85123. /** @hidden */
  85124. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85125. /** @hidden */
  85126. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85127. /** @hidden */
  85128. private _getEffect;
  85129. /**
  85130. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85131. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85132. */
  85133. animate(preWarmOnly?: boolean): void;
  85134. private _appendParticleVertices;
  85135. /**
  85136. * Rebuilds the particle system.
  85137. */
  85138. rebuild(): void;
  85139. /**
  85140. * Is this system ready to be used/rendered
  85141. * @return true if the system is ready
  85142. */
  85143. isReady(): boolean;
  85144. private _render;
  85145. /**
  85146. * Renders the particle system in its current state.
  85147. * @returns the current number of particles
  85148. */
  85149. render(): number;
  85150. /**
  85151. * Disposes the particle system and free the associated resources
  85152. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85153. */
  85154. dispose(disposeTexture?: boolean): void;
  85155. /**
  85156. * Clones the particle system.
  85157. * @param name The name of the cloned object
  85158. * @param newEmitter The new emitter to use
  85159. * @returns the cloned particle system
  85160. */
  85161. clone(name: string, newEmitter: any): ParticleSystem;
  85162. /**
  85163. * Serializes the particle system to a JSON object.
  85164. * @returns the JSON object
  85165. */
  85166. serialize(): any;
  85167. /** @hidden */
  85168. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85169. /** @hidden */
  85170. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85171. /**
  85172. * Parses a JSON object to create a particle system.
  85173. * @param parsedParticleSystem The JSON object to parse
  85174. * @param scene The scene to create the particle system in
  85175. * @param rootUrl The root url to use to load external dependencies like texture
  85176. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85177. * @returns the Parsed particle system
  85178. */
  85179. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85180. }
  85181. }
  85182. declare module BABYLON {
  85183. /**
  85184. * A particle represents one of the element emitted by a particle system.
  85185. * This is mainly define by its coordinates, direction, velocity and age.
  85186. */
  85187. export class Particle {
  85188. /**
  85189. * The particle system the particle belongs to.
  85190. */
  85191. particleSystem: ParticleSystem;
  85192. private static _Count;
  85193. /**
  85194. * Unique ID of the particle
  85195. */
  85196. id: number;
  85197. /**
  85198. * The world position of the particle in the scene.
  85199. */
  85200. position: Vector3;
  85201. /**
  85202. * The world direction of the particle in the scene.
  85203. */
  85204. direction: Vector3;
  85205. /**
  85206. * The color of the particle.
  85207. */
  85208. color: Color4;
  85209. /**
  85210. * The color change of the particle per step.
  85211. */
  85212. colorStep: Color4;
  85213. /**
  85214. * Defines how long will the life of the particle be.
  85215. */
  85216. lifeTime: number;
  85217. /**
  85218. * The current age of the particle.
  85219. */
  85220. age: number;
  85221. /**
  85222. * The current size of the particle.
  85223. */
  85224. size: number;
  85225. /**
  85226. * The current scale of the particle.
  85227. */
  85228. scale: Vector2;
  85229. /**
  85230. * The current angle of the particle.
  85231. */
  85232. angle: number;
  85233. /**
  85234. * Defines how fast is the angle changing.
  85235. */
  85236. angularSpeed: number;
  85237. /**
  85238. * Defines the cell index used by the particle to be rendered from a sprite.
  85239. */
  85240. cellIndex: number;
  85241. /**
  85242. * The information required to support color remapping
  85243. */
  85244. remapData: Vector4;
  85245. /** @hidden */
  85246. _randomCellOffset?: number;
  85247. /** @hidden */
  85248. _initialDirection: Nullable<Vector3>;
  85249. /** @hidden */
  85250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85251. /** @hidden */
  85252. _initialStartSpriteCellID: number;
  85253. /** @hidden */
  85254. _initialEndSpriteCellID: number;
  85255. /** @hidden */
  85256. _currentColorGradient: Nullable<ColorGradient>;
  85257. /** @hidden */
  85258. _currentColor1: Color4;
  85259. /** @hidden */
  85260. _currentColor2: Color4;
  85261. /** @hidden */
  85262. _currentSizeGradient: Nullable<FactorGradient>;
  85263. /** @hidden */
  85264. _currentSize1: number;
  85265. /** @hidden */
  85266. _currentSize2: number;
  85267. /** @hidden */
  85268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85269. /** @hidden */
  85270. _currentAngularSpeed1: number;
  85271. /** @hidden */
  85272. _currentAngularSpeed2: number;
  85273. /** @hidden */
  85274. _currentVelocityGradient: Nullable<FactorGradient>;
  85275. /** @hidden */
  85276. _currentVelocity1: number;
  85277. /** @hidden */
  85278. _currentVelocity2: number;
  85279. /** @hidden */
  85280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85281. /** @hidden */
  85282. _currentLimitVelocity1: number;
  85283. /** @hidden */
  85284. _currentLimitVelocity2: number;
  85285. /** @hidden */
  85286. _currentDragGradient: Nullable<FactorGradient>;
  85287. /** @hidden */
  85288. _currentDrag1: number;
  85289. /** @hidden */
  85290. _currentDrag2: number;
  85291. /** @hidden */
  85292. _randomNoiseCoordinates1: Vector3;
  85293. /** @hidden */
  85294. _randomNoiseCoordinates2: Vector3;
  85295. /** @hidden */
  85296. _localPosition?: Vector3;
  85297. /**
  85298. * Creates a new instance Particle
  85299. * @param particleSystem the particle system the particle belongs to
  85300. */
  85301. constructor(
  85302. /**
  85303. * The particle system the particle belongs to.
  85304. */
  85305. particleSystem: ParticleSystem);
  85306. private updateCellInfoFromSystem;
  85307. /**
  85308. * Defines how the sprite cell index is updated for the particle
  85309. */
  85310. updateCellIndex(): void;
  85311. /** @hidden */
  85312. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85313. /** @hidden */
  85314. _inheritParticleInfoToSubEmitters(): void;
  85315. /** @hidden */
  85316. _reset(): void;
  85317. /**
  85318. * Copy the properties of particle to another one.
  85319. * @param other the particle to copy the information to.
  85320. */
  85321. copyTo(other: Particle): void;
  85322. }
  85323. }
  85324. declare module BABYLON {
  85325. /**
  85326. * Particle emitter represents a volume emitting particles.
  85327. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85328. */
  85329. export interface IParticleEmitterType {
  85330. /**
  85331. * Called by the particle System when the direction is computed for the created particle.
  85332. * @param worldMatrix is the world matrix of the particle system
  85333. * @param directionToUpdate is the direction vector to update with the result
  85334. * @param particle is the particle we are computed the direction for
  85335. * @param isLocal defines if the direction should be set in local space
  85336. */
  85337. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85338. /**
  85339. * Called by the particle System when the position is computed for the created particle.
  85340. * @param worldMatrix is the world matrix of the particle system
  85341. * @param positionToUpdate is the position vector to update with the result
  85342. * @param particle is the particle we are computed the position for
  85343. * @param isLocal defines if the position should be set in local space
  85344. */
  85345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85346. /**
  85347. * Clones the current emitter and returns a copy of it
  85348. * @returns the new emitter
  85349. */
  85350. clone(): IParticleEmitterType;
  85351. /**
  85352. * Called by the GPUParticleSystem to setup the update shader
  85353. * @param effect defines the update shader
  85354. */
  85355. applyToShader(effect: Effect): void;
  85356. /**
  85357. * Returns a string to use to update the GPU particles update shader
  85358. * @returns the effect defines string
  85359. */
  85360. getEffectDefines(): string;
  85361. /**
  85362. * Returns a string representing the class name
  85363. * @returns a string containing the class name
  85364. */
  85365. getClassName(): string;
  85366. /**
  85367. * Serializes the particle system to a JSON object.
  85368. * @returns the JSON object
  85369. */
  85370. serialize(): any;
  85371. /**
  85372. * Parse properties from a JSON object
  85373. * @param serializationObject defines the JSON object
  85374. * @param scene defines the hosting scene
  85375. */
  85376. parse(serializationObject: any, scene: Scene): void;
  85377. }
  85378. }
  85379. declare module BABYLON {
  85380. /**
  85381. * Particle emitter emitting particles from the inside of a box.
  85382. * It emits the particles randomly between 2 given directions.
  85383. */
  85384. export class BoxParticleEmitter implements IParticleEmitterType {
  85385. /**
  85386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85387. */
  85388. direction1: Vector3;
  85389. /**
  85390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85391. */
  85392. direction2: Vector3;
  85393. /**
  85394. * 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.
  85395. */
  85396. minEmitBox: Vector3;
  85397. /**
  85398. * 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.
  85399. */
  85400. maxEmitBox: Vector3;
  85401. /**
  85402. * Creates a new instance BoxParticleEmitter
  85403. */
  85404. constructor();
  85405. /**
  85406. * Called by the particle System when the direction is computed for the created particle.
  85407. * @param worldMatrix is the world matrix of the particle system
  85408. * @param directionToUpdate is the direction vector to update with the result
  85409. * @param particle is the particle we are computed the direction for
  85410. * @param isLocal defines if the direction should be set in local space
  85411. */
  85412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85413. /**
  85414. * Called by the particle System when the position is computed for the created particle.
  85415. * @param worldMatrix is the world matrix of the particle system
  85416. * @param positionToUpdate is the position vector to update with the result
  85417. * @param particle is the particle we are computed the position for
  85418. * @param isLocal defines if the position should be set in local space
  85419. */
  85420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85421. /**
  85422. * Clones the current emitter and returns a copy of it
  85423. * @returns the new emitter
  85424. */
  85425. clone(): BoxParticleEmitter;
  85426. /**
  85427. * Called by the GPUParticleSystem to setup the update shader
  85428. * @param effect defines the update shader
  85429. */
  85430. applyToShader(effect: Effect): void;
  85431. /**
  85432. * Returns a string to use to update the GPU particles update shader
  85433. * @returns a string containng the defines string
  85434. */
  85435. getEffectDefines(): string;
  85436. /**
  85437. * Returns the string "BoxParticleEmitter"
  85438. * @returns a string containing the class name
  85439. */
  85440. getClassName(): string;
  85441. /**
  85442. * Serializes the particle system to a JSON object.
  85443. * @returns the JSON object
  85444. */
  85445. serialize(): any;
  85446. /**
  85447. * Parse properties from a JSON object
  85448. * @param serializationObject defines the JSON object
  85449. */
  85450. parse(serializationObject: any): void;
  85451. }
  85452. }
  85453. declare module BABYLON {
  85454. /**
  85455. * Particle emitter emitting particles from the inside of a cone.
  85456. * It emits the particles alongside the cone volume from the base to the particle.
  85457. * The emission direction might be randomized.
  85458. */
  85459. export class ConeParticleEmitter implements IParticleEmitterType {
  85460. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85461. directionRandomizer: number;
  85462. private _radius;
  85463. private _angle;
  85464. private _height;
  85465. /**
  85466. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85467. */
  85468. radiusRange: number;
  85469. /**
  85470. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85471. */
  85472. heightRange: number;
  85473. /**
  85474. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85475. */
  85476. emitFromSpawnPointOnly: boolean;
  85477. /**
  85478. * Gets or sets the radius of the emission cone
  85479. */
  85480. get radius(): number;
  85481. set radius(value: number);
  85482. /**
  85483. * Gets or sets the angle of the emission cone
  85484. */
  85485. get angle(): number;
  85486. set angle(value: number);
  85487. private _buildHeight;
  85488. /**
  85489. * Creates a new instance ConeParticleEmitter
  85490. * @param radius the radius of the emission cone (1 by default)
  85491. * @param angle the cone base angle (PI by default)
  85492. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85493. */
  85494. constructor(radius?: number, angle?: number,
  85495. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85496. directionRandomizer?: number);
  85497. /**
  85498. * Called by the particle System when the direction is computed for the created particle.
  85499. * @param worldMatrix is the world matrix of the particle system
  85500. * @param directionToUpdate is the direction vector to update with the result
  85501. * @param particle is the particle we are computed the direction for
  85502. * @param isLocal defines if the direction should be set in local space
  85503. */
  85504. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85505. /**
  85506. * Called by the particle System when the position is computed for the created particle.
  85507. * @param worldMatrix is the world matrix of the particle system
  85508. * @param positionToUpdate is the position vector to update with the result
  85509. * @param particle is the particle we are computed the position for
  85510. * @param isLocal defines if the position should be set in local space
  85511. */
  85512. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85513. /**
  85514. * Clones the current emitter and returns a copy of it
  85515. * @returns the new emitter
  85516. */
  85517. clone(): ConeParticleEmitter;
  85518. /**
  85519. * Called by the GPUParticleSystem to setup the update shader
  85520. * @param effect defines the update shader
  85521. */
  85522. applyToShader(effect: Effect): void;
  85523. /**
  85524. * Returns a string to use to update the GPU particles update shader
  85525. * @returns a string containng the defines string
  85526. */
  85527. getEffectDefines(): string;
  85528. /**
  85529. * Returns the string "ConeParticleEmitter"
  85530. * @returns a string containing the class name
  85531. */
  85532. getClassName(): string;
  85533. /**
  85534. * Serializes the particle system to a JSON object.
  85535. * @returns the JSON object
  85536. */
  85537. serialize(): any;
  85538. /**
  85539. * Parse properties from a JSON object
  85540. * @param serializationObject defines the JSON object
  85541. */
  85542. parse(serializationObject: any): void;
  85543. }
  85544. }
  85545. declare module BABYLON {
  85546. /**
  85547. * Particle emitter emitting particles from the inside of a cylinder.
  85548. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85549. */
  85550. export class CylinderParticleEmitter implements IParticleEmitterType {
  85551. /**
  85552. * The radius of the emission cylinder.
  85553. */
  85554. radius: number;
  85555. /**
  85556. * The height of the emission cylinder.
  85557. */
  85558. height: number;
  85559. /**
  85560. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85561. */
  85562. radiusRange: number;
  85563. /**
  85564. * How much to randomize the particle direction [0-1].
  85565. */
  85566. directionRandomizer: number;
  85567. /**
  85568. * Creates a new instance CylinderParticleEmitter
  85569. * @param radius the radius of the emission cylinder (1 by default)
  85570. * @param height the height of the emission cylinder (1 by default)
  85571. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85572. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85573. */
  85574. constructor(
  85575. /**
  85576. * The radius of the emission cylinder.
  85577. */
  85578. radius?: number,
  85579. /**
  85580. * The height of the emission cylinder.
  85581. */
  85582. height?: number,
  85583. /**
  85584. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85585. */
  85586. radiusRange?: number,
  85587. /**
  85588. * How much to randomize the particle direction [0-1].
  85589. */
  85590. directionRandomizer?: number);
  85591. /**
  85592. * Called by the particle System when the direction is computed for the created particle.
  85593. * @param worldMatrix is the world matrix of the particle system
  85594. * @param directionToUpdate is the direction vector to update with the result
  85595. * @param particle is the particle we are computed the direction for
  85596. * @param isLocal defines if the direction should be set in local space
  85597. */
  85598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85599. /**
  85600. * Called by the particle System when the position is computed for the created particle.
  85601. * @param worldMatrix is the world matrix of the particle system
  85602. * @param positionToUpdate is the position vector to update with the result
  85603. * @param particle is the particle we are computed the position for
  85604. * @param isLocal defines if the position should be set in local space
  85605. */
  85606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85607. /**
  85608. * Clones the current emitter and returns a copy of it
  85609. * @returns the new emitter
  85610. */
  85611. clone(): CylinderParticleEmitter;
  85612. /**
  85613. * Called by the GPUParticleSystem to setup the update shader
  85614. * @param effect defines the update shader
  85615. */
  85616. applyToShader(effect: Effect): void;
  85617. /**
  85618. * Returns a string to use to update the GPU particles update shader
  85619. * @returns a string containng the defines string
  85620. */
  85621. getEffectDefines(): string;
  85622. /**
  85623. * Returns the string "CylinderParticleEmitter"
  85624. * @returns a string containing the class name
  85625. */
  85626. getClassName(): string;
  85627. /**
  85628. * Serializes the particle system to a JSON object.
  85629. * @returns the JSON object
  85630. */
  85631. serialize(): any;
  85632. /**
  85633. * Parse properties from a JSON object
  85634. * @param serializationObject defines the JSON object
  85635. */
  85636. parse(serializationObject: any): void;
  85637. }
  85638. /**
  85639. * Particle emitter emitting particles from the inside of a cylinder.
  85640. * It emits the particles randomly between two vectors.
  85641. */
  85642. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85643. /**
  85644. * The min limit of the emission direction.
  85645. */
  85646. direction1: Vector3;
  85647. /**
  85648. * The max limit of the emission direction.
  85649. */
  85650. direction2: Vector3;
  85651. /**
  85652. * Creates a new instance CylinderDirectedParticleEmitter
  85653. * @param radius the radius of the emission cylinder (1 by default)
  85654. * @param height the height of the emission cylinder (1 by default)
  85655. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85656. * @param direction1 the min limit of the emission direction (up vector by default)
  85657. * @param direction2 the max limit of the emission direction (up vector by default)
  85658. */
  85659. constructor(radius?: number, height?: number, radiusRange?: number,
  85660. /**
  85661. * The min limit of the emission direction.
  85662. */
  85663. direction1?: Vector3,
  85664. /**
  85665. * The max limit of the emission direction.
  85666. */
  85667. direction2?: Vector3);
  85668. /**
  85669. * Called by the particle System when the direction is computed for the created particle.
  85670. * @param worldMatrix is the world matrix of the particle system
  85671. * @param directionToUpdate is the direction vector to update with the result
  85672. * @param particle is the particle we are computed the direction for
  85673. */
  85674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85675. /**
  85676. * Clones the current emitter and returns a copy of it
  85677. * @returns the new emitter
  85678. */
  85679. clone(): CylinderDirectedParticleEmitter;
  85680. /**
  85681. * Called by the GPUParticleSystem to setup the update shader
  85682. * @param effect defines the update shader
  85683. */
  85684. applyToShader(effect: Effect): void;
  85685. /**
  85686. * Returns a string to use to update the GPU particles update shader
  85687. * @returns a string containng the defines string
  85688. */
  85689. getEffectDefines(): string;
  85690. /**
  85691. * Returns the string "CylinderDirectedParticleEmitter"
  85692. * @returns a string containing the class name
  85693. */
  85694. getClassName(): string;
  85695. /**
  85696. * Serializes the particle system to a JSON object.
  85697. * @returns the JSON object
  85698. */
  85699. serialize(): any;
  85700. /**
  85701. * Parse properties from a JSON object
  85702. * @param serializationObject defines the JSON object
  85703. */
  85704. parse(serializationObject: any): void;
  85705. }
  85706. }
  85707. declare module BABYLON {
  85708. /**
  85709. * Particle emitter emitting particles from the inside of a hemisphere.
  85710. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85711. */
  85712. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85713. /**
  85714. * The radius of the emission hemisphere.
  85715. */
  85716. radius: number;
  85717. /**
  85718. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85719. */
  85720. radiusRange: number;
  85721. /**
  85722. * How much to randomize the particle direction [0-1].
  85723. */
  85724. directionRandomizer: number;
  85725. /**
  85726. * Creates a new instance HemisphericParticleEmitter
  85727. * @param radius the radius of the emission hemisphere (1 by default)
  85728. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85729. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85730. */
  85731. constructor(
  85732. /**
  85733. * The radius of the emission hemisphere.
  85734. */
  85735. radius?: number,
  85736. /**
  85737. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85738. */
  85739. radiusRange?: number,
  85740. /**
  85741. * How much to randomize the particle direction [0-1].
  85742. */
  85743. directionRandomizer?: number);
  85744. /**
  85745. * Called by the particle System when the direction is computed for the created particle.
  85746. * @param worldMatrix is the world matrix of the particle system
  85747. * @param directionToUpdate is the direction vector to update with the result
  85748. * @param particle is the particle we are computed the direction for
  85749. * @param isLocal defines if the direction should be set in local space
  85750. */
  85751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85752. /**
  85753. * Called by the particle System when the position is computed for the created particle.
  85754. * @param worldMatrix is the world matrix of the particle system
  85755. * @param positionToUpdate is the position vector to update with the result
  85756. * @param particle is the particle we are computed the position for
  85757. * @param isLocal defines if the position should be set in local space
  85758. */
  85759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85760. /**
  85761. * Clones the current emitter and returns a copy of it
  85762. * @returns the new emitter
  85763. */
  85764. clone(): HemisphericParticleEmitter;
  85765. /**
  85766. * Called by the GPUParticleSystem to setup the update shader
  85767. * @param effect defines the update shader
  85768. */
  85769. applyToShader(effect: Effect): void;
  85770. /**
  85771. * Returns a string to use to update the GPU particles update shader
  85772. * @returns a string containng the defines string
  85773. */
  85774. getEffectDefines(): string;
  85775. /**
  85776. * Returns the string "HemisphericParticleEmitter"
  85777. * @returns a string containing the class name
  85778. */
  85779. getClassName(): string;
  85780. /**
  85781. * Serializes the particle system to a JSON object.
  85782. * @returns the JSON object
  85783. */
  85784. serialize(): any;
  85785. /**
  85786. * Parse properties from a JSON object
  85787. * @param serializationObject defines the JSON object
  85788. */
  85789. parse(serializationObject: any): void;
  85790. }
  85791. }
  85792. declare module BABYLON {
  85793. /**
  85794. * Particle emitter emitting particles from a point.
  85795. * It emits the particles randomly between 2 given directions.
  85796. */
  85797. export class PointParticleEmitter implements IParticleEmitterType {
  85798. /**
  85799. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85800. */
  85801. direction1: Vector3;
  85802. /**
  85803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85804. */
  85805. direction2: Vector3;
  85806. /**
  85807. * Creates a new instance PointParticleEmitter
  85808. */
  85809. constructor();
  85810. /**
  85811. * Called by the particle System when the direction is computed for the created particle.
  85812. * @param worldMatrix is the world matrix of the particle system
  85813. * @param directionToUpdate is the direction vector to update with the result
  85814. * @param particle is the particle we are computed the direction for
  85815. * @param isLocal defines if the direction should be set in local space
  85816. */
  85817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85818. /**
  85819. * Called by the particle System when the position is computed for the created particle.
  85820. * @param worldMatrix is the world matrix of the particle system
  85821. * @param positionToUpdate is the position vector to update with the result
  85822. * @param particle is the particle we are computed the position for
  85823. * @param isLocal defines if the position should be set in local space
  85824. */
  85825. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85826. /**
  85827. * Clones the current emitter and returns a copy of it
  85828. * @returns the new emitter
  85829. */
  85830. clone(): PointParticleEmitter;
  85831. /**
  85832. * Called by the GPUParticleSystem to setup the update shader
  85833. * @param effect defines the update shader
  85834. */
  85835. applyToShader(effect: Effect): void;
  85836. /**
  85837. * Returns a string to use to update the GPU particles update shader
  85838. * @returns a string containng the defines string
  85839. */
  85840. getEffectDefines(): string;
  85841. /**
  85842. * Returns the string "PointParticleEmitter"
  85843. * @returns a string containing the class name
  85844. */
  85845. getClassName(): string;
  85846. /**
  85847. * Serializes the particle system to a JSON object.
  85848. * @returns the JSON object
  85849. */
  85850. serialize(): any;
  85851. /**
  85852. * Parse properties from a JSON object
  85853. * @param serializationObject defines the JSON object
  85854. */
  85855. parse(serializationObject: any): void;
  85856. }
  85857. }
  85858. declare module BABYLON {
  85859. /**
  85860. * Particle emitter emitting particles from the inside of a sphere.
  85861. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85862. */
  85863. export class SphereParticleEmitter implements IParticleEmitterType {
  85864. /**
  85865. * The radius of the emission sphere.
  85866. */
  85867. radius: number;
  85868. /**
  85869. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85870. */
  85871. radiusRange: number;
  85872. /**
  85873. * How much to randomize the particle direction [0-1].
  85874. */
  85875. directionRandomizer: number;
  85876. /**
  85877. * Creates a new instance SphereParticleEmitter
  85878. * @param radius the radius of the emission sphere (1 by default)
  85879. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85880. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85881. */
  85882. constructor(
  85883. /**
  85884. * The radius of the emission sphere.
  85885. */
  85886. radius?: number,
  85887. /**
  85888. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85889. */
  85890. radiusRange?: number,
  85891. /**
  85892. * How much to randomize the particle direction [0-1].
  85893. */
  85894. directionRandomizer?: number);
  85895. /**
  85896. * Called by the particle System when the direction is computed for the created particle.
  85897. * @param worldMatrix is the world matrix of the particle system
  85898. * @param directionToUpdate is the direction vector to update with the result
  85899. * @param particle is the particle we are computed the direction for
  85900. * @param isLocal defines if the direction should be set in local space
  85901. */
  85902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85903. /**
  85904. * Called by the particle System when the position is computed for the created particle.
  85905. * @param worldMatrix is the world matrix of the particle system
  85906. * @param positionToUpdate is the position vector to update with the result
  85907. * @param particle is the particle we are computed the position for
  85908. * @param isLocal defines if the position should be set in local space
  85909. */
  85910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85911. /**
  85912. * Clones the current emitter and returns a copy of it
  85913. * @returns the new emitter
  85914. */
  85915. clone(): SphereParticleEmitter;
  85916. /**
  85917. * Called by the GPUParticleSystem to setup the update shader
  85918. * @param effect defines the update shader
  85919. */
  85920. applyToShader(effect: Effect): void;
  85921. /**
  85922. * Returns a string to use to update the GPU particles update shader
  85923. * @returns a string containng the defines string
  85924. */
  85925. getEffectDefines(): string;
  85926. /**
  85927. * Returns the string "SphereParticleEmitter"
  85928. * @returns a string containing the class name
  85929. */
  85930. getClassName(): string;
  85931. /**
  85932. * Serializes the particle system to a JSON object.
  85933. * @returns the JSON object
  85934. */
  85935. serialize(): any;
  85936. /**
  85937. * Parse properties from a JSON object
  85938. * @param serializationObject defines the JSON object
  85939. */
  85940. parse(serializationObject: any): void;
  85941. }
  85942. /**
  85943. * Particle emitter emitting particles from the inside of a sphere.
  85944. * It emits the particles randomly between two vectors.
  85945. */
  85946. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85947. /**
  85948. * The min limit of the emission direction.
  85949. */
  85950. direction1: Vector3;
  85951. /**
  85952. * The max limit of the emission direction.
  85953. */
  85954. direction2: Vector3;
  85955. /**
  85956. * Creates a new instance SphereDirectedParticleEmitter
  85957. * @param radius the radius of the emission sphere (1 by default)
  85958. * @param direction1 the min limit of the emission direction (up vector by default)
  85959. * @param direction2 the max limit of the emission direction (up vector by default)
  85960. */
  85961. constructor(radius?: number,
  85962. /**
  85963. * The min limit of the emission direction.
  85964. */
  85965. direction1?: Vector3,
  85966. /**
  85967. * The max limit of the emission direction.
  85968. */
  85969. direction2?: Vector3);
  85970. /**
  85971. * Called by the particle System when the direction is computed for the created particle.
  85972. * @param worldMatrix is the world matrix of the particle system
  85973. * @param directionToUpdate is the direction vector to update with the result
  85974. * @param particle is the particle we are computed the direction for
  85975. */
  85976. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85977. /**
  85978. * Clones the current emitter and returns a copy of it
  85979. * @returns the new emitter
  85980. */
  85981. clone(): SphereDirectedParticleEmitter;
  85982. /**
  85983. * Called by the GPUParticleSystem to setup the update shader
  85984. * @param effect defines the update shader
  85985. */
  85986. applyToShader(effect: Effect): void;
  85987. /**
  85988. * Returns a string to use to update the GPU particles update shader
  85989. * @returns a string containng the defines string
  85990. */
  85991. getEffectDefines(): string;
  85992. /**
  85993. * Returns the string "SphereDirectedParticleEmitter"
  85994. * @returns a string containing the class name
  85995. */
  85996. getClassName(): string;
  85997. /**
  85998. * Serializes the particle system to a JSON object.
  85999. * @returns the JSON object
  86000. */
  86001. serialize(): any;
  86002. /**
  86003. * Parse properties from a JSON object
  86004. * @param serializationObject defines the JSON object
  86005. */
  86006. parse(serializationObject: any): void;
  86007. }
  86008. }
  86009. declare module BABYLON {
  86010. /**
  86011. * Particle emitter emitting particles from a custom list of positions.
  86012. */
  86013. export class CustomParticleEmitter implements IParticleEmitterType {
  86014. /**
  86015. * Gets or sets the position generator that will create the inital position of each particle.
  86016. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86017. */
  86018. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86019. /**
  86020. * Gets or sets the destination generator that will create the final destination of each particle.
  86021. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86022. */
  86023. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86024. /**
  86025. * Creates a new instance CustomParticleEmitter
  86026. */
  86027. constructor();
  86028. /**
  86029. * Called by the particle System when the direction is computed for the created particle.
  86030. * @param worldMatrix is the world matrix of the particle system
  86031. * @param directionToUpdate is the direction vector to update with the result
  86032. * @param particle is the particle we are computed the direction for
  86033. * @param isLocal defines if the direction should be set in local space
  86034. */
  86035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86036. /**
  86037. * Called by the particle System when the position is computed for the created particle.
  86038. * @param worldMatrix is the world matrix of the particle system
  86039. * @param positionToUpdate is the position vector to update with the result
  86040. * @param particle is the particle we are computed the position for
  86041. * @param isLocal defines if the position should be set in local space
  86042. */
  86043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86044. /**
  86045. * Clones the current emitter and returns a copy of it
  86046. * @returns the new emitter
  86047. */
  86048. clone(): CustomParticleEmitter;
  86049. /**
  86050. * Called by the GPUParticleSystem to setup the update shader
  86051. * @param effect defines the update shader
  86052. */
  86053. applyToShader(effect: Effect): void;
  86054. /**
  86055. * Returns a string to use to update the GPU particles update shader
  86056. * @returns a string containng the defines string
  86057. */
  86058. getEffectDefines(): string;
  86059. /**
  86060. * Returns the string "PointParticleEmitter"
  86061. * @returns a string containing the class name
  86062. */
  86063. getClassName(): string;
  86064. /**
  86065. * Serializes the particle system to a JSON object.
  86066. * @returns the JSON object
  86067. */
  86068. serialize(): any;
  86069. /**
  86070. * Parse properties from a JSON object
  86071. * @param serializationObject defines the JSON object
  86072. */
  86073. parse(serializationObject: any): void;
  86074. }
  86075. }
  86076. declare module BABYLON {
  86077. /**
  86078. * Particle emitter emitting particles from the inside of a box.
  86079. * It emits the particles randomly between 2 given directions.
  86080. */
  86081. export class MeshParticleEmitter implements IParticleEmitterType {
  86082. /** Defines the mesh to use as source */
  86083. mesh?: AbstractMesh | undefined;
  86084. private _indices;
  86085. private _positions;
  86086. private _normals;
  86087. private _storedNormal;
  86088. /**
  86089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86090. */
  86091. direction1: Vector3;
  86092. /**
  86093. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86094. */
  86095. direction2: Vector3;
  86096. /**
  86097. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86098. */
  86099. useMeshNormalsForDirection: boolean;
  86100. /**
  86101. * Creates a new instance MeshParticleEmitter
  86102. * @param mesh defines the mesh to use as source
  86103. */
  86104. constructor(
  86105. /** Defines the mesh to use as source */
  86106. mesh?: AbstractMesh | undefined);
  86107. /**
  86108. * Called by the particle System when the direction is computed for the created particle.
  86109. * @param worldMatrix is the world matrix of the particle system
  86110. * @param directionToUpdate is the direction vector to update with the result
  86111. * @param particle is the particle we are computed the direction for
  86112. * @param isLocal defines if the direction should be set in local space
  86113. */
  86114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86115. /**
  86116. * Called by the particle System when the position is computed for the created particle.
  86117. * @param worldMatrix is the world matrix of the particle system
  86118. * @param positionToUpdate is the position vector to update with the result
  86119. * @param particle is the particle we are computed the position for
  86120. * @param isLocal defines if the position should be set in local space
  86121. */
  86122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86123. /**
  86124. * Clones the current emitter and returns a copy of it
  86125. * @returns the new emitter
  86126. */
  86127. clone(): MeshParticleEmitter;
  86128. /**
  86129. * Called by the GPUParticleSystem to setup the update shader
  86130. * @param effect defines the update shader
  86131. */
  86132. applyToShader(effect: Effect): void;
  86133. /**
  86134. * Returns a string to use to update the GPU particles update shader
  86135. * @returns a string containng the defines string
  86136. */
  86137. getEffectDefines(): string;
  86138. /**
  86139. * Returns the string "BoxParticleEmitter"
  86140. * @returns a string containing the class name
  86141. */
  86142. getClassName(): string;
  86143. /**
  86144. * Serializes the particle system to a JSON object.
  86145. * @returns the JSON object
  86146. */
  86147. serialize(): any;
  86148. /**
  86149. * Parse properties from a JSON object
  86150. * @param serializationObject defines the JSON object
  86151. * @param scene defines the hosting scene
  86152. */
  86153. parse(serializationObject: any, scene: Scene): void;
  86154. }
  86155. }
  86156. declare module BABYLON {
  86157. /**
  86158. * Interface representing a particle system in Babylon.js.
  86159. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86160. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86161. */
  86162. export interface IParticleSystem {
  86163. /**
  86164. * List of animations used by the particle system.
  86165. */
  86166. animations: Animation[];
  86167. /**
  86168. * The id of the Particle system.
  86169. */
  86170. id: string;
  86171. /**
  86172. * The name of the Particle system.
  86173. */
  86174. name: string;
  86175. /**
  86176. * The emitter represents the Mesh or position we are attaching the particle system to.
  86177. */
  86178. emitter: Nullable<AbstractMesh | Vector3>;
  86179. /**
  86180. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86181. */
  86182. isBillboardBased: boolean;
  86183. /**
  86184. * The rendering group used by the Particle system to chose when to render.
  86185. */
  86186. renderingGroupId: number;
  86187. /**
  86188. * The layer mask we are rendering the particles through.
  86189. */
  86190. layerMask: number;
  86191. /**
  86192. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86193. */
  86194. updateSpeed: number;
  86195. /**
  86196. * The amount of time the particle system is running (depends of the overall update speed).
  86197. */
  86198. targetStopDuration: number;
  86199. /**
  86200. * The texture used to render each particle. (this can be a spritesheet)
  86201. */
  86202. particleTexture: Nullable<Texture>;
  86203. /**
  86204. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86205. */
  86206. blendMode: number;
  86207. /**
  86208. * Minimum life time of emitting particles.
  86209. */
  86210. minLifeTime: number;
  86211. /**
  86212. * Maximum life time of emitting particles.
  86213. */
  86214. maxLifeTime: number;
  86215. /**
  86216. * Minimum Size of emitting particles.
  86217. */
  86218. minSize: number;
  86219. /**
  86220. * Maximum Size of emitting particles.
  86221. */
  86222. maxSize: number;
  86223. /**
  86224. * Minimum scale of emitting particles on X axis.
  86225. */
  86226. minScaleX: number;
  86227. /**
  86228. * Maximum scale of emitting particles on X axis.
  86229. */
  86230. maxScaleX: number;
  86231. /**
  86232. * Minimum scale of emitting particles on Y axis.
  86233. */
  86234. minScaleY: number;
  86235. /**
  86236. * Maximum scale of emitting particles on Y axis.
  86237. */
  86238. maxScaleY: number;
  86239. /**
  86240. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86241. */
  86242. color1: Color4;
  86243. /**
  86244. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86245. */
  86246. color2: Color4;
  86247. /**
  86248. * Color the particle will have at the end of its lifetime.
  86249. */
  86250. colorDead: Color4;
  86251. /**
  86252. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86253. */
  86254. emitRate: number;
  86255. /**
  86256. * You can use gravity if you want to give an orientation to your particles.
  86257. */
  86258. gravity: Vector3;
  86259. /**
  86260. * Minimum power of emitting particles.
  86261. */
  86262. minEmitPower: number;
  86263. /**
  86264. * Maximum power of emitting particles.
  86265. */
  86266. maxEmitPower: number;
  86267. /**
  86268. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86269. */
  86270. minAngularSpeed: number;
  86271. /**
  86272. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86273. */
  86274. maxAngularSpeed: number;
  86275. /**
  86276. * Gets or sets the minimal initial rotation in radians.
  86277. */
  86278. minInitialRotation: number;
  86279. /**
  86280. * Gets or sets the maximal initial rotation in radians.
  86281. */
  86282. maxInitialRotation: number;
  86283. /**
  86284. * The particle emitter type defines the emitter used by the particle system.
  86285. * It can be for example box, sphere, or cone...
  86286. */
  86287. particleEmitterType: Nullable<IParticleEmitterType>;
  86288. /**
  86289. * Defines the delay in milliseconds before starting the system (0 by default)
  86290. */
  86291. startDelay: number;
  86292. /**
  86293. * 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
  86294. */
  86295. preWarmCycles: number;
  86296. /**
  86297. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86298. */
  86299. preWarmStepOffset: number;
  86300. /**
  86301. * 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)
  86302. */
  86303. spriteCellChangeSpeed: number;
  86304. /**
  86305. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86306. */
  86307. startSpriteCellID: number;
  86308. /**
  86309. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86310. */
  86311. endSpriteCellID: number;
  86312. /**
  86313. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86314. */
  86315. spriteCellWidth: number;
  86316. /**
  86317. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86318. */
  86319. spriteCellHeight: number;
  86320. /**
  86321. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86322. */
  86323. spriteRandomStartCell: boolean;
  86324. /**
  86325. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86326. */
  86327. isAnimationSheetEnabled: boolean;
  86328. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86329. translationPivot: Vector2;
  86330. /**
  86331. * Gets or sets a texture used to add random noise to particle positions
  86332. */
  86333. noiseTexture: Nullable<BaseTexture>;
  86334. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86335. noiseStrength: Vector3;
  86336. /**
  86337. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86338. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86339. */
  86340. billboardMode: number;
  86341. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86342. limitVelocityDamping: number;
  86343. /**
  86344. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86345. */
  86346. beginAnimationOnStart: boolean;
  86347. /**
  86348. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86349. */
  86350. beginAnimationFrom: number;
  86351. /**
  86352. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86353. */
  86354. beginAnimationTo: number;
  86355. /**
  86356. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86357. */
  86358. beginAnimationLoop: boolean;
  86359. /**
  86360. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86361. */
  86362. disposeOnStop: boolean;
  86363. /**
  86364. * Specifies if the particles are updated in emitter local space or world space
  86365. */
  86366. isLocal: boolean;
  86367. /**
  86368. * Gets the maximum number of particles active at the same time.
  86369. * @returns The max number of active particles.
  86370. */
  86371. getCapacity(): number;
  86372. /**
  86373. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86374. * @returns True if it has been started, otherwise false.
  86375. */
  86376. isStarted(): boolean;
  86377. /**
  86378. * Animates the particle system for this frame.
  86379. */
  86380. animate(): void;
  86381. /**
  86382. * Renders the particle system in its current state.
  86383. * @returns the current number of particles
  86384. */
  86385. render(): number;
  86386. /**
  86387. * Dispose the particle system and frees its associated resources.
  86388. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86389. */
  86390. dispose(disposeTexture?: boolean): void;
  86391. /**
  86392. * Clones the particle system.
  86393. * @param name The name of the cloned object
  86394. * @param newEmitter The new emitter to use
  86395. * @returns the cloned particle system
  86396. */
  86397. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86398. /**
  86399. * Serializes the particle system to a JSON object.
  86400. * @returns the JSON object
  86401. */
  86402. serialize(): any;
  86403. /**
  86404. * Rebuild the particle system
  86405. */
  86406. rebuild(): void;
  86407. /**
  86408. * Starts the particle system and begins to emit
  86409. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86410. */
  86411. start(delay?: number): void;
  86412. /**
  86413. * Stops the particle system.
  86414. */
  86415. stop(): void;
  86416. /**
  86417. * Remove all active particles
  86418. */
  86419. reset(): void;
  86420. /**
  86421. * Is this system ready to be used/rendered
  86422. * @return true if the system is ready
  86423. */
  86424. isReady(): boolean;
  86425. /**
  86426. * Adds a new color gradient
  86427. * @param gradient defines the gradient to use (between 0 and 1)
  86428. * @param color1 defines the color to affect to the specified gradient
  86429. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86430. * @returns the current particle system
  86431. */
  86432. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86433. /**
  86434. * Remove a specific color gradient
  86435. * @param gradient defines the gradient to remove
  86436. * @returns the current particle system
  86437. */
  86438. removeColorGradient(gradient: number): IParticleSystem;
  86439. /**
  86440. * Adds a new size gradient
  86441. * @param gradient defines the gradient to use (between 0 and 1)
  86442. * @param factor defines the size factor to affect to the specified gradient
  86443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86444. * @returns the current particle system
  86445. */
  86446. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86447. /**
  86448. * Remove a specific size gradient
  86449. * @param gradient defines the gradient to remove
  86450. * @returns the current particle system
  86451. */
  86452. removeSizeGradient(gradient: number): IParticleSystem;
  86453. /**
  86454. * Gets the current list of color gradients.
  86455. * You must use addColorGradient and removeColorGradient to udpate this list
  86456. * @returns the list of color gradients
  86457. */
  86458. getColorGradients(): Nullable<Array<ColorGradient>>;
  86459. /**
  86460. * Gets the current list of size gradients.
  86461. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86462. * @returns the list of size gradients
  86463. */
  86464. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86465. /**
  86466. * Gets the current list of angular speed gradients.
  86467. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86468. * @returns the list of angular speed gradients
  86469. */
  86470. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86471. /**
  86472. * Adds a new angular speed gradient
  86473. * @param gradient defines the gradient to use (between 0 and 1)
  86474. * @param factor defines the angular speed to affect to the specified gradient
  86475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86476. * @returns the current particle system
  86477. */
  86478. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86479. /**
  86480. * Remove a specific angular speed gradient
  86481. * @param gradient defines the gradient to remove
  86482. * @returns the current particle system
  86483. */
  86484. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86485. /**
  86486. * Gets the current list of velocity gradients.
  86487. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86488. * @returns the list of velocity gradients
  86489. */
  86490. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86491. /**
  86492. * Adds a new velocity gradient
  86493. * @param gradient defines the gradient to use (between 0 and 1)
  86494. * @param factor defines the velocity to affect to the specified gradient
  86495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86496. * @returns the current particle system
  86497. */
  86498. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86499. /**
  86500. * Remove a specific velocity gradient
  86501. * @param gradient defines the gradient to remove
  86502. * @returns the current particle system
  86503. */
  86504. removeVelocityGradient(gradient: number): IParticleSystem;
  86505. /**
  86506. * Gets the current list of limit velocity gradients.
  86507. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86508. * @returns the list of limit velocity gradients
  86509. */
  86510. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86511. /**
  86512. * Adds a new limit velocity gradient
  86513. * @param gradient defines the gradient to use (between 0 and 1)
  86514. * @param factor defines the limit velocity to affect to the specified gradient
  86515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86516. * @returns the current particle system
  86517. */
  86518. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86519. /**
  86520. * Remove a specific limit velocity gradient
  86521. * @param gradient defines the gradient to remove
  86522. * @returns the current particle system
  86523. */
  86524. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86525. /**
  86526. * Adds a new drag gradient
  86527. * @param gradient defines the gradient to use (between 0 and 1)
  86528. * @param factor defines the drag to affect to the specified gradient
  86529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86530. * @returns the current particle system
  86531. */
  86532. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86533. /**
  86534. * Remove a specific drag gradient
  86535. * @param gradient defines the gradient to remove
  86536. * @returns the current particle system
  86537. */
  86538. removeDragGradient(gradient: number): IParticleSystem;
  86539. /**
  86540. * Gets the current list of drag gradients.
  86541. * You must use addDragGradient and removeDragGradient to udpate this list
  86542. * @returns the list of drag gradients
  86543. */
  86544. getDragGradients(): Nullable<Array<FactorGradient>>;
  86545. /**
  86546. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86547. * @param gradient defines the gradient to use (between 0 and 1)
  86548. * @param factor defines the emit rate to affect to the specified gradient
  86549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86550. * @returns the current particle system
  86551. */
  86552. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86553. /**
  86554. * Remove a specific emit rate gradient
  86555. * @param gradient defines the gradient to remove
  86556. * @returns the current particle system
  86557. */
  86558. removeEmitRateGradient(gradient: number): IParticleSystem;
  86559. /**
  86560. * Gets the current list of emit rate gradients.
  86561. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86562. * @returns the list of emit rate gradients
  86563. */
  86564. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86565. /**
  86566. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86567. * @param gradient defines the gradient to use (between 0 and 1)
  86568. * @param factor defines the start size to affect to the specified gradient
  86569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86570. * @returns the current particle system
  86571. */
  86572. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86573. /**
  86574. * Remove a specific start size gradient
  86575. * @param gradient defines the gradient to remove
  86576. * @returns the current particle system
  86577. */
  86578. removeStartSizeGradient(gradient: number): IParticleSystem;
  86579. /**
  86580. * Gets the current list of start size gradients.
  86581. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86582. * @returns the list of start size gradients
  86583. */
  86584. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86585. /**
  86586. * Adds a new life time gradient
  86587. * @param gradient defines the gradient to use (between 0 and 1)
  86588. * @param factor defines the life time factor to affect to the specified gradient
  86589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86590. * @returns the current particle system
  86591. */
  86592. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86593. /**
  86594. * Remove a specific life time gradient
  86595. * @param gradient defines the gradient to remove
  86596. * @returns the current particle system
  86597. */
  86598. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86599. /**
  86600. * Gets the current list of life time gradients.
  86601. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86602. * @returns the list of life time gradients
  86603. */
  86604. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86605. /**
  86606. * Gets the current list of color gradients.
  86607. * You must use addColorGradient and removeColorGradient to udpate this list
  86608. * @returns the list of color gradients
  86609. */
  86610. getColorGradients(): Nullable<Array<ColorGradient>>;
  86611. /**
  86612. * Adds a new ramp gradient used to remap particle colors
  86613. * @param gradient defines the gradient to use (between 0 and 1)
  86614. * @param color defines the color to affect to the specified gradient
  86615. * @returns the current particle system
  86616. */
  86617. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86618. /**
  86619. * Gets the current list of ramp gradients.
  86620. * You must use addRampGradient and removeRampGradient to udpate this list
  86621. * @returns the list of ramp gradients
  86622. */
  86623. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86624. /** Gets or sets a boolean indicating that ramp gradients must be used
  86625. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86626. */
  86627. useRampGradients: boolean;
  86628. /**
  86629. * Adds a new color remap gradient
  86630. * @param gradient defines the gradient to use (between 0 and 1)
  86631. * @param min defines the color remap minimal range
  86632. * @param max defines the color remap maximal range
  86633. * @returns the current particle system
  86634. */
  86635. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86636. /**
  86637. * Gets the current list of color remap gradients.
  86638. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86639. * @returns the list of color remap gradients
  86640. */
  86641. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86642. /**
  86643. * Adds a new alpha remap gradient
  86644. * @param gradient defines the gradient to use (between 0 and 1)
  86645. * @param min defines the alpha remap minimal range
  86646. * @param max defines the alpha remap maximal range
  86647. * @returns the current particle system
  86648. */
  86649. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86650. /**
  86651. * Gets the current list of alpha remap gradients.
  86652. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86653. * @returns the list of alpha remap gradients
  86654. */
  86655. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86656. /**
  86657. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86660. * @returns the emitter
  86661. */
  86662. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86663. /**
  86664. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86665. * @param radius The radius of the hemisphere to emit from
  86666. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86667. * @returns the emitter
  86668. */
  86669. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86670. /**
  86671. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86672. * @param radius The radius of the sphere to emit from
  86673. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86674. * @returns the emitter
  86675. */
  86676. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86677. /**
  86678. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86679. * @param radius The radius of the sphere to emit from
  86680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86682. * @returns the emitter
  86683. */
  86684. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86685. /**
  86686. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86687. * @param radius The radius of the emission cylinder
  86688. * @param height The height of the emission cylinder
  86689. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86690. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86691. * @returns the emitter
  86692. */
  86693. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86694. /**
  86695. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86696. * @param radius The radius of the cylinder to emit from
  86697. * @param height The height of the emission cylinder
  86698. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86701. * @returns the emitter
  86702. */
  86703. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86704. /**
  86705. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86706. * @param radius The radius of the cone to emit from
  86707. * @param angle The base angle of the cone
  86708. * @returns the emitter
  86709. */
  86710. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86711. /**
  86712. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86715. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86716. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86717. * @returns the emitter
  86718. */
  86719. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86720. /**
  86721. * Get hosting scene
  86722. * @returns the scene
  86723. */
  86724. getScene(): Scene;
  86725. }
  86726. }
  86727. declare module BABYLON {
  86728. /**
  86729. * 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.
  86730. * @see https://doc.babylonjs.com/how_to/transformnode
  86731. */
  86732. export class TransformNode extends Node {
  86733. /**
  86734. * Object will not rotate to face the camera
  86735. */
  86736. static BILLBOARDMODE_NONE: number;
  86737. /**
  86738. * Object will rotate to face the camera but only on the x axis
  86739. */
  86740. static BILLBOARDMODE_X: number;
  86741. /**
  86742. * Object will rotate to face the camera but only on the y axis
  86743. */
  86744. static BILLBOARDMODE_Y: number;
  86745. /**
  86746. * Object will rotate to face the camera but only on the z axis
  86747. */
  86748. static BILLBOARDMODE_Z: number;
  86749. /**
  86750. * Object will rotate to face the camera
  86751. */
  86752. static BILLBOARDMODE_ALL: number;
  86753. /**
  86754. * Object will rotate to face the camera's position instead of orientation
  86755. */
  86756. static BILLBOARDMODE_USE_POSITION: number;
  86757. private _forward;
  86758. private _forwardInverted;
  86759. private _up;
  86760. private _right;
  86761. private _rightInverted;
  86762. private _position;
  86763. private _rotation;
  86764. private _rotationQuaternion;
  86765. protected _scaling: Vector3;
  86766. protected _isDirty: boolean;
  86767. private _transformToBoneReferal;
  86768. private _isAbsoluteSynced;
  86769. private _billboardMode;
  86770. /**
  86771. * Gets or sets the billboard mode. Default is 0.
  86772. *
  86773. * | Value | Type | Description |
  86774. * | --- | --- | --- |
  86775. * | 0 | BILLBOARDMODE_NONE | |
  86776. * | 1 | BILLBOARDMODE_X | |
  86777. * | 2 | BILLBOARDMODE_Y | |
  86778. * | 4 | BILLBOARDMODE_Z | |
  86779. * | 7 | BILLBOARDMODE_ALL | |
  86780. *
  86781. */
  86782. get billboardMode(): number;
  86783. set billboardMode(value: number);
  86784. private _preserveParentRotationForBillboard;
  86785. /**
  86786. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86787. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86788. */
  86789. get preserveParentRotationForBillboard(): boolean;
  86790. set preserveParentRotationForBillboard(value: boolean);
  86791. /**
  86792. * 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
  86793. */
  86794. scalingDeterminant: number;
  86795. private _infiniteDistance;
  86796. /**
  86797. * Gets or sets the distance of the object to max, often used by skybox
  86798. */
  86799. get infiniteDistance(): boolean;
  86800. set infiniteDistance(value: boolean);
  86801. /**
  86802. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86803. * By default the system will update normals to compensate
  86804. */
  86805. ignoreNonUniformScaling: boolean;
  86806. /**
  86807. * 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
  86808. */
  86809. reIntegrateRotationIntoRotationQuaternion: boolean;
  86810. /** @hidden */
  86811. _poseMatrix: Nullable<Matrix>;
  86812. /** @hidden */
  86813. _localMatrix: Matrix;
  86814. private _usePivotMatrix;
  86815. private _absolutePosition;
  86816. private _absoluteScaling;
  86817. private _absoluteRotationQuaternion;
  86818. private _pivotMatrix;
  86819. private _pivotMatrixInverse;
  86820. protected _postMultiplyPivotMatrix: boolean;
  86821. protected _isWorldMatrixFrozen: boolean;
  86822. /** @hidden */
  86823. _indexInSceneTransformNodesArray: number;
  86824. /**
  86825. * An event triggered after the world matrix is updated
  86826. */
  86827. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86828. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86829. /**
  86830. * Gets a string identifying the name of the class
  86831. * @returns "TransformNode" string
  86832. */
  86833. getClassName(): string;
  86834. /**
  86835. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86836. */
  86837. get position(): Vector3;
  86838. set position(newPosition: Vector3);
  86839. /**
  86840. * 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)).
  86841. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86842. */
  86843. get rotation(): Vector3;
  86844. set rotation(newRotation: Vector3);
  86845. /**
  86846. * 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)).
  86847. */
  86848. get scaling(): Vector3;
  86849. set scaling(newScaling: Vector3);
  86850. /**
  86851. * 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).
  86852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86853. */
  86854. get rotationQuaternion(): Nullable<Quaternion>;
  86855. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86856. /**
  86857. * The forward direction of that transform in world space.
  86858. */
  86859. get forward(): Vector3;
  86860. /**
  86861. * The up direction of that transform in world space.
  86862. */
  86863. get up(): Vector3;
  86864. /**
  86865. * The right direction of that transform in world space.
  86866. */
  86867. get right(): Vector3;
  86868. /**
  86869. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86870. * @param matrix the matrix to copy the pose from
  86871. * @returns this TransformNode.
  86872. */
  86873. updatePoseMatrix(matrix: Matrix): TransformNode;
  86874. /**
  86875. * Returns the mesh Pose matrix.
  86876. * @returns the pose matrix
  86877. */
  86878. getPoseMatrix(): Matrix;
  86879. /** @hidden */
  86880. _isSynchronized(): boolean;
  86881. /** @hidden */
  86882. _initCache(): void;
  86883. /**
  86884. * Flag the transform node as dirty (Forcing it to update everything)
  86885. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86886. * @returns this transform node
  86887. */
  86888. markAsDirty(property: string): TransformNode;
  86889. /**
  86890. * Returns the current mesh absolute position.
  86891. * Returns a Vector3.
  86892. */
  86893. get absolutePosition(): Vector3;
  86894. /**
  86895. * Returns the current mesh absolute scaling.
  86896. * Returns a Vector3.
  86897. */
  86898. get absoluteScaling(): Vector3;
  86899. /**
  86900. * Returns the current mesh absolute rotation.
  86901. * Returns a Quaternion.
  86902. */
  86903. get absoluteRotationQuaternion(): Quaternion;
  86904. /**
  86905. * Sets a new matrix to apply before all other transformation
  86906. * @param matrix defines the transform matrix
  86907. * @returns the current TransformNode
  86908. */
  86909. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86910. /**
  86911. * Sets a new pivot matrix to the current node
  86912. * @param matrix defines the new pivot matrix to use
  86913. * @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
  86914. * @returns the current TransformNode
  86915. */
  86916. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86917. /**
  86918. * Returns the mesh pivot matrix.
  86919. * Default : Identity.
  86920. * @returns the matrix
  86921. */
  86922. getPivotMatrix(): Matrix;
  86923. /**
  86924. * Instantiate (when possible) or clone that node with its hierarchy
  86925. * @param newParent defines the new parent to use for the instance (or clone)
  86926. * @param options defines options to configure how copy is done
  86927. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86928. * @returns an instance (or a clone) of the current node with its hiearchy
  86929. */
  86930. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86931. doNotInstantiate: boolean;
  86932. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86933. /**
  86934. * Prevents the World matrix to be computed any longer
  86935. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86936. * @returns the TransformNode.
  86937. */
  86938. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86939. /**
  86940. * Allows back the World matrix computation.
  86941. * @returns the TransformNode.
  86942. */
  86943. unfreezeWorldMatrix(): this;
  86944. /**
  86945. * True if the World matrix has been frozen.
  86946. */
  86947. get isWorldMatrixFrozen(): boolean;
  86948. /**
  86949. * Retuns the mesh absolute position in the World.
  86950. * @returns a Vector3.
  86951. */
  86952. getAbsolutePosition(): Vector3;
  86953. /**
  86954. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86955. * @param absolutePosition the absolute position to set
  86956. * @returns the TransformNode.
  86957. */
  86958. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86959. /**
  86960. * Sets the mesh position in its local space.
  86961. * @param vector3 the position to set in localspace
  86962. * @returns the TransformNode.
  86963. */
  86964. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86965. /**
  86966. * Returns the mesh position in the local space from the current World matrix values.
  86967. * @returns a new Vector3.
  86968. */
  86969. getPositionExpressedInLocalSpace(): Vector3;
  86970. /**
  86971. * Translates the mesh along the passed Vector3 in its local space.
  86972. * @param vector3 the distance to translate in localspace
  86973. * @returns the TransformNode.
  86974. */
  86975. locallyTranslate(vector3: Vector3): TransformNode;
  86976. private static _lookAtVectorCache;
  86977. /**
  86978. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86979. * @param targetPoint the position (must be in same space as current mesh) to look at
  86980. * @param yawCor optional yaw (y-axis) correction in radians
  86981. * @param pitchCor optional pitch (x-axis) correction in radians
  86982. * @param rollCor optional roll (z-axis) correction in radians
  86983. * @param space the choosen space of the target
  86984. * @returns the TransformNode.
  86985. */
  86986. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86987. /**
  86988. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86989. * This Vector3 is expressed in the World space.
  86990. * @param localAxis axis to rotate
  86991. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86992. */
  86993. getDirection(localAxis: Vector3): Vector3;
  86994. /**
  86995. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86996. * localAxis is expressed in the mesh local space.
  86997. * result is computed in the Wordl space from the mesh World matrix.
  86998. * @param localAxis axis to rotate
  86999. * @param result the resulting transformnode
  87000. * @returns this TransformNode.
  87001. */
  87002. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87003. /**
  87004. * Sets this transform node rotation to the given local axis.
  87005. * @param localAxis the axis in local space
  87006. * @param yawCor optional yaw (y-axis) correction in radians
  87007. * @param pitchCor optional pitch (x-axis) correction in radians
  87008. * @param rollCor optional roll (z-axis) correction in radians
  87009. * @returns this TransformNode
  87010. */
  87011. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87012. /**
  87013. * Sets a new pivot point to the current node
  87014. * @param point defines the new pivot point to use
  87015. * @param space defines if the point is in world or local space (local by default)
  87016. * @returns the current TransformNode
  87017. */
  87018. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87019. /**
  87020. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87021. * @returns the pivot point
  87022. */
  87023. getPivotPoint(): Vector3;
  87024. /**
  87025. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87026. * @param result the vector3 to store the result
  87027. * @returns this TransformNode.
  87028. */
  87029. getPivotPointToRef(result: Vector3): TransformNode;
  87030. /**
  87031. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87032. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87033. */
  87034. getAbsolutePivotPoint(): Vector3;
  87035. /**
  87036. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87037. * @param result vector3 to store the result
  87038. * @returns this TransformNode.
  87039. */
  87040. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87041. /**
  87042. * Defines the passed node as the parent of the current node.
  87043. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87044. * @see https://doc.babylonjs.com/how_to/parenting
  87045. * @param node the node ot set as the parent
  87046. * @returns this TransformNode.
  87047. */
  87048. setParent(node: Nullable<Node>): TransformNode;
  87049. private _nonUniformScaling;
  87050. /**
  87051. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87052. */
  87053. get nonUniformScaling(): boolean;
  87054. /** @hidden */
  87055. _updateNonUniformScalingState(value: boolean): boolean;
  87056. /**
  87057. * Attach the current TransformNode to another TransformNode associated with a bone
  87058. * @param bone Bone affecting the TransformNode
  87059. * @param affectedTransformNode TransformNode associated with the bone
  87060. * @returns this object
  87061. */
  87062. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87063. /**
  87064. * Detach the transform node if its associated with a bone
  87065. * @returns this object
  87066. */
  87067. detachFromBone(): TransformNode;
  87068. private static _rotationAxisCache;
  87069. /**
  87070. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87071. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87072. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87073. * The passed axis is also normalized.
  87074. * @param axis the axis to rotate around
  87075. * @param amount the amount to rotate in radians
  87076. * @param space Space to rotate in (Default: local)
  87077. * @returns the TransformNode.
  87078. */
  87079. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87080. /**
  87081. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87082. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87083. * The passed axis is also normalized. .
  87084. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87085. * @param point the point to rotate around
  87086. * @param axis the axis to rotate around
  87087. * @param amount the amount to rotate in radians
  87088. * @returns the TransformNode
  87089. */
  87090. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87091. /**
  87092. * Translates the mesh along the axis vector for the passed distance in the given space.
  87093. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87094. * @param axis the axis to translate in
  87095. * @param distance the distance to translate
  87096. * @param space Space to rotate in (Default: local)
  87097. * @returns the TransformNode.
  87098. */
  87099. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87100. /**
  87101. * Adds a rotation step to the mesh current rotation.
  87102. * x, y, z are Euler angles expressed in radians.
  87103. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87104. * This means this rotation is made in the mesh local space only.
  87105. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87106. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87107. * ```javascript
  87108. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87109. * ```
  87110. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87111. * 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.
  87112. * @param x Rotation to add
  87113. * @param y Rotation to add
  87114. * @param z Rotation to add
  87115. * @returns the TransformNode.
  87116. */
  87117. addRotation(x: number, y: number, z: number): TransformNode;
  87118. /**
  87119. * @hidden
  87120. */
  87121. protected _getEffectiveParent(): Nullable<Node>;
  87122. /**
  87123. * Computes the world matrix of the node
  87124. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87125. * @returns the world matrix
  87126. */
  87127. computeWorldMatrix(force?: boolean): Matrix;
  87128. /**
  87129. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87130. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87131. */
  87132. resetLocalMatrix(independentOfChildren?: boolean): void;
  87133. protected _afterComputeWorldMatrix(): void;
  87134. /**
  87135. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87136. * @param func callback function to add
  87137. *
  87138. * @returns the TransformNode.
  87139. */
  87140. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87141. /**
  87142. * Removes a registered callback function.
  87143. * @param func callback function to remove
  87144. * @returns the TransformNode.
  87145. */
  87146. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87147. /**
  87148. * Gets the position of the current mesh in camera space
  87149. * @param camera defines the camera to use
  87150. * @returns a position
  87151. */
  87152. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87153. /**
  87154. * Returns the distance from the mesh to the active camera
  87155. * @param camera defines the camera to use
  87156. * @returns the distance
  87157. */
  87158. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87159. /**
  87160. * Clone the current transform node
  87161. * @param name Name of the new clone
  87162. * @param newParent New parent for the clone
  87163. * @param doNotCloneChildren Do not clone children hierarchy
  87164. * @returns the new transform node
  87165. */
  87166. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87167. /**
  87168. * Serializes the objects information.
  87169. * @param currentSerializationObject defines the object to serialize in
  87170. * @returns the serialized object
  87171. */
  87172. serialize(currentSerializationObject?: any): any;
  87173. /**
  87174. * Returns a new TransformNode object parsed from the source provided.
  87175. * @param parsedTransformNode is the source.
  87176. * @param scene the scne the object belongs to
  87177. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87178. * @returns a new TransformNode object parsed from the source provided.
  87179. */
  87180. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87181. /**
  87182. * Get all child-transformNodes of this node
  87183. * @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
  87184. * @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
  87185. * @returns an array of TransformNode
  87186. */
  87187. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87188. /**
  87189. * Releases resources associated with this transform node.
  87190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87192. */
  87193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87194. /**
  87195. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87196. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87197. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87198. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87199. * @returns the current mesh
  87200. */
  87201. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87202. private _syncAbsoluteScalingAndRotation;
  87203. }
  87204. }
  87205. declare module BABYLON {
  87206. /**
  87207. * Class used to override all child animations of a given target
  87208. */
  87209. export class AnimationPropertiesOverride {
  87210. /**
  87211. * Gets or sets a value indicating if animation blending must be used
  87212. */
  87213. enableBlending: boolean;
  87214. /**
  87215. * Gets or sets the blending speed to use when enableBlending is true
  87216. */
  87217. blendingSpeed: number;
  87218. /**
  87219. * Gets or sets the default loop mode to use
  87220. */
  87221. loopMode: number;
  87222. }
  87223. }
  87224. declare module BABYLON {
  87225. /**
  87226. * Class used to store bone information
  87227. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87228. */
  87229. export class Bone extends Node {
  87230. /**
  87231. * defines the bone name
  87232. */
  87233. name: string;
  87234. private static _tmpVecs;
  87235. private static _tmpQuat;
  87236. private static _tmpMats;
  87237. /**
  87238. * Gets the list of child bones
  87239. */
  87240. children: Bone[];
  87241. /** Gets the animations associated with this bone */
  87242. animations: Animation[];
  87243. /**
  87244. * Gets or sets bone length
  87245. */
  87246. length: number;
  87247. /**
  87248. * @hidden Internal only
  87249. * Set this value to map this bone to a different index in the transform matrices
  87250. * Set this value to -1 to exclude the bone from the transform matrices
  87251. */
  87252. _index: Nullable<number>;
  87253. private _skeleton;
  87254. private _localMatrix;
  87255. private _restPose;
  87256. private _baseMatrix;
  87257. private _absoluteTransform;
  87258. private _invertedAbsoluteTransform;
  87259. private _parent;
  87260. private _scalingDeterminant;
  87261. private _worldTransform;
  87262. private _localScaling;
  87263. private _localRotation;
  87264. private _localPosition;
  87265. private _needToDecompose;
  87266. private _needToCompose;
  87267. /** @hidden */
  87268. _linkedTransformNode: Nullable<TransformNode>;
  87269. /** @hidden */
  87270. _waitingTransformNodeId: Nullable<string>;
  87271. /** @hidden */
  87272. get _matrix(): Matrix;
  87273. /** @hidden */
  87274. set _matrix(value: Matrix);
  87275. /**
  87276. * Create a new bone
  87277. * @param name defines the bone name
  87278. * @param skeleton defines the parent skeleton
  87279. * @param parentBone defines the parent (can be null if the bone is the root)
  87280. * @param localMatrix defines the local matrix
  87281. * @param restPose defines the rest pose matrix
  87282. * @param baseMatrix defines the base matrix
  87283. * @param index defines index of the bone in the hiearchy
  87284. */
  87285. constructor(
  87286. /**
  87287. * defines the bone name
  87288. */
  87289. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87290. /**
  87291. * Gets the current object class name.
  87292. * @return the class name
  87293. */
  87294. getClassName(): string;
  87295. /**
  87296. * Gets the parent skeleton
  87297. * @returns a skeleton
  87298. */
  87299. getSkeleton(): Skeleton;
  87300. /**
  87301. * Gets parent bone
  87302. * @returns a bone or null if the bone is the root of the bone hierarchy
  87303. */
  87304. getParent(): Nullable<Bone>;
  87305. /**
  87306. * Returns an array containing the root bones
  87307. * @returns an array containing the root bones
  87308. */
  87309. getChildren(): Array<Bone>;
  87310. /**
  87311. * Gets the node index in matrix array generated for rendering
  87312. * @returns the node index
  87313. */
  87314. getIndex(): number;
  87315. /**
  87316. * Sets the parent bone
  87317. * @param parent defines the parent (can be null if the bone is the root)
  87318. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87319. */
  87320. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87321. /**
  87322. * Gets the local matrix
  87323. * @returns a matrix
  87324. */
  87325. getLocalMatrix(): Matrix;
  87326. /**
  87327. * Gets the base matrix (initial matrix which remains unchanged)
  87328. * @returns a matrix
  87329. */
  87330. getBaseMatrix(): Matrix;
  87331. /**
  87332. * Gets the rest pose matrix
  87333. * @returns a matrix
  87334. */
  87335. getRestPose(): Matrix;
  87336. /**
  87337. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87338. */
  87339. getWorldMatrix(): Matrix;
  87340. /**
  87341. * Sets the local matrix to rest pose matrix
  87342. */
  87343. returnToRest(): void;
  87344. /**
  87345. * Gets the inverse of the absolute transform matrix.
  87346. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87347. * @returns a matrix
  87348. */
  87349. getInvertedAbsoluteTransform(): Matrix;
  87350. /**
  87351. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87352. * @returns a matrix
  87353. */
  87354. getAbsoluteTransform(): Matrix;
  87355. /**
  87356. * Links with the given transform node.
  87357. * The local matrix of this bone is copied from the transform node every frame.
  87358. * @param transformNode defines the transform node to link to
  87359. */
  87360. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87361. /**
  87362. * Gets the node used to drive the bone's transformation
  87363. * @returns a transform node or null
  87364. */
  87365. getTransformNode(): Nullable<TransformNode>;
  87366. /** Gets or sets current position (in local space) */
  87367. get position(): Vector3;
  87368. set position(newPosition: Vector3);
  87369. /** Gets or sets current rotation (in local space) */
  87370. get rotation(): Vector3;
  87371. set rotation(newRotation: Vector3);
  87372. /** Gets or sets current rotation quaternion (in local space) */
  87373. get rotationQuaternion(): Quaternion;
  87374. set rotationQuaternion(newRotation: Quaternion);
  87375. /** Gets or sets current scaling (in local space) */
  87376. get scaling(): Vector3;
  87377. set scaling(newScaling: Vector3);
  87378. /**
  87379. * Gets the animation properties override
  87380. */
  87381. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87382. private _decompose;
  87383. private _compose;
  87384. /**
  87385. * Update the base and local matrices
  87386. * @param matrix defines the new base or local matrix
  87387. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87388. * @param updateLocalMatrix defines if the local matrix should be updated
  87389. */
  87390. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87391. /** @hidden */
  87392. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87393. /**
  87394. * Flag the bone as dirty (Forcing it to update everything)
  87395. */
  87396. markAsDirty(): void;
  87397. /** @hidden */
  87398. _markAsDirtyAndCompose(): void;
  87399. private _markAsDirtyAndDecompose;
  87400. /**
  87401. * Translate the bone in local or world space
  87402. * @param vec The amount to translate the bone
  87403. * @param space The space that the translation is in
  87404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87405. */
  87406. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87407. /**
  87408. * Set the postion of the bone in local or world space
  87409. * @param position The position to set the bone
  87410. * @param space The space that the position is in
  87411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87412. */
  87413. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87414. /**
  87415. * Set the absolute position of the bone (world space)
  87416. * @param position The position to set the bone
  87417. * @param mesh The mesh that this bone is attached to
  87418. */
  87419. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87420. /**
  87421. * Scale the bone on the x, y and z axes (in local space)
  87422. * @param x The amount to scale the bone on the x axis
  87423. * @param y The amount to scale the bone on the y axis
  87424. * @param z The amount to scale the bone on the z axis
  87425. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87426. */
  87427. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87428. /**
  87429. * Set the bone scaling in local space
  87430. * @param scale defines the scaling vector
  87431. */
  87432. setScale(scale: Vector3): void;
  87433. /**
  87434. * Gets the current scaling in local space
  87435. * @returns the current scaling vector
  87436. */
  87437. getScale(): Vector3;
  87438. /**
  87439. * Gets the current scaling in local space and stores it in a target vector
  87440. * @param result defines the target vector
  87441. */
  87442. getScaleToRef(result: Vector3): void;
  87443. /**
  87444. * Set the yaw, pitch, and roll of the bone in local or world space
  87445. * @param yaw The rotation of the bone on the y axis
  87446. * @param pitch The rotation of the bone on the x axis
  87447. * @param roll The rotation of the bone on the z axis
  87448. * @param space The space that the axes of rotation are in
  87449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87450. */
  87451. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87452. /**
  87453. * Add a rotation to the bone on an axis in local or world space
  87454. * @param axis The axis to rotate the bone on
  87455. * @param amount The amount to rotate the bone
  87456. * @param space The space that the axis is in
  87457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87458. */
  87459. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87460. /**
  87461. * Set the rotation of the bone to a particular axis angle in local or world space
  87462. * @param axis The axis to rotate the bone on
  87463. * @param angle The angle that the bone should be rotated to
  87464. * @param space The space that the axis is in
  87465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87466. */
  87467. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87468. /**
  87469. * Set the euler rotation of the bone in local of world space
  87470. * @param rotation The euler rotation that the bone should be set to
  87471. * @param space The space that the rotation is in
  87472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87473. */
  87474. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87475. /**
  87476. * Set the quaternion rotation of the bone in local of world space
  87477. * @param quat The quaternion rotation that the bone should be set to
  87478. * @param space The space that the rotation is in
  87479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87480. */
  87481. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87482. /**
  87483. * Set the rotation matrix of the bone in local of world space
  87484. * @param rotMat The rotation matrix that the bone should be set to
  87485. * @param space The space that the rotation is in
  87486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87487. */
  87488. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87489. private _rotateWithMatrix;
  87490. private _getNegativeRotationToRef;
  87491. /**
  87492. * Get the position of the bone in local or world space
  87493. * @param space The space that the returned position is in
  87494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87495. * @returns The position of the bone
  87496. */
  87497. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87498. /**
  87499. * Copy the position of the bone to a vector3 in local or world space
  87500. * @param space The space that the returned position is in
  87501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87502. * @param result The vector3 to copy the position to
  87503. */
  87504. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87505. /**
  87506. * Get the absolute position of the bone (world space)
  87507. * @param mesh The mesh that this bone is attached to
  87508. * @returns The absolute position of the bone
  87509. */
  87510. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87511. /**
  87512. * Copy the absolute position of the bone (world space) to the result param
  87513. * @param mesh The mesh that this bone is attached to
  87514. * @param result The vector3 to copy the absolute position to
  87515. */
  87516. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87517. /**
  87518. * Compute the absolute transforms of this bone and its children
  87519. */
  87520. computeAbsoluteTransforms(): void;
  87521. /**
  87522. * Get the world direction from an axis that is in the local space of the bone
  87523. * @param localAxis The local direction that is used to compute the world direction
  87524. * @param mesh The mesh that this bone is attached to
  87525. * @returns The world direction
  87526. */
  87527. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87528. /**
  87529. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87530. * @param localAxis The local direction that is used to compute the world direction
  87531. * @param mesh The mesh that this bone is attached to
  87532. * @param result The vector3 that the world direction will be copied to
  87533. */
  87534. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87535. /**
  87536. * Get the euler rotation of the bone in local or world space
  87537. * @param space The space that the rotation should be in
  87538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87539. * @returns The euler rotation
  87540. */
  87541. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87542. /**
  87543. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87544. * @param space The space that the rotation should be in
  87545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87546. * @param result The vector3 that the rotation should be copied to
  87547. */
  87548. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87549. /**
  87550. * Get the quaternion rotation of the bone in either local or world space
  87551. * @param space The space that the rotation should be in
  87552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87553. * @returns The quaternion rotation
  87554. */
  87555. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87556. /**
  87557. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87558. * @param space The space that the rotation should be in
  87559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87560. * @param result The quaternion that the rotation should be copied to
  87561. */
  87562. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87563. /**
  87564. * Get the rotation matrix of the bone in local or world space
  87565. * @param space The space that the rotation should be in
  87566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87567. * @returns The rotation matrix
  87568. */
  87569. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87570. /**
  87571. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87572. * @param space The space that the rotation should be in
  87573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87574. * @param result The quaternion that the rotation should be copied to
  87575. */
  87576. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87577. /**
  87578. * Get the world position of a point that is in the local space of the bone
  87579. * @param position The local position
  87580. * @param mesh The mesh that this bone is attached to
  87581. * @returns The world position
  87582. */
  87583. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87584. /**
  87585. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87586. * @param position The local position
  87587. * @param mesh The mesh that this bone is attached to
  87588. * @param result The vector3 that the world position should be copied to
  87589. */
  87590. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87591. /**
  87592. * Get the local position of a point that is in world space
  87593. * @param position The world position
  87594. * @param mesh The mesh that this bone is attached to
  87595. * @returns The local position
  87596. */
  87597. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87598. /**
  87599. * Get the local position of a point that is in world space and copy it to the result param
  87600. * @param position The world position
  87601. * @param mesh The mesh that this bone is attached to
  87602. * @param result The vector3 that the local position should be copied to
  87603. */
  87604. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87605. }
  87606. }
  87607. declare module BABYLON {
  87608. /**
  87609. * Defines a runtime animation
  87610. */
  87611. export class RuntimeAnimation {
  87612. private _events;
  87613. /**
  87614. * The current frame of the runtime animation
  87615. */
  87616. private _currentFrame;
  87617. /**
  87618. * The animation used by the runtime animation
  87619. */
  87620. private _animation;
  87621. /**
  87622. * The target of the runtime animation
  87623. */
  87624. private _target;
  87625. /**
  87626. * The initiating animatable
  87627. */
  87628. private _host;
  87629. /**
  87630. * The original value of the runtime animation
  87631. */
  87632. private _originalValue;
  87633. /**
  87634. * The original blend value of the runtime animation
  87635. */
  87636. private _originalBlendValue;
  87637. /**
  87638. * The offsets cache of the runtime animation
  87639. */
  87640. private _offsetsCache;
  87641. /**
  87642. * The high limits cache of the runtime animation
  87643. */
  87644. private _highLimitsCache;
  87645. /**
  87646. * Specifies if the runtime animation has been stopped
  87647. */
  87648. private _stopped;
  87649. /**
  87650. * The blending factor of the runtime animation
  87651. */
  87652. private _blendingFactor;
  87653. /**
  87654. * The BabylonJS scene
  87655. */
  87656. private _scene;
  87657. /**
  87658. * The current value of the runtime animation
  87659. */
  87660. private _currentValue;
  87661. /** @hidden */
  87662. _animationState: _IAnimationState;
  87663. /**
  87664. * The active target of the runtime animation
  87665. */
  87666. private _activeTargets;
  87667. private _currentActiveTarget;
  87668. private _directTarget;
  87669. /**
  87670. * The target path of the runtime animation
  87671. */
  87672. private _targetPath;
  87673. /**
  87674. * The weight of the runtime animation
  87675. */
  87676. private _weight;
  87677. /**
  87678. * The ratio offset of the runtime animation
  87679. */
  87680. private _ratioOffset;
  87681. /**
  87682. * The previous delay of the runtime animation
  87683. */
  87684. private _previousDelay;
  87685. /**
  87686. * The previous ratio of the runtime animation
  87687. */
  87688. private _previousRatio;
  87689. private _enableBlending;
  87690. private _keys;
  87691. private _minFrame;
  87692. private _maxFrame;
  87693. private _minValue;
  87694. private _maxValue;
  87695. private _targetIsArray;
  87696. /**
  87697. * Gets the current frame of the runtime animation
  87698. */
  87699. get currentFrame(): number;
  87700. /**
  87701. * Gets the weight of the runtime animation
  87702. */
  87703. get weight(): number;
  87704. /**
  87705. * Gets the current value of the runtime animation
  87706. */
  87707. get currentValue(): any;
  87708. /**
  87709. * Gets the target path of the runtime animation
  87710. */
  87711. get targetPath(): string;
  87712. /**
  87713. * Gets the actual target of the runtime animation
  87714. */
  87715. get target(): any;
  87716. /** @hidden */
  87717. _onLoop: () => void;
  87718. /**
  87719. * Create a new RuntimeAnimation object
  87720. * @param target defines the target of the animation
  87721. * @param animation defines the source animation object
  87722. * @param scene defines the hosting scene
  87723. * @param host defines the initiating Animatable
  87724. */
  87725. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87726. private _preparePath;
  87727. /**
  87728. * Gets the animation from the runtime animation
  87729. */
  87730. get animation(): Animation;
  87731. /**
  87732. * Resets the runtime animation to the beginning
  87733. * @param restoreOriginal defines whether to restore the target property to the original value
  87734. */
  87735. reset(restoreOriginal?: boolean): void;
  87736. /**
  87737. * Specifies if the runtime animation is stopped
  87738. * @returns Boolean specifying if the runtime animation is stopped
  87739. */
  87740. isStopped(): boolean;
  87741. /**
  87742. * Disposes of the runtime animation
  87743. */
  87744. dispose(): void;
  87745. /**
  87746. * Apply the interpolated value to the target
  87747. * @param currentValue defines the value computed by the animation
  87748. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87749. */
  87750. setValue(currentValue: any, weight: number): void;
  87751. private _getOriginalValues;
  87752. private _setValue;
  87753. /**
  87754. * Gets the loop pmode of the runtime animation
  87755. * @returns Loop Mode
  87756. */
  87757. private _getCorrectLoopMode;
  87758. /**
  87759. * Move the current animation to a given frame
  87760. * @param frame defines the frame to move to
  87761. */
  87762. goToFrame(frame: number): void;
  87763. /**
  87764. * @hidden Internal use only
  87765. */
  87766. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87767. /**
  87768. * Execute the current animation
  87769. * @param delay defines the delay to add to the current frame
  87770. * @param from defines the lower bound of the animation range
  87771. * @param to defines the upper bound of the animation range
  87772. * @param loop defines if the current animation must loop
  87773. * @param speedRatio defines the current speed ratio
  87774. * @param weight defines the weight of the animation (default is -1 so no weight)
  87775. * @param onLoop optional callback called when animation loops
  87776. * @returns a boolean indicating if the animation is running
  87777. */
  87778. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87779. }
  87780. }
  87781. declare module BABYLON {
  87782. /**
  87783. * Class used to store an actual running animation
  87784. */
  87785. export class Animatable {
  87786. /** defines the target object */
  87787. target: any;
  87788. /** defines the starting frame number (default is 0) */
  87789. fromFrame: number;
  87790. /** defines the ending frame number (default is 100) */
  87791. toFrame: number;
  87792. /** defines if the animation must loop (default is false) */
  87793. loopAnimation: boolean;
  87794. /** defines a callback to call when animation ends if it is not looping */
  87795. onAnimationEnd?: (() => void) | null | undefined;
  87796. /** defines a callback to call when animation loops */
  87797. onAnimationLoop?: (() => void) | null | undefined;
  87798. private _localDelayOffset;
  87799. private _pausedDelay;
  87800. private _runtimeAnimations;
  87801. private _paused;
  87802. private _scene;
  87803. private _speedRatio;
  87804. private _weight;
  87805. private _syncRoot;
  87806. /**
  87807. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87808. * This will only apply for non looping animation (default is true)
  87809. */
  87810. disposeOnEnd: boolean;
  87811. /**
  87812. * Gets a boolean indicating if the animation has started
  87813. */
  87814. animationStarted: boolean;
  87815. /**
  87816. * Observer raised when the animation ends
  87817. */
  87818. onAnimationEndObservable: Observable<Animatable>;
  87819. /**
  87820. * Observer raised when the animation loops
  87821. */
  87822. onAnimationLoopObservable: Observable<Animatable>;
  87823. /**
  87824. * Gets the root Animatable used to synchronize and normalize animations
  87825. */
  87826. get syncRoot(): Nullable<Animatable>;
  87827. /**
  87828. * Gets the current frame of the first RuntimeAnimation
  87829. * Used to synchronize Animatables
  87830. */
  87831. get masterFrame(): number;
  87832. /**
  87833. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87834. */
  87835. get weight(): number;
  87836. set weight(value: number);
  87837. /**
  87838. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87839. */
  87840. get speedRatio(): number;
  87841. set speedRatio(value: number);
  87842. /**
  87843. * Creates a new Animatable
  87844. * @param scene defines the hosting scene
  87845. * @param target defines the target object
  87846. * @param fromFrame defines the starting frame number (default is 0)
  87847. * @param toFrame defines the ending frame number (default is 100)
  87848. * @param loopAnimation defines if the animation must loop (default is false)
  87849. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87850. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87851. * @param animations defines a group of animation to add to the new Animatable
  87852. * @param onAnimationLoop defines a callback to call when animation loops
  87853. */
  87854. constructor(scene: Scene,
  87855. /** defines the target object */
  87856. target: any,
  87857. /** defines the starting frame number (default is 0) */
  87858. fromFrame?: number,
  87859. /** defines the ending frame number (default is 100) */
  87860. toFrame?: number,
  87861. /** defines if the animation must loop (default is false) */
  87862. loopAnimation?: boolean, speedRatio?: number,
  87863. /** defines a callback to call when animation ends if it is not looping */
  87864. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87865. /** defines a callback to call when animation loops */
  87866. onAnimationLoop?: (() => void) | null | undefined);
  87867. /**
  87868. * Synchronize and normalize current Animatable with a source Animatable
  87869. * This is useful when using animation weights and when animations are not of the same length
  87870. * @param root defines the root Animatable to synchronize with
  87871. * @returns the current Animatable
  87872. */
  87873. syncWith(root: Animatable): Animatable;
  87874. /**
  87875. * Gets the list of runtime animations
  87876. * @returns an array of RuntimeAnimation
  87877. */
  87878. getAnimations(): RuntimeAnimation[];
  87879. /**
  87880. * Adds more animations to the current animatable
  87881. * @param target defines the target of the animations
  87882. * @param animations defines the new animations to add
  87883. */
  87884. appendAnimations(target: any, animations: Animation[]): void;
  87885. /**
  87886. * Gets the source animation for a specific property
  87887. * @param property defines the propertyu to look for
  87888. * @returns null or the source animation for the given property
  87889. */
  87890. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87891. /**
  87892. * Gets the runtime animation for a specific property
  87893. * @param property defines the propertyu to look for
  87894. * @returns null or the runtime animation for the given property
  87895. */
  87896. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87897. /**
  87898. * Resets the animatable to its original state
  87899. */
  87900. reset(): void;
  87901. /**
  87902. * Allows the animatable to blend with current running animations
  87903. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87904. * @param blendingSpeed defines the blending speed to use
  87905. */
  87906. enableBlending(blendingSpeed: number): void;
  87907. /**
  87908. * Disable animation blending
  87909. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87910. */
  87911. disableBlending(): void;
  87912. /**
  87913. * Jump directly to a given frame
  87914. * @param frame defines the frame to jump to
  87915. */
  87916. goToFrame(frame: number): void;
  87917. /**
  87918. * Pause the animation
  87919. */
  87920. pause(): void;
  87921. /**
  87922. * Restart the animation
  87923. */
  87924. restart(): void;
  87925. private _raiseOnAnimationEnd;
  87926. /**
  87927. * Stop and delete the current animation
  87928. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87929. * @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)
  87930. */
  87931. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87932. /**
  87933. * Wait asynchronously for the animation to end
  87934. * @returns a promise which will be fullfilled when the animation ends
  87935. */
  87936. waitAsync(): Promise<Animatable>;
  87937. /** @hidden */
  87938. _animate(delay: number): boolean;
  87939. }
  87940. interface Scene {
  87941. /** @hidden */
  87942. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87943. /** @hidden */
  87944. _processLateAnimationBindingsForMatrices(holder: {
  87945. totalWeight: number;
  87946. animations: RuntimeAnimation[];
  87947. originalValue: Matrix;
  87948. }): any;
  87949. /** @hidden */
  87950. _processLateAnimationBindingsForQuaternions(holder: {
  87951. totalWeight: number;
  87952. animations: RuntimeAnimation[];
  87953. originalValue: Quaternion;
  87954. }, refQuaternion: Quaternion): Quaternion;
  87955. /** @hidden */
  87956. _processLateAnimationBindings(): void;
  87957. /**
  87958. * Will start the animation sequence of a given target
  87959. * @param target defines the target
  87960. * @param from defines from which frame should animation start
  87961. * @param to defines until which frame should animation run.
  87962. * @param weight defines the weight to apply to the animation (1.0 by default)
  87963. * @param loop defines if the animation loops
  87964. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87965. * @param onAnimationEnd defines the function to be executed when the animation ends
  87966. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87967. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87968. * @param onAnimationLoop defines the callback to call when an animation loops
  87969. * @returns the animatable object created for this animation
  87970. */
  87971. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87972. /**
  87973. * Will start the animation sequence of a given target
  87974. * @param target defines the target
  87975. * @param from defines from which frame should animation start
  87976. * @param to defines until which frame should animation run.
  87977. * @param loop defines if the animation loops
  87978. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87979. * @param onAnimationEnd defines the function to be executed when the animation ends
  87980. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87981. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87982. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87983. * @param onAnimationLoop defines the callback to call when an animation loops
  87984. * @returns the animatable object created for this animation
  87985. */
  87986. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87987. /**
  87988. * Will start the animation sequence of a given target and its hierarchy
  87989. * @param target defines the target
  87990. * @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.
  87991. * @param from defines from which frame should animation start
  87992. * @param to defines until which frame should animation run.
  87993. * @param loop defines if the animation loops
  87994. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87995. * @param onAnimationEnd defines the function to be executed when the animation ends
  87996. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87997. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87998. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87999. * @param onAnimationLoop defines the callback to call when an animation loops
  88000. * @returns the list of created animatables
  88001. */
  88002. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  88003. /**
  88004. * Begin a new animation on a given node
  88005. * @param target defines the target where the animation will take place
  88006. * @param animations defines the list of animations to start
  88007. * @param from defines the initial value
  88008. * @param to defines the final value
  88009. * @param loop defines if you want animation to loop (off by default)
  88010. * @param speedRatio defines the speed ratio to apply to all animations
  88011. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88012. * @param onAnimationLoop defines the callback to call when an animation loops
  88013. * @returns the list of created animatables
  88014. */
  88015. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88016. /**
  88017. * Begin a new animation on a given node and its hierarchy
  88018. * @param target defines the root node where the animation will take place
  88019. * @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.
  88020. * @param animations defines the list of animations to start
  88021. * @param from defines the initial value
  88022. * @param to defines the final value
  88023. * @param loop defines if you want animation to loop (off by default)
  88024. * @param speedRatio defines the speed ratio to apply to all animations
  88025. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88026. * @param onAnimationLoop defines the callback to call when an animation loops
  88027. * @returns the list of animatables created for all nodes
  88028. */
  88029. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88030. /**
  88031. * Gets the animatable associated with a specific target
  88032. * @param target defines the target of the animatable
  88033. * @returns the required animatable if found
  88034. */
  88035. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88036. /**
  88037. * Gets all animatables associated with a given target
  88038. * @param target defines the target to look animatables for
  88039. * @returns an array of Animatables
  88040. */
  88041. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88042. /**
  88043. * Stops and removes all animations that have been applied to the scene
  88044. */
  88045. stopAllAnimations(): void;
  88046. /**
  88047. * Gets the current delta time used by animation engine
  88048. */
  88049. deltaTime: number;
  88050. }
  88051. interface Bone {
  88052. /**
  88053. * Copy an animation range from another bone
  88054. * @param source defines the source bone
  88055. * @param rangeName defines the range name to copy
  88056. * @param frameOffset defines the frame offset
  88057. * @param rescaleAsRequired defines if rescaling must be applied if required
  88058. * @param skelDimensionsRatio defines the scaling ratio
  88059. * @returns true if operation was successful
  88060. */
  88061. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88062. }
  88063. }
  88064. declare module BABYLON {
  88065. /**
  88066. * Class used to handle skinning animations
  88067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88068. */
  88069. export class Skeleton implements IAnimatable {
  88070. /** defines the skeleton name */
  88071. name: string;
  88072. /** defines the skeleton Id */
  88073. id: string;
  88074. /**
  88075. * Defines the list of child bones
  88076. */
  88077. bones: Bone[];
  88078. /**
  88079. * Defines an estimate of the dimension of the skeleton at rest
  88080. */
  88081. dimensionsAtRest: Vector3;
  88082. /**
  88083. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88084. */
  88085. needInitialSkinMatrix: boolean;
  88086. /**
  88087. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88088. */
  88089. overrideMesh: Nullable<AbstractMesh>;
  88090. /**
  88091. * Gets the list of animations attached to this skeleton
  88092. */
  88093. animations: Array<Animation>;
  88094. private _scene;
  88095. private _isDirty;
  88096. private _transformMatrices;
  88097. private _transformMatrixTexture;
  88098. private _meshesWithPoseMatrix;
  88099. private _animatables;
  88100. private _identity;
  88101. private _synchronizedWithMesh;
  88102. private _ranges;
  88103. private _lastAbsoluteTransformsUpdateId;
  88104. private _canUseTextureForBones;
  88105. private _uniqueId;
  88106. /** @hidden */
  88107. _numBonesWithLinkedTransformNode: number;
  88108. /** @hidden */
  88109. _hasWaitingData: Nullable<boolean>;
  88110. /**
  88111. * Specifies if the skeleton should be serialized
  88112. */
  88113. doNotSerialize: boolean;
  88114. private _useTextureToStoreBoneMatrices;
  88115. /**
  88116. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88117. * Please note that this option is not available if the hardware does not support it
  88118. */
  88119. get useTextureToStoreBoneMatrices(): boolean;
  88120. set useTextureToStoreBoneMatrices(value: boolean);
  88121. private _animationPropertiesOverride;
  88122. /**
  88123. * Gets or sets the animation properties override
  88124. */
  88125. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88126. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88127. /**
  88128. * List of inspectable custom properties (used by the Inspector)
  88129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88130. */
  88131. inspectableCustomProperties: IInspectable[];
  88132. /**
  88133. * An observable triggered before computing the skeleton's matrices
  88134. */
  88135. onBeforeComputeObservable: Observable<Skeleton>;
  88136. /**
  88137. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88138. */
  88139. get isUsingTextureForMatrices(): boolean;
  88140. /**
  88141. * Gets the unique ID of this skeleton
  88142. */
  88143. get uniqueId(): number;
  88144. /**
  88145. * Creates a new skeleton
  88146. * @param name defines the skeleton name
  88147. * @param id defines the skeleton Id
  88148. * @param scene defines the hosting scene
  88149. */
  88150. constructor(
  88151. /** defines the skeleton name */
  88152. name: string,
  88153. /** defines the skeleton Id */
  88154. id: string, scene: Scene);
  88155. /**
  88156. * Gets the current object class name.
  88157. * @return the class name
  88158. */
  88159. getClassName(): string;
  88160. /**
  88161. * Returns an array containing the root bones
  88162. * @returns an array containing the root bones
  88163. */
  88164. getChildren(): Array<Bone>;
  88165. /**
  88166. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88167. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88168. * @returns a Float32Array containing matrices data
  88169. */
  88170. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88171. /**
  88172. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88173. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88174. * @returns a raw texture containing the data
  88175. */
  88176. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88177. /**
  88178. * Gets the current hosting scene
  88179. * @returns a scene object
  88180. */
  88181. getScene(): Scene;
  88182. /**
  88183. * Gets a string representing the current skeleton data
  88184. * @param fullDetails defines a boolean indicating if we want a verbose version
  88185. * @returns a string representing the current skeleton data
  88186. */
  88187. toString(fullDetails?: boolean): string;
  88188. /**
  88189. * Get bone's index searching by name
  88190. * @param name defines bone's name to search for
  88191. * @return the indice of the bone. Returns -1 if not found
  88192. */
  88193. getBoneIndexByName(name: string): number;
  88194. /**
  88195. * Creater a new animation range
  88196. * @param name defines the name of the range
  88197. * @param from defines the start key
  88198. * @param to defines the end key
  88199. */
  88200. createAnimationRange(name: string, from: number, to: number): void;
  88201. /**
  88202. * Delete a specific animation range
  88203. * @param name defines the name of the range
  88204. * @param deleteFrames defines if frames must be removed as well
  88205. */
  88206. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88207. /**
  88208. * Gets a specific animation range
  88209. * @param name defines the name of the range to look for
  88210. * @returns the requested animation range or null if not found
  88211. */
  88212. getAnimationRange(name: string): Nullable<AnimationRange>;
  88213. /**
  88214. * Gets the list of all animation ranges defined on this skeleton
  88215. * @returns an array
  88216. */
  88217. getAnimationRanges(): Nullable<AnimationRange>[];
  88218. /**
  88219. * Copy animation range from a source skeleton.
  88220. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88221. * @param source defines the source skeleton
  88222. * @param name defines the name of the range to copy
  88223. * @param rescaleAsRequired defines if rescaling must be applied if required
  88224. * @returns true if operation was successful
  88225. */
  88226. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88227. /**
  88228. * Forces the skeleton to go to rest pose
  88229. */
  88230. returnToRest(): void;
  88231. private _getHighestAnimationFrame;
  88232. /**
  88233. * Begin a specific animation range
  88234. * @param name defines the name of the range to start
  88235. * @param loop defines if looping must be turned on (false by default)
  88236. * @param speedRatio defines the speed ratio to apply (1 by default)
  88237. * @param onAnimationEnd defines a callback which will be called when animation will end
  88238. * @returns a new animatable
  88239. */
  88240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88241. /** @hidden */
  88242. _markAsDirty(): void;
  88243. /** @hidden */
  88244. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88245. /** @hidden */
  88246. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88247. private _computeTransformMatrices;
  88248. /**
  88249. * Build all resources required to render a skeleton
  88250. */
  88251. prepare(): void;
  88252. /**
  88253. * Gets the list of animatables currently running for this skeleton
  88254. * @returns an array of animatables
  88255. */
  88256. getAnimatables(): IAnimatable[];
  88257. /**
  88258. * Clone the current skeleton
  88259. * @param name defines the name of the new skeleton
  88260. * @param id defines the id of the new skeleton
  88261. * @returns the new skeleton
  88262. */
  88263. clone(name: string, id?: string): Skeleton;
  88264. /**
  88265. * Enable animation blending for this skeleton
  88266. * @param blendingSpeed defines the blending speed to apply
  88267. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88268. */
  88269. enableBlending(blendingSpeed?: number): void;
  88270. /**
  88271. * Releases all resources associated with the current skeleton
  88272. */
  88273. dispose(): void;
  88274. /**
  88275. * Serialize the skeleton in a JSON object
  88276. * @returns a JSON object
  88277. */
  88278. serialize(): any;
  88279. /**
  88280. * Creates a new skeleton from serialized data
  88281. * @param parsedSkeleton defines the serialized data
  88282. * @param scene defines the hosting scene
  88283. * @returns a new skeleton
  88284. */
  88285. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88286. /**
  88287. * Compute all node absolute transforms
  88288. * @param forceUpdate defines if computation must be done even if cache is up to date
  88289. */
  88290. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88291. /**
  88292. * Gets the root pose matrix
  88293. * @returns a matrix
  88294. */
  88295. getPoseMatrix(): Nullable<Matrix>;
  88296. /**
  88297. * Sorts bones per internal index
  88298. */
  88299. sortBones(): void;
  88300. private _sortBones;
  88301. }
  88302. }
  88303. declare module BABYLON {
  88304. /**
  88305. * Creates an instance based on a source mesh.
  88306. */
  88307. export class InstancedMesh extends AbstractMesh {
  88308. private _sourceMesh;
  88309. private _currentLOD;
  88310. /** @hidden */
  88311. _indexInSourceMeshInstanceArray: number;
  88312. constructor(name: string, source: Mesh);
  88313. /**
  88314. * Returns the string "InstancedMesh".
  88315. */
  88316. getClassName(): string;
  88317. /** Gets the list of lights affecting that mesh */
  88318. get lightSources(): Light[];
  88319. _resyncLightSources(): void;
  88320. _resyncLightSource(light: Light): void;
  88321. _removeLightSource(light: Light, dispose: boolean): void;
  88322. /**
  88323. * If the source mesh receives shadows
  88324. */
  88325. get receiveShadows(): boolean;
  88326. /**
  88327. * The material of the source mesh
  88328. */
  88329. get material(): Nullable<Material>;
  88330. /**
  88331. * Visibility of the source mesh
  88332. */
  88333. get visibility(): number;
  88334. /**
  88335. * Skeleton of the source mesh
  88336. */
  88337. get skeleton(): Nullable<Skeleton>;
  88338. /**
  88339. * Rendering ground id of the source mesh
  88340. */
  88341. get renderingGroupId(): number;
  88342. set renderingGroupId(value: number);
  88343. /**
  88344. * Returns the total number of vertices (integer).
  88345. */
  88346. getTotalVertices(): number;
  88347. /**
  88348. * Returns a positive integer : the total number of indices in this mesh geometry.
  88349. * @returns the numner of indices or zero if the mesh has no geometry.
  88350. */
  88351. getTotalIndices(): number;
  88352. /**
  88353. * The source mesh of the instance
  88354. */
  88355. get sourceMesh(): Mesh;
  88356. /**
  88357. * Is this node ready to be used/rendered
  88358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88359. * @return {boolean} is it ready
  88360. */
  88361. isReady(completeCheck?: boolean): boolean;
  88362. /**
  88363. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88364. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88365. * @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.
  88366. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88367. */
  88368. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88369. /**
  88370. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88371. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88372. * The `data` are either a numeric array either a Float32Array.
  88373. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88374. * 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).
  88375. * Note that a new underlying VertexBuffer object is created each call.
  88376. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88377. *
  88378. * Possible `kind` values :
  88379. * - VertexBuffer.PositionKind
  88380. * - VertexBuffer.UVKind
  88381. * - VertexBuffer.UV2Kind
  88382. * - VertexBuffer.UV3Kind
  88383. * - VertexBuffer.UV4Kind
  88384. * - VertexBuffer.UV5Kind
  88385. * - VertexBuffer.UV6Kind
  88386. * - VertexBuffer.ColorKind
  88387. * - VertexBuffer.MatricesIndicesKind
  88388. * - VertexBuffer.MatricesIndicesExtraKind
  88389. * - VertexBuffer.MatricesWeightsKind
  88390. * - VertexBuffer.MatricesWeightsExtraKind
  88391. *
  88392. * Returns the Mesh.
  88393. */
  88394. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88395. /**
  88396. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88397. * If the mesh has no geometry, it is simply returned as it is.
  88398. * The `data` are either a numeric array either a Float32Array.
  88399. * No new underlying VertexBuffer object is created.
  88400. * 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.
  88401. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88402. *
  88403. * Possible `kind` values :
  88404. * - VertexBuffer.PositionKind
  88405. * - VertexBuffer.UVKind
  88406. * - VertexBuffer.UV2Kind
  88407. * - VertexBuffer.UV3Kind
  88408. * - VertexBuffer.UV4Kind
  88409. * - VertexBuffer.UV5Kind
  88410. * - VertexBuffer.UV6Kind
  88411. * - VertexBuffer.ColorKind
  88412. * - VertexBuffer.MatricesIndicesKind
  88413. * - VertexBuffer.MatricesIndicesExtraKind
  88414. * - VertexBuffer.MatricesWeightsKind
  88415. * - VertexBuffer.MatricesWeightsExtraKind
  88416. *
  88417. * Returns the Mesh.
  88418. */
  88419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88420. /**
  88421. * Sets the mesh indices.
  88422. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88423. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88424. * This method creates a new index buffer each call.
  88425. * Returns the Mesh.
  88426. */
  88427. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88428. /**
  88429. * Boolean : True if the mesh owns the requested kind of data.
  88430. */
  88431. isVerticesDataPresent(kind: string): boolean;
  88432. /**
  88433. * Returns an array of indices (IndicesArray).
  88434. */
  88435. getIndices(): Nullable<IndicesArray>;
  88436. get _positions(): Nullable<Vector3[]>;
  88437. /**
  88438. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88439. * This means the mesh underlying bounding box and sphere are recomputed.
  88440. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88441. * @returns the current mesh
  88442. */
  88443. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88444. /** @hidden */
  88445. _preActivate(): InstancedMesh;
  88446. /** @hidden */
  88447. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88448. /** @hidden */
  88449. _postActivate(): void;
  88450. getWorldMatrix(): Matrix;
  88451. get isAnInstance(): boolean;
  88452. /**
  88453. * Returns the current associated LOD AbstractMesh.
  88454. */
  88455. getLOD(camera: Camera): AbstractMesh;
  88456. /** @hidden */
  88457. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88458. /** @hidden */
  88459. _syncSubMeshes(): InstancedMesh;
  88460. /** @hidden */
  88461. _generatePointsArray(): boolean;
  88462. /**
  88463. * Creates a new InstancedMesh from the current mesh.
  88464. * - name (string) : the cloned mesh name
  88465. * - newParent (optional Node) : the optional Node to parent the clone to.
  88466. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88467. *
  88468. * Returns the clone.
  88469. */
  88470. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88471. /**
  88472. * Disposes the InstancedMesh.
  88473. * Returns nothing.
  88474. */
  88475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88476. }
  88477. interface Mesh {
  88478. /**
  88479. * Register a custom buffer that will be instanced
  88480. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88481. * @param kind defines the buffer kind
  88482. * @param stride defines the stride in floats
  88483. */
  88484. registerInstancedBuffer(kind: string, stride: number): void;
  88485. /** @hidden */
  88486. _userInstancedBuffersStorage: {
  88487. data: {
  88488. [key: string]: Float32Array;
  88489. };
  88490. sizes: {
  88491. [key: string]: number;
  88492. };
  88493. vertexBuffers: {
  88494. [key: string]: Nullable<VertexBuffer>;
  88495. };
  88496. strides: {
  88497. [key: string]: number;
  88498. };
  88499. };
  88500. }
  88501. interface AbstractMesh {
  88502. /**
  88503. * Object used to store instanced buffers defined by user
  88504. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88505. */
  88506. instancedBuffers: {
  88507. [key: string]: any;
  88508. };
  88509. }
  88510. }
  88511. declare module BABYLON {
  88512. /**
  88513. * Defines the options associated with the creation of a shader material.
  88514. */
  88515. export interface IShaderMaterialOptions {
  88516. /**
  88517. * Does the material work in alpha blend mode
  88518. */
  88519. needAlphaBlending: boolean;
  88520. /**
  88521. * Does the material work in alpha test mode
  88522. */
  88523. needAlphaTesting: boolean;
  88524. /**
  88525. * The list of attribute names used in the shader
  88526. */
  88527. attributes: string[];
  88528. /**
  88529. * The list of unifrom names used in the shader
  88530. */
  88531. uniforms: string[];
  88532. /**
  88533. * The list of UBO names used in the shader
  88534. */
  88535. uniformBuffers: string[];
  88536. /**
  88537. * The list of sampler names used in the shader
  88538. */
  88539. samplers: string[];
  88540. /**
  88541. * The list of defines used in the shader
  88542. */
  88543. defines: string[];
  88544. }
  88545. /**
  88546. * 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.
  88547. *
  88548. * This returned material effects how the mesh will look based on the code in the shaders.
  88549. *
  88550. * @see http://doc.babylonjs.com/how_to/shader_material
  88551. */
  88552. export class ShaderMaterial extends Material {
  88553. private _shaderPath;
  88554. private _options;
  88555. private _textures;
  88556. private _textureArrays;
  88557. private _floats;
  88558. private _ints;
  88559. private _floatsArrays;
  88560. private _colors3;
  88561. private _colors3Arrays;
  88562. private _colors4;
  88563. private _colors4Arrays;
  88564. private _vectors2;
  88565. private _vectors3;
  88566. private _vectors4;
  88567. private _matrices;
  88568. private _matrixArrays;
  88569. private _matrices3x3;
  88570. private _matrices2x2;
  88571. private _vectors2Arrays;
  88572. private _vectors3Arrays;
  88573. private _vectors4Arrays;
  88574. private _cachedWorldViewMatrix;
  88575. private _cachedWorldViewProjectionMatrix;
  88576. private _renderId;
  88577. private _multiview;
  88578. /**
  88579. * Instantiate a new shader material.
  88580. * 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.
  88581. * This returned material effects how the mesh will look based on the code in the shaders.
  88582. * @see http://doc.babylonjs.com/how_to/shader_material
  88583. * @param name Define the name of the material in the scene
  88584. * @param scene Define the scene the material belongs to
  88585. * @param shaderPath Defines the route to the shader code in one of three ways:
  88586. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88587. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88588. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88589. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88590. * @param options Define the options used to create the shader
  88591. */
  88592. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88593. /**
  88594. * Gets the shader path used to define the shader code
  88595. * It can be modified to trigger a new compilation
  88596. */
  88597. get shaderPath(): any;
  88598. /**
  88599. * Sets the shader path used to define the shader code
  88600. * It can be modified to trigger a new compilation
  88601. */
  88602. set shaderPath(shaderPath: any);
  88603. /**
  88604. * Gets the options used to compile the shader.
  88605. * They can be modified to trigger a new compilation
  88606. */
  88607. get options(): IShaderMaterialOptions;
  88608. /**
  88609. * Gets the current class name of the material e.g. "ShaderMaterial"
  88610. * Mainly use in serialization.
  88611. * @returns the class name
  88612. */
  88613. getClassName(): string;
  88614. /**
  88615. * Specifies if the material will require alpha blending
  88616. * @returns a boolean specifying if alpha blending is needed
  88617. */
  88618. needAlphaBlending(): boolean;
  88619. /**
  88620. * Specifies if this material should be rendered in alpha test mode
  88621. * @returns a boolean specifying if an alpha test is needed.
  88622. */
  88623. needAlphaTesting(): boolean;
  88624. private _checkUniform;
  88625. /**
  88626. * Set a texture in the shader.
  88627. * @param name Define the name of the uniform samplers as defined in the shader
  88628. * @param texture Define the texture to bind to this sampler
  88629. * @return the material itself allowing "fluent" like uniform updates
  88630. */
  88631. setTexture(name: string, texture: Texture): ShaderMaterial;
  88632. /**
  88633. * Set a texture array in the shader.
  88634. * @param name Define the name of the uniform sampler array as defined in the shader
  88635. * @param textures Define the list of textures to bind to this sampler
  88636. * @return the material itself allowing "fluent" like uniform updates
  88637. */
  88638. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88639. /**
  88640. * Set a float in the shader.
  88641. * @param name Define the name of the uniform as defined in the shader
  88642. * @param value Define the value to give to the uniform
  88643. * @return the material itself allowing "fluent" like uniform updates
  88644. */
  88645. setFloat(name: string, value: number): ShaderMaterial;
  88646. /**
  88647. * Set a int in the shader.
  88648. * @param name Define the name of the uniform as defined in the shader
  88649. * @param value Define the value to give to the uniform
  88650. * @return the material itself allowing "fluent" like uniform updates
  88651. */
  88652. setInt(name: string, value: number): ShaderMaterial;
  88653. /**
  88654. * Set an array of floats in the shader.
  88655. * @param name Define the name of the uniform as defined in the shader
  88656. * @param value Define the value to give to the uniform
  88657. * @return the material itself allowing "fluent" like uniform updates
  88658. */
  88659. setFloats(name: string, value: number[]): ShaderMaterial;
  88660. /**
  88661. * Set a vec3 in the shader from a Color3.
  88662. * @param name Define the name of the uniform as defined in the shader
  88663. * @param value Define the value to give to the uniform
  88664. * @return the material itself allowing "fluent" like uniform updates
  88665. */
  88666. setColor3(name: string, value: Color3): ShaderMaterial;
  88667. /**
  88668. * Set a vec3 array in the shader from a Color3 array.
  88669. * @param name Define the name of the uniform as defined in the shader
  88670. * @param value Define the value to give to the uniform
  88671. * @return the material itself allowing "fluent" like uniform updates
  88672. */
  88673. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88674. /**
  88675. * Set a vec4 in the shader from a Color4.
  88676. * @param name Define the name of the uniform as defined in the shader
  88677. * @param value Define the value to give to the uniform
  88678. * @return the material itself allowing "fluent" like uniform updates
  88679. */
  88680. setColor4(name: string, value: Color4): ShaderMaterial;
  88681. /**
  88682. * Set a vec4 array in the shader from a Color4 array.
  88683. * @param name Define the name of the uniform as defined in the shader
  88684. * @param value Define the value to give to the uniform
  88685. * @return the material itself allowing "fluent" like uniform updates
  88686. */
  88687. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88688. /**
  88689. * Set a vec2 in the shader from a Vector2.
  88690. * @param name Define the name of the uniform as defined in the shader
  88691. * @param value Define the value to give to the uniform
  88692. * @return the material itself allowing "fluent" like uniform updates
  88693. */
  88694. setVector2(name: string, value: Vector2): ShaderMaterial;
  88695. /**
  88696. * Set a vec3 in the shader from a Vector3.
  88697. * @param name Define the name of the uniform as defined in the shader
  88698. * @param value Define the value to give to the uniform
  88699. * @return the material itself allowing "fluent" like uniform updates
  88700. */
  88701. setVector3(name: string, value: Vector3): ShaderMaterial;
  88702. /**
  88703. * Set a vec4 in the shader from a Vector4.
  88704. * @param name Define the name of the uniform as defined in the shader
  88705. * @param value Define the value to give to the uniform
  88706. * @return the material itself allowing "fluent" like uniform updates
  88707. */
  88708. setVector4(name: string, value: Vector4): ShaderMaterial;
  88709. /**
  88710. * Set a mat4 in the shader from a Matrix.
  88711. * @param name Define the name of the uniform as defined in the shader
  88712. * @param value Define the value to give to the uniform
  88713. * @return the material itself allowing "fluent" like uniform updates
  88714. */
  88715. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88716. /**
  88717. * Set a float32Array in the shader from a matrix array.
  88718. * @param name Define the name of the uniform as defined in the shader
  88719. * @param value Define the value to give to the uniform
  88720. * @return the material itself allowing "fluent" like uniform updates
  88721. */
  88722. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88723. /**
  88724. * Set a mat3 in the shader from a Float32Array.
  88725. * @param name Define the name of the uniform as defined in the shader
  88726. * @param value Define the value to give to the uniform
  88727. * @return the material itself allowing "fluent" like uniform updates
  88728. */
  88729. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88730. /**
  88731. * Set a mat2 in the shader from a Float32Array.
  88732. * @param name Define the name of the uniform as defined in the shader
  88733. * @param value Define the value to give to the uniform
  88734. * @return the material itself allowing "fluent" like uniform updates
  88735. */
  88736. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88737. /**
  88738. * Set a vec2 array in the shader from a number array.
  88739. * @param name Define the name of the uniform as defined in the shader
  88740. * @param value Define the value to give to the uniform
  88741. * @return the material itself allowing "fluent" like uniform updates
  88742. */
  88743. setArray2(name: string, value: number[]): ShaderMaterial;
  88744. /**
  88745. * Set a vec3 array in the shader from a number array.
  88746. * @param name Define the name of the uniform as defined in the shader
  88747. * @param value Define the value to give to the uniform
  88748. * @return the material itself allowing "fluent" like uniform updates
  88749. */
  88750. setArray3(name: string, value: number[]): ShaderMaterial;
  88751. /**
  88752. * Set a vec4 array in the shader from a number array.
  88753. * @param name Define the name of the uniform as defined in the shader
  88754. * @param value Define the value to give to the uniform
  88755. * @return the material itself allowing "fluent" like uniform updates
  88756. */
  88757. setArray4(name: string, value: number[]): ShaderMaterial;
  88758. private _checkCache;
  88759. /**
  88760. * Specifies that the submesh is ready to be used
  88761. * @param mesh defines the mesh to check
  88762. * @param subMesh defines which submesh to check
  88763. * @param useInstances specifies that instances should be used
  88764. * @returns a boolean indicating that the submesh is ready or not
  88765. */
  88766. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88767. /**
  88768. * Checks if the material is ready to render the requested mesh
  88769. * @param mesh Define the mesh to render
  88770. * @param useInstances Define whether or not the material is used with instances
  88771. * @returns true if ready, otherwise false
  88772. */
  88773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88774. /**
  88775. * Binds the world matrix to the material
  88776. * @param world defines the world transformation matrix
  88777. */
  88778. bindOnlyWorldMatrix(world: Matrix): void;
  88779. /**
  88780. * Binds the material to the mesh
  88781. * @param world defines the world transformation matrix
  88782. * @param mesh defines the mesh to bind the material to
  88783. */
  88784. bind(world: Matrix, mesh?: Mesh): void;
  88785. /**
  88786. * Gets the active textures from the material
  88787. * @returns an array of textures
  88788. */
  88789. getActiveTextures(): BaseTexture[];
  88790. /**
  88791. * Specifies if the material uses a texture
  88792. * @param texture defines the texture to check against the material
  88793. * @returns a boolean specifying if the material uses the texture
  88794. */
  88795. hasTexture(texture: BaseTexture): boolean;
  88796. /**
  88797. * Makes a duplicate of the material, and gives it a new name
  88798. * @param name defines the new name for the duplicated material
  88799. * @returns the cloned material
  88800. */
  88801. clone(name: string): ShaderMaterial;
  88802. /**
  88803. * Disposes the material
  88804. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88805. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88806. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88807. */
  88808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88809. /**
  88810. * Serializes this material in a JSON representation
  88811. * @returns the serialized material object
  88812. */
  88813. serialize(): any;
  88814. /**
  88815. * Creates a shader material from parsed shader material data
  88816. * @param source defines the JSON represnetation of the material
  88817. * @param scene defines the hosting scene
  88818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88819. * @returns a new material
  88820. */
  88821. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88822. }
  88823. }
  88824. declare module BABYLON {
  88825. /** @hidden */
  88826. export var colorPixelShader: {
  88827. name: string;
  88828. shader: string;
  88829. };
  88830. }
  88831. declare module BABYLON {
  88832. /** @hidden */
  88833. export var colorVertexShader: {
  88834. name: string;
  88835. shader: string;
  88836. };
  88837. }
  88838. declare module BABYLON {
  88839. /**
  88840. * Line mesh
  88841. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88842. */
  88843. export class LinesMesh extends Mesh {
  88844. /**
  88845. * If vertex color should be applied to the mesh
  88846. */
  88847. readonly useVertexColor?: boolean | undefined;
  88848. /**
  88849. * If vertex alpha should be applied to the mesh
  88850. */
  88851. readonly useVertexAlpha?: boolean | undefined;
  88852. /**
  88853. * Color of the line (Default: White)
  88854. */
  88855. color: Color3;
  88856. /**
  88857. * Alpha of the line (Default: 1)
  88858. */
  88859. alpha: number;
  88860. /**
  88861. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88862. * This margin is expressed in world space coordinates, so its value may vary.
  88863. * Default value is 0.1
  88864. */
  88865. intersectionThreshold: number;
  88866. private _colorShader;
  88867. private color4;
  88868. /**
  88869. * Creates a new LinesMesh
  88870. * @param name defines the name
  88871. * @param scene defines the hosting scene
  88872. * @param parent defines the parent mesh if any
  88873. * @param source defines the optional source LinesMesh used to clone data from
  88874. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88875. * When false, achieved by calling a clone(), also passing False.
  88876. * This will make creation of children, recursive.
  88877. * @param useVertexColor defines if this LinesMesh supports vertex color
  88878. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88879. */
  88880. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88881. /**
  88882. * If vertex color should be applied to the mesh
  88883. */
  88884. useVertexColor?: boolean | undefined,
  88885. /**
  88886. * If vertex alpha should be applied to the mesh
  88887. */
  88888. useVertexAlpha?: boolean | undefined);
  88889. private _addClipPlaneDefine;
  88890. private _removeClipPlaneDefine;
  88891. isReady(): boolean;
  88892. /**
  88893. * Returns the string "LineMesh"
  88894. */
  88895. getClassName(): string;
  88896. /**
  88897. * @hidden
  88898. */
  88899. get material(): Material;
  88900. /**
  88901. * @hidden
  88902. */
  88903. set material(value: Material);
  88904. /**
  88905. * @hidden
  88906. */
  88907. get checkCollisions(): boolean;
  88908. /** @hidden */
  88909. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88910. /** @hidden */
  88911. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88912. /**
  88913. * Disposes of the line mesh
  88914. * @param doNotRecurse If children should be disposed
  88915. */
  88916. dispose(doNotRecurse?: boolean): void;
  88917. /**
  88918. * Returns a new LineMesh object cloned from the current one.
  88919. */
  88920. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88921. /**
  88922. * Creates a new InstancedLinesMesh object from the mesh model.
  88923. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88924. * @param name defines the name of the new instance
  88925. * @returns a new InstancedLinesMesh
  88926. */
  88927. createInstance(name: string): InstancedLinesMesh;
  88928. }
  88929. /**
  88930. * Creates an instance based on a source LinesMesh
  88931. */
  88932. export class InstancedLinesMesh extends InstancedMesh {
  88933. /**
  88934. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88935. * This margin is expressed in world space coordinates, so its value may vary.
  88936. * Initilized with the intersectionThreshold value of the source LinesMesh
  88937. */
  88938. intersectionThreshold: number;
  88939. constructor(name: string, source: LinesMesh);
  88940. /**
  88941. * Returns the string "InstancedLinesMesh".
  88942. */
  88943. getClassName(): string;
  88944. }
  88945. }
  88946. declare module BABYLON {
  88947. /** @hidden */
  88948. export var linePixelShader: {
  88949. name: string;
  88950. shader: string;
  88951. };
  88952. }
  88953. declare module BABYLON {
  88954. /** @hidden */
  88955. export var lineVertexShader: {
  88956. name: string;
  88957. shader: string;
  88958. };
  88959. }
  88960. declare module BABYLON {
  88961. interface AbstractMesh {
  88962. /**
  88963. * Gets the edgesRenderer associated with the mesh
  88964. */
  88965. edgesRenderer: Nullable<EdgesRenderer>;
  88966. }
  88967. interface LinesMesh {
  88968. /**
  88969. * Enables the edge rendering mode on the mesh.
  88970. * This mode makes the mesh edges visible
  88971. * @param epsilon defines the maximal distance between two angles to detect a face
  88972. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88973. * @returns the currentAbstractMesh
  88974. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88975. */
  88976. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88977. }
  88978. interface InstancedLinesMesh {
  88979. /**
  88980. * Enables the edge rendering mode on the mesh.
  88981. * This mode makes the mesh edges visible
  88982. * @param epsilon defines the maximal distance between two angles to detect a face
  88983. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88984. * @returns the current InstancedLinesMesh
  88985. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88986. */
  88987. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88988. }
  88989. /**
  88990. * Defines the minimum contract an Edges renderer should follow.
  88991. */
  88992. export interface IEdgesRenderer extends IDisposable {
  88993. /**
  88994. * Gets or sets a boolean indicating if the edgesRenderer is active
  88995. */
  88996. isEnabled: boolean;
  88997. /**
  88998. * Renders the edges of the attached mesh,
  88999. */
  89000. render(): void;
  89001. /**
  89002. * Checks wether or not the edges renderer is ready to render.
  89003. * @return true if ready, otherwise false.
  89004. */
  89005. isReady(): boolean;
  89006. }
  89007. /**
  89008. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89009. */
  89010. export class EdgesRenderer implements IEdgesRenderer {
  89011. /**
  89012. * Define the size of the edges with an orthographic camera
  89013. */
  89014. edgesWidthScalerForOrthographic: number;
  89015. /**
  89016. * Define the size of the edges with a perspective camera
  89017. */
  89018. edgesWidthScalerForPerspective: number;
  89019. protected _source: AbstractMesh;
  89020. protected _linesPositions: number[];
  89021. protected _linesNormals: number[];
  89022. protected _linesIndices: number[];
  89023. protected _epsilon: number;
  89024. protected _indicesCount: number;
  89025. protected _lineShader: ShaderMaterial;
  89026. protected _ib: DataBuffer;
  89027. protected _buffers: {
  89028. [key: string]: Nullable<VertexBuffer>;
  89029. };
  89030. protected _checkVerticesInsteadOfIndices: boolean;
  89031. private _meshRebuildObserver;
  89032. private _meshDisposeObserver;
  89033. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89034. isEnabled: boolean;
  89035. /**
  89036. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89037. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89038. * @param source Mesh used to create edges
  89039. * @param epsilon sum of angles in adjacency to check for edge
  89040. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89041. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89042. */
  89043. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89044. protected _prepareRessources(): void;
  89045. /** @hidden */
  89046. _rebuild(): void;
  89047. /**
  89048. * Releases the required resources for the edges renderer
  89049. */
  89050. dispose(): void;
  89051. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89052. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89053. /**
  89054. * Checks if the pair of p0 and p1 is en edge
  89055. * @param faceIndex
  89056. * @param edge
  89057. * @param faceNormals
  89058. * @param p0
  89059. * @param p1
  89060. * @private
  89061. */
  89062. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89063. /**
  89064. * push line into the position, normal and index buffer
  89065. * @protected
  89066. */
  89067. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89068. /**
  89069. * Generates lines edges from adjacencjes
  89070. * @private
  89071. */
  89072. _generateEdgesLines(): void;
  89073. /**
  89074. * Checks wether or not the edges renderer is ready to render.
  89075. * @return true if ready, otherwise false.
  89076. */
  89077. isReady(): boolean;
  89078. /**
  89079. * Renders the edges of the attached mesh,
  89080. */
  89081. render(): void;
  89082. }
  89083. /**
  89084. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89085. */
  89086. export class LineEdgesRenderer extends EdgesRenderer {
  89087. /**
  89088. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89089. * @param source LineMesh used to generate edges
  89090. * @param epsilon not important (specified angle for edge detection)
  89091. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89092. */
  89093. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89094. /**
  89095. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89096. */
  89097. _generateEdgesLines(): void;
  89098. }
  89099. }
  89100. declare module BABYLON {
  89101. /**
  89102. * This represents the object necessary to create a rendering group.
  89103. * This is exclusively used and created by the rendering manager.
  89104. * To modify the behavior, you use the available helpers in your scene or meshes.
  89105. * @hidden
  89106. */
  89107. export class RenderingGroup {
  89108. index: number;
  89109. private static _zeroVector;
  89110. private _scene;
  89111. private _opaqueSubMeshes;
  89112. private _transparentSubMeshes;
  89113. private _alphaTestSubMeshes;
  89114. private _depthOnlySubMeshes;
  89115. private _particleSystems;
  89116. private _spriteManagers;
  89117. private _opaqueSortCompareFn;
  89118. private _alphaTestSortCompareFn;
  89119. private _transparentSortCompareFn;
  89120. private _renderOpaque;
  89121. private _renderAlphaTest;
  89122. private _renderTransparent;
  89123. /** @hidden */
  89124. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89125. onBeforeTransparentRendering: () => void;
  89126. /**
  89127. * Set the opaque sort comparison function.
  89128. * If null the sub meshes will be render in the order they were created
  89129. */
  89130. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89131. /**
  89132. * Set the alpha test sort comparison function.
  89133. * If null the sub meshes will be render in the order they were created
  89134. */
  89135. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89136. /**
  89137. * Set the transparent sort comparison function.
  89138. * If null the sub meshes will be render in the order they were created
  89139. */
  89140. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89141. /**
  89142. * Creates a new rendering group.
  89143. * @param index The rendering group index
  89144. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89145. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89146. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89147. */
  89148. 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>);
  89149. /**
  89150. * Render all the sub meshes contained in the group.
  89151. * @param customRenderFunction Used to override the default render behaviour of the group.
  89152. * @returns true if rendered some submeshes.
  89153. */
  89154. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89155. /**
  89156. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89157. * @param subMeshes The submeshes to render
  89158. */
  89159. private renderOpaqueSorted;
  89160. /**
  89161. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89162. * @param subMeshes The submeshes to render
  89163. */
  89164. private renderAlphaTestSorted;
  89165. /**
  89166. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89167. * @param subMeshes The submeshes to render
  89168. */
  89169. private renderTransparentSorted;
  89170. /**
  89171. * Renders the submeshes in a specified order.
  89172. * @param subMeshes The submeshes to sort before render
  89173. * @param sortCompareFn The comparison function use to sort
  89174. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89175. * @param transparent Specifies to activate blending if true
  89176. */
  89177. private static renderSorted;
  89178. /**
  89179. * Renders the submeshes in the order they were dispatched (no sort applied).
  89180. * @param subMeshes The submeshes to render
  89181. */
  89182. private static renderUnsorted;
  89183. /**
  89184. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89185. * are rendered back to front if in the same alpha index.
  89186. *
  89187. * @param a The first submesh
  89188. * @param b The second submesh
  89189. * @returns The result of the comparison
  89190. */
  89191. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89192. /**
  89193. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89194. * are rendered back to front.
  89195. *
  89196. * @param a The first submesh
  89197. * @param b The second submesh
  89198. * @returns The result of the comparison
  89199. */
  89200. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89201. /**
  89202. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89203. * are rendered front to back (prevent overdraw).
  89204. *
  89205. * @param a The first submesh
  89206. * @param b The second submesh
  89207. * @returns The result of the comparison
  89208. */
  89209. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89210. /**
  89211. * Resets the different lists of submeshes to prepare a new frame.
  89212. */
  89213. prepare(): void;
  89214. dispose(): void;
  89215. /**
  89216. * Inserts the submesh in its correct queue depending on its material.
  89217. * @param subMesh The submesh to dispatch
  89218. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89219. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89220. */
  89221. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89222. dispatchSprites(spriteManager: ISpriteManager): void;
  89223. dispatchParticles(particleSystem: IParticleSystem): void;
  89224. private _renderParticles;
  89225. private _renderSprites;
  89226. }
  89227. }
  89228. declare module BABYLON {
  89229. /**
  89230. * Interface describing the different options available in the rendering manager
  89231. * regarding Auto Clear between groups.
  89232. */
  89233. export interface IRenderingManagerAutoClearSetup {
  89234. /**
  89235. * Defines whether or not autoclear is enable.
  89236. */
  89237. autoClear: boolean;
  89238. /**
  89239. * Defines whether or not to autoclear the depth buffer.
  89240. */
  89241. depth: boolean;
  89242. /**
  89243. * Defines whether or not to autoclear the stencil buffer.
  89244. */
  89245. stencil: boolean;
  89246. }
  89247. /**
  89248. * This class is used by the onRenderingGroupObservable
  89249. */
  89250. export class RenderingGroupInfo {
  89251. /**
  89252. * The Scene that being rendered
  89253. */
  89254. scene: Scene;
  89255. /**
  89256. * The camera currently used for the rendering pass
  89257. */
  89258. camera: Nullable<Camera>;
  89259. /**
  89260. * The ID of the renderingGroup being processed
  89261. */
  89262. renderingGroupId: number;
  89263. }
  89264. /**
  89265. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89266. * It is enable to manage the different groups as well as the different necessary sort functions.
  89267. * This should not be used directly aside of the few static configurations
  89268. */
  89269. export class RenderingManager {
  89270. /**
  89271. * The max id used for rendering groups (not included)
  89272. */
  89273. static MAX_RENDERINGGROUPS: number;
  89274. /**
  89275. * The min id used for rendering groups (included)
  89276. */
  89277. static MIN_RENDERINGGROUPS: number;
  89278. /**
  89279. * Used to globally prevent autoclearing scenes.
  89280. */
  89281. static AUTOCLEAR: boolean;
  89282. /**
  89283. * @hidden
  89284. */
  89285. _useSceneAutoClearSetup: boolean;
  89286. private _scene;
  89287. private _renderingGroups;
  89288. private _depthStencilBufferAlreadyCleaned;
  89289. private _autoClearDepthStencil;
  89290. private _customOpaqueSortCompareFn;
  89291. private _customAlphaTestSortCompareFn;
  89292. private _customTransparentSortCompareFn;
  89293. private _renderingGroupInfo;
  89294. /**
  89295. * Instantiates a new rendering group for a particular scene
  89296. * @param scene Defines the scene the groups belongs to
  89297. */
  89298. constructor(scene: Scene);
  89299. private _clearDepthStencilBuffer;
  89300. /**
  89301. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89302. * @hidden
  89303. */
  89304. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89305. /**
  89306. * Resets the different information of the group to prepare a new frame
  89307. * @hidden
  89308. */
  89309. reset(): void;
  89310. /**
  89311. * Dispose and release the group and its associated resources.
  89312. * @hidden
  89313. */
  89314. dispose(): void;
  89315. /**
  89316. * Clear the info related to rendering groups preventing retention points during dispose.
  89317. */
  89318. freeRenderingGroups(): void;
  89319. private _prepareRenderingGroup;
  89320. /**
  89321. * Add a sprite manager to the rendering manager in order to render it this frame.
  89322. * @param spriteManager Define the sprite manager to render
  89323. */
  89324. dispatchSprites(spriteManager: ISpriteManager): void;
  89325. /**
  89326. * Add a particle system to the rendering manager in order to render it this frame.
  89327. * @param particleSystem Define the particle system to render
  89328. */
  89329. dispatchParticles(particleSystem: IParticleSystem): void;
  89330. /**
  89331. * Add a submesh to the manager in order to render it this frame
  89332. * @param subMesh The submesh to dispatch
  89333. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89334. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89335. */
  89336. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89337. /**
  89338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89339. * This allowed control for front to back rendering or reversly depending of the special needs.
  89340. *
  89341. * @param renderingGroupId The rendering group id corresponding to its index
  89342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89345. */
  89346. 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;
  89347. /**
  89348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89349. *
  89350. * @param renderingGroupId The rendering group id corresponding to its index
  89351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89352. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89353. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89354. */
  89355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89356. /**
  89357. * Gets the current auto clear configuration for one rendering group of the rendering
  89358. * manager.
  89359. * @param index the rendering group index to get the information for
  89360. * @returns The auto clear setup for the requested rendering group
  89361. */
  89362. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89363. }
  89364. }
  89365. declare module BABYLON {
  89366. /**
  89367. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89368. */
  89369. export interface ICustomShaderOptions {
  89370. /**
  89371. * Gets or sets the custom shader name to use
  89372. */
  89373. shaderName: string;
  89374. /**
  89375. * The list of attribute names used in the shader
  89376. */
  89377. attributes?: string[];
  89378. /**
  89379. * The list of unifrom names used in the shader
  89380. */
  89381. uniforms?: string[];
  89382. /**
  89383. * The list of sampler names used in the shader
  89384. */
  89385. samplers?: string[];
  89386. /**
  89387. * The list of defines used in the shader
  89388. */
  89389. defines?: string[];
  89390. }
  89391. /**
  89392. * Interface to implement to create a shadow generator compatible with BJS.
  89393. */
  89394. export interface IShadowGenerator {
  89395. /**
  89396. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89397. * @returns The render target texture if present otherwise, null
  89398. */
  89399. getShadowMap(): Nullable<RenderTargetTexture>;
  89400. /**
  89401. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89402. * @param subMesh The submesh we want to render in the shadow map
  89403. * @param useInstances Defines wether will draw in the map using instances
  89404. * @returns true if ready otherwise, false
  89405. */
  89406. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89407. /**
  89408. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89409. * @param defines Defines of the material we want to update
  89410. * @param lightIndex Index of the light in the enabled light list of the material
  89411. */
  89412. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89413. /**
  89414. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89415. * defined in the generator but impacting the effect).
  89416. * It implies the unifroms available on the materials are the standard BJS ones.
  89417. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89418. * @param effect The effect we are binfing the information for
  89419. */
  89420. bindShadowLight(lightIndex: string, effect: Effect): void;
  89421. /**
  89422. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89423. * (eq to shadow prjection matrix * light transform matrix)
  89424. * @returns The transform matrix used to create the shadow map
  89425. */
  89426. getTransformMatrix(): Matrix;
  89427. /**
  89428. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89429. * Cube and 2D textures for instance.
  89430. */
  89431. recreateShadowMap(): void;
  89432. /**
  89433. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89434. * @param onCompiled Callback triggered at the and of the effects compilation
  89435. * @param options Sets of optional options forcing the compilation with different modes
  89436. */
  89437. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89438. useInstances: boolean;
  89439. }>): void;
  89440. /**
  89441. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89442. * @param options Sets of optional options forcing the compilation with different modes
  89443. * @returns A promise that resolves when the compilation completes
  89444. */
  89445. forceCompilationAsync(options?: Partial<{
  89446. useInstances: boolean;
  89447. }>): Promise<void>;
  89448. /**
  89449. * Serializes the shadow generator setup to a json object.
  89450. * @returns The serialized JSON object
  89451. */
  89452. serialize(): any;
  89453. /**
  89454. * Disposes the Shadow map and related Textures and effects.
  89455. */
  89456. dispose(): void;
  89457. }
  89458. /**
  89459. * Default implementation IShadowGenerator.
  89460. * This is the main object responsible of generating shadows in the framework.
  89461. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89462. */
  89463. export class ShadowGenerator implements IShadowGenerator {
  89464. /**
  89465. * Name of the shadow generator class
  89466. */
  89467. static CLASSNAME: string;
  89468. /**
  89469. * Shadow generator mode None: no filtering applied.
  89470. */
  89471. static readonly FILTER_NONE: number;
  89472. /**
  89473. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89475. */
  89476. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89477. /**
  89478. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89479. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89480. */
  89481. static readonly FILTER_POISSONSAMPLING: number;
  89482. /**
  89483. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89485. */
  89486. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89487. /**
  89488. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89489. * edge artifacts on steep falloff.
  89490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89491. */
  89492. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89493. /**
  89494. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89495. * edge artifacts on steep falloff.
  89496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89497. */
  89498. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89499. /**
  89500. * Shadow generator mode PCF: Percentage Closer Filtering
  89501. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89502. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89503. */
  89504. static readonly FILTER_PCF: number;
  89505. /**
  89506. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89507. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89508. * Contact Hardening
  89509. */
  89510. static readonly FILTER_PCSS: number;
  89511. /**
  89512. * Reserved for PCF and PCSS
  89513. * Highest Quality.
  89514. *
  89515. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89516. *
  89517. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89518. */
  89519. static readonly QUALITY_HIGH: number;
  89520. /**
  89521. * Reserved for PCF and PCSS
  89522. * Good tradeoff for quality/perf cross devices
  89523. *
  89524. * Execute PCF on a 3*3 kernel.
  89525. *
  89526. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89527. */
  89528. static readonly QUALITY_MEDIUM: number;
  89529. /**
  89530. * Reserved for PCF and PCSS
  89531. * The lowest quality but the fastest.
  89532. *
  89533. * Execute PCF on a 1*1 kernel.
  89534. *
  89535. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89536. */
  89537. static readonly QUALITY_LOW: number;
  89538. /** Gets or sets the custom shader name to use */
  89539. customShaderOptions: ICustomShaderOptions;
  89540. /**
  89541. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89542. */
  89543. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89544. /**
  89545. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89546. */
  89547. onAfterShadowMapRenderObservable: Observable<Effect>;
  89548. /**
  89549. * Observable triggered before a mesh is rendered in the shadow map.
  89550. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89551. */
  89552. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89553. /**
  89554. * Observable triggered after a mesh is rendered in the shadow map.
  89555. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89556. */
  89557. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89558. protected _bias: number;
  89559. /**
  89560. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89561. */
  89562. get bias(): number;
  89563. /**
  89564. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89565. */
  89566. set bias(bias: number);
  89567. protected _normalBias: number;
  89568. /**
  89569. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89570. */
  89571. get normalBias(): number;
  89572. /**
  89573. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89574. */
  89575. set normalBias(normalBias: number);
  89576. protected _blurBoxOffset: number;
  89577. /**
  89578. * Gets the blur box offset: offset applied during the blur pass.
  89579. * Only useful if useKernelBlur = false
  89580. */
  89581. get blurBoxOffset(): number;
  89582. /**
  89583. * Sets the blur box offset: offset applied during the blur pass.
  89584. * Only useful if useKernelBlur = false
  89585. */
  89586. set blurBoxOffset(value: number);
  89587. protected _blurScale: number;
  89588. /**
  89589. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89590. * 2 means half of the size.
  89591. */
  89592. get blurScale(): number;
  89593. /**
  89594. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89595. * 2 means half of the size.
  89596. */
  89597. set blurScale(value: number);
  89598. protected _blurKernel: number;
  89599. /**
  89600. * Gets the blur kernel: kernel size of the blur pass.
  89601. * Only useful if useKernelBlur = true
  89602. */
  89603. get blurKernel(): number;
  89604. /**
  89605. * Sets the blur kernel: kernel size of the blur pass.
  89606. * Only useful if useKernelBlur = true
  89607. */
  89608. set blurKernel(value: number);
  89609. protected _useKernelBlur: boolean;
  89610. /**
  89611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89613. */
  89614. get useKernelBlur(): boolean;
  89615. /**
  89616. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89617. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89618. */
  89619. set useKernelBlur(value: boolean);
  89620. protected _depthScale: number;
  89621. /**
  89622. * Gets the depth scale used in ESM mode.
  89623. */
  89624. get depthScale(): number;
  89625. /**
  89626. * Sets the depth scale used in ESM mode.
  89627. * This can override the scale stored on the light.
  89628. */
  89629. set depthScale(value: number);
  89630. protected _validateFilter(filter: number): number;
  89631. protected _filter: number;
  89632. /**
  89633. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89634. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89635. */
  89636. get filter(): number;
  89637. /**
  89638. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89639. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89640. */
  89641. set filter(value: number);
  89642. /**
  89643. * Gets if the current filter is set to Poisson Sampling.
  89644. */
  89645. get usePoissonSampling(): boolean;
  89646. /**
  89647. * Sets the current filter to Poisson Sampling.
  89648. */
  89649. set usePoissonSampling(value: boolean);
  89650. /**
  89651. * Gets if the current filter is set to ESM.
  89652. */
  89653. get useExponentialShadowMap(): boolean;
  89654. /**
  89655. * Sets the current filter is to ESM.
  89656. */
  89657. set useExponentialShadowMap(value: boolean);
  89658. /**
  89659. * Gets if the current filter is set to filtered ESM.
  89660. */
  89661. get useBlurExponentialShadowMap(): boolean;
  89662. /**
  89663. * Gets if the current filter is set to filtered ESM.
  89664. */
  89665. set useBlurExponentialShadowMap(value: boolean);
  89666. /**
  89667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89668. * exponential to prevent steep falloff artifacts).
  89669. */
  89670. get useCloseExponentialShadowMap(): boolean;
  89671. /**
  89672. * Sets the current filter to "close ESM" (using the inverse of the
  89673. * exponential to prevent steep falloff artifacts).
  89674. */
  89675. set useCloseExponentialShadowMap(value: boolean);
  89676. /**
  89677. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89678. * exponential to prevent steep falloff artifacts).
  89679. */
  89680. get useBlurCloseExponentialShadowMap(): boolean;
  89681. /**
  89682. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89683. * exponential to prevent steep falloff artifacts).
  89684. */
  89685. set useBlurCloseExponentialShadowMap(value: boolean);
  89686. /**
  89687. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89688. */
  89689. get usePercentageCloserFiltering(): boolean;
  89690. /**
  89691. * Sets the current filter to "PCF" (percentage closer filtering).
  89692. */
  89693. set usePercentageCloserFiltering(value: boolean);
  89694. protected _filteringQuality: number;
  89695. /**
  89696. * Gets the PCF or PCSS Quality.
  89697. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89698. */
  89699. get filteringQuality(): number;
  89700. /**
  89701. * Sets the PCF or PCSS Quality.
  89702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89703. */
  89704. set filteringQuality(filteringQuality: number);
  89705. /**
  89706. * Gets if the current filter is set to "PCSS" (contact hardening).
  89707. */
  89708. get useContactHardeningShadow(): boolean;
  89709. /**
  89710. * Sets the current filter to "PCSS" (contact hardening).
  89711. */
  89712. set useContactHardeningShadow(value: boolean);
  89713. protected _contactHardeningLightSizeUVRatio: number;
  89714. /**
  89715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89716. * Using a ratio helps keeping shape stability independently of the map size.
  89717. *
  89718. * It does not account for the light projection as it was having too much
  89719. * instability during the light setup or during light position changes.
  89720. *
  89721. * Only valid if useContactHardeningShadow is true.
  89722. */
  89723. get contactHardeningLightSizeUVRatio(): number;
  89724. /**
  89725. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89726. * Using a ratio helps keeping shape stability independently of the map size.
  89727. *
  89728. * It does not account for the light projection as it was having too much
  89729. * instability during the light setup or during light position changes.
  89730. *
  89731. * Only valid if useContactHardeningShadow is true.
  89732. */
  89733. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89734. protected _darkness: number;
  89735. /** Gets or sets the actual darkness of a shadow */
  89736. get darkness(): number;
  89737. set darkness(value: number);
  89738. /**
  89739. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89740. * 0 means strongest and 1 would means no shadow.
  89741. * @returns the darkness.
  89742. */
  89743. getDarkness(): number;
  89744. /**
  89745. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89746. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89747. * @returns the shadow generator allowing fluent coding.
  89748. */
  89749. setDarkness(darkness: number): ShadowGenerator;
  89750. protected _transparencyShadow: boolean;
  89751. /** Gets or sets the ability to have transparent shadow */
  89752. get transparencyShadow(): boolean;
  89753. set transparencyShadow(value: boolean);
  89754. /**
  89755. * Sets the ability to have transparent shadow (boolean).
  89756. * @param transparent True if transparent else False
  89757. * @returns the shadow generator allowing fluent coding
  89758. */
  89759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89760. protected _shadowMap: Nullable<RenderTargetTexture>;
  89761. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89762. /**
  89763. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89764. * @returns The render target texture if present otherwise, null
  89765. */
  89766. getShadowMap(): Nullable<RenderTargetTexture>;
  89767. /**
  89768. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89769. * @returns The render target texture if the shadow map is present otherwise, null
  89770. */
  89771. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89772. /**
  89773. * Gets the class name of that object
  89774. * @returns "ShadowGenerator"
  89775. */
  89776. getClassName(): string;
  89777. /**
  89778. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89779. * @param mesh Mesh to add
  89780. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89781. * @returns the Shadow Generator itself
  89782. */
  89783. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89784. /**
  89785. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89786. * @param mesh Mesh to remove
  89787. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89788. * @returns the Shadow Generator itself
  89789. */
  89790. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89791. /**
  89792. * Controls the extent to which the shadows fade out at the edge of the frustum
  89793. */
  89794. frustumEdgeFalloff: number;
  89795. protected _light: IShadowLight;
  89796. /**
  89797. * Returns the associated light object.
  89798. * @returns the light generating the shadow
  89799. */
  89800. getLight(): IShadowLight;
  89801. /**
  89802. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89803. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89804. * It might on the other hand introduce peter panning.
  89805. */
  89806. forceBackFacesOnly: boolean;
  89807. protected _scene: Scene;
  89808. protected _lightDirection: Vector3;
  89809. protected _effect: Effect;
  89810. protected _viewMatrix: Matrix;
  89811. protected _projectionMatrix: Matrix;
  89812. protected _transformMatrix: Matrix;
  89813. protected _cachedPosition: Vector3;
  89814. protected _cachedDirection: Vector3;
  89815. protected _cachedDefines: string;
  89816. protected _currentRenderID: number;
  89817. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89818. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89819. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89820. protected _blurPostProcesses: PostProcess[];
  89821. protected _mapSize: number;
  89822. protected _currentFaceIndex: number;
  89823. protected _currentFaceIndexCache: number;
  89824. protected _textureType: number;
  89825. protected _defaultTextureMatrix: Matrix;
  89826. protected _storedUniqueId: Nullable<number>;
  89827. /** @hidden */
  89828. static _SceneComponentInitialization: (scene: Scene) => void;
  89829. /**
  89830. * Creates a ShadowGenerator object.
  89831. * A ShadowGenerator is the required tool to use the shadows.
  89832. * Each light casting shadows needs to use its own ShadowGenerator.
  89833. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89834. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89835. * @param light The light object generating the shadows.
  89836. * @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.
  89837. */
  89838. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89839. protected _initializeGenerator(): void;
  89840. protected _createTargetRenderTexture(): void;
  89841. protected _initializeShadowMap(): void;
  89842. protected _initializeBlurRTTAndPostProcesses(): void;
  89843. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89844. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89845. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89846. protected _applyFilterValues(): void;
  89847. /**
  89848. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89849. * @param onCompiled Callback triggered at the and of the effects compilation
  89850. * @param options Sets of optional options forcing the compilation with different modes
  89851. */
  89852. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89853. useInstances: boolean;
  89854. }>): void;
  89855. /**
  89856. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89857. * @param options Sets of optional options forcing the compilation with different modes
  89858. * @returns A promise that resolves when the compilation completes
  89859. */
  89860. forceCompilationAsync(options?: Partial<{
  89861. useInstances: boolean;
  89862. }>): Promise<void>;
  89863. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89864. /**
  89865. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89866. * @param subMesh The submesh we want to render in the shadow map
  89867. * @param useInstances Defines wether will draw in the map using instances
  89868. * @returns true if ready otherwise, false
  89869. */
  89870. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89871. /**
  89872. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89873. * @param defines Defines of the material we want to update
  89874. * @param lightIndex Index of the light in the enabled light list of the material
  89875. */
  89876. prepareDefines(defines: any, lightIndex: number): void;
  89877. /**
  89878. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89879. * defined in the generator but impacting the effect).
  89880. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89881. * @param effect The effect we are binfing the information for
  89882. */
  89883. bindShadowLight(lightIndex: string, effect: Effect): void;
  89884. /**
  89885. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89886. * (eq to shadow prjection matrix * light transform matrix)
  89887. * @returns The transform matrix used to create the shadow map
  89888. */
  89889. getTransformMatrix(): Matrix;
  89890. /**
  89891. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89892. * Cube and 2D textures for instance.
  89893. */
  89894. recreateShadowMap(): void;
  89895. protected _disposeBlurPostProcesses(): void;
  89896. protected _disposeRTTandPostProcesses(): void;
  89897. /**
  89898. * Disposes the ShadowGenerator.
  89899. * Returns nothing.
  89900. */
  89901. dispose(): void;
  89902. /**
  89903. * Serializes the shadow generator setup to a json object.
  89904. * @returns The serialized JSON object
  89905. */
  89906. serialize(): any;
  89907. /**
  89908. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89909. * @param parsedShadowGenerator The JSON object to parse
  89910. * @param scene The scene to create the shadow map for
  89911. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89912. * @returns The parsed shadow generator
  89913. */
  89914. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89915. }
  89916. }
  89917. declare module BABYLON {
  89918. /**
  89919. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89920. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89921. * 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.
  89922. */
  89923. export abstract class Light extends Node {
  89924. /**
  89925. * Falloff Default: light is falling off following the material specification:
  89926. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89927. */
  89928. static readonly FALLOFF_DEFAULT: number;
  89929. /**
  89930. * Falloff Physical: light is falling off following the inverse squared distance law.
  89931. */
  89932. static readonly FALLOFF_PHYSICAL: number;
  89933. /**
  89934. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89935. * to enhance interoperability with other engines.
  89936. */
  89937. static readonly FALLOFF_GLTF: number;
  89938. /**
  89939. * Falloff Standard: light is falling off like in the standard material
  89940. * to enhance interoperability with other materials.
  89941. */
  89942. static readonly FALLOFF_STANDARD: number;
  89943. /**
  89944. * If every light affecting the material is in this lightmapMode,
  89945. * material.lightmapTexture adds or multiplies
  89946. * (depends on material.useLightmapAsShadowmap)
  89947. * after every other light calculations.
  89948. */
  89949. static readonly LIGHTMAP_DEFAULT: number;
  89950. /**
  89951. * material.lightmapTexture as only diffuse lighting from this light
  89952. * adds only specular lighting from this light
  89953. * adds dynamic shadows
  89954. */
  89955. static readonly LIGHTMAP_SPECULAR: number;
  89956. /**
  89957. * material.lightmapTexture as only lighting
  89958. * no light calculation from this light
  89959. * only adds dynamic shadows from this light
  89960. */
  89961. static readonly LIGHTMAP_SHADOWSONLY: number;
  89962. /**
  89963. * Each light type uses the default quantity according to its type:
  89964. * point/spot lights use luminous intensity
  89965. * directional lights use illuminance
  89966. */
  89967. static readonly INTENSITYMODE_AUTOMATIC: number;
  89968. /**
  89969. * lumen (lm)
  89970. */
  89971. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89972. /**
  89973. * candela (lm/sr)
  89974. */
  89975. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89976. /**
  89977. * lux (lm/m^2)
  89978. */
  89979. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89980. /**
  89981. * nit (cd/m^2)
  89982. */
  89983. static readonly INTENSITYMODE_LUMINANCE: number;
  89984. /**
  89985. * Light type const id of the point light.
  89986. */
  89987. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89988. /**
  89989. * Light type const id of the directional light.
  89990. */
  89991. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89992. /**
  89993. * Light type const id of the spot light.
  89994. */
  89995. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89996. /**
  89997. * Light type const id of the hemispheric light.
  89998. */
  89999. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90000. /**
  90001. * Diffuse gives the basic color to an object.
  90002. */
  90003. diffuse: Color3;
  90004. /**
  90005. * Specular produces a highlight color on an object.
  90006. * Note: This is note affecting PBR materials.
  90007. */
  90008. specular: Color3;
  90009. /**
  90010. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90011. * falling off base on range or angle.
  90012. * This can be set to any values in Light.FALLOFF_x.
  90013. *
  90014. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90015. * other types of materials.
  90016. */
  90017. falloffType: number;
  90018. /**
  90019. * Strength of the light.
  90020. * Note: By default it is define in the framework own unit.
  90021. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90022. */
  90023. intensity: number;
  90024. private _range;
  90025. protected _inverseSquaredRange: number;
  90026. /**
  90027. * Defines how far from the source the light is impacting in scene units.
  90028. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90029. */
  90030. get range(): number;
  90031. /**
  90032. * Defines how far from the source the light is impacting in scene units.
  90033. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90034. */
  90035. set range(value: number);
  90036. /**
  90037. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90038. * of light.
  90039. */
  90040. private _photometricScale;
  90041. private _intensityMode;
  90042. /**
  90043. * Gets the photometric scale used to interpret the intensity.
  90044. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90045. */
  90046. get intensityMode(): number;
  90047. /**
  90048. * Sets the photometric scale used to interpret the intensity.
  90049. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90050. */
  90051. set intensityMode(value: number);
  90052. private _radius;
  90053. /**
  90054. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90055. */
  90056. get radius(): number;
  90057. /**
  90058. * sets the light radius used by PBR Materials to simulate soft area lights.
  90059. */
  90060. set radius(value: number);
  90061. private _renderPriority;
  90062. /**
  90063. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90064. * exceeding the number allowed of the materials.
  90065. */
  90066. renderPriority: number;
  90067. private _shadowEnabled;
  90068. /**
  90069. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90070. * the current shadow generator.
  90071. */
  90072. get shadowEnabled(): boolean;
  90073. /**
  90074. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90075. * the current shadow generator.
  90076. */
  90077. set shadowEnabled(value: boolean);
  90078. private _includedOnlyMeshes;
  90079. /**
  90080. * Gets the only meshes impacted by this light.
  90081. */
  90082. get includedOnlyMeshes(): AbstractMesh[];
  90083. /**
  90084. * Sets the only meshes impacted by this light.
  90085. */
  90086. set includedOnlyMeshes(value: AbstractMesh[]);
  90087. private _excludedMeshes;
  90088. /**
  90089. * Gets the meshes not impacted by this light.
  90090. */
  90091. get excludedMeshes(): AbstractMesh[];
  90092. /**
  90093. * Sets the meshes not impacted by this light.
  90094. */
  90095. set excludedMeshes(value: AbstractMesh[]);
  90096. private _excludeWithLayerMask;
  90097. /**
  90098. * Gets the layer id use to find what meshes are not impacted by the light.
  90099. * Inactive if 0
  90100. */
  90101. get excludeWithLayerMask(): number;
  90102. /**
  90103. * Sets the layer id use to find what meshes are not impacted by the light.
  90104. * Inactive if 0
  90105. */
  90106. set excludeWithLayerMask(value: number);
  90107. private _includeOnlyWithLayerMask;
  90108. /**
  90109. * Gets the layer id use to find what meshes are impacted by the light.
  90110. * Inactive if 0
  90111. */
  90112. get includeOnlyWithLayerMask(): number;
  90113. /**
  90114. * Sets the layer id use to find what meshes are impacted by the light.
  90115. * Inactive if 0
  90116. */
  90117. set includeOnlyWithLayerMask(value: number);
  90118. private _lightmapMode;
  90119. /**
  90120. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90121. */
  90122. get lightmapMode(): number;
  90123. /**
  90124. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90125. */
  90126. set lightmapMode(value: number);
  90127. /**
  90128. * Shadow generator associted to the light.
  90129. * @hidden Internal use only.
  90130. */
  90131. _shadowGenerator: Nullable<IShadowGenerator>;
  90132. /**
  90133. * @hidden Internal use only.
  90134. */
  90135. _excludedMeshesIds: string[];
  90136. /**
  90137. * @hidden Internal use only.
  90138. */
  90139. _includedOnlyMeshesIds: string[];
  90140. /**
  90141. * The current light unifom buffer.
  90142. * @hidden Internal use only.
  90143. */
  90144. _uniformBuffer: UniformBuffer;
  90145. /** @hidden */
  90146. _renderId: number;
  90147. /**
  90148. * Creates a Light object in the scene.
  90149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90150. * @param name The firendly name of the light
  90151. * @param scene The scene the light belongs too
  90152. */
  90153. constructor(name: string, scene: Scene);
  90154. protected abstract _buildUniformLayout(): void;
  90155. /**
  90156. * Sets the passed Effect "effect" with the Light information.
  90157. * @param effect The effect to update
  90158. * @param lightIndex The index of the light in the effect to update
  90159. * @returns The light
  90160. */
  90161. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90162. /**
  90163. * Sets the passed Effect "effect" with the Light textures.
  90164. * @param effect The effect to update
  90165. * @param lightIndex The index of the light in the effect to update
  90166. * @returns The light
  90167. */
  90168. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90169. /**
  90170. * Binds the lights information from the scene to the effect for the given mesh.
  90171. * @param lightIndex Light index
  90172. * @param scene The scene where the light belongs to
  90173. * @param effect The effect we are binding the data to
  90174. * @param useSpecular Defines if specular is supported
  90175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90176. */
  90177. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90178. /**
  90179. * Sets the passed Effect "effect" with the Light information.
  90180. * @param effect The effect to update
  90181. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90182. * @returns The light
  90183. */
  90184. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90185. /**
  90186. * Returns the string "Light".
  90187. * @returns the class name
  90188. */
  90189. getClassName(): string;
  90190. /** @hidden */
  90191. readonly _isLight: boolean;
  90192. /**
  90193. * Converts the light information to a readable string for debug purpose.
  90194. * @param fullDetails Supports for multiple levels of logging within scene loading
  90195. * @returns the human readable light info
  90196. */
  90197. toString(fullDetails?: boolean): string;
  90198. /** @hidden */
  90199. protected _syncParentEnabledState(): void;
  90200. /**
  90201. * Set the enabled state of this node.
  90202. * @param value - the new enabled state
  90203. */
  90204. setEnabled(value: boolean): void;
  90205. /**
  90206. * Returns the Light associated shadow generator if any.
  90207. * @return the associated shadow generator.
  90208. */
  90209. getShadowGenerator(): Nullable<IShadowGenerator>;
  90210. /**
  90211. * Returns a Vector3, the absolute light position in the World.
  90212. * @returns the world space position of the light
  90213. */
  90214. getAbsolutePosition(): Vector3;
  90215. /**
  90216. * Specifies if the light will affect the passed mesh.
  90217. * @param mesh The mesh to test against the light
  90218. * @return true the mesh is affected otherwise, false.
  90219. */
  90220. canAffectMesh(mesh: AbstractMesh): boolean;
  90221. /**
  90222. * Sort function to order lights for rendering.
  90223. * @param a First Light object to compare to second.
  90224. * @param b Second Light object to compare first.
  90225. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90226. */
  90227. static CompareLightsPriority(a: Light, b: Light): number;
  90228. /**
  90229. * Releases resources associated with this node.
  90230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90232. */
  90233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90234. /**
  90235. * Returns the light type ID (integer).
  90236. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90237. */
  90238. getTypeID(): number;
  90239. /**
  90240. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90241. * @returns the scaled intensity in intensity mode unit
  90242. */
  90243. getScaledIntensity(): number;
  90244. /**
  90245. * Returns a new Light object, named "name", from the current one.
  90246. * @param name The name of the cloned light
  90247. * @returns the new created light
  90248. */
  90249. clone(name: string): Nullable<Light>;
  90250. /**
  90251. * Serializes the current light into a Serialization object.
  90252. * @returns the serialized object.
  90253. */
  90254. serialize(): any;
  90255. /**
  90256. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90257. * This new light is named "name" and added to the passed scene.
  90258. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90259. * @param name The friendly name of the light
  90260. * @param scene The scene the new light will belong to
  90261. * @returns the constructor function
  90262. */
  90263. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90264. /**
  90265. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90266. * @param parsedLight The JSON representation of the light
  90267. * @param scene The scene to create the parsed light in
  90268. * @returns the created light after parsing
  90269. */
  90270. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90271. private _hookArrayForExcluded;
  90272. private _hookArrayForIncludedOnly;
  90273. private _resyncMeshes;
  90274. /**
  90275. * Forces the meshes to update their light related information in their rendering used effects
  90276. * @hidden Internal Use Only
  90277. */
  90278. _markMeshesAsLightDirty(): void;
  90279. /**
  90280. * Recomputes the cached photometric scale if needed.
  90281. */
  90282. private _computePhotometricScale;
  90283. /**
  90284. * Returns the Photometric Scale according to the light type and intensity mode.
  90285. */
  90286. private _getPhotometricScale;
  90287. /**
  90288. * Reorder the light in the scene according to their defined priority.
  90289. * @hidden Internal Use Only
  90290. */
  90291. _reorderLightsInScene(): void;
  90292. /**
  90293. * Prepares the list of defines specific to the light type.
  90294. * @param defines the list of defines
  90295. * @param lightIndex defines the index of the light for the effect
  90296. */
  90297. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90298. }
  90299. }
  90300. declare module BABYLON {
  90301. /**
  90302. * Interface used to define Action
  90303. */
  90304. export interface IAction {
  90305. /**
  90306. * Trigger for the action
  90307. */
  90308. trigger: number;
  90309. /** Options of the trigger */
  90310. triggerOptions: any;
  90311. /**
  90312. * Gets the trigger parameters
  90313. * @returns the trigger parameters
  90314. */
  90315. getTriggerParameter(): any;
  90316. /**
  90317. * Internal only - executes current action event
  90318. * @hidden
  90319. */
  90320. _executeCurrent(evt?: ActionEvent): void;
  90321. /**
  90322. * Serialize placeholder for child classes
  90323. * @param parent of child
  90324. * @returns the serialized object
  90325. */
  90326. serialize(parent: any): any;
  90327. /**
  90328. * Internal only
  90329. * @hidden
  90330. */
  90331. _prepare(): void;
  90332. /**
  90333. * Internal only - manager for action
  90334. * @hidden
  90335. */
  90336. _actionManager: AbstractActionManager;
  90337. /**
  90338. * Adds action to chain of actions, may be a DoNothingAction
  90339. * @param action defines the next action to execute
  90340. * @returns The action passed in
  90341. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90342. */
  90343. then(action: IAction): IAction;
  90344. }
  90345. /**
  90346. * The action to be carried out following a trigger
  90347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90348. */
  90349. export class Action implements IAction {
  90350. /** the trigger, with or without parameters, for the action */
  90351. triggerOptions: any;
  90352. /**
  90353. * Trigger for the action
  90354. */
  90355. trigger: number;
  90356. /**
  90357. * Internal only - manager for action
  90358. * @hidden
  90359. */
  90360. _actionManager: ActionManager;
  90361. private _nextActiveAction;
  90362. private _child;
  90363. private _condition?;
  90364. private _triggerParameter;
  90365. /**
  90366. * An event triggered prior to action being executed.
  90367. */
  90368. onBeforeExecuteObservable: Observable<Action>;
  90369. /**
  90370. * Creates a new Action
  90371. * @param triggerOptions the trigger, with or without parameters, for the action
  90372. * @param condition an optional determinant of action
  90373. */
  90374. constructor(
  90375. /** the trigger, with or without parameters, for the action */
  90376. triggerOptions: any, condition?: Condition);
  90377. /**
  90378. * Internal only
  90379. * @hidden
  90380. */
  90381. _prepare(): void;
  90382. /**
  90383. * Gets the trigger parameters
  90384. * @returns the trigger parameters
  90385. */
  90386. getTriggerParameter(): any;
  90387. /**
  90388. * Internal only - executes current action event
  90389. * @hidden
  90390. */
  90391. _executeCurrent(evt?: ActionEvent): void;
  90392. /**
  90393. * Execute placeholder for child classes
  90394. * @param evt optional action event
  90395. */
  90396. execute(evt?: ActionEvent): void;
  90397. /**
  90398. * Skips to next active action
  90399. */
  90400. skipToNextActiveAction(): void;
  90401. /**
  90402. * Adds action to chain of actions, may be a DoNothingAction
  90403. * @param action defines the next action to execute
  90404. * @returns The action passed in
  90405. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90406. */
  90407. then(action: Action): Action;
  90408. /**
  90409. * Internal only
  90410. * @hidden
  90411. */
  90412. _getProperty(propertyPath: string): string;
  90413. /**
  90414. * Internal only
  90415. * @hidden
  90416. */
  90417. _getEffectiveTarget(target: any, propertyPath: string): any;
  90418. /**
  90419. * Serialize placeholder for child classes
  90420. * @param parent of child
  90421. * @returns the serialized object
  90422. */
  90423. serialize(parent: any): any;
  90424. /**
  90425. * Internal only called by serialize
  90426. * @hidden
  90427. */
  90428. protected _serialize(serializedAction: any, parent?: any): any;
  90429. /**
  90430. * Internal only
  90431. * @hidden
  90432. */
  90433. static _SerializeValueAsString: (value: any) => string;
  90434. /**
  90435. * Internal only
  90436. * @hidden
  90437. */
  90438. static _GetTargetProperty: (target: Node | Scene) => {
  90439. name: string;
  90440. targetType: string;
  90441. value: string;
  90442. };
  90443. }
  90444. }
  90445. declare module BABYLON {
  90446. /**
  90447. * A Condition applied to an Action
  90448. */
  90449. export class Condition {
  90450. /**
  90451. * Internal only - manager for action
  90452. * @hidden
  90453. */
  90454. _actionManager: ActionManager;
  90455. /**
  90456. * Internal only
  90457. * @hidden
  90458. */
  90459. _evaluationId: number;
  90460. /**
  90461. * Internal only
  90462. * @hidden
  90463. */
  90464. _currentResult: boolean;
  90465. /**
  90466. * Creates a new Condition
  90467. * @param actionManager the manager of the action the condition is applied to
  90468. */
  90469. constructor(actionManager: ActionManager);
  90470. /**
  90471. * Check if the current condition is valid
  90472. * @returns a boolean
  90473. */
  90474. isValid(): boolean;
  90475. /**
  90476. * Internal only
  90477. * @hidden
  90478. */
  90479. _getProperty(propertyPath: string): string;
  90480. /**
  90481. * Internal only
  90482. * @hidden
  90483. */
  90484. _getEffectiveTarget(target: any, propertyPath: string): any;
  90485. /**
  90486. * Serialize placeholder for child classes
  90487. * @returns the serialized object
  90488. */
  90489. serialize(): any;
  90490. /**
  90491. * Internal only
  90492. * @hidden
  90493. */
  90494. protected _serialize(serializedCondition: any): any;
  90495. }
  90496. /**
  90497. * Defines specific conditional operators as extensions of Condition
  90498. */
  90499. export class ValueCondition extends Condition {
  90500. /** path to specify the property of the target the conditional operator uses */
  90501. propertyPath: string;
  90502. /** the value compared by the conditional operator against the current value of the property */
  90503. value: any;
  90504. /** the conditional operator, default ValueCondition.IsEqual */
  90505. operator: number;
  90506. /**
  90507. * Internal only
  90508. * @hidden
  90509. */
  90510. private static _IsEqual;
  90511. /**
  90512. * Internal only
  90513. * @hidden
  90514. */
  90515. private static _IsDifferent;
  90516. /**
  90517. * Internal only
  90518. * @hidden
  90519. */
  90520. private static _IsGreater;
  90521. /**
  90522. * Internal only
  90523. * @hidden
  90524. */
  90525. private static _IsLesser;
  90526. /**
  90527. * returns the number for IsEqual
  90528. */
  90529. static get IsEqual(): number;
  90530. /**
  90531. * Returns the number for IsDifferent
  90532. */
  90533. static get IsDifferent(): number;
  90534. /**
  90535. * Returns the number for IsGreater
  90536. */
  90537. static get IsGreater(): number;
  90538. /**
  90539. * Returns the number for IsLesser
  90540. */
  90541. static get IsLesser(): number;
  90542. /**
  90543. * Internal only The action manager for the condition
  90544. * @hidden
  90545. */
  90546. _actionManager: ActionManager;
  90547. /**
  90548. * Internal only
  90549. * @hidden
  90550. */
  90551. private _target;
  90552. /**
  90553. * Internal only
  90554. * @hidden
  90555. */
  90556. private _effectiveTarget;
  90557. /**
  90558. * Internal only
  90559. * @hidden
  90560. */
  90561. private _property;
  90562. /**
  90563. * Creates a new ValueCondition
  90564. * @param actionManager manager for the action the condition applies to
  90565. * @param target for the action
  90566. * @param propertyPath path to specify the property of the target the conditional operator uses
  90567. * @param value the value compared by the conditional operator against the current value of the property
  90568. * @param operator the conditional operator, default ValueCondition.IsEqual
  90569. */
  90570. constructor(actionManager: ActionManager, target: any,
  90571. /** path to specify the property of the target the conditional operator uses */
  90572. propertyPath: string,
  90573. /** the value compared by the conditional operator against the current value of the property */
  90574. value: any,
  90575. /** the conditional operator, default ValueCondition.IsEqual */
  90576. operator?: number);
  90577. /**
  90578. * Compares the given value with the property value for the specified conditional operator
  90579. * @returns the result of the comparison
  90580. */
  90581. isValid(): boolean;
  90582. /**
  90583. * Serialize the ValueCondition into a JSON compatible object
  90584. * @returns serialization object
  90585. */
  90586. serialize(): any;
  90587. /**
  90588. * Gets the name of the conditional operator for the ValueCondition
  90589. * @param operator the conditional operator
  90590. * @returns the name
  90591. */
  90592. static GetOperatorName(operator: number): string;
  90593. }
  90594. /**
  90595. * Defines a predicate condition as an extension of Condition
  90596. */
  90597. export class PredicateCondition extends Condition {
  90598. /** defines the predicate function used to validate the condition */
  90599. predicate: () => boolean;
  90600. /**
  90601. * Internal only - manager for action
  90602. * @hidden
  90603. */
  90604. _actionManager: ActionManager;
  90605. /**
  90606. * Creates a new PredicateCondition
  90607. * @param actionManager manager for the action the condition applies to
  90608. * @param predicate defines the predicate function used to validate the condition
  90609. */
  90610. constructor(actionManager: ActionManager,
  90611. /** defines the predicate function used to validate the condition */
  90612. predicate: () => boolean);
  90613. /**
  90614. * @returns the validity of the predicate condition
  90615. */
  90616. isValid(): boolean;
  90617. }
  90618. /**
  90619. * Defines a state condition as an extension of Condition
  90620. */
  90621. export class StateCondition extends Condition {
  90622. /** Value to compare with target state */
  90623. value: string;
  90624. /**
  90625. * Internal only - manager for action
  90626. * @hidden
  90627. */
  90628. _actionManager: ActionManager;
  90629. /**
  90630. * Internal only
  90631. * @hidden
  90632. */
  90633. private _target;
  90634. /**
  90635. * Creates a new StateCondition
  90636. * @param actionManager manager for the action the condition applies to
  90637. * @param target of the condition
  90638. * @param value to compare with target state
  90639. */
  90640. constructor(actionManager: ActionManager, target: any,
  90641. /** Value to compare with target state */
  90642. value: string);
  90643. /**
  90644. * Gets a boolean indicating if the current condition is met
  90645. * @returns the validity of the state
  90646. */
  90647. isValid(): boolean;
  90648. /**
  90649. * Serialize the StateCondition into a JSON compatible object
  90650. * @returns serialization object
  90651. */
  90652. serialize(): any;
  90653. }
  90654. }
  90655. declare module BABYLON {
  90656. /**
  90657. * This defines an action responsible to toggle a boolean once triggered.
  90658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90659. */
  90660. export class SwitchBooleanAction extends Action {
  90661. /**
  90662. * The path to the boolean property in the target object
  90663. */
  90664. propertyPath: string;
  90665. private _target;
  90666. private _effectiveTarget;
  90667. private _property;
  90668. /**
  90669. * Instantiate the action
  90670. * @param triggerOptions defines the trigger options
  90671. * @param target defines the object containing the boolean
  90672. * @param propertyPath defines the path to the boolean property in the target object
  90673. * @param condition defines the trigger related conditions
  90674. */
  90675. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90676. /** @hidden */
  90677. _prepare(): void;
  90678. /**
  90679. * Execute the action toggle the boolean value.
  90680. */
  90681. execute(): void;
  90682. /**
  90683. * Serializes the actions and its related information.
  90684. * @param parent defines the object to serialize in
  90685. * @returns the serialized object
  90686. */
  90687. serialize(parent: any): any;
  90688. }
  90689. /**
  90690. * This defines an action responsible to set a the state field of the target
  90691. * to a desired value once triggered.
  90692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90693. */
  90694. export class SetStateAction extends Action {
  90695. /**
  90696. * The value to store in the state field.
  90697. */
  90698. value: string;
  90699. private _target;
  90700. /**
  90701. * Instantiate the action
  90702. * @param triggerOptions defines the trigger options
  90703. * @param target defines the object containing the state property
  90704. * @param value defines the value to store in the state field
  90705. * @param condition defines the trigger related conditions
  90706. */
  90707. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90708. /**
  90709. * Execute the action and store the value on the target state property.
  90710. */
  90711. execute(): void;
  90712. /**
  90713. * Serializes the actions and its related information.
  90714. * @param parent defines the object to serialize in
  90715. * @returns the serialized object
  90716. */
  90717. serialize(parent: any): any;
  90718. }
  90719. /**
  90720. * This defines an action responsible to set a property of the target
  90721. * to a desired value once triggered.
  90722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90723. */
  90724. export class SetValueAction extends Action {
  90725. /**
  90726. * The path of the property to set in the target.
  90727. */
  90728. propertyPath: string;
  90729. /**
  90730. * The value to set in the property
  90731. */
  90732. value: any;
  90733. private _target;
  90734. private _effectiveTarget;
  90735. private _property;
  90736. /**
  90737. * Instantiate the action
  90738. * @param triggerOptions defines the trigger options
  90739. * @param target defines the object containing the property
  90740. * @param propertyPath defines the path of the property to set in the target
  90741. * @param value defines the value to set in the property
  90742. * @param condition defines the trigger related conditions
  90743. */
  90744. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90745. /** @hidden */
  90746. _prepare(): void;
  90747. /**
  90748. * Execute the action and set the targetted property to the desired value.
  90749. */
  90750. execute(): void;
  90751. /**
  90752. * Serializes the actions and its related information.
  90753. * @param parent defines the object to serialize in
  90754. * @returns the serialized object
  90755. */
  90756. serialize(parent: any): any;
  90757. }
  90758. /**
  90759. * This defines an action responsible to increment the target value
  90760. * to a desired value once triggered.
  90761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90762. */
  90763. export class IncrementValueAction extends Action {
  90764. /**
  90765. * The path of the property to increment in the target.
  90766. */
  90767. propertyPath: string;
  90768. /**
  90769. * The value we should increment the property by.
  90770. */
  90771. value: any;
  90772. private _target;
  90773. private _effectiveTarget;
  90774. private _property;
  90775. /**
  90776. * Instantiate the action
  90777. * @param triggerOptions defines the trigger options
  90778. * @param target defines the object containing the property
  90779. * @param propertyPath defines the path of the property to increment in the target
  90780. * @param value defines the value value we should increment the property by
  90781. * @param condition defines the trigger related conditions
  90782. */
  90783. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90784. /** @hidden */
  90785. _prepare(): void;
  90786. /**
  90787. * Execute the action and increment the target of the value amount.
  90788. */
  90789. execute(): void;
  90790. /**
  90791. * Serializes the actions and its related information.
  90792. * @param parent defines the object to serialize in
  90793. * @returns the serialized object
  90794. */
  90795. serialize(parent: any): any;
  90796. }
  90797. /**
  90798. * This defines an action responsible to start an animation once triggered.
  90799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90800. */
  90801. export class PlayAnimationAction extends Action {
  90802. /**
  90803. * Where the animation should start (animation frame)
  90804. */
  90805. from: number;
  90806. /**
  90807. * Where the animation should stop (animation frame)
  90808. */
  90809. to: number;
  90810. /**
  90811. * Define if the animation should loop or stop after the first play.
  90812. */
  90813. loop?: boolean;
  90814. private _target;
  90815. /**
  90816. * Instantiate the action
  90817. * @param triggerOptions defines the trigger options
  90818. * @param target defines the target animation or animation name
  90819. * @param from defines from where the animation should start (animation frame)
  90820. * @param end defines where the animation should stop (animation frame)
  90821. * @param loop defines if the animation should loop or stop after the first play
  90822. * @param condition defines the trigger related conditions
  90823. */
  90824. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90825. /** @hidden */
  90826. _prepare(): void;
  90827. /**
  90828. * Execute the action and play the animation.
  90829. */
  90830. execute(): void;
  90831. /**
  90832. * Serializes the actions and its related information.
  90833. * @param parent defines the object to serialize in
  90834. * @returns the serialized object
  90835. */
  90836. serialize(parent: any): any;
  90837. }
  90838. /**
  90839. * This defines an action responsible to stop an animation once triggered.
  90840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90841. */
  90842. export class StopAnimationAction extends Action {
  90843. private _target;
  90844. /**
  90845. * Instantiate the action
  90846. * @param triggerOptions defines the trigger options
  90847. * @param target defines the target animation or animation name
  90848. * @param condition defines the trigger related conditions
  90849. */
  90850. constructor(triggerOptions: any, target: any, condition?: Condition);
  90851. /** @hidden */
  90852. _prepare(): void;
  90853. /**
  90854. * Execute the action and stop the animation.
  90855. */
  90856. execute(): void;
  90857. /**
  90858. * Serializes the actions and its related information.
  90859. * @param parent defines the object to serialize in
  90860. * @returns the serialized object
  90861. */
  90862. serialize(parent: any): any;
  90863. }
  90864. /**
  90865. * This defines an action responsible that does nothing once triggered.
  90866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90867. */
  90868. export class DoNothingAction extends Action {
  90869. /**
  90870. * Instantiate the action
  90871. * @param triggerOptions defines the trigger options
  90872. * @param condition defines the trigger related conditions
  90873. */
  90874. constructor(triggerOptions?: any, condition?: Condition);
  90875. /**
  90876. * Execute the action and do nothing.
  90877. */
  90878. execute(): void;
  90879. /**
  90880. * Serializes the actions and its related information.
  90881. * @param parent defines the object to serialize in
  90882. * @returns the serialized object
  90883. */
  90884. serialize(parent: any): any;
  90885. }
  90886. /**
  90887. * This defines an action responsible to trigger several actions once triggered.
  90888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90889. */
  90890. export class CombineAction extends Action {
  90891. /**
  90892. * The list of aggregated animations to run.
  90893. */
  90894. children: Action[];
  90895. /**
  90896. * Instantiate the action
  90897. * @param triggerOptions defines the trigger options
  90898. * @param children defines the list of aggregated animations to run
  90899. * @param condition defines the trigger related conditions
  90900. */
  90901. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90902. /** @hidden */
  90903. _prepare(): void;
  90904. /**
  90905. * Execute the action and executes all the aggregated actions.
  90906. */
  90907. execute(evt: ActionEvent): void;
  90908. /**
  90909. * Serializes the actions and its related information.
  90910. * @param parent defines the object to serialize in
  90911. * @returns the serialized object
  90912. */
  90913. serialize(parent: any): any;
  90914. }
  90915. /**
  90916. * This defines an action responsible to run code (external event) once triggered.
  90917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90918. */
  90919. export class ExecuteCodeAction extends Action {
  90920. /**
  90921. * The callback function to run.
  90922. */
  90923. func: (evt: ActionEvent) => void;
  90924. /**
  90925. * Instantiate the action
  90926. * @param triggerOptions defines the trigger options
  90927. * @param func defines the callback function to run
  90928. * @param condition defines the trigger related conditions
  90929. */
  90930. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90931. /**
  90932. * Execute the action and run the attached code.
  90933. */
  90934. execute(evt: ActionEvent): void;
  90935. }
  90936. /**
  90937. * This defines an action responsible to set the parent property of the target once triggered.
  90938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90939. */
  90940. export class SetParentAction extends Action {
  90941. private _parent;
  90942. private _target;
  90943. /**
  90944. * Instantiate the action
  90945. * @param triggerOptions defines the trigger options
  90946. * @param target defines the target containing the parent property
  90947. * @param parent defines from where the animation should start (animation frame)
  90948. * @param condition defines the trigger related conditions
  90949. */
  90950. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90951. /** @hidden */
  90952. _prepare(): void;
  90953. /**
  90954. * Execute the action and set the parent property.
  90955. */
  90956. execute(): void;
  90957. /**
  90958. * Serializes the actions and its related information.
  90959. * @param parent defines the object to serialize in
  90960. * @returns the serialized object
  90961. */
  90962. serialize(parent: any): any;
  90963. }
  90964. }
  90965. declare module BABYLON {
  90966. /**
  90967. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90968. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90970. */
  90971. export class ActionManager extends AbstractActionManager {
  90972. /**
  90973. * Nothing
  90974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90975. */
  90976. static readonly NothingTrigger: number;
  90977. /**
  90978. * On pick
  90979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90980. */
  90981. static readonly OnPickTrigger: number;
  90982. /**
  90983. * On left pick
  90984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90985. */
  90986. static readonly OnLeftPickTrigger: number;
  90987. /**
  90988. * On right pick
  90989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90990. */
  90991. static readonly OnRightPickTrigger: number;
  90992. /**
  90993. * On center pick
  90994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90995. */
  90996. static readonly OnCenterPickTrigger: number;
  90997. /**
  90998. * On pick down
  90999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91000. */
  91001. static readonly OnPickDownTrigger: number;
  91002. /**
  91003. * On double pick
  91004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91005. */
  91006. static readonly OnDoublePickTrigger: number;
  91007. /**
  91008. * On pick up
  91009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91010. */
  91011. static readonly OnPickUpTrigger: number;
  91012. /**
  91013. * On pick out.
  91014. * This trigger will only be raised if you also declared a OnPickDown
  91015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91016. */
  91017. static readonly OnPickOutTrigger: number;
  91018. /**
  91019. * On long press
  91020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91021. */
  91022. static readonly OnLongPressTrigger: number;
  91023. /**
  91024. * On pointer over
  91025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91026. */
  91027. static readonly OnPointerOverTrigger: number;
  91028. /**
  91029. * On pointer out
  91030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91031. */
  91032. static readonly OnPointerOutTrigger: number;
  91033. /**
  91034. * On every frame
  91035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91036. */
  91037. static readonly OnEveryFrameTrigger: number;
  91038. /**
  91039. * On intersection enter
  91040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91041. */
  91042. static readonly OnIntersectionEnterTrigger: number;
  91043. /**
  91044. * On intersection exit
  91045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91046. */
  91047. static readonly OnIntersectionExitTrigger: number;
  91048. /**
  91049. * On key down
  91050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91051. */
  91052. static readonly OnKeyDownTrigger: number;
  91053. /**
  91054. * On key up
  91055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91056. */
  91057. static readonly OnKeyUpTrigger: number;
  91058. private _scene;
  91059. /**
  91060. * Creates a new action manager
  91061. * @param scene defines the hosting scene
  91062. */
  91063. constructor(scene: Scene);
  91064. /**
  91065. * Releases all associated resources
  91066. */
  91067. dispose(): void;
  91068. /**
  91069. * Gets hosting scene
  91070. * @returns the hosting scene
  91071. */
  91072. getScene(): Scene;
  91073. /**
  91074. * Does this action manager handles actions of any of the given triggers
  91075. * @param triggers defines the triggers to be tested
  91076. * @return a boolean indicating whether one (or more) of the triggers is handled
  91077. */
  91078. hasSpecificTriggers(triggers: number[]): boolean;
  91079. /**
  91080. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91081. * speed.
  91082. * @param triggerA defines the trigger to be tested
  91083. * @param triggerB defines the trigger to be tested
  91084. * @return a boolean indicating whether one (or more) of the triggers is handled
  91085. */
  91086. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91087. /**
  91088. * Does this action manager handles actions of a given trigger
  91089. * @param trigger defines the trigger to be tested
  91090. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91091. * @return whether the trigger is handled
  91092. */
  91093. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91094. /**
  91095. * Does this action manager has pointer triggers
  91096. */
  91097. get hasPointerTriggers(): boolean;
  91098. /**
  91099. * Does this action manager has pick triggers
  91100. */
  91101. get hasPickTriggers(): boolean;
  91102. /**
  91103. * Registers an action to this action manager
  91104. * @param action defines the action to be registered
  91105. * @return the action amended (prepared) after registration
  91106. */
  91107. registerAction(action: IAction): Nullable<IAction>;
  91108. /**
  91109. * Unregisters an action to this action manager
  91110. * @param action defines the action to be unregistered
  91111. * @return a boolean indicating whether the action has been unregistered
  91112. */
  91113. unregisterAction(action: IAction): Boolean;
  91114. /**
  91115. * Process a specific trigger
  91116. * @param trigger defines the trigger to process
  91117. * @param evt defines the event details to be processed
  91118. */
  91119. processTrigger(trigger: number, evt?: IActionEvent): void;
  91120. /** @hidden */
  91121. _getEffectiveTarget(target: any, propertyPath: string): any;
  91122. /** @hidden */
  91123. _getProperty(propertyPath: string): string;
  91124. /**
  91125. * Serialize this manager to a JSON object
  91126. * @param name defines the property name to store this manager
  91127. * @returns a JSON representation of this manager
  91128. */
  91129. serialize(name: string): any;
  91130. /**
  91131. * Creates a new ActionManager from a JSON data
  91132. * @param parsedActions defines the JSON data to read from
  91133. * @param object defines the hosting mesh
  91134. * @param scene defines the hosting scene
  91135. */
  91136. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91137. /**
  91138. * Get a trigger name by index
  91139. * @param trigger defines the trigger index
  91140. * @returns a trigger name
  91141. */
  91142. static GetTriggerName(trigger: number): string;
  91143. }
  91144. }
  91145. declare module BABYLON {
  91146. /**
  91147. * Class used to represent a sprite
  91148. * @see http://doc.babylonjs.com/babylon101/sprites
  91149. */
  91150. export class Sprite {
  91151. /** defines the name */
  91152. name: string;
  91153. /** Gets or sets the current world position */
  91154. position: Vector3;
  91155. /** Gets or sets the main color */
  91156. color: Color4;
  91157. /** Gets or sets the width */
  91158. width: number;
  91159. /** Gets or sets the height */
  91160. height: number;
  91161. /** Gets or sets rotation angle */
  91162. angle: number;
  91163. /** Gets or sets the cell index in the sprite sheet */
  91164. cellIndex: number;
  91165. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91166. cellRef: string;
  91167. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91168. invertU: number;
  91169. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91170. invertV: number;
  91171. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91172. disposeWhenFinishedAnimating: boolean;
  91173. /** Gets the list of attached animations */
  91174. animations: Animation[];
  91175. /** Gets or sets a boolean indicating if the sprite can be picked */
  91176. isPickable: boolean;
  91177. /**
  91178. * Gets or sets the associated action manager
  91179. */
  91180. actionManager: Nullable<ActionManager>;
  91181. private _animationStarted;
  91182. private _loopAnimation;
  91183. private _fromIndex;
  91184. private _toIndex;
  91185. private _delay;
  91186. private _direction;
  91187. private _manager;
  91188. private _time;
  91189. private _onAnimationEnd;
  91190. /**
  91191. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91192. */
  91193. isVisible: boolean;
  91194. /**
  91195. * Gets or sets the sprite size
  91196. */
  91197. get size(): number;
  91198. set size(value: number);
  91199. /**
  91200. * Creates a new Sprite
  91201. * @param name defines the name
  91202. * @param manager defines the manager
  91203. */
  91204. constructor(
  91205. /** defines the name */
  91206. name: string, manager: ISpriteManager);
  91207. /**
  91208. * Starts an animation
  91209. * @param from defines the initial key
  91210. * @param to defines the end key
  91211. * @param loop defines if the animation must loop
  91212. * @param delay defines the start delay (in ms)
  91213. * @param onAnimationEnd defines a callback to call when animation ends
  91214. */
  91215. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91216. /** Stops current animation (if any) */
  91217. stopAnimation(): void;
  91218. /** @hidden */
  91219. _animate(deltaTime: number): void;
  91220. /** Release associated resources */
  91221. dispose(): void;
  91222. }
  91223. }
  91224. declare module BABYLON {
  91225. /**
  91226. * Information about the result of picking within a scene
  91227. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91228. */
  91229. export class PickingInfo {
  91230. /** @hidden */
  91231. _pickingUnavailable: boolean;
  91232. /**
  91233. * If the pick collided with an object
  91234. */
  91235. hit: boolean;
  91236. /**
  91237. * Distance away where the pick collided
  91238. */
  91239. distance: number;
  91240. /**
  91241. * The location of pick collision
  91242. */
  91243. pickedPoint: Nullable<Vector3>;
  91244. /**
  91245. * The mesh corresponding the the pick collision
  91246. */
  91247. pickedMesh: Nullable<AbstractMesh>;
  91248. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91249. bu: number;
  91250. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91251. bv: number;
  91252. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91253. faceId: number;
  91254. /** Id of the the submesh that was picked */
  91255. subMeshId: number;
  91256. /** If a sprite was picked, this will be the sprite the pick collided with */
  91257. pickedSprite: Nullable<Sprite>;
  91258. /**
  91259. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91260. */
  91261. originMesh: Nullable<AbstractMesh>;
  91262. /**
  91263. * The ray that was used to perform the picking.
  91264. */
  91265. ray: Nullable<Ray>;
  91266. /**
  91267. * Gets the normal correspodning to the face the pick collided with
  91268. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91269. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91270. * @returns The normal correspodning to the face the pick collided with
  91271. */
  91272. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91273. /**
  91274. * Gets the texture coordinates of where the pick occured
  91275. * @returns the vector containing the coordnates of the texture
  91276. */
  91277. getTextureCoordinates(): Nullable<Vector2>;
  91278. }
  91279. }
  91280. declare module BABYLON {
  91281. /**
  91282. * Gather the list of pointer event types as constants.
  91283. */
  91284. export class PointerEventTypes {
  91285. /**
  91286. * 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.
  91287. */
  91288. static readonly POINTERDOWN: number;
  91289. /**
  91290. * The pointerup event is fired when a pointer is no longer active.
  91291. */
  91292. static readonly POINTERUP: number;
  91293. /**
  91294. * The pointermove event is fired when a pointer changes coordinates.
  91295. */
  91296. static readonly POINTERMOVE: number;
  91297. /**
  91298. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91299. */
  91300. static readonly POINTERWHEEL: number;
  91301. /**
  91302. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91303. */
  91304. static readonly POINTERPICK: number;
  91305. /**
  91306. * The pointertap event is fired when a the object has been touched and released without drag.
  91307. */
  91308. static readonly POINTERTAP: number;
  91309. /**
  91310. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91311. */
  91312. static readonly POINTERDOUBLETAP: number;
  91313. }
  91314. /**
  91315. * Base class of pointer info types.
  91316. */
  91317. export class PointerInfoBase {
  91318. /**
  91319. * Defines the type of event (PointerEventTypes)
  91320. */
  91321. type: number;
  91322. /**
  91323. * Defines the related dom event
  91324. */
  91325. event: PointerEvent | MouseWheelEvent;
  91326. /**
  91327. * Instantiates the base class of pointers info.
  91328. * @param type Defines the type of event (PointerEventTypes)
  91329. * @param event Defines the related dom event
  91330. */
  91331. constructor(
  91332. /**
  91333. * Defines the type of event (PointerEventTypes)
  91334. */
  91335. type: number,
  91336. /**
  91337. * Defines the related dom event
  91338. */
  91339. event: PointerEvent | MouseWheelEvent);
  91340. }
  91341. /**
  91342. * This class is used to store pointer related info for the onPrePointerObservable event.
  91343. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91344. */
  91345. export class PointerInfoPre extends PointerInfoBase {
  91346. /**
  91347. * Ray from a pointer if availible (eg. 6dof controller)
  91348. */
  91349. ray: Nullable<Ray>;
  91350. /**
  91351. * Defines the local position of the pointer on the canvas.
  91352. */
  91353. localPosition: Vector2;
  91354. /**
  91355. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91356. */
  91357. skipOnPointerObservable: boolean;
  91358. /**
  91359. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91360. * @param type Defines the type of event (PointerEventTypes)
  91361. * @param event Defines the related dom event
  91362. * @param localX Defines the local x coordinates of the pointer when the event occured
  91363. * @param localY Defines the local y coordinates of the pointer when the event occured
  91364. */
  91365. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91366. }
  91367. /**
  91368. * This type contains all the data related to a pointer event in Babylon.js.
  91369. * 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.
  91370. */
  91371. export class PointerInfo extends PointerInfoBase {
  91372. /**
  91373. * Defines the picking info associated to the info (if any)\
  91374. */
  91375. pickInfo: Nullable<PickingInfo>;
  91376. /**
  91377. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91378. * @param type Defines the type of event (PointerEventTypes)
  91379. * @param event Defines the related dom event
  91380. * @param pickInfo Defines the picking info associated to the info (if any)\
  91381. */
  91382. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91383. /**
  91384. * Defines the picking info associated to the info (if any)\
  91385. */
  91386. pickInfo: Nullable<PickingInfo>);
  91387. }
  91388. /**
  91389. * Data relating to a touch event on the screen.
  91390. */
  91391. export interface PointerTouch {
  91392. /**
  91393. * X coordinate of touch.
  91394. */
  91395. x: number;
  91396. /**
  91397. * Y coordinate of touch.
  91398. */
  91399. y: number;
  91400. /**
  91401. * Id of touch. Unique for each finger.
  91402. */
  91403. pointerId: number;
  91404. /**
  91405. * Event type passed from DOM.
  91406. */
  91407. type: any;
  91408. }
  91409. }
  91410. declare module BABYLON {
  91411. /**
  91412. * Manage the mouse inputs to control the movement of a free camera.
  91413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91414. */
  91415. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91416. /**
  91417. * Define if touch is enabled in the mouse input
  91418. */
  91419. touchEnabled: boolean;
  91420. /**
  91421. * Defines the camera the input is attached to.
  91422. */
  91423. camera: FreeCamera;
  91424. /**
  91425. * Defines the buttons associated with the input to handle camera move.
  91426. */
  91427. buttons: number[];
  91428. /**
  91429. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91430. */
  91431. angularSensibility: number;
  91432. private _pointerInput;
  91433. private _onMouseMove;
  91434. private _observer;
  91435. private previousPosition;
  91436. /**
  91437. * Observable for when a pointer move event occurs containing the move offset
  91438. */
  91439. onPointerMovedObservable: Observable<{
  91440. offsetX: number;
  91441. offsetY: number;
  91442. }>;
  91443. /**
  91444. * @hidden
  91445. * If the camera should be rotated automatically based on pointer movement
  91446. */
  91447. _allowCameraRotation: boolean;
  91448. /**
  91449. * Manage the mouse inputs to control the movement of a free camera.
  91450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91451. * @param touchEnabled Defines if touch is enabled or not
  91452. */
  91453. constructor(
  91454. /**
  91455. * Define if touch is enabled in the mouse input
  91456. */
  91457. touchEnabled?: boolean);
  91458. /**
  91459. * Attach the input controls to a specific dom element to get the input from.
  91460. * @param element Defines the element the controls should be listened from
  91461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91462. */
  91463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91464. /**
  91465. * Called on JS contextmenu event.
  91466. * Override this method to provide functionality.
  91467. */
  91468. protected onContextMenu(evt: PointerEvent): void;
  91469. /**
  91470. * Detach the current controls from the specified dom element.
  91471. * @param element Defines the element to stop listening the inputs from
  91472. */
  91473. detachControl(element: Nullable<HTMLElement>): void;
  91474. /**
  91475. * Gets the class name of the current intput.
  91476. * @returns the class name
  91477. */
  91478. getClassName(): string;
  91479. /**
  91480. * Get the friendly name associated with the input class.
  91481. * @returns the input friendly name
  91482. */
  91483. getSimpleName(): string;
  91484. }
  91485. }
  91486. declare module BABYLON {
  91487. /**
  91488. * Manage the touch inputs to control the movement of a free camera.
  91489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91490. */
  91491. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91492. /**
  91493. * Defines the camera the input is attached to.
  91494. */
  91495. camera: FreeCamera;
  91496. /**
  91497. * Defines the touch sensibility for rotation.
  91498. * The higher the faster.
  91499. */
  91500. touchAngularSensibility: number;
  91501. /**
  91502. * Defines the touch sensibility for move.
  91503. * The higher the faster.
  91504. */
  91505. touchMoveSensibility: number;
  91506. private _offsetX;
  91507. private _offsetY;
  91508. private _pointerPressed;
  91509. private _pointerInput;
  91510. private _observer;
  91511. private _onLostFocus;
  91512. /**
  91513. * Attach the input controls to a specific dom element to get the input from.
  91514. * @param element Defines the element the controls should be listened from
  91515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91516. */
  91517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91518. /**
  91519. * Detach the current controls from the specified dom element.
  91520. * @param element Defines the element to stop listening the inputs from
  91521. */
  91522. detachControl(element: Nullable<HTMLElement>): void;
  91523. /**
  91524. * Update the current camera state depending on the inputs that have been used this frame.
  91525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91526. */
  91527. checkInputs(): void;
  91528. /**
  91529. * Gets the class name of the current intput.
  91530. * @returns the class name
  91531. */
  91532. getClassName(): string;
  91533. /**
  91534. * Get the friendly name associated with the input class.
  91535. * @returns the input friendly name
  91536. */
  91537. getSimpleName(): string;
  91538. }
  91539. }
  91540. declare module BABYLON {
  91541. /**
  91542. * Default Inputs manager for the FreeCamera.
  91543. * It groups all the default supported inputs for ease of use.
  91544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91545. */
  91546. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91547. /**
  91548. * @hidden
  91549. */
  91550. _mouseInput: Nullable<FreeCameraMouseInput>;
  91551. /**
  91552. * Instantiates a new FreeCameraInputsManager.
  91553. * @param camera Defines the camera the inputs belong to
  91554. */
  91555. constructor(camera: FreeCamera);
  91556. /**
  91557. * Add keyboard input support to the input manager.
  91558. * @returns the current input manager
  91559. */
  91560. addKeyboard(): FreeCameraInputsManager;
  91561. /**
  91562. * Add mouse input support to the input manager.
  91563. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91564. * @returns the current input manager
  91565. */
  91566. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91567. /**
  91568. * Removes the mouse input support from the manager
  91569. * @returns the current input manager
  91570. */
  91571. removeMouse(): FreeCameraInputsManager;
  91572. /**
  91573. * Add touch input support to the input manager.
  91574. * @returns the current input manager
  91575. */
  91576. addTouch(): FreeCameraInputsManager;
  91577. /**
  91578. * Remove all attached input methods from a camera
  91579. */
  91580. clear(): void;
  91581. }
  91582. }
  91583. declare module BABYLON {
  91584. /**
  91585. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91586. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91587. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91588. */
  91589. export class FreeCamera extends TargetCamera {
  91590. /**
  91591. * Define the collision ellipsoid of the camera.
  91592. * This is helpful to simulate a camera body like the player body around the camera
  91593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91594. */
  91595. ellipsoid: Vector3;
  91596. /**
  91597. * Define an offset for the position of the ellipsoid around the camera.
  91598. * This can be helpful to determine the center of the body near the gravity center of the body
  91599. * instead of its head.
  91600. */
  91601. ellipsoidOffset: Vector3;
  91602. /**
  91603. * Enable or disable collisions of the camera with the rest of the scene objects.
  91604. */
  91605. checkCollisions: boolean;
  91606. /**
  91607. * Enable or disable gravity on the camera.
  91608. */
  91609. applyGravity: boolean;
  91610. /**
  91611. * Define the input manager associated to the camera.
  91612. */
  91613. inputs: FreeCameraInputsManager;
  91614. /**
  91615. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91616. * Higher values reduce sensitivity.
  91617. */
  91618. get angularSensibility(): number;
  91619. /**
  91620. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91621. * Higher values reduce sensitivity.
  91622. */
  91623. set angularSensibility(value: number);
  91624. /**
  91625. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91626. */
  91627. get keysUp(): number[];
  91628. set keysUp(value: number[]);
  91629. /**
  91630. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91631. */
  91632. get keysDown(): number[];
  91633. set keysDown(value: number[]);
  91634. /**
  91635. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91636. */
  91637. get keysLeft(): number[];
  91638. set keysLeft(value: number[]);
  91639. /**
  91640. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91641. */
  91642. get keysRight(): number[];
  91643. set keysRight(value: number[]);
  91644. /**
  91645. * Event raised when the camera collide with a mesh in the scene.
  91646. */
  91647. onCollide: (collidedMesh: AbstractMesh) => void;
  91648. private _collider;
  91649. private _needMoveForGravity;
  91650. private _oldPosition;
  91651. private _diffPosition;
  91652. private _newPosition;
  91653. /** @hidden */
  91654. _localDirection: Vector3;
  91655. /** @hidden */
  91656. _transformedDirection: Vector3;
  91657. /**
  91658. * Instantiates a Free Camera.
  91659. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91660. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91661. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91662. * @param name Define the name of the camera in the scene
  91663. * @param position Define the start position of the camera in the scene
  91664. * @param scene Define the scene the camera belongs to
  91665. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91666. */
  91667. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91668. /**
  91669. * Attached controls to the current camera.
  91670. * @param element Defines the element the controls should be listened from
  91671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91672. */
  91673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91674. /**
  91675. * Detach the current controls from the camera.
  91676. * The camera will stop reacting to inputs.
  91677. * @param element Defines the element to stop listening the inputs from
  91678. */
  91679. detachControl(element: HTMLElement): void;
  91680. private _collisionMask;
  91681. /**
  91682. * Define a collision mask to limit the list of object the camera can collide with
  91683. */
  91684. get collisionMask(): number;
  91685. set collisionMask(mask: number);
  91686. /** @hidden */
  91687. _collideWithWorld(displacement: Vector3): void;
  91688. private _onCollisionPositionChange;
  91689. /** @hidden */
  91690. _checkInputs(): void;
  91691. /** @hidden */
  91692. _decideIfNeedsToMove(): boolean;
  91693. /** @hidden */
  91694. _updatePosition(): void;
  91695. /**
  91696. * Destroy the camera and release the current resources hold by it.
  91697. */
  91698. dispose(): void;
  91699. /**
  91700. * Gets the current object class name.
  91701. * @return the class name
  91702. */
  91703. getClassName(): string;
  91704. }
  91705. }
  91706. declare module BABYLON {
  91707. /**
  91708. * Represents a gamepad control stick position
  91709. */
  91710. export class StickValues {
  91711. /**
  91712. * The x component of the control stick
  91713. */
  91714. x: number;
  91715. /**
  91716. * The y component of the control stick
  91717. */
  91718. y: number;
  91719. /**
  91720. * Initializes the gamepad x and y control stick values
  91721. * @param x The x component of the gamepad control stick value
  91722. * @param y The y component of the gamepad control stick value
  91723. */
  91724. constructor(
  91725. /**
  91726. * The x component of the control stick
  91727. */
  91728. x: number,
  91729. /**
  91730. * The y component of the control stick
  91731. */
  91732. y: number);
  91733. }
  91734. /**
  91735. * An interface which manages callbacks for gamepad button changes
  91736. */
  91737. export interface GamepadButtonChanges {
  91738. /**
  91739. * Called when a gamepad has been changed
  91740. */
  91741. changed: boolean;
  91742. /**
  91743. * Called when a gamepad press event has been triggered
  91744. */
  91745. pressChanged: boolean;
  91746. /**
  91747. * Called when a touch event has been triggered
  91748. */
  91749. touchChanged: boolean;
  91750. /**
  91751. * Called when a value has changed
  91752. */
  91753. valueChanged: boolean;
  91754. }
  91755. /**
  91756. * Represents a gamepad
  91757. */
  91758. export class Gamepad {
  91759. /**
  91760. * The id of the gamepad
  91761. */
  91762. id: string;
  91763. /**
  91764. * The index of the gamepad
  91765. */
  91766. index: number;
  91767. /**
  91768. * The browser gamepad
  91769. */
  91770. browserGamepad: any;
  91771. /**
  91772. * Specifies what type of gamepad this represents
  91773. */
  91774. type: number;
  91775. private _leftStick;
  91776. private _rightStick;
  91777. /** @hidden */
  91778. _isConnected: boolean;
  91779. private _leftStickAxisX;
  91780. private _leftStickAxisY;
  91781. private _rightStickAxisX;
  91782. private _rightStickAxisY;
  91783. /**
  91784. * Triggered when the left control stick has been changed
  91785. */
  91786. private _onleftstickchanged;
  91787. /**
  91788. * Triggered when the right control stick has been changed
  91789. */
  91790. private _onrightstickchanged;
  91791. /**
  91792. * Represents a gamepad controller
  91793. */
  91794. static GAMEPAD: number;
  91795. /**
  91796. * Represents a generic controller
  91797. */
  91798. static GENERIC: number;
  91799. /**
  91800. * Represents an XBox controller
  91801. */
  91802. static XBOX: number;
  91803. /**
  91804. * Represents a pose-enabled controller
  91805. */
  91806. static POSE_ENABLED: number;
  91807. /**
  91808. * Represents an Dual Shock controller
  91809. */
  91810. static DUALSHOCK: number;
  91811. /**
  91812. * Specifies whether the left control stick should be Y-inverted
  91813. */
  91814. protected _invertLeftStickY: boolean;
  91815. /**
  91816. * Specifies if the gamepad has been connected
  91817. */
  91818. get isConnected(): boolean;
  91819. /**
  91820. * Initializes the gamepad
  91821. * @param id The id of the gamepad
  91822. * @param index The index of the gamepad
  91823. * @param browserGamepad The browser gamepad
  91824. * @param leftStickX The x component of the left joystick
  91825. * @param leftStickY The y component of the left joystick
  91826. * @param rightStickX The x component of the right joystick
  91827. * @param rightStickY The y component of the right joystick
  91828. */
  91829. constructor(
  91830. /**
  91831. * The id of the gamepad
  91832. */
  91833. id: string,
  91834. /**
  91835. * The index of the gamepad
  91836. */
  91837. index: number,
  91838. /**
  91839. * The browser gamepad
  91840. */
  91841. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91842. /**
  91843. * Callback triggered when the left joystick has changed
  91844. * @param callback
  91845. */
  91846. onleftstickchanged(callback: (values: StickValues) => void): void;
  91847. /**
  91848. * Callback triggered when the right joystick has changed
  91849. * @param callback
  91850. */
  91851. onrightstickchanged(callback: (values: StickValues) => void): void;
  91852. /**
  91853. * Gets the left joystick
  91854. */
  91855. get leftStick(): StickValues;
  91856. /**
  91857. * Sets the left joystick values
  91858. */
  91859. set leftStick(newValues: StickValues);
  91860. /**
  91861. * Gets the right joystick
  91862. */
  91863. get rightStick(): StickValues;
  91864. /**
  91865. * Sets the right joystick value
  91866. */
  91867. set rightStick(newValues: StickValues);
  91868. /**
  91869. * Updates the gamepad joystick positions
  91870. */
  91871. update(): void;
  91872. /**
  91873. * Disposes the gamepad
  91874. */
  91875. dispose(): void;
  91876. }
  91877. /**
  91878. * Represents a generic gamepad
  91879. */
  91880. export class GenericPad extends Gamepad {
  91881. private _buttons;
  91882. private _onbuttondown;
  91883. private _onbuttonup;
  91884. /**
  91885. * Observable triggered when a button has been pressed
  91886. */
  91887. onButtonDownObservable: Observable<number>;
  91888. /**
  91889. * Observable triggered when a button has been released
  91890. */
  91891. onButtonUpObservable: Observable<number>;
  91892. /**
  91893. * Callback triggered when a button has been pressed
  91894. * @param callback Called when a button has been pressed
  91895. */
  91896. onbuttondown(callback: (buttonPressed: number) => void): void;
  91897. /**
  91898. * Callback triggered when a button has been released
  91899. * @param callback Called when a button has been released
  91900. */
  91901. onbuttonup(callback: (buttonReleased: number) => void): void;
  91902. /**
  91903. * Initializes the generic gamepad
  91904. * @param id The id of the generic gamepad
  91905. * @param index The index of the generic gamepad
  91906. * @param browserGamepad The browser gamepad
  91907. */
  91908. constructor(id: string, index: number, browserGamepad: any);
  91909. private _setButtonValue;
  91910. /**
  91911. * Updates the generic gamepad
  91912. */
  91913. update(): void;
  91914. /**
  91915. * Disposes the generic gamepad
  91916. */
  91917. dispose(): void;
  91918. }
  91919. }
  91920. declare module BABYLON {
  91921. /**
  91922. * Defines the types of pose enabled controllers that are supported
  91923. */
  91924. export enum PoseEnabledControllerType {
  91925. /**
  91926. * HTC Vive
  91927. */
  91928. VIVE = 0,
  91929. /**
  91930. * Oculus Rift
  91931. */
  91932. OCULUS = 1,
  91933. /**
  91934. * Windows mixed reality
  91935. */
  91936. WINDOWS = 2,
  91937. /**
  91938. * Samsung gear VR
  91939. */
  91940. GEAR_VR = 3,
  91941. /**
  91942. * Google Daydream
  91943. */
  91944. DAYDREAM = 4,
  91945. /**
  91946. * Generic
  91947. */
  91948. GENERIC = 5
  91949. }
  91950. /**
  91951. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91952. */
  91953. export interface MutableGamepadButton {
  91954. /**
  91955. * Value of the button/trigger
  91956. */
  91957. value: number;
  91958. /**
  91959. * If the button/trigger is currently touched
  91960. */
  91961. touched: boolean;
  91962. /**
  91963. * If the button/trigger is currently pressed
  91964. */
  91965. pressed: boolean;
  91966. }
  91967. /**
  91968. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91969. * @hidden
  91970. */
  91971. export interface ExtendedGamepadButton extends GamepadButton {
  91972. /**
  91973. * If the button/trigger is currently pressed
  91974. */
  91975. readonly pressed: boolean;
  91976. /**
  91977. * If the button/trigger is currently touched
  91978. */
  91979. readonly touched: boolean;
  91980. /**
  91981. * Value of the button/trigger
  91982. */
  91983. readonly value: number;
  91984. }
  91985. /** @hidden */
  91986. export interface _GamePadFactory {
  91987. /**
  91988. * Returns whether or not the current gamepad can be created for this type of controller.
  91989. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91990. * @returns true if it can be created, otherwise false
  91991. */
  91992. canCreate(gamepadInfo: any): boolean;
  91993. /**
  91994. * Creates a new instance of the Gamepad.
  91995. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91996. * @returns the new gamepad instance
  91997. */
  91998. create(gamepadInfo: any): Gamepad;
  91999. }
  92000. /**
  92001. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92002. */
  92003. export class PoseEnabledControllerHelper {
  92004. /** @hidden */
  92005. static _ControllerFactories: _GamePadFactory[];
  92006. /** @hidden */
  92007. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92008. /**
  92009. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92010. * @param vrGamepad the gamepad to initialized
  92011. * @returns a vr controller of the type the gamepad identified as
  92012. */
  92013. static InitiateController(vrGamepad: any): Gamepad;
  92014. }
  92015. /**
  92016. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92017. */
  92018. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92019. /**
  92020. * If the controller is used in a webXR session
  92021. */
  92022. isXR: boolean;
  92023. private _deviceRoomPosition;
  92024. private _deviceRoomRotationQuaternion;
  92025. /**
  92026. * The device position in babylon space
  92027. */
  92028. devicePosition: Vector3;
  92029. /**
  92030. * The device rotation in babylon space
  92031. */
  92032. deviceRotationQuaternion: Quaternion;
  92033. /**
  92034. * The scale factor of the device in babylon space
  92035. */
  92036. deviceScaleFactor: number;
  92037. /**
  92038. * (Likely devicePosition should be used instead) The device position in its room space
  92039. */
  92040. position: Vector3;
  92041. /**
  92042. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92043. */
  92044. rotationQuaternion: Quaternion;
  92045. /**
  92046. * The type of controller (Eg. Windows mixed reality)
  92047. */
  92048. controllerType: PoseEnabledControllerType;
  92049. protected _calculatedPosition: Vector3;
  92050. private _calculatedRotation;
  92051. /**
  92052. * The raw pose from the device
  92053. */
  92054. rawPose: DevicePose;
  92055. private _trackPosition;
  92056. private _maxRotationDistFromHeadset;
  92057. private _draggedRoomRotation;
  92058. /**
  92059. * @hidden
  92060. */
  92061. _disableTrackPosition(fixedPosition: Vector3): void;
  92062. /**
  92063. * Internal, the mesh attached to the controller
  92064. * @hidden
  92065. */
  92066. _mesh: Nullable<AbstractMesh>;
  92067. private _poseControlledCamera;
  92068. private _leftHandSystemQuaternion;
  92069. /**
  92070. * Internal, matrix used to convert room space to babylon space
  92071. * @hidden
  92072. */
  92073. _deviceToWorld: Matrix;
  92074. /**
  92075. * Node to be used when casting a ray from the controller
  92076. * @hidden
  92077. */
  92078. _pointingPoseNode: Nullable<TransformNode>;
  92079. /**
  92080. * Name of the child mesh that can be used to cast a ray from the controller
  92081. */
  92082. static readonly POINTING_POSE: string;
  92083. /**
  92084. * Creates a new PoseEnabledController from a gamepad
  92085. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92086. */
  92087. constructor(browserGamepad: any);
  92088. private _workingMatrix;
  92089. /**
  92090. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92091. */
  92092. update(): void;
  92093. /**
  92094. * Updates only the pose device and mesh without doing any button event checking
  92095. */
  92096. protected _updatePoseAndMesh(): void;
  92097. /**
  92098. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92099. * @param poseData raw pose fromthe device
  92100. */
  92101. updateFromDevice(poseData: DevicePose): void;
  92102. /**
  92103. * @hidden
  92104. */
  92105. _meshAttachedObservable: Observable<AbstractMesh>;
  92106. /**
  92107. * Attaches a mesh to the controller
  92108. * @param mesh the mesh to be attached
  92109. */
  92110. attachToMesh(mesh: AbstractMesh): void;
  92111. /**
  92112. * Attaches the controllers mesh to a camera
  92113. * @param camera the camera the mesh should be attached to
  92114. */
  92115. attachToPoseControlledCamera(camera: TargetCamera): void;
  92116. /**
  92117. * Disposes of the controller
  92118. */
  92119. dispose(): void;
  92120. /**
  92121. * The mesh that is attached to the controller
  92122. */
  92123. get mesh(): Nullable<AbstractMesh>;
  92124. /**
  92125. * Gets the ray of the controller in the direction the controller is pointing
  92126. * @param length the length the resulting ray should be
  92127. * @returns a ray in the direction the controller is pointing
  92128. */
  92129. getForwardRay(length?: number): Ray;
  92130. }
  92131. }
  92132. declare module BABYLON {
  92133. /**
  92134. * Defines the WebVRController object that represents controllers tracked in 3D space
  92135. */
  92136. export abstract class WebVRController extends PoseEnabledController {
  92137. /**
  92138. * Internal, the default controller model for the controller
  92139. */
  92140. protected _defaultModel: Nullable<AbstractMesh>;
  92141. /**
  92142. * Fired when the trigger state has changed
  92143. */
  92144. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92145. /**
  92146. * Fired when the main button state has changed
  92147. */
  92148. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92149. /**
  92150. * Fired when the secondary button state has changed
  92151. */
  92152. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92153. /**
  92154. * Fired when the pad state has changed
  92155. */
  92156. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92157. /**
  92158. * Fired when controllers stick values have changed
  92159. */
  92160. onPadValuesChangedObservable: Observable<StickValues>;
  92161. /**
  92162. * Array of button availible on the controller
  92163. */
  92164. protected _buttons: Array<MutableGamepadButton>;
  92165. private _onButtonStateChange;
  92166. /**
  92167. * Fired when a controller button's state has changed
  92168. * @param callback the callback containing the button that was modified
  92169. */
  92170. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92171. /**
  92172. * X and Y axis corresponding to the controllers joystick
  92173. */
  92174. pad: StickValues;
  92175. /**
  92176. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92177. */
  92178. hand: string;
  92179. /**
  92180. * The default controller model for the controller
  92181. */
  92182. get defaultModel(): Nullable<AbstractMesh>;
  92183. /**
  92184. * Creates a new WebVRController from a gamepad
  92185. * @param vrGamepad the gamepad that the WebVRController should be created from
  92186. */
  92187. constructor(vrGamepad: any);
  92188. /**
  92189. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92190. */
  92191. update(): void;
  92192. /**
  92193. * Function to be called when a button is modified
  92194. */
  92195. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92196. /**
  92197. * Loads a mesh and attaches it to the controller
  92198. * @param scene the scene the mesh should be added to
  92199. * @param meshLoaded callback for when the mesh has been loaded
  92200. */
  92201. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92202. private _setButtonValue;
  92203. private _changes;
  92204. private _checkChanges;
  92205. /**
  92206. * Disposes of th webVRCOntroller
  92207. */
  92208. dispose(): void;
  92209. }
  92210. }
  92211. declare module BABYLON {
  92212. /**
  92213. * The HemisphericLight simulates the ambient environment light,
  92214. * so the passed direction is the light reflection direction, not the incoming direction.
  92215. */
  92216. export class HemisphericLight extends Light {
  92217. /**
  92218. * The groundColor is the light in the opposite direction to the one specified during creation.
  92219. * 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.
  92220. */
  92221. groundColor: Color3;
  92222. /**
  92223. * The light reflection direction, not the incoming direction.
  92224. */
  92225. direction: Vector3;
  92226. /**
  92227. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92228. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92229. * The HemisphericLight can't cast shadows.
  92230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92231. * @param name The friendly name of the light
  92232. * @param direction The direction of the light reflection
  92233. * @param scene The scene the light belongs to
  92234. */
  92235. constructor(name: string, direction: Vector3, scene: Scene);
  92236. protected _buildUniformLayout(): void;
  92237. /**
  92238. * Returns the string "HemisphericLight".
  92239. * @return The class name
  92240. */
  92241. getClassName(): string;
  92242. /**
  92243. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92244. * Returns the updated direction.
  92245. * @param target The target the direction should point to
  92246. * @return The computed direction
  92247. */
  92248. setDirectionToTarget(target: Vector3): Vector3;
  92249. /**
  92250. * Returns the shadow generator associated to the light.
  92251. * @returns Always null for hemispheric lights because it does not support shadows.
  92252. */
  92253. getShadowGenerator(): Nullable<IShadowGenerator>;
  92254. /**
  92255. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92256. * @param effect The effect to update
  92257. * @param lightIndex The index of the light in the effect to update
  92258. * @returns The hemispheric light
  92259. */
  92260. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92261. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92262. /**
  92263. * Computes the world matrix of the node
  92264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92265. * @param useWasUpdatedFlag defines a reserved property
  92266. * @returns the world matrix
  92267. */
  92268. computeWorldMatrix(): Matrix;
  92269. /**
  92270. * Returns the integer 3.
  92271. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92272. */
  92273. getTypeID(): number;
  92274. /**
  92275. * Prepares the list of defines specific to the light type.
  92276. * @param defines the list of defines
  92277. * @param lightIndex defines the index of the light for the effect
  92278. */
  92279. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92280. }
  92281. }
  92282. declare module BABYLON {
  92283. /** @hidden */
  92284. export var vrMultiviewToSingleviewPixelShader: {
  92285. name: string;
  92286. shader: string;
  92287. };
  92288. }
  92289. declare module BABYLON {
  92290. /**
  92291. * Renders to multiple views with a single draw call
  92292. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92293. */
  92294. export class MultiviewRenderTarget extends RenderTargetTexture {
  92295. /**
  92296. * Creates a multiview render target
  92297. * @param scene scene used with the render target
  92298. * @param size the size of the render target (used for each view)
  92299. */
  92300. constructor(scene: Scene, size?: number | {
  92301. width: number;
  92302. height: number;
  92303. } | {
  92304. ratio: number;
  92305. });
  92306. /**
  92307. * @hidden
  92308. * @param faceIndex the face index, if its a cube texture
  92309. */
  92310. _bindFrameBuffer(faceIndex?: number): void;
  92311. /**
  92312. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92313. * @returns the view count
  92314. */
  92315. getViewCount(): number;
  92316. }
  92317. }
  92318. declare module BABYLON {
  92319. /**
  92320. * Represents a camera frustum
  92321. */
  92322. export class Frustum {
  92323. /**
  92324. * Gets the planes representing the frustum
  92325. * @param transform matrix to be applied to the returned planes
  92326. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92327. */
  92328. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92329. /**
  92330. * Gets the near frustum plane transformed by the transform matrix
  92331. * @param transform transformation matrix to be applied to the resulting frustum plane
  92332. * @param frustumPlane the resuling frustum plane
  92333. */
  92334. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92335. /**
  92336. * Gets the far frustum plane transformed by the transform matrix
  92337. * @param transform transformation matrix to be applied to the resulting frustum plane
  92338. * @param frustumPlane the resuling frustum plane
  92339. */
  92340. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92341. /**
  92342. * Gets the left frustum plane transformed by the transform matrix
  92343. * @param transform transformation matrix to be applied to the resulting frustum plane
  92344. * @param frustumPlane the resuling frustum plane
  92345. */
  92346. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92347. /**
  92348. * Gets the right frustum plane transformed by the transform matrix
  92349. * @param transform transformation matrix to be applied to the resulting frustum plane
  92350. * @param frustumPlane the resuling frustum plane
  92351. */
  92352. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92353. /**
  92354. * Gets the top frustum plane transformed by the transform matrix
  92355. * @param transform transformation matrix to be applied to the resulting frustum plane
  92356. * @param frustumPlane the resuling frustum plane
  92357. */
  92358. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92359. /**
  92360. * Gets the bottom frustum plane transformed by the transform matrix
  92361. * @param transform transformation matrix to be applied to the resulting frustum plane
  92362. * @param frustumPlane the resuling frustum plane
  92363. */
  92364. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92365. /**
  92366. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92367. * @param transform transformation matrix to be applied to the resulting frustum planes
  92368. * @param frustumPlanes the resuling frustum planes
  92369. */
  92370. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92371. }
  92372. }
  92373. declare module BABYLON {
  92374. interface Engine {
  92375. /**
  92376. * Creates a new multiview render target
  92377. * @param width defines the width of the texture
  92378. * @param height defines the height of the texture
  92379. * @returns the created multiview texture
  92380. */
  92381. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92382. /**
  92383. * Binds a multiview framebuffer to be drawn to
  92384. * @param multiviewTexture texture to bind
  92385. */
  92386. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92387. }
  92388. interface Camera {
  92389. /**
  92390. * @hidden
  92391. * 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)
  92392. */
  92393. _useMultiviewToSingleView: boolean;
  92394. /**
  92395. * @hidden
  92396. * 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)
  92397. */
  92398. _multiviewTexture: Nullable<RenderTargetTexture>;
  92399. /**
  92400. * @hidden
  92401. * ensures the multiview texture of the camera exists and has the specified width/height
  92402. * @param width height to set on the multiview texture
  92403. * @param height width to set on the multiview texture
  92404. */
  92405. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92406. }
  92407. interface Scene {
  92408. /** @hidden */
  92409. _transformMatrixR: Matrix;
  92410. /** @hidden */
  92411. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92412. /** @hidden */
  92413. _createMultiviewUbo(): void;
  92414. /** @hidden */
  92415. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92416. /** @hidden */
  92417. _renderMultiviewToSingleView(camera: Camera): void;
  92418. }
  92419. }
  92420. declare module BABYLON {
  92421. /**
  92422. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92423. * This will not be used for webXR as it supports displaying texture arrays directly
  92424. */
  92425. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92426. /**
  92427. * Initializes a VRMultiviewToSingleview
  92428. * @param name name of the post process
  92429. * @param camera camera to be applied to
  92430. * @param scaleFactor scaling factor to the size of the output texture
  92431. */
  92432. constructor(name: string, camera: Camera, scaleFactor: number);
  92433. }
  92434. }
  92435. declare module BABYLON {
  92436. /**
  92437. * Interface used to define additional presentation attributes
  92438. */
  92439. export interface IVRPresentationAttributes {
  92440. /**
  92441. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92442. */
  92443. highRefreshRate: boolean;
  92444. /**
  92445. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92446. */
  92447. foveationLevel: number;
  92448. }
  92449. interface Engine {
  92450. /** @hidden */
  92451. _vrDisplay: any;
  92452. /** @hidden */
  92453. _vrSupported: boolean;
  92454. /** @hidden */
  92455. _oldSize: Size;
  92456. /** @hidden */
  92457. _oldHardwareScaleFactor: number;
  92458. /** @hidden */
  92459. _vrExclusivePointerMode: boolean;
  92460. /** @hidden */
  92461. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92462. /** @hidden */
  92463. _onVRDisplayPointerRestricted: () => void;
  92464. /** @hidden */
  92465. _onVRDisplayPointerUnrestricted: () => void;
  92466. /** @hidden */
  92467. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92468. /** @hidden */
  92469. _onVrDisplayDisconnect: Nullable<() => void>;
  92470. /** @hidden */
  92471. _onVrDisplayPresentChange: Nullable<() => void>;
  92472. /**
  92473. * Observable signaled when VR display mode changes
  92474. */
  92475. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92476. /**
  92477. * Observable signaled when VR request present is complete
  92478. */
  92479. onVRRequestPresentComplete: Observable<boolean>;
  92480. /**
  92481. * Observable signaled when VR request present starts
  92482. */
  92483. onVRRequestPresentStart: Observable<Engine>;
  92484. /**
  92485. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92486. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92487. */
  92488. isInVRExclusivePointerMode: boolean;
  92489. /**
  92490. * Gets a boolean indicating if a webVR device was detected
  92491. * @returns true if a webVR device was detected
  92492. */
  92493. isVRDevicePresent(): boolean;
  92494. /**
  92495. * Gets the current webVR device
  92496. * @returns the current webVR device (or null)
  92497. */
  92498. getVRDevice(): any;
  92499. /**
  92500. * Initializes a webVR display and starts listening to display change events
  92501. * The onVRDisplayChangedObservable will be notified upon these changes
  92502. * @returns A promise containing a VRDisplay and if vr is supported
  92503. */
  92504. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92505. /** @hidden */
  92506. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92507. /**
  92508. * Gets or sets the presentation attributes used to configure VR rendering
  92509. */
  92510. vrPresentationAttributes?: IVRPresentationAttributes;
  92511. /**
  92512. * Call this function to switch to webVR mode
  92513. * Will do nothing if webVR is not supported or if there is no webVR device
  92514. * @param options the webvr options provided to the camera. mainly used for multiview
  92515. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92516. */
  92517. enableVR(options: WebVROptions): void;
  92518. /** @hidden */
  92519. _onVRFullScreenTriggered(): void;
  92520. }
  92521. }
  92522. declare module BABYLON {
  92523. /**
  92524. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92525. * IMPORTANT!! The data is right-hand data.
  92526. * @export
  92527. * @interface DevicePose
  92528. */
  92529. export interface DevicePose {
  92530. /**
  92531. * The position of the device, values in array are [x,y,z].
  92532. */
  92533. readonly position: Nullable<Float32Array>;
  92534. /**
  92535. * The linearVelocity of the device, values in array are [x,y,z].
  92536. */
  92537. readonly linearVelocity: Nullable<Float32Array>;
  92538. /**
  92539. * The linearAcceleration of the device, values in array are [x,y,z].
  92540. */
  92541. readonly linearAcceleration: Nullable<Float32Array>;
  92542. /**
  92543. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92544. */
  92545. readonly orientation: Nullable<Float32Array>;
  92546. /**
  92547. * The angularVelocity of the device, values in array are [x,y,z].
  92548. */
  92549. readonly angularVelocity: Nullable<Float32Array>;
  92550. /**
  92551. * The angularAcceleration of the device, values in array are [x,y,z].
  92552. */
  92553. readonly angularAcceleration: Nullable<Float32Array>;
  92554. }
  92555. /**
  92556. * Interface representing a pose controlled object in Babylon.
  92557. * A pose controlled object has both regular pose values as well as pose values
  92558. * from an external device such as a VR head mounted display
  92559. */
  92560. export interface PoseControlled {
  92561. /**
  92562. * The position of the object in babylon space.
  92563. */
  92564. position: Vector3;
  92565. /**
  92566. * The rotation quaternion of the object in babylon space.
  92567. */
  92568. rotationQuaternion: Quaternion;
  92569. /**
  92570. * The position of the device in babylon space.
  92571. */
  92572. devicePosition?: Vector3;
  92573. /**
  92574. * The rotation quaternion of the device in babylon space.
  92575. */
  92576. deviceRotationQuaternion: Quaternion;
  92577. /**
  92578. * The raw pose coming from the device.
  92579. */
  92580. rawPose: Nullable<DevicePose>;
  92581. /**
  92582. * The scale of the device to be used when translating from device space to babylon space.
  92583. */
  92584. deviceScaleFactor: number;
  92585. /**
  92586. * Updates the poseControlled values based on the input device pose.
  92587. * @param poseData the pose data to update the object with
  92588. */
  92589. updateFromDevice(poseData: DevicePose): void;
  92590. }
  92591. /**
  92592. * Set of options to customize the webVRCamera
  92593. */
  92594. export interface WebVROptions {
  92595. /**
  92596. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92597. */
  92598. trackPosition?: boolean;
  92599. /**
  92600. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92601. */
  92602. positionScale?: number;
  92603. /**
  92604. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92605. */
  92606. displayName?: string;
  92607. /**
  92608. * Should the native controller meshes be initialized. (default: true)
  92609. */
  92610. controllerMeshes?: boolean;
  92611. /**
  92612. * Creating a default HemiLight only on controllers. (default: true)
  92613. */
  92614. defaultLightingOnControllers?: boolean;
  92615. /**
  92616. * If you don't want to use the default VR button of the helper. (default: false)
  92617. */
  92618. useCustomVRButton?: boolean;
  92619. /**
  92620. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92621. */
  92622. customVRButton?: HTMLButtonElement;
  92623. /**
  92624. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92625. */
  92626. rayLength?: number;
  92627. /**
  92628. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92629. */
  92630. defaultHeight?: number;
  92631. /**
  92632. * If multiview should be used if availible (default: false)
  92633. */
  92634. useMultiview?: boolean;
  92635. }
  92636. /**
  92637. * This represents a WebVR camera.
  92638. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92639. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92640. */
  92641. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92642. private webVROptions;
  92643. /**
  92644. * @hidden
  92645. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92646. */
  92647. _vrDevice: any;
  92648. /**
  92649. * The rawPose of the vrDevice.
  92650. */
  92651. rawPose: Nullable<DevicePose>;
  92652. private _onVREnabled;
  92653. private _specsVersion;
  92654. private _attached;
  92655. private _frameData;
  92656. protected _descendants: Array<Node>;
  92657. private _deviceRoomPosition;
  92658. /** @hidden */
  92659. _deviceRoomRotationQuaternion: Quaternion;
  92660. private _standingMatrix;
  92661. /**
  92662. * Represents device position in babylon space.
  92663. */
  92664. devicePosition: Vector3;
  92665. /**
  92666. * Represents device rotation in babylon space.
  92667. */
  92668. deviceRotationQuaternion: Quaternion;
  92669. /**
  92670. * The scale of the device to be used when translating from device space to babylon space.
  92671. */
  92672. deviceScaleFactor: number;
  92673. private _deviceToWorld;
  92674. private _worldToDevice;
  92675. /**
  92676. * References to the webVR controllers for the vrDevice.
  92677. */
  92678. controllers: Array<WebVRController>;
  92679. /**
  92680. * Emits an event when a controller is attached.
  92681. */
  92682. onControllersAttachedObservable: Observable<WebVRController[]>;
  92683. /**
  92684. * Emits an event when a controller's mesh has been loaded;
  92685. */
  92686. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92687. /**
  92688. * Emits an event when the HMD's pose has been updated.
  92689. */
  92690. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92691. private _poseSet;
  92692. /**
  92693. * If the rig cameras be used as parent instead of this camera.
  92694. */
  92695. rigParenting: boolean;
  92696. private _lightOnControllers;
  92697. private _defaultHeight?;
  92698. /**
  92699. * Instantiates a WebVRFreeCamera.
  92700. * @param name The name of the WebVRFreeCamera
  92701. * @param position The starting anchor position for the camera
  92702. * @param scene The scene the camera belongs to
  92703. * @param webVROptions a set of customizable options for the webVRCamera
  92704. */
  92705. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92706. /**
  92707. * Gets the device distance from the ground in meters.
  92708. * @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.
  92709. */
  92710. deviceDistanceToRoomGround(): number;
  92711. /**
  92712. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92713. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92714. */
  92715. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92716. /**
  92717. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92718. * @returns A promise with a boolean set to if the standing matrix is supported.
  92719. */
  92720. useStandingMatrixAsync(): Promise<boolean>;
  92721. /**
  92722. * Disposes the camera
  92723. */
  92724. dispose(): void;
  92725. /**
  92726. * Gets a vrController by name.
  92727. * @param name The name of the controller to retreive
  92728. * @returns the controller matching the name specified or null if not found
  92729. */
  92730. getControllerByName(name: string): Nullable<WebVRController>;
  92731. private _leftController;
  92732. /**
  92733. * The controller corresponding to the users left hand.
  92734. */
  92735. get leftController(): Nullable<WebVRController>;
  92736. private _rightController;
  92737. /**
  92738. * The controller corresponding to the users right hand.
  92739. */
  92740. get rightController(): Nullable<WebVRController>;
  92741. /**
  92742. * Casts a ray forward from the vrCamera's gaze.
  92743. * @param length Length of the ray (default: 100)
  92744. * @returns the ray corresponding to the gaze
  92745. */
  92746. getForwardRay(length?: number): Ray;
  92747. /**
  92748. * @hidden
  92749. * Updates the camera based on device's frame data
  92750. */
  92751. _checkInputs(): void;
  92752. /**
  92753. * Updates the poseControlled values based on the input device pose.
  92754. * @param poseData Pose coming from the device
  92755. */
  92756. updateFromDevice(poseData: DevicePose): void;
  92757. private _htmlElementAttached;
  92758. private _detachIfAttached;
  92759. /**
  92760. * WebVR's attach control will start broadcasting frames to the device.
  92761. * Note that in certain browsers (chrome for example) this function must be called
  92762. * within a user-interaction callback. Example:
  92763. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92764. *
  92765. * @param element html element to attach the vrDevice to
  92766. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92767. */
  92768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92769. /**
  92770. * Detaches the camera from the html element and disables VR
  92771. *
  92772. * @param element html element to detach from
  92773. */
  92774. detachControl(element: HTMLElement): void;
  92775. /**
  92776. * @returns the name of this class
  92777. */
  92778. getClassName(): string;
  92779. /**
  92780. * Calls resetPose on the vrDisplay
  92781. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92782. */
  92783. resetToCurrentRotation(): void;
  92784. /**
  92785. * @hidden
  92786. * Updates the rig cameras (left and right eye)
  92787. */
  92788. _updateRigCameras(): void;
  92789. private _workingVector;
  92790. private _oneVector;
  92791. private _workingMatrix;
  92792. private updateCacheCalled;
  92793. private _correctPositionIfNotTrackPosition;
  92794. /**
  92795. * @hidden
  92796. * Updates the cached values of the camera
  92797. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92798. */
  92799. _updateCache(ignoreParentClass?: boolean): void;
  92800. /**
  92801. * @hidden
  92802. * Get current device position in babylon world
  92803. */
  92804. _computeDevicePosition(): void;
  92805. /**
  92806. * Updates the current device position and rotation in the babylon world
  92807. */
  92808. update(): void;
  92809. /**
  92810. * @hidden
  92811. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92812. * @returns an identity matrix
  92813. */
  92814. _getViewMatrix(): Matrix;
  92815. private _tmpMatrix;
  92816. /**
  92817. * This function is called by the two RIG cameras.
  92818. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92819. * @hidden
  92820. */
  92821. _getWebVRViewMatrix(): Matrix;
  92822. /** @hidden */
  92823. _getWebVRProjectionMatrix(): Matrix;
  92824. private _onGamepadConnectedObserver;
  92825. private _onGamepadDisconnectedObserver;
  92826. private _updateCacheWhenTrackingDisabledObserver;
  92827. /**
  92828. * Initializes the controllers and their meshes
  92829. */
  92830. initControllers(): void;
  92831. }
  92832. }
  92833. declare module BABYLON {
  92834. /**
  92835. * Size options for a post process
  92836. */
  92837. export type PostProcessOptions = {
  92838. width: number;
  92839. height: number;
  92840. };
  92841. /**
  92842. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92843. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92844. */
  92845. export class PostProcess {
  92846. /** Name of the PostProcess. */
  92847. name: string;
  92848. /**
  92849. * Gets or sets the unique id of the post process
  92850. */
  92851. uniqueId: number;
  92852. /**
  92853. * Width of the texture to apply the post process on
  92854. */
  92855. width: number;
  92856. /**
  92857. * Height of the texture to apply the post process on
  92858. */
  92859. height: number;
  92860. /**
  92861. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92862. * @hidden
  92863. */
  92864. _outputTexture: Nullable<InternalTexture>;
  92865. /**
  92866. * Sampling mode used by the shader
  92867. * See https://doc.babylonjs.com/classes/3.1/texture
  92868. */
  92869. renderTargetSamplingMode: number;
  92870. /**
  92871. * Clear color to use when screen clearing
  92872. */
  92873. clearColor: Color4;
  92874. /**
  92875. * If the buffer needs to be cleared before applying the post process. (default: true)
  92876. * Should be set to false if shader will overwrite all previous pixels.
  92877. */
  92878. autoClear: boolean;
  92879. /**
  92880. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92881. */
  92882. alphaMode: number;
  92883. /**
  92884. * Sets the setAlphaBlendConstants of the babylon engine
  92885. */
  92886. alphaConstants: Color4;
  92887. /**
  92888. * Animations to be used for the post processing
  92889. */
  92890. animations: Animation[];
  92891. /**
  92892. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92893. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92894. */
  92895. enablePixelPerfectMode: boolean;
  92896. /**
  92897. * Force the postprocess to be applied without taking in account viewport
  92898. */
  92899. forceFullscreenViewport: boolean;
  92900. /**
  92901. * List of inspectable custom properties (used by the Inspector)
  92902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92903. */
  92904. inspectableCustomProperties: IInspectable[];
  92905. /**
  92906. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92907. *
  92908. * | Value | Type | Description |
  92909. * | ----- | ----------------------------------- | ----------- |
  92910. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92911. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92912. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92913. *
  92914. */
  92915. scaleMode: number;
  92916. /**
  92917. * Force textures to be a power of two (default: false)
  92918. */
  92919. alwaysForcePOT: boolean;
  92920. private _samples;
  92921. /**
  92922. * Number of sample textures (default: 1)
  92923. */
  92924. get samples(): number;
  92925. set samples(n: number);
  92926. /**
  92927. * Modify the scale of the post process to be the same as the viewport (default: false)
  92928. */
  92929. adaptScaleToCurrentViewport: boolean;
  92930. private _camera;
  92931. private _scene;
  92932. private _engine;
  92933. private _options;
  92934. private _reusable;
  92935. private _textureType;
  92936. private _textureFormat;
  92937. /**
  92938. * Smart array of input and output textures for the post process.
  92939. * @hidden
  92940. */
  92941. _textures: SmartArray<InternalTexture>;
  92942. /**
  92943. * The index in _textures that corresponds to the output texture.
  92944. * @hidden
  92945. */
  92946. _currentRenderTextureInd: number;
  92947. private _effect;
  92948. private _samplers;
  92949. private _fragmentUrl;
  92950. private _vertexUrl;
  92951. private _parameters;
  92952. private _scaleRatio;
  92953. protected _indexParameters: any;
  92954. private _shareOutputWithPostProcess;
  92955. private _texelSize;
  92956. private _forcedOutputTexture;
  92957. /**
  92958. * Returns the fragment url or shader name used in the post process.
  92959. * @returns the fragment url or name in the shader store.
  92960. */
  92961. getEffectName(): string;
  92962. /**
  92963. * An event triggered when the postprocess is activated.
  92964. */
  92965. onActivateObservable: Observable<Camera>;
  92966. private _onActivateObserver;
  92967. /**
  92968. * A function that is added to the onActivateObservable
  92969. */
  92970. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92971. /**
  92972. * An event triggered when the postprocess changes its size.
  92973. */
  92974. onSizeChangedObservable: Observable<PostProcess>;
  92975. private _onSizeChangedObserver;
  92976. /**
  92977. * A function that is added to the onSizeChangedObservable
  92978. */
  92979. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92980. /**
  92981. * An event triggered when the postprocess applies its effect.
  92982. */
  92983. onApplyObservable: Observable<Effect>;
  92984. private _onApplyObserver;
  92985. /**
  92986. * A function that is added to the onApplyObservable
  92987. */
  92988. set onApply(callback: (effect: Effect) => void);
  92989. /**
  92990. * An event triggered before rendering the postprocess
  92991. */
  92992. onBeforeRenderObservable: Observable<Effect>;
  92993. private _onBeforeRenderObserver;
  92994. /**
  92995. * A function that is added to the onBeforeRenderObservable
  92996. */
  92997. set onBeforeRender(callback: (effect: Effect) => void);
  92998. /**
  92999. * An event triggered after rendering the postprocess
  93000. */
  93001. onAfterRenderObservable: Observable<Effect>;
  93002. private _onAfterRenderObserver;
  93003. /**
  93004. * A function that is added to the onAfterRenderObservable
  93005. */
  93006. set onAfterRender(callback: (efect: Effect) => void);
  93007. /**
  93008. * 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
  93009. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93010. */
  93011. get inputTexture(): InternalTexture;
  93012. set inputTexture(value: InternalTexture);
  93013. /**
  93014. * Gets the camera which post process is applied to.
  93015. * @returns The camera the post process is applied to.
  93016. */
  93017. getCamera(): Camera;
  93018. /**
  93019. * Gets the texel size of the postprocess.
  93020. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93021. */
  93022. get texelSize(): Vector2;
  93023. /**
  93024. * Creates a new instance PostProcess
  93025. * @param name The name of the PostProcess.
  93026. * @param fragmentUrl The url of the fragment shader to be used.
  93027. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93028. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93029. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93030. * @param camera The camera to apply the render pass to.
  93031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93032. * @param engine The engine which the post process will be applied. (default: current engine)
  93033. * @param reusable If the post process can be reused on the same frame. (default: false)
  93034. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93035. * @param textureType Type of textures used when performing the post process. (default: 0)
  93036. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93037. * @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
  93038. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93039. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93040. */
  93041. constructor(
  93042. /** Name of the PostProcess. */
  93043. 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);
  93044. /**
  93045. * Gets a string idenfifying the name of the class
  93046. * @returns "PostProcess" string
  93047. */
  93048. getClassName(): string;
  93049. /**
  93050. * Gets the engine which this post process belongs to.
  93051. * @returns The engine the post process was enabled with.
  93052. */
  93053. getEngine(): Engine;
  93054. /**
  93055. * The effect that is created when initializing the post process.
  93056. * @returns The created effect corresponding the the postprocess.
  93057. */
  93058. getEffect(): Effect;
  93059. /**
  93060. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93061. * @param postProcess The post process to share the output with.
  93062. * @returns This post process.
  93063. */
  93064. shareOutputWith(postProcess: PostProcess): PostProcess;
  93065. /**
  93066. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93067. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93068. */
  93069. useOwnOutput(): void;
  93070. /**
  93071. * Updates the effect with the current post process compile time values and recompiles the shader.
  93072. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93073. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93074. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93075. * @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
  93076. * @param onCompiled Called when the shader has been compiled.
  93077. * @param onError Called if there is an error when compiling a shader.
  93078. */
  93079. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93080. /**
  93081. * The post process is reusable if it can be used multiple times within one frame.
  93082. * @returns If the post process is reusable
  93083. */
  93084. isReusable(): boolean;
  93085. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93086. markTextureDirty(): void;
  93087. /**
  93088. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93089. * 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.
  93090. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93091. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93092. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93093. * @returns The target texture that was bound to be written to.
  93094. */
  93095. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93096. /**
  93097. * If the post process is supported.
  93098. */
  93099. get isSupported(): boolean;
  93100. /**
  93101. * The aspect ratio of the output texture.
  93102. */
  93103. get aspectRatio(): number;
  93104. /**
  93105. * Get a value indicating if the post-process is ready to be used
  93106. * @returns true if the post-process is ready (shader is compiled)
  93107. */
  93108. isReady(): boolean;
  93109. /**
  93110. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93111. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93112. */
  93113. apply(): Nullable<Effect>;
  93114. private _disposeTextures;
  93115. /**
  93116. * Disposes the post process.
  93117. * @param camera The camera to dispose the post process on.
  93118. */
  93119. dispose(camera?: Camera): void;
  93120. }
  93121. }
  93122. declare module BABYLON {
  93123. /** @hidden */
  93124. export var kernelBlurVaryingDeclaration: {
  93125. name: string;
  93126. shader: string;
  93127. };
  93128. }
  93129. declare module BABYLON {
  93130. /** @hidden */
  93131. export var kernelBlurFragment: {
  93132. name: string;
  93133. shader: string;
  93134. };
  93135. }
  93136. declare module BABYLON {
  93137. /** @hidden */
  93138. export var kernelBlurFragment2: {
  93139. name: string;
  93140. shader: string;
  93141. };
  93142. }
  93143. declare module BABYLON {
  93144. /** @hidden */
  93145. export var kernelBlurPixelShader: {
  93146. name: string;
  93147. shader: string;
  93148. };
  93149. }
  93150. declare module BABYLON {
  93151. /** @hidden */
  93152. export var kernelBlurVertex: {
  93153. name: string;
  93154. shader: string;
  93155. };
  93156. }
  93157. declare module BABYLON {
  93158. /** @hidden */
  93159. export var kernelBlurVertexShader: {
  93160. name: string;
  93161. shader: string;
  93162. };
  93163. }
  93164. declare module BABYLON {
  93165. /**
  93166. * The Blur Post Process which blurs an image based on a kernel and direction.
  93167. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93168. */
  93169. export class BlurPostProcess extends PostProcess {
  93170. /** The direction in which to blur the image. */
  93171. direction: Vector2;
  93172. private blockCompilation;
  93173. protected _kernel: number;
  93174. protected _idealKernel: number;
  93175. protected _packedFloat: boolean;
  93176. private _staticDefines;
  93177. /**
  93178. * Sets the length in pixels of the blur sample region
  93179. */
  93180. set kernel(v: number);
  93181. /**
  93182. * Gets the length in pixels of the blur sample region
  93183. */
  93184. get kernel(): number;
  93185. /**
  93186. * Sets wether or not the blur needs to unpack/repack floats
  93187. */
  93188. set packedFloat(v: boolean);
  93189. /**
  93190. * Gets wether or not the blur is unpacking/repacking floats
  93191. */
  93192. get packedFloat(): boolean;
  93193. /**
  93194. * Creates a new instance BlurPostProcess
  93195. * @param name The name of the effect.
  93196. * @param direction The direction in which to blur the image.
  93197. * @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.
  93198. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93199. * @param camera The camera to apply the render pass to.
  93200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93201. * @param engine The engine which the post process will be applied. (default: current engine)
  93202. * @param reusable If the post process can be reused on the same frame. (default: false)
  93203. * @param textureType Type of textures used when performing the post process. (default: 0)
  93204. * @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)
  93205. */
  93206. constructor(name: string,
  93207. /** The direction in which to blur the image. */
  93208. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93209. /**
  93210. * Updates the effect with the current post process compile time values and recompiles the shader.
  93211. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93212. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93213. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93214. * @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
  93215. * @param onCompiled Called when the shader has been compiled.
  93216. * @param onError Called if there is an error when compiling a shader.
  93217. */
  93218. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93219. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93220. /**
  93221. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93222. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93223. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93224. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93225. * The gaps between physical kernels are compensated for in the weighting of the samples
  93226. * @param idealKernel Ideal blur kernel.
  93227. * @return Nearest best kernel.
  93228. */
  93229. protected _nearestBestKernel(idealKernel: number): number;
  93230. /**
  93231. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93232. * @param x The point on the Gaussian distribution to sample.
  93233. * @return the value of the Gaussian function at x.
  93234. */
  93235. protected _gaussianWeight(x: number): number;
  93236. /**
  93237. * Generates a string that can be used as a floating point number in GLSL.
  93238. * @param x Value to print.
  93239. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93240. * @return GLSL float string.
  93241. */
  93242. protected _glslFloat(x: number, decimalFigures?: number): string;
  93243. }
  93244. }
  93245. declare module BABYLON {
  93246. /**
  93247. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93248. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93249. * You can then easily use it as a reflectionTexture on a flat surface.
  93250. * In case the surface is not a plane, please consider relying on reflection probes.
  93251. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93252. */
  93253. export class MirrorTexture extends RenderTargetTexture {
  93254. private scene;
  93255. /**
  93256. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93257. * 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.
  93258. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93259. */
  93260. mirrorPlane: Plane;
  93261. /**
  93262. * Define the blur ratio used to blur the reflection if needed.
  93263. */
  93264. set blurRatio(value: number);
  93265. get blurRatio(): number;
  93266. /**
  93267. * Define the adaptive blur kernel used to blur the reflection if needed.
  93268. * This will autocompute the closest best match for the `blurKernel`
  93269. */
  93270. set adaptiveBlurKernel(value: number);
  93271. /**
  93272. * Define the blur kernel used to blur the reflection if needed.
  93273. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93274. */
  93275. set blurKernel(value: number);
  93276. /**
  93277. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93278. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93279. */
  93280. set blurKernelX(value: number);
  93281. get blurKernelX(): number;
  93282. /**
  93283. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93284. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93285. */
  93286. set blurKernelY(value: number);
  93287. get blurKernelY(): number;
  93288. private _autoComputeBlurKernel;
  93289. protected _onRatioRescale(): void;
  93290. private _updateGammaSpace;
  93291. private _imageProcessingConfigChangeObserver;
  93292. private _transformMatrix;
  93293. private _mirrorMatrix;
  93294. private _savedViewMatrix;
  93295. private _blurX;
  93296. private _blurY;
  93297. private _adaptiveBlurKernel;
  93298. private _blurKernelX;
  93299. private _blurKernelY;
  93300. private _blurRatio;
  93301. /**
  93302. * Instantiates a Mirror Texture.
  93303. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93304. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93305. * You can then easily use it as a reflectionTexture on a flat surface.
  93306. * In case the surface is not a plane, please consider relying on reflection probes.
  93307. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93308. * @param name
  93309. * @param size
  93310. * @param scene
  93311. * @param generateMipMaps
  93312. * @param type
  93313. * @param samplingMode
  93314. * @param generateDepthBuffer
  93315. */
  93316. constructor(name: string, size: number | {
  93317. width: number;
  93318. height: number;
  93319. } | {
  93320. ratio: number;
  93321. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93322. private _preparePostProcesses;
  93323. /**
  93324. * Clone the mirror texture.
  93325. * @returns the cloned texture
  93326. */
  93327. clone(): MirrorTexture;
  93328. /**
  93329. * Serialize the texture to a JSON representation you could use in Parse later on
  93330. * @returns the serialized JSON representation
  93331. */
  93332. serialize(): any;
  93333. /**
  93334. * Dispose the texture and release its associated resources.
  93335. */
  93336. dispose(): void;
  93337. }
  93338. }
  93339. declare module BABYLON {
  93340. /**
  93341. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93342. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93343. */
  93344. export class Texture extends BaseTexture {
  93345. /**
  93346. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93347. */
  93348. static SerializeBuffers: boolean;
  93349. /** @hidden */
  93350. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93351. /** @hidden */
  93352. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93353. /** @hidden */
  93354. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93355. /** nearest is mag = nearest and min = nearest and mip = linear */
  93356. static readonly NEAREST_SAMPLINGMODE: number;
  93357. /** nearest is mag = nearest and min = nearest and mip = linear */
  93358. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93360. static readonly BILINEAR_SAMPLINGMODE: number;
  93361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93362. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93363. /** Trilinear is mag = linear and min = linear and mip = linear */
  93364. static readonly TRILINEAR_SAMPLINGMODE: number;
  93365. /** Trilinear is mag = linear and min = linear and mip = linear */
  93366. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93367. /** mag = nearest and min = nearest and mip = nearest */
  93368. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93369. /** mag = nearest and min = linear and mip = nearest */
  93370. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93371. /** mag = nearest and min = linear and mip = linear */
  93372. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93373. /** mag = nearest and min = linear and mip = none */
  93374. static readonly NEAREST_LINEAR: number;
  93375. /** mag = nearest and min = nearest and mip = none */
  93376. static readonly NEAREST_NEAREST: number;
  93377. /** mag = linear and min = nearest and mip = nearest */
  93378. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93379. /** mag = linear and min = nearest and mip = linear */
  93380. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93381. /** mag = linear and min = linear and mip = none */
  93382. static readonly LINEAR_LINEAR: number;
  93383. /** mag = linear and min = nearest and mip = none */
  93384. static readonly LINEAR_NEAREST: number;
  93385. /** Explicit coordinates mode */
  93386. static readonly EXPLICIT_MODE: number;
  93387. /** Spherical coordinates mode */
  93388. static readonly SPHERICAL_MODE: number;
  93389. /** Planar coordinates mode */
  93390. static readonly PLANAR_MODE: number;
  93391. /** Cubic coordinates mode */
  93392. static readonly CUBIC_MODE: number;
  93393. /** Projection coordinates mode */
  93394. static readonly PROJECTION_MODE: number;
  93395. /** Inverse Cubic coordinates mode */
  93396. static readonly SKYBOX_MODE: number;
  93397. /** Inverse Cubic coordinates mode */
  93398. static readonly INVCUBIC_MODE: number;
  93399. /** Equirectangular coordinates mode */
  93400. static readonly EQUIRECTANGULAR_MODE: number;
  93401. /** Equirectangular Fixed coordinates mode */
  93402. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93403. /** Equirectangular Fixed Mirrored coordinates mode */
  93404. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93405. /** Texture is not repeating outside of 0..1 UVs */
  93406. static readonly CLAMP_ADDRESSMODE: number;
  93407. /** Texture is repeating outside of 0..1 UVs */
  93408. static readonly WRAP_ADDRESSMODE: number;
  93409. /** Texture is repeating and mirrored */
  93410. static readonly MIRROR_ADDRESSMODE: number;
  93411. /**
  93412. * 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
  93413. */
  93414. static UseSerializedUrlIfAny: boolean;
  93415. /**
  93416. * Define the url of the texture.
  93417. */
  93418. url: Nullable<string>;
  93419. /**
  93420. * Define an offset on the texture to offset the u coordinates of the UVs
  93421. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93422. */
  93423. uOffset: number;
  93424. /**
  93425. * Define an offset on the texture to offset the v coordinates of the UVs
  93426. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93427. */
  93428. vOffset: number;
  93429. /**
  93430. * Define an offset on the texture to scale the u coordinates of the UVs
  93431. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93432. */
  93433. uScale: number;
  93434. /**
  93435. * Define an offset on the texture to scale the v coordinates of the UVs
  93436. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93437. */
  93438. vScale: number;
  93439. /**
  93440. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93441. * @see http://doc.babylonjs.com/how_to/more_materials
  93442. */
  93443. uAng: number;
  93444. /**
  93445. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93446. * @see http://doc.babylonjs.com/how_to/more_materials
  93447. */
  93448. vAng: number;
  93449. /**
  93450. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93451. * @see http://doc.babylonjs.com/how_to/more_materials
  93452. */
  93453. wAng: number;
  93454. /**
  93455. * Defines the center of rotation (U)
  93456. */
  93457. uRotationCenter: number;
  93458. /**
  93459. * Defines the center of rotation (V)
  93460. */
  93461. vRotationCenter: number;
  93462. /**
  93463. * Defines the center of rotation (W)
  93464. */
  93465. wRotationCenter: number;
  93466. /**
  93467. * Are mip maps generated for this texture or not.
  93468. */
  93469. get noMipmap(): boolean;
  93470. /**
  93471. * List of inspectable custom properties (used by the Inspector)
  93472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93473. */
  93474. inspectableCustomProperties: Nullable<IInspectable[]>;
  93475. private _noMipmap;
  93476. /** @hidden */
  93477. _invertY: boolean;
  93478. private _rowGenerationMatrix;
  93479. private _cachedTextureMatrix;
  93480. private _projectionModeMatrix;
  93481. private _t0;
  93482. private _t1;
  93483. private _t2;
  93484. private _cachedUOffset;
  93485. private _cachedVOffset;
  93486. private _cachedUScale;
  93487. private _cachedVScale;
  93488. private _cachedUAng;
  93489. private _cachedVAng;
  93490. private _cachedWAng;
  93491. private _cachedProjectionMatrixId;
  93492. private _cachedCoordinatesMode;
  93493. /** @hidden */
  93494. protected _initialSamplingMode: number;
  93495. /** @hidden */
  93496. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93497. private _deleteBuffer;
  93498. protected _format: Nullable<number>;
  93499. private _delayedOnLoad;
  93500. private _delayedOnError;
  93501. private _mimeType?;
  93502. /**
  93503. * Observable triggered once the texture has been loaded.
  93504. */
  93505. onLoadObservable: Observable<Texture>;
  93506. protected _isBlocking: boolean;
  93507. /**
  93508. * Is the texture preventing material to render while loading.
  93509. * If false, a default texture will be used instead of the loading one during the preparation step.
  93510. */
  93511. set isBlocking(value: boolean);
  93512. get isBlocking(): boolean;
  93513. /**
  93514. * Get the current sampling mode associated with the texture.
  93515. */
  93516. get samplingMode(): number;
  93517. /**
  93518. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93519. */
  93520. get invertY(): boolean;
  93521. /**
  93522. * Instantiates a new texture.
  93523. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93524. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93525. * @param url defines the url of the picture to load as a texture
  93526. * @param scene defines the scene or engine the texture will belong to
  93527. * @param noMipmap defines if the texture will require mip maps or not
  93528. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93529. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93530. * @param onLoad defines a callback triggered when the texture has been loaded
  93531. * @param onError defines a callback triggered when an error occurred during the loading session
  93532. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93533. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93534. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93535. * @param mimeType defines an optional mime type information
  93536. */
  93537. 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);
  93538. /**
  93539. * Update the url (and optional buffer) of this texture if url was null during construction.
  93540. * @param url the url of the texture
  93541. * @param buffer the buffer of the texture (defaults to null)
  93542. * @param onLoad callback called when the texture is loaded (defaults to null)
  93543. */
  93544. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93545. /**
  93546. * Finish the loading sequence of a texture flagged as delayed load.
  93547. * @hidden
  93548. */
  93549. delayLoad(): void;
  93550. private _prepareRowForTextureGeneration;
  93551. /**
  93552. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93553. * @returns the transform matrix of the texture.
  93554. */
  93555. getTextureMatrix(uBase?: number): Matrix;
  93556. /**
  93557. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93558. * @returns The reflection texture transform
  93559. */
  93560. getReflectionTextureMatrix(): Matrix;
  93561. /**
  93562. * Clones the texture.
  93563. * @returns the cloned texture
  93564. */
  93565. clone(): Texture;
  93566. /**
  93567. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93568. * @returns The JSON representation of the texture
  93569. */
  93570. serialize(): any;
  93571. /**
  93572. * Get the current class name of the texture useful for serialization or dynamic coding.
  93573. * @returns "Texture"
  93574. */
  93575. getClassName(): string;
  93576. /**
  93577. * Dispose the texture and release its associated resources.
  93578. */
  93579. dispose(): void;
  93580. /**
  93581. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93582. * @param parsedTexture Define the JSON representation of the texture
  93583. * @param scene Define the scene the parsed texture should be instantiated in
  93584. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93585. * @returns The parsed texture if successful
  93586. */
  93587. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93588. /**
  93589. * Creates a texture from its base 64 representation.
  93590. * @param data Define the base64 payload without the data: prefix
  93591. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93592. * @param scene Define the scene the texture should belong to
  93593. * @param noMipmap Forces the texture to not create mip map information if true
  93594. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93595. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93596. * @param onLoad define a callback triggered when the texture has been loaded
  93597. * @param onError define a callback triggered when an error occurred during the loading session
  93598. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93599. * @returns the created texture
  93600. */
  93601. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93602. /**
  93603. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93604. * @param data Define the base64 payload without the data: prefix
  93605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93606. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93607. * @param scene Define the scene the texture should belong to
  93608. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93609. * @param noMipmap Forces the texture to not create mip map information if true
  93610. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93611. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93612. * @param onLoad define a callback triggered when the texture has been loaded
  93613. * @param onError define a callback triggered when an error occurred during the loading session
  93614. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93615. * @returns the created texture
  93616. */
  93617. 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;
  93618. }
  93619. }
  93620. declare module BABYLON {
  93621. /**
  93622. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93623. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93624. */
  93625. export class PostProcessManager {
  93626. private _scene;
  93627. private _indexBuffer;
  93628. private _vertexBuffers;
  93629. /**
  93630. * Creates a new instance PostProcess
  93631. * @param scene The scene that the post process is associated with.
  93632. */
  93633. constructor(scene: Scene);
  93634. private _prepareBuffers;
  93635. private _buildIndexBuffer;
  93636. /**
  93637. * Rebuilds the vertex buffers of the manager.
  93638. * @hidden
  93639. */
  93640. _rebuild(): void;
  93641. /**
  93642. * Prepares a frame to be run through a post process.
  93643. * @param sourceTexture The input texture to the post procesess. (default: null)
  93644. * @param postProcesses An array of post processes to be run. (default: null)
  93645. * @returns True if the post processes were able to be run.
  93646. * @hidden
  93647. */
  93648. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93649. /**
  93650. * Manually render a set of post processes to a texture.
  93651. * @param postProcesses An array of post processes to be run.
  93652. * @param targetTexture The target texture to render to.
  93653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93654. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93655. * @param lodLevel defines which lod of the texture to render to
  93656. */
  93657. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93658. /**
  93659. * Finalize the result of the output of the postprocesses.
  93660. * @param doNotPresent If true the result will not be displayed to the screen.
  93661. * @param targetTexture The target texture to render to.
  93662. * @param faceIndex The index of the face to bind the target texture to.
  93663. * @param postProcesses The array of post processes to render.
  93664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93665. * @hidden
  93666. */
  93667. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93668. /**
  93669. * Disposes of the post process manager.
  93670. */
  93671. dispose(): void;
  93672. }
  93673. }
  93674. declare module BABYLON {
  93675. /**
  93676. * This Helps creating a texture that will be created from a camera in your scene.
  93677. * It is basically a dynamic texture that could be used to create special effects for instance.
  93678. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93679. */
  93680. export class RenderTargetTexture extends Texture {
  93681. isCube: boolean;
  93682. /**
  93683. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93684. */
  93685. static readonly REFRESHRATE_RENDER_ONCE: number;
  93686. /**
  93687. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93688. */
  93689. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93690. /**
  93691. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93692. * the central point of your effect and can save a lot of performances.
  93693. */
  93694. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93695. /**
  93696. * Use this predicate to dynamically define the list of mesh you want to render.
  93697. * If set, the renderList property will be overwritten.
  93698. */
  93699. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93700. private _renderList;
  93701. /**
  93702. * Use this list to define the list of mesh you want to render.
  93703. */
  93704. get renderList(): Nullable<Array<AbstractMesh>>;
  93705. set renderList(value: Nullable<Array<AbstractMesh>>);
  93706. /**
  93707. * Use this function to overload the renderList array at rendering time.
  93708. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93709. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93710. * the cube (if the RTT is a cube, else layerOrFace=0).
  93711. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93712. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93713. * hold dummy elements!
  93714. */
  93715. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93716. private _hookArray;
  93717. /**
  93718. * Define if particles should be rendered in your texture.
  93719. */
  93720. renderParticles: boolean;
  93721. /**
  93722. * Define if sprites should be rendered in your texture.
  93723. */
  93724. renderSprites: boolean;
  93725. /**
  93726. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93727. */
  93728. coordinatesMode: number;
  93729. /**
  93730. * Define the camera used to render the texture.
  93731. */
  93732. activeCamera: Nullable<Camera>;
  93733. /**
  93734. * Override the render function of the texture with your own one.
  93735. */
  93736. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93737. /**
  93738. * Define if camera post processes should be use while rendering the texture.
  93739. */
  93740. useCameraPostProcesses: boolean;
  93741. /**
  93742. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93743. */
  93744. ignoreCameraViewport: boolean;
  93745. private _postProcessManager;
  93746. private _postProcesses;
  93747. private _resizeObserver;
  93748. /**
  93749. * An event triggered when the texture is unbind.
  93750. */
  93751. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93752. /**
  93753. * An event triggered when the texture is unbind.
  93754. */
  93755. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93756. private _onAfterUnbindObserver;
  93757. /**
  93758. * Set a after unbind callback in the texture.
  93759. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93760. */
  93761. set onAfterUnbind(callback: () => void);
  93762. /**
  93763. * An event triggered before rendering the texture
  93764. */
  93765. onBeforeRenderObservable: Observable<number>;
  93766. private _onBeforeRenderObserver;
  93767. /**
  93768. * Set a before render callback in the texture.
  93769. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93770. */
  93771. set onBeforeRender(callback: (faceIndex: number) => void);
  93772. /**
  93773. * An event triggered after rendering the texture
  93774. */
  93775. onAfterRenderObservable: Observable<number>;
  93776. private _onAfterRenderObserver;
  93777. /**
  93778. * Set a after render callback in the texture.
  93779. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93780. */
  93781. set onAfterRender(callback: (faceIndex: number) => void);
  93782. /**
  93783. * An event triggered after the texture clear
  93784. */
  93785. onClearObservable: Observable<Engine>;
  93786. private _onClearObserver;
  93787. /**
  93788. * Set a clear callback in the texture.
  93789. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93790. */
  93791. set onClear(callback: (Engine: Engine) => void);
  93792. /**
  93793. * An event triggered when the texture is resized.
  93794. */
  93795. onResizeObservable: Observable<RenderTargetTexture>;
  93796. /**
  93797. * Define the clear color of the Render Target if it should be different from the scene.
  93798. */
  93799. clearColor: Color4;
  93800. protected _size: number | {
  93801. width: number;
  93802. height: number;
  93803. layers?: number;
  93804. };
  93805. protected _initialSizeParameter: number | {
  93806. width: number;
  93807. height: number;
  93808. } | {
  93809. ratio: number;
  93810. };
  93811. protected _sizeRatio: Nullable<number>;
  93812. /** @hidden */
  93813. _generateMipMaps: boolean;
  93814. protected _renderingManager: RenderingManager;
  93815. /** @hidden */
  93816. _waitingRenderList: string[];
  93817. protected _doNotChangeAspectRatio: boolean;
  93818. protected _currentRefreshId: number;
  93819. protected _refreshRate: number;
  93820. protected _textureMatrix: Matrix;
  93821. protected _samples: number;
  93822. protected _renderTargetOptions: RenderTargetCreationOptions;
  93823. /**
  93824. * Gets render target creation options that were used.
  93825. */
  93826. get renderTargetOptions(): RenderTargetCreationOptions;
  93827. protected _engine: Engine;
  93828. protected _onRatioRescale(): void;
  93829. /**
  93830. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93831. * It must define where the camera used to render the texture is set
  93832. */
  93833. boundingBoxPosition: Vector3;
  93834. private _boundingBoxSize;
  93835. /**
  93836. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93837. * When defined, the cubemap will switch to local mode
  93838. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93839. * @example https://www.babylonjs-playground.com/#RNASML
  93840. */
  93841. set boundingBoxSize(value: Vector3);
  93842. get boundingBoxSize(): Vector3;
  93843. /**
  93844. * In case the RTT has been created with a depth texture, get the associated
  93845. * depth texture.
  93846. * Otherwise, return null.
  93847. */
  93848. get depthStencilTexture(): Nullable<InternalTexture>;
  93849. /**
  93850. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93851. * or used a shadow, depth texture...
  93852. * @param name The friendly name of the texture
  93853. * @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)
  93854. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93855. * @param generateMipMaps True if mip maps need to be generated after render.
  93856. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93857. * @param type The type of the buffer in the RTT (int, half float, float...)
  93858. * @param isCube True if a cube texture needs to be created
  93859. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93860. * @param generateDepthBuffer True to generate a depth buffer
  93861. * @param generateStencilBuffer True to generate a stencil buffer
  93862. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93863. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93864. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93865. */
  93866. constructor(name: string, size: number | {
  93867. width: number;
  93868. height: number;
  93869. layers?: number;
  93870. } | {
  93871. ratio: number;
  93872. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93873. /**
  93874. * Creates a depth stencil texture.
  93875. * This is only available in WebGL 2 or with the depth texture extension available.
  93876. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93877. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93878. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93879. */
  93880. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93881. private _processSizeParameter;
  93882. /**
  93883. * Define the number of samples to use in case of MSAA.
  93884. * It defaults to one meaning no MSAA has been enabled.
  93885. */
  93886. get samples(): number;
  93887. set samples(value: number);
  93888. /**
  93889. * Resets the refresh counter of the texture and start bak from scratch.
  93890. * Could be useful to regenerate the texture if it is setup to render only once.
  93891. */
  93892. resetRefreshCounter(): void;
  93893. /**
  93894. * Define the refresh rate of the texture or the rendering frequency.
  93895. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93896. */
  93897. get refreshRate(): number;
  93898. set refreshRate(value: number);
  93899. /**
  93900. * Adds a post process to the render target rendering passes.
  93901. * @param postProcess define the post process to add
  93902. */
  93903. addPostProcess(postProcess: PostProcess): void;
  93904. /**
  93905. * Clear all the post processes attached to the render target
  93906. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93907. */
  93908. clearPostProcesses(dispose?: boolean): void;
  93909. /**
  93910. * Remove one of the post process from the list of attached post processes to the texture
  93911. * @param postProcess define the post process to remove from the list
  93912. */
  93913. removePostProcess(postProcess: PostProcess): void;
  93914. /** @hidden */
  93915. _shouldRender(): boolean;
  93916. /**
  93917. * Gets the actual render size of the texture.
  93918. * @returns the width of the render size
  93919. */
  93920. getRenderSize(): number;
  93921. /**
  93922. * Gets the actual render width of the texture.
  93923. * @returns the width of the render size
  93924. */
  93925. getRenderWidth(): number;
  93926. /**
  93927. * Gets the actual render height of the texture.
  93928. * @returns the height of the render size
  93929. */
  93930. getRenderHeight(): number;
  93931. /**
  93932. * Gets the actual number of layers of the texture.
  93933. * @returns the number of layers
  93934. */
  93935. getRenderLayers(): number;
  93936. /**
  93937. * Get if the texture can be rescaled or not.
  93938. */
  93939. get canRescale(): boolean;
  93940. /**
  93941. * Resize the texture using a ratio.
  93942. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93943. */
  93944. scale(ratio: number): void;
  93945. /**
  93946. * Get the texture reflection matrix used to rotate/transform the reflection.
  93947. * @returns the reflection matrix
  93948. */
  93949. getReflectionTextureMatrix(): Matrix;
  93950. /**
  93951. * Resize the texture to a new desired size.
  93952. * Be carrefull as it will recreate all the data in the new texture.
  93953. * @param size Define the new size. It can be:
  93954. * - a number for squared texture,
  93955. * - an object containing { width: number, height: number }
  93956. * - or an object containing a ratio { ratio: number }
  93957. */
  93958. resize(size: number | {
  93959. width: number;
  93960. height: number;
  93961. } | {
  93962. ratio: number;
  93963. }): void;
  93964. private _defaultRenderListPrepared;
  93965. /**
  93966. * Renders all the objects from the render list into the texture.
  93967. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93968. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93969. */
  93970. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93971. private _bestReflectionRenderTargetDimension;
  93972. private _prepareRenderingManager;
  93973. /**
  93974. * @hidden
  93975. * @param faceIndex face index to bind to if this is a cubetexture
  93976. * @param layer defines the index of the texture to bind in the array
  93977. */
  93978. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93979. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93980. private renderToTarget;
  93981. /**
  93982. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93983. * This allowed control for front to back rendering or reversly depending of the special needs.
  93984. *
  93985. * @param renderingGroupId The rendering group id corresponding to its index
  93986. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93987. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93988. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93989. */
  93990. 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;
  93991. /**
  93992. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93993. *
  93994. * @param renderingGroupId The rendering group id corresponding to its index
  93995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93996. */
  93997. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93998. /**
  93999. * Clones the texture.
  94000. * @returns the cloned texture
  94001. */
  94002. clone(): RenderTargetTexture;
  94003. /**
  94004. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94005. * @returns The JSON representation of the texture
  94006. */
  94007. serialize(): any;
  94008. /**
  94009. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94010. */
  94011. disposeFramebufferObjects(): void;
  94012. /**
  94013. * Dispose the texture and release its associated resources.
  94014. */
  94015. dispose(): void;
  94016. /** @hidden */
  94017. _rebuild(): void;
  94018. /**
  94019. * Clear the info related to rendering groups preventing retention point in material dispose.
  94020. */
  94021. freeRenderingGroups(): void;
  94022. /**
  94023. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94024. * @returns the view count
  94025. */
  94026. getViewCount(): number;
  94027. }
  94028. }
  94029. declare module BABYLON {
  94030. /**
  94031. * Options for compiling materials.
  94032. */
  94033. export interface IMaterialCompilationOptions {
  94034. /**
  94035. * Defines whether clip planes are enabled.
  94036. */
  94037. clipPlane: boolean;
  94038. /**
  94039. * Defines whether instances are enabled.
  94040. */
  94041. useInstances: boolean;
  94042. }
  94043. /**
  94044. * Base class for the main features of a material in Babylon.js
  94045. */
  94046. export class Material implements IAnimatable {
  94047. /**
  94048. * Returns the triangle fill mode
  94049. */
  94050. static readonly TriangleFillMode: number;
  94051. /**
  94052. * Returns the wireframe mode
  94053. */
  94054. static readonly WireFrameFillMode: number;
  94055. /**
  94056. * Returns the point fill mode
  94057. */
  94058. static readonly PointFillMode: number;
  94059. /**
  94060. * Returns the point list draw mode
  94061. */
  94062. static readonly PointListDrawMode: number;
  94063. /**
  94064. * Returns the line list draw mode
  94065. */
  94066. static readonly LineListDrawMode: number;
  94067. /**
  94068. * Returns the line loop draw mode
  94069. */
  94070. static readonly LineLoopDrawMode: number;
  94071. /**
  94072. * Returns the line strip draw mode
  94073. */
  94074. static readonly LineStripDrawMode: number;
  94075. /**
  94076. * Returns the triangle strip draw mode
  94077. */
  94078. static readonly TriangleStripDrawMode: number;
  94079. /**
  94080. * Returns the triangle fan draw mode
  94081. */
  94082. static readonly TriangleFanDrawMode: number;
  94083. /**
  94084. * Stores the clock-wise side orientation
  94085. */
  94086. static readonly ClockWiseSideOrientation: number;
  94087. /**
  94088. * Stores the counter clock-wise side orientation
  94089. */
  94090. static readonly CounterClockWiseSideOrientation: number;
  94091. /**
  94092. * The dirty texture flag value
  94093. */
  94094. static readonly TextureDirtyFlag: number;
  94095. /**
  94096. * The dirty light flag value
  94097. */
  94098. static readonly LightDirtyFlag: number;
  94099. /**
  94100. * The dirty fresnel flag value
  94101. */
  94102. static readonly FresnelDirtyFlag: number;
  94103. /**
  94104. * The dirty attribute flag value
  94105. */
  94106. static readonly AttributesDirtyFlag: number;
  94107. /**
  94108. * The dirty misc flag value
  94109. */
  94110. static readonly MiscDirtyFlag: number;
  94111. /**
  94112. * The all dirty flag value
  94113. */
  94114. static readonly AllDirtyFlag: number;
  94115. /**
  94116. * The ID of the material
  94117. */
  94118. id: string;
  94119. /**
  94120. * Gets or sets the unique id of the material
  94121. */
  94122. uniqueId: number;
  94123. /**
  94124. * The name of the material
  94125. */
  94126. name: string;
  94127. /**
  94128. * Gets or sets user defined metadata
  94129. */
  94130. metadata: any;
  94131. /**
  94132. * For internal use only. Please do not use.
  94133. */
  94134. reservedDataStore: any;
  94135. /**
  94136. * Specifies if the ready state should be checked on each call
  94137. */
  94138. checkReadyOnEveryCall: boolean;
  94139. /**
  94140. * Specifies if the ready state should be checked once
  94141. */
  94142. checkReadyOnlyOnce: boolean;
  94143. /**
  94144. * The state of the material
  94145. */
  94146. state: string;
  94147. /**
  94148. * The alpha value of the material
  94149. */
  94150. protected _alpha: number;
  94151. /**
  94152. * List of inspectable custom properties (used by the Inspector)
  94153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94154. */
  94155. inspectableCustomProperties: IInspectable[];
  94156. /**
  94157. * Sets the alpha value of the material
  94158. */
  94159. set alpha(value: number);
  94160. /**
  94161. * Gets the alpha value of the material
  94162. */
  94163. get alpha(): number;
  94164. /**
  94165. * Specifies if back face culling is enabled
  94166. */
  94167. protected _backFaceCulling: boolean;
  94168. /**
  94169. * Sets the back-face culling state
  94170. */
  94171. set backFaceCulling(value: boolean);
  94172. /**
  94173. * Gets the back-face culling state
  94174. */
  94175. get backFaceCulling(): boolean;
  94176. /**
  94177. * Stores the value for side orientation
  94178. */
  94179. sideOrientation: number;
  94180. /**
  94181. * Callback triggered when the material is compiled
  94182. */
  94183. onCompiled: Nullable<(effect: Effect) => void>;
  94184. /**
  94185. * Callback triggered when an error occurs
  94186. */
  94187. onError: Nullable<(effect: Effect, errors: string) => void>;
  94188. /**
  94189. * Callback triggered to get the render target textures
  94190. */
  94191. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94192. /**
  94193. * Gets a boolean indicating that current material needs to register RTT
  94194. */
  94195. get hasRenderTargetTextures(): boolean;
  94196. /**
  94197. * Specifies if the material should be serialized
  94198. */
  94199. doNotSerialize: boolean;
  94200. /**
  94201. * @hidden
  94202. */
  94203. _storeEffectOnSubMeshes: boolean;
  94204. /**
  94205. * Stores the animations for the material
  94206. */
  94207. animations: Nullable<Array<Animation>>;
  94208. /**
  94209. * An event triggered when the material is disposed
  94210. */
  94211. onDisposeObservable: Observable<Material>;
  94212. /**
  94213. * An observer which watches for dispose events
  94214. */
  94215. private _onDisposeObserver;
  94216. private _onUnBindObservable;
  94217. /**
  94218. * Called during a dispose event
  94219. */
  94220. set onDispose(callback: () => void);
  94221. private _onBindObservable;
  94222. /**
  94223. * An event triggered when the material is bound
  94224. */
  94225. get onBindObservable(): Observable<AbstractMesh>;
  94226. /**
  94227. * An observer which watches for bind events
  94228. */
  94229. private _onBindObserver;
  94230. /**
  94231. * Called during a bind event
  94232. */
  94233. set onBind(callback: (Mesh: AbstractMesh) => void);
  94234. /**
  94235. * An event triggered when the material is unbound
  94236. */
  94237. get onUnBindObservable(): Observable<Material>;
  94238. /**
  94239. * Stores the value of the alpha mode
  94240. */
  94241. private _alphaMode;
  94242. /**
  94243. * Sets the value of the alpha mode.
  94244. *
  94245. * | Value | Type | Description |
  94246. * | --- | --- | --- |
  94247. * | 0 | ALPHA_DISABLE | |
  94248. * | 1 | ALPHA_ADD | |
  94249. * | 2 | ALPHA_COMBINE | |
  94250. * | 3 | ALPHA_SUBTRACT | |
  94251. * | 4 | ALPHA_MULTIPLY | |
  94252. * | 5 | ALPHA_MAXIMIZED | |
  94253. * | 6 | ALPHA_ONEONE | |
  94254. * | 7 | ALPHA_PREMULTIPLIED | |
  94255. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94256. * | 9 | ALPHA_INTERPOLATE | |
  94257. * | 10 | ALPHA_SCREENMODE | |
  94258. *
  94259. */
  94260. set alphaMode(value: number);
  94261. /**
  94262. * Gets the value of the alpha mode
  94263. */
  94264. get alphaMode(): number;
  94265. /**
  94266. * Stores the state of the need depth pre-pass value
  94267. */
  94268. private _needDepthPrePass;
  94269. /**
  94270. * Sets the need depth pre-pass value
  94271. */
  94272. set needDepthPrePass(value: boolean);
  94273. /**
  94274. * Gets the depth pre-pass value
  94275. */
  94276. get needDepthPrePass(): boolean;
  94277. /**
  94278. * Specifies if depth writing should be disabled
  94279. */
  94280. disableDepthWrite: boolean;
  94281. /**
  94282. * Specifies if depth writing should be forced
  94283. */
  94284. forceDepthWrite: boolean;
  94285. /**
  94286. * Specifies the depth function that should be used. 0 means the default engine function
  94287. */
  94288. depthFunction: number;
  94289. /**
  94290. * Specifies if there should be a separate pass for culling
  94291. */
  94292. separateCullingPass: boolean;
  94293. /**
  94294. * Stores the state specifing if fog should be enabled
  94295. */
  94296. private _fogEnabled;
  94297. /**
  94298. * Sets the state for enabling fog
  94299. */
  94300. set fogEnabled(value: boolean);
  94301. /**
  94302. * Gets the value of the fog enabled state
  94303. */
  94304. get fogEnabled(): boolean;
  94305. /**
  94306. * Stores the size of points
  94307. */
  94308. pointSize: number;
  94309. /**
  94310. * Stores the z offset value
  94311. */
  94312. zOffset: number;
  94313. /**
  94314. * Gets a value specifying if wireframe mode is enabled
  94315. */
  94316. get wireframe(): boolean;
  94317. /**
  94318. * Sets the state of wireframe mode
  94319. */
  94320. set wireframe(value: boolean);
  94321. /**
  94322. * Gets the value specifying if point clouds are enabled
  94323. */
  94324. get pointsCloud(): boolean;
  94325. /**
  94326. * Sets the state of point cloud mode
  94327. */
  94328. set pointsCloud(value: boolean);
  94329. /**
  94330. * Gets the material fill mode
  94331. */
  94332. get fillMode(): number;
  94333. /**
  94334. * Sets the material fill mode
  94335. */
  94336. set fillMode(value: number);
  94337. /**
  94338. * @hidden
  94339. * Stores the effects for the material
  94340. */
  94341. _effect: Nullable<Effect>;
  94342. /**
  94343. * Specifies if uniform buffers should be used
  94344. */
  94345. private _useUBO;
  94346. /**
  94347. * Stores a reference to the scene
  94348. */
  94349. private _scene;
  94350. /**
  94351. * Stores the fill mode state
  94352. */
  94353. private _fillMode;
  94354. /**
  94355. * Specifies if the depth write state should be cached
  94356. */
  94357. private _cachedDepthWriteState;
  94358. /**
  94359. * Specifies if the depth function state should be cached
  94360. */
  94361. private _cachedDepthFunctionState;
  94362. /**
  94363. * Stores the uniform buffer
  94364. */
  94365. protected _uniformBuffer: UniformBuffer;
  94366. /** @hidden */
  94367. _indexInSceneMaterialArray: number;
  94368. /** @hidden */
  94369. meshMap: Nullable<{
  94370. [id: string]: AbstractMesh | undefined;
  94371. }>;
  94372. /**
  94373. * Creates a material instance
  94374. * @param name defines the name of the material
  94375. * @param scene defines the scene to reference
  94376. * @param doNotAdd specifies if the material should be added to the scene
  94377. */
  94378. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94379. /**
  94380. * Returns a string representation of the current material
  94381. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94382. * @returns a string with material information
  94383. */
  94384. toString(fullDetails?: boolean): string;
  94385. /**
  94386. * Gets the class name of the material
  94387. * @returns a string with the class name of the material
  94388. */
  94389. getClassName(): string;
  94390. /**
  94391. * Specifies if updates for the material been locked
  94392. */
  94393. get isFrozen(): boolean;
  94394. /**
  94395. * Locks updates for the material
  94396. */
  94397. freeze(): void;
  94398. /**
  94399. * Unlocks updates for the material
  94400. */
  94401. unfreeze(): void;
  94402. /**
  94403. * Specifies if the material is ready to be used
  94404. * @param mesh defines the mesh to check
  94405. * @param useInstances specifies if instances should be used
  94406. * @returns a boolean indicating if the material is ready to be used
  94407. */
  94408. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94409. /**
  94410. * Specifies that the submesh is ready to be used
  94411. * @param mesh defines the mesh to check
  94412. * @param subMesh defines which submesh to check
  94413. * @param useInstances specifies that instances should be used
  94414. * @returns a boolean indicating that the submesh is ready or not
  94415. */
  94416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94417. /**
  94418. * Returns the material effect
  94419. * @returns the effect associated with the material
  94420. */
  94421. getEffect(): Nullable<Effect>;
  94422. /**
  94423. * Returns the current scene
  94424. * @returns a Scene
  94425. */
  94426. getScene(): Scene;
  94427. /**
  94428. * Specifies if the material will require alpha blending
  94429. * @returns a boolean specifying if alpha blending is needed
  94430. */
  94431. needAlphaBlending(): boolean;
  94432. /**
  94433. * Specifies if the mesh will require alpha blending
  94434. * @param mesh defines the mesh to check
  94435. * @returns a boolean specifying if alpha blending is needed for the mesh
  94436. */
  94437. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94438. /**
  94439. * Specifies if this material should be rendered in alpha test mode
  94440. * @returns a boolean specifying if an alpha test is needed.
  94441. */
  94442. needAlphaTesting(): boolean;
  94443. /**
  94444. * Gets the texture used for the alpha test
  94445. * @returns the texture to use for alpha testing
  94446. */
  94447. getAlphaTestTexture(): Nullable<BaseTexture>;
  94448. /**
  94449. * Marks the material to indicate that it needs to be re-calculated
  94450. */
  94451. markDirty(): void;
  94452. /** @hidden */
  94453. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94454. /**
  94455. * Binds the material to the mesh
  94456. * @param world defines the world transformation matrix
  94457. * @param mesh defines the mesh to bind the material to
  94458. */
  94459. bind(world: Matrix, mesh?: Mesh): void;
  94460. /**
  94461. * Binds the submesh to the material
  94462. * @param world defines the world transformation matrix
  94463. * @param mesh defines the mesh containing the submesh
  94464. * @param subMesh defines the submesh to bind the material to
  94465. */
  94466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94467. /**
  94468. * Binds the world matrix to the material
  94469. * @param world defines the world transformation matrix
  94470. */
  94471. bindOnlyWorldMatrix(world: Matrix): void;
  94472. /**
  94473. * Binds the scene's uniform buffer to the effect.
  94474. * @param effect defines the effect to bind to the scene uniform buffer
  94475. * @param sceneUbo defines the uniform buffer storing scene data
  94476. */
  94477. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94478. /**
  94479. * Binds the view matrix to the effect
  94480. * @param effect defines the effect to bind the view matrix to
  94481. */
  94482. bindView(effect: Effect): void;
  94483. /**
  94484. * Binds the view projection matrix to the effect
  94485. * @param effect defines the effect to bind the view projection matrix to
  94486. */
  94487. bindViewProjection(effect: Effect): void;
  94488. /**
  94489. * Specifies if material alpha testing should be turned on for the mesh
  94490. * @param mesh defines the mesh to check
  94491. */
  94492. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94493. /**
  94494. * Processes to execute after binding the material to a mesh
  94495. * @param mesh defines the rendered mesh
  94496. */
  94497. protected _afterBind(mesh?: Mesh): void;
  94498. /**
  94499. * Unbinds the material from the mesh
  94500. */
  94501. unbind(): void;
  94502. /**
  94503. * Gets the active textures from the material
  94504. * @returns an array of textures
  94505. */
  94506. getActiveTextures(): BaseTexture[];
  94507. /**
  94508. * Specifies if the material uses a texture
  94509. * @param texture defines the texture to check against the material
  94510. * @returns a boolean specifying if the material uses the texture
  94511. */
  94512. hasTexture(texture: BaseTexture): boolean;
  94513. /**
  94514. * Makes a duplicate of the material, and gives it a new name
  94515. * @param name defines the new name for the duplicated material
  94516. * @returns the cloned material
  94517. */
  94518. clone(name: string): Nullable<Material>;
  94519. /**
  94520. * Gets the meshes bound to the material
  94521. * @returns an array of meshes bound to the material
  94522. */
  94523. getBindedMeshes(): AbstractMesh[];
  94524. /**
  94525. * Force shader compilation
  94526. * @param mesh defines the mesh associated with this material
  94527. * @param onCompiled defines a function to execute once the material is compiled
  94528. * @param options defines the options to configure the compilation
  94529. * @param onError defines a function to execute if the material fails compiling
  94530. */
  94531. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94532. /**
  94533. * Force shader compilation
  94534. * @param mesh defines the mesh that will use this material
  94535. * @param options defines additional options for compiling the shaders
  94536. * @returns a promise that resolves when the compilation completes
  94537. */
  94538. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94539. private static readonly _AllDirtyCallBack;
  94540. private static readonly _ImageProcessingDirtyCallBack;
  94541. private static readonly _TextureDirtyCallBack;
  94542. private static readonly _FresnelDirtyCallBack;
  94543. private static readonly _MiscDirtyCallBack;
  94544. private static readonly _LightsDirtyCallBack;
  94545. private static readonly _AttributeDirtyCallBack;
  94546. private static _FresnelAndMiscDirtyCallBack;
  94547. private static _TextureAndMiscDirtyCallBack;
  94548. private static readonly _DirtyCallbackArray;
  94549. private static readonly _RunDirtyCallBacks;
  94550. /**
  94551. * Marks a define in the material to indicate that it needs to be re-computed
  94552. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94553. */
  94554. markAsDirty(flag: number): void;
  94555. /**
  94556. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94557. * @param func defines a function which checks material defines against the submeshes
  94558. */
  94559. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94560. /**
  94561. * Indicates that we need to re-calculated for all submeshes
  94562. */
  94563. protected _markAllSubMeshesAsAllDirty(): void;
  94564. /**
  94565. * Indicates that image processing needs to be re-calculated for all submeshes
  94566. */
  94567. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94568. /**
  94569. * Indicates that textures need to be re-calculated for all submeshes
  94570. */
  94571. protected _markAllSubMeshesAsTexturesDirty(): void;
  94572. /**
  94573. * Indicates that fresnel needs to be re-calculated for all submeshes
  94574. */
  94575. protected _markAllSubMeshesAsFresnelDirty(): void;
  94576. /**
  94577. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94578. */
  94579. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94580. /**
  94581. * Indicates that lights need to be re-calculated for all submeshes
  94582. */
  94583. protected _markAllSubMeshesAsLightsDirty(): void;
  94584. /**
  94585. * Indicates that attributes need to be re-calculated for all submeshes
  94586. */
  94587. protected _markAllSubMeshesAsAttributesDirty(): void;
  94588. /**
  94589. * Indicates that misc needs to be re-calculated for all submeshes
  94590. */
  94591. protected _markAllSubMeshesAsMiscDirty(): void;
  94592. /**
  94593. * Indicates that textures and misc need to be re-calculated for all submeshes
  94594. */
  94595. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94596. /**
  94597. * Disposes the material
  94598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94599. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94600. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94601. */
  94602. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94603. /** @hidden */
  94604. private releaseVertexArrayObject;
  94605. /**
  94606. * Serializes this material
  94607. * @returns the serialized material object
  94608. */
  94609. serialize(): any;
  94610. /**
  94611. * Creates a material from parsed material data
  94612. * @param parsedMaterial defines parsed material data
  94613. * @param scene defines the hosting scene
  94614. * @param rootUrl defines the root URL to use to load textures
  94615. * @returns a new material
  94616. */
  94617. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94618. }
  94619. }
  94620. declare module BABYLON {
  94621. /**
  94622. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94623. * separate meshes. This can be use to improve performances.
  94624. * @see http://doc.babylonjs.com/how_to/multi_materials
  94625. */
  94626. export class MultiMaterial extends Material {
  94627. private _subMaterials;
  94628. /**
  94629. * Gets or Sets the list of Materials used within the multi material.
  94630. * They need to be ordered according to the submeshes order in the associated mesh
  94631. */
  94632. get subMaterials(): Nullable<Material>[];
  94633. set subMaterials(value: Nullable<Material>[]);
  94634. /**
  94635. * Function used to align with Node.getChildren()
  94636. * @returns the list of Materials used within the multi material
  94637. */
  94638. getChildren(): Nullable<Material>[];
  94639. /**
  94640. * Instantiates a new Multi Material
  94641. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94642. * separate meshes. This can be use to improve performances.
  94643. * @see http://doc.babylonjs.com/how_to/multi_materials
  94644. * @param name Define the name in the scene
  94645. * @param scene Define the scene the material belongs to
  94646. */
  94647. constructor(name: string, scene: Scene);
  94648. private _hookArray;
  94649. /**
  94650. * Get one of the submaterial by its index in the submaterials array
  94651. * @param index The index to look the sub material at
  94652. * @returns The Material if the index has been defined
  94653. */
  94654. getSubMaterial(index: number): Nullable<Material>;
  94655. /**
  94656. * Get the list of active textures for the whole sub materials list.
  94657. * @returns All the textures that will be used during the rendering
  94658. */
  94659. getActiveTextures(): BaseTexture[];
  94660. /**
  94661. * Gets the current class name of the material e.g. "MultiMaterial"
  94662. * Mainly use in serialization.
  94663. * @returns the class name
  94664. */
  94665. getClassName(): string;
  94666. /**
  94667. * Checks if the material is ready to render the requested sub mesh
  94668. * @param mesh Define the mesh the submesh belongs to
  94669. * @param subMesh Define the sub mesh to look readyness for
  94670. * @param useInstances Define whether or not the material is used with instances
  94671. * @returns true if ready, otherwise false
  94672. */
  94673. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94674. /**
  94675. * Clones the current material and its related sub materials
  94676. * @param name Define the name of the newly cloned material
  94677. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94678. * @returns the cloned material
  94679. */
  94680. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94681. /**
  94682. * Serializes the materials into a JSON representation.
  94683. * @returns the JSON representation
  94684. */
  94685. serialize(): any;
  94686. /**
  94687. * Dispose the material and release its associated resources
  94688. * @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)
  94689. * @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)
  94690. * @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)
  94691. */
  94692. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94693. /**
  94694. * Creates a MultiMaterial from parsed MultiMaterial data.
  94695. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94696. * @param scene defines the hosting scene
  94697. * @returns a new MultiMaterial
  94698. */
  94699. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94700. }
  94701. }
  94702. declare module BABYLON {
  94703. /**
  94704. * Base class for submeshes
  94705. */
  94706. export class BaseSubMesh {
  94707. /** @hidden */
  94708. _materialDefines: Nullable<MaterialDefines>;
  94709. /** @hidden */
  94710. _materialEffect: Nullable<Effect>;
  94711. /**
  94712. * Gets material defines used by the effect associated to the sub mesh
  94713. */
  94714. get materialDefines(): Nullable<MaterialDefines>;
  94715. /**
  94716. * Sets material defines used by the effect associated to the sub mesh
  94717. */
  94718. set materialDefines(defines: Nullable<MaterialDefines>);
  94719. /**
  94720. * Gets associated effect
  94721. */
  94722. get effect(): Nullable<Effect>;
  94723. /**
  94724. * Sets associated effect (effect used to render this submesh)
  94725. * @param effect defines the effect to associate with
  94726. * @param defines defines the set of defines used to compile this effect
  94727. */
  94728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94729. }
  94730. /**
  94731. * Defines a subdivision inside a mesh
  94732. */
  94733. export class SubMesh extends BaseSubMesh implements ICullable {
  94734. /** the material index to use */
  94735. materialIndex: number;
  94736. /** vertex index start */
  94737. verticesStart: number;
  94738. /** vertices count */
  94739. verticesCount: number;
  94740. /** index start */
  94741. indexStart: number;
  94742. /** indices count */
  94743. indexCount: number;
  94744. /** @hidden */
  94745. _linesIndexCount: number;
  94746. private _mesh;
  94747. private _renderingMesh;
  94748. private _boundingInfo;
  94749. private _linesIndexBuffer;
  94750. /** @hidden */
  94751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94752. /** @hidden */
  94753. _trianglePlanes: Plane[];
  94754. /** @hidden */
  94755. _lastColliderTransformMatrix: Nullable<Matrix>;
  94756. /** @hidden */
  94757. _renderId: number;
  94758. /** @hidden */
  94759. _alphaIndex: number;
  94760. /** @hidden */
  94761. _distanceToCamera: number;
  94762. /** @hidden */
  94763. _id: number;
  94764. private _currentMaterial;
  94765. /**
  94766. * Add a new submesh to a mesh
  94767. * @param materialIndex defines the material index to use
  94768. * @param verticesStart defines vertex index start
  94769. * @param verticesCount defines vertices count
  94770. * @param indexStart defines index start
  94771. * @param indexCount defines indices count
  94772. * @param mesh defines the parent mesh
  94773. * @param renderingMesh defines an optional rendering mesh
  94774. * @param createBoundingBox defines if bounding box should be created for this submesh
  94775. * @returns the new submesh
  94776. */
  94777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94778. /**
  94779. * Creates a new submesh
  94780. * @param materialIndex defines the material index to use
  94781. * @param verticesStart defines vertex index start
  94782. * @param verticesCount defines vertices count
  94783. * @param indexStart defines index start
  94784. * @param indexCount defines indices count
  94785. * @param mesh defines the parent mesh
  94786. * @param renderingMesh defines an optional rendering mesh
  94787. * @param createBoundingBox defines if bounding box should be created for this submesh
  94788. */
  94789. constructor(
  94790. /** the material index to use */
  94791. materialIndex: number,
  94792. /** vertex index start */
  94793. verticesStart: number,
  94794. /** vertices count */
  94795. verticesCount: number,
  94796. /** index start */
  94797. indexStart: number,
  94798. /** indices count */
  94799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94800. /**
  94801. * Returns true if this submesh covers the entire parent mesh
  94802. * @ignorenaming
  94803. */
  94804. get IsGlobal(): boolean;
  94805. /**
  94806. * Returns the submesh BoudingInfo object
  94807. * @returns current bounding info (or mesh's one if the submesh is global)
  94808. */
  94809. getBoundingInfo(): BoundingInfo;
  94810. /**
  94811. * Sets the submesh BoundingInfo
  94812. * @param boundingInfo defines the new bounding info to use
  94813. * @returns the SubMesh
  94814. */
  94815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94816. /**
  94817. * Returns the mesh of the current submesh
  94818. * @return the parent mesh
  94819. */
  94820. getMesh(): AbstractMesh;
  94821. /**
  94822. * Returns the rendering mesh of the submesh
  94823. * @returns the rendering mesh (could be different from parent mesh)
  94824. */
  94825. getRenderingMesh(): Mesh;
  94826. /**
  94827. * Returns the submesh material
  94828. * @returns null or the current material
  94829. */
  94830. getMaterial(): Nullable<Material>;
  94831. /**
  94832. * Sets a new updated BoundingInfo object to the submesh
  94833. * @param data defines an optional position array to use to determine the bounding info
  94834. * @returns the SubMesh
  94835. */
  94836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94837. /** @hidden */
  94838. _checkCollision(collider: Collider): boolean;
  94839. /**
  94840. * Updates the submesh BoundingInfo
  94841. * @param world defines the world matrix to use to update the bounding info
  94842. * @returns the submesh
  94843. */
  94844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94845. /**
  94846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94847. * @param frustumPlanes defines the frustum planes
  94848. * @returns true if the submesh is intersecting with the frustum
  94849. */
  94850. isInFrustum(frustumPlanes: Plane[]): boolean;
  94851. /**
  94852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94853. * @param frustumPlanes defines the frustum planes
  94854. * @returns true if the submesh is inside the frustum
  94855. */
  94856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94857. /**
  94858. * Renders the submesh
  94859. * @param enableAlphaMode defines if alpha needs to be used
  94860. * @returns the submesh
  94861. */
  94862. render(enableAlphaMode: boolean): SubMesh;
  94863. /**
  94864. * @hidden
  94865. */
  94866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94867. /**
  94868. * Checks if the submesh intersects with a ray
  94869. * @param ray defines the ray to test
  94870. * @returns true is the passed ray intersects the submesh bounding box
  94871. */
  94872. canIntersects(ray: Ray): boolean;
  94873. /**
  94874. * Intersects current submesh with a ray
  94875. * @param ray defines the ray to test
  94876. * @param positions defines mesh's positions array
  94877. * @param indices defines mesh's indices array
  94878. * @param fastCheck defines if only bounding info should be used
  94879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94880. * @returns intersection info or null if no intersection
  94881. */
  94882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94883. /** @hidden */
  94884. private _intersectLines;
  94885. /** @hidden */
  94886. private _intersectUnIndexedLines;
  94887. /** @hidden */
  94888. private _intersectTriangles;
  94889. /** @hidden */
  94890. private _intersectUnIndexedTriangles;
  94891. /** @hidden */
  94892. _rebuild(): void;
  94893. /**
  94894. * Creates a new submesh from the passed mesh
  94895. * @param newMesh defines the new hosting mesh
  94896. * @param newRenderingMesh defines an optional rendering mesh
  94897. * @returns the new submesh
  94898. */
  94899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94900. /**
  94901. * Release associated resources
  94902. */
  94903. dispose(): void;
  94904. /**
  94905. * Gets the class name
  94906. * @returns the string "SubMesh".
  94907. */
  94908. getClassName(): string;
  94909. /**
  94910. * Creates a new submesh from indices data
  94911. * @param materialIndex the index of the main mesh material
  94912. * @param startIndex the index where to start the copy in the mesh indices array
  94913. * @param indexCount the number of indices to copy then from the startIndex
  94914. * @param mesh the main mesh to create the submesh from
  94915. * @param renderingMesh the optional rendering mesh
  94916. * @returns a new submesh
  94917. */
  94918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94919. }
  94920. }
  94921. declare module BABYLON {
  94922. /**
  94923. * Class used to represent data loading progression
  94924. */
  94925. export class SceneLoaderFlags {
  94926. private static _ForceFullSceneLoadingForIncremental;
  94927. private static _ShowLoadingScreen;
  94928. private static _CleanBoneMatrixWeights;
  94929. private static _loggingLevel;
  94930. /**
  94931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94932. */
  94933. static get ForceFullSceneLoadingForIncremental(): boolean;
  94934. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94935. /**
  94936. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94937. */
  94938. static get ShowLoadingScreen(): boolean;
  94939. static set ShowLoadingScreen(value: boolean);
  94940. /**
  94941. * Defines the current logging level (while loading the scene)
  94942. * @ignorenaming
  94943. */
  94944. static get loggingLevel(): number;
  94945. static set loggingLevel(value: number);
  94946. /**
  94947. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94948. */
  94949. static get CleanBoneMatrixWeights(): boolean;
  94950. static set CleanBoneMatrixWeights(value: boolean);
  94951. }
  94952. }
  94953. declare module BABYLON {
  94954. /**
  94955. * Class used to store geometry data (vertex buffers + index buffer)
  94956. */
  94957. export class Geometry implements IGetSetVerticesData {
  94958. /**
  94959. * Gets or sets the ID of the geometry
  94960. */
  94961. id: string;
  94962. /**
  94963. * Gets or sets the unique ID of the geometry
  94964. */
  94965. uniqueId: number;
  94966. /**
  94967. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94968. */
  94969. delayLoadState: number;
  94970. /**
  94971. * Gets the file containing the data to load when running in delay load state
  94972. */
  94973. delayLoadingFile: Nullable<string>;
  94974. /**
  94975. * Callback called when the geometry is updated
  94976. */
  94977. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94978. private _scene;
  94979. private _engine;
  94980. private _meshes;
  94981. private _totalVertices;
  94982. /** @hidden */
  94983. _indices: IndicesArray;
  94984. /** @hidden */
  94985. _vertexBuffers: {
  94986. [key: string]: VertexBuffer;
  94987. };
  94988. private _isDisposed;
  94989. private _extend;
  94990. private _boundingBias;
  94991. /** @hidden */
  94992. _delayInfo: Array<string>;
  94993. private _indexBuffer;
  94994. private _indexBufferIsUpdatable;
  94995. /** @hidden */
  94996. _boundingInfo: Nullable<BoundingInfo>;
  94997. /** @hidden */
  94998. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94999. /** @hidden */
  95000. _softwareSkinningFrameId: number;
  95001. private _vertexArrayObjects;
  95002. private _updatable;
  95003. /** @hidden */
  95004. _positions: Nullable<Vector3[]>;
  95005. /**
  95006. * 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
  95007. */
  95008. get boundingBias(): Vector2;
  95009. /**
  95010. * 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
  95011. */
  95012. set boundingBias(value: Vector2);
  95013. /**
  95014. * Static function used to attach a new empty geometry to a mesh
  95015. * @param mesh defines the mesh to attach the geometry to
  95016. * @returns the new Geometry
  95017. */
  95018. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95019. /**
  95020. * Creates a new geometry
  95021. * @param id defines the unique ID
  95022. * @param scene defines the hosting scene
  95023. * @param vertexData defines the VertexData used to get geometry data
  95024. * @param updatable defines if geometry must be updatable (false by default)
  95025. * @param mesh defines the mesh that will be associated with the geometry
  95026. */
  95027. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95028. /**
  95029. * Gets the current extend of the geometry
  95030. */
  95031. get extend(): {
  95032. minimum: Vector3;
  95033. maximum: Vector3;
  95034. };
  95035. /**
  95036. * Gets the hosting scene
  95037. * @returns the hosting Scene
  95038. */
  95039. getScene(): Scene;
  95040. /**
  95041. * Gets the hosting engine
  95042. * @returns the hosting Engine
  95043. */
  95044. getEngine(): Engine;
  95045. /**
  95046. * Defines if the geometry is ready to use
  95047. * @returns true if the geometry is ready to be used
  95048. */
  95049. isReady(): boolean;
  95050. /**
  95051. * Gets a value indicating that the geometry should not be serialized
  95052. */
  95053. get doNotSerialize(): boolean;
  95054. /** @hidden */
  95055. _rebuild(): void;
  95056. /**
  95057. * Affects all geometry data in one call
  95058. * @param vertexData defines the geometry data
  95059. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95060. */
  95061. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95062. /**
  95063. * Set specific vertex data
  95064. * @param kind defines the data kind (Position, normal, etc...)
  95065. * @param data defines the vertex data to use
  95066. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95067. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95068. */
  95069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95070. /**
  95071. * Removes a specific vertex data
  95072. * @param kind defines the data kind (Position, normal, etc...)
  95073. */
  95074. removeVerticesData(kind: string): void;
  95075. /**
  95076. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95077. * @param buffer defines the vertex buffer to use
  95078. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95079. */
  95080. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95081. /**
  95082. * Update a specific vertex buffer
  95083. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95084. * It will do nothing if the buffer is not updatable
  95085. * @param kind defines the data kind (Position, normal, etc...)
  95086. * @param data defines the data to use
  95087. * @param offset defines the offset in the target buffer where to store the data
  95088. * @param useBytes set to true if the offset is in bytes
  95089. */
  95090. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95091. /**
  95092. * Update a specific vertex buffer
  95093. * This function will create a new buffer if the current one is not updatable
  95094. * @param kind defines the data kind (Position, normal, etc...)
  95095. * @param data defines the data to use
  95096. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95097. */
  95098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95099. private _updateBoundingInfo;
  95100. /** @hidden */
  95101. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95102. /**
  95103. * Gets total number of vertices
  95104. * @returns the total number of vertices
  95105. */
  95106. getTotalVertices(): number;
  95107. /**
  95108. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95109. * @param kind defines the data kind (Position, normal, etc...)
  95110. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95111. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95112. * @returns a float array containing vertex data
  95113. */
  95114. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95115. /**
  95116. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95117. * @param kind defines the data kind (Position, normal, etc...)
  95118. * @returns true if the vertex buffer with the specified kind is updatable
  95119. */
  95120. isVertexBufferUpdatable(kind: string): boolean;
  95121. /**
  95122. * Gets a specific vertex buffer
  95123. * @param kind defines the data kind (Position, normal, etc...)
  95124. * @returns a VertexBuffer
  95125. */
  95126. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95127. /**
  95128. * Returns all vertex buffers
  95129. * @return an object holding all vertex buffers indexed by kind
  95130. */
  95131. getVertexBuffers(): Nullable<{
  95132. [key: string]: VertexBuffer;
  95133. }>;
  95134. /**
  95135. * Gets a boolean indicating if specific vertex buffer is present
  95136. * @param kind defines the data kind (Position, normal, etc...)
  95137. * @returns true if data is present
  95138. */
  95139. isVerticesDataPresent(kind: string): boolean;
  95140. /**
  95141. * Gets a list of all attached data kinds (Position, normal, etc...)
  95142. * @returns a list of string containing all kinds
  95143. */
  95144. getVerticesDataKinds(): string[];
  95145. /**
  95146. * Update index buffer
  95147. * @param indices defines the indices to store in the index buffer
  95148. * @param offset defines the offset in the target buffer where to store the data
  95149. * @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)
  95150. */
  95151. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95152. /**
  95153. * Creates a new index buffer
  95154. * @param indices defines the indices to store in the index buffer
  95155. * @param totalVertices defines the total number of vertices (could be null)
  95156. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95157. */
  95158. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95159. /**
  95160. * Return the total number of indices
  95161. * @returns the total number of indices
  95162. */
  95163. getTotalIndices(): number;
  95164. /**
  95165. * Gets the index buffer array
  95166. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95167. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95168. * @returns the index buffer array
  95169. */
  95170. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95171. /**
  95172. * Gets the index buffer
  95173. * @return the index buffer
  95174. */
  95175. getIndexBuffer(): Nullable<DataBuffer>;
  95176. /** @hidden */
  95177. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95178. /**
  95179. * Release the associated resources for a specific mesh
  95180. * @param mesh defines the source mesh
  95181. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95182. */
  95183. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95184. /**
  95185. * Apply current geometry to a given mesh
  95186. * @param mesh defines the mesh to apply geometry to
  95187. */
  95188. applyToMesh(mesh: Mesh): void;
  95189. private _updateExtend;
  95190. private _applyToMesh;
  95191. private notifyUpdate;
  95192. /**
  95193. * Load the geometry if it was flagged as delay loaded
  95194. * @param scene defines the hosting scene
  95195. * @param onLoaded defines a callback called when the geometry is loaded
  95196. */
  95197. load(scene: Scene, onLoaded?: () => void): void;
  95198. private _queueLoad;
  95199. /**
  95200. * Invert the geometry to move from a right handed system to a left handed one.
  95201. */
  95202. toLeftHanded(): void;
  95203. /** @hidden */
  95204. _resetPointsArrayCache(): void;
  95205. /** @hidden */
  95206. _generatePointsArray(): boolean;
  95207. /**
  95208. * Gets a value indicating if the geometry is disposed
  95209. * @returns true if the geometry was disposed
  95210. */
  95211. isDisposed(): boolean;
  95212. private _disposeVertexArrayObjects;
  95213. /**
  95214. * Free all associated resources
  95215. */
  95216. dispose(): void;
  95217. /**
  95218. * Clone the current geometry into a new geometry
  95219. * @param id defines the unique ID of the new geometry
  95220. * @returns a new geometry object
  95221. */
  95222. copy(id: string): Geometry;
  95223. /**
  95224. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95225. * @return a JSON representation of the current geometry data (without the vertices data)
  95226. */
  95227. serialize(): any;
  95228. private toNumberArray;
  95229. /**
  95230. * Serialize all vertices data into a JSON oject
  95231. * @returns a JSON representation of the current geometry data
  95232. */
  95233. serializeVerticeData(): any;
  95234. /**
  95235. * Extracts a clone of a mesh geometry
  95236. * @param mesh defines the source mesh
  95237. * @param id defines the unique ID of the new geometry object
  95238. * @returns the new geometry object
  95239. */
  95240. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95241. /**
  95242. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95243. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95244. * Be aware Math.random() could cause collisions, but:
  95245. * "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"
  95246. * @returns a string containing a new GUID
  95247. */
  95248. static RandomId(): string;
  95249. /** @hidden */
  95250. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95251. private static _CleanMatricesWeights;
  95252. /**
  95253. * Create a new geometry from persisted data (Using .babylon file format)
  95254. * @param parsedVertexData defines the persisted data
  95255. * @param scene defines the hosting scene
  95256. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95257. * @returns the new geometry object
  95258. */
  95259. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95260. }
  95261. }
  95262. declare module BABYLON {
  95263. /**
  95264. * Define an interface for all classes that will get and set the data on vertices
  95265. */
  95266. export interface IGetSetVerticesData {
  95267. /**
  95268. * Gets a boolean indicating if specific vertex data is present
  95269. * @param kind defines the vertex data kind to use
  95270. * @returns true is data kind is present
  95271. */
  95272. isVerticesDataPresent(kind: string): boolean;
  95273. /**
  95274. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95275. * @param kind defines the data kind (Position, normal, etc...)
  95276. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95277. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95278. * @returns a float array containing vertex data
  95279. */
  95280. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95281. /**
  95282. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95283. * @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.
  95284. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95285. * @returns the indices array or an empty array if the mesh has no geometry
  95286. */
  95287. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95288. /**
  95289. * Set specific vertex data
  95290. * @param kind defines the data kind (Position, normal, etc...)
  95291. * @param data defines the vertex data to use
  95292. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95293. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95294. */
  95295. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95296. /**
  95297. * Update a specific associated vertex buffer
  95298. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95299. * - VertexBuffer.PositionKind
  95300. * - VertexBuffer.UVKind
  95301. * - VertexBuffer.UV2Kind
  95302. * - VertexBuffer.UV3Kind
  95303. * - VertexBuffer.UV4Kind
  95304. * - VertexBuffer.UV5Kind
  95305. * - VertexBuffer.UV6Kind
  95306. * - VertexBuffer.ColorKind
  95307. * - VertexBuffer.MatricesIndicesKind
  95308. * - VertexBuffer.MatricesIndicesExtraKind
  95309. * - VertexBuffer.MatricesWeightsKind
  95310. * - VertexBuffer.MatricesWeightsExtraKind
  95311. * @param data defines the data source
  95312. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95313. * @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)
  95314. */
  95315. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95316. /**
  95317. * Creates a new index buffer
  95318. * @param indices defines the indices to store in the index buffer
  95319. * @param totalVertices defines the total number of vertices (could be null)
  95320. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95321. */
  95322. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95323. }
  95324. /**
  95325. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95326. */
  95327. export class VertexData {
  95328. /**
  95329. * Mesh side orientation : usually the external or front surface
  95330. */
  95331. static readonly FRONTSIDE: number;
  95332. /**
  95333. * Mesh side orientation : usually the internal or back surface
  95334. */
  95335. static readonly BACKSIDE: number;
  95336. /**
  95337. * Mesh side orientation : both internal and external or front and back surfaces
  95338. */
  95339. static readonly DOUBLESIDE: number;
  95340. /**
  95341. * Mesh side orientation : by default, `FRONTSIDE`
  95342. */
  95343. static readonly DEFAULTSIDE: number;
  95344. /**
  95345. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95346. */
  95347. positions: Nullable<FloatArray>;
  95348. /**
  95349. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95350. */
  95351. normals: Nullable<FloatArray>;
  95352. /**
  95353. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95354. */
  95355. tangents: Nullable<FloatArray>;
  95356. /**
  95357. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95358. */
  95359. uvs: Nullable<FloatArray>;
  95360. /**
  95361. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95362. */
  95363. uvs2: Nullable<FloatArray>;
  95364. /**
  95365. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95366. */
  95367. uvs3: Nullable<FloatArray>;
  95368. /**
  95369. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95370. */
  95371. uvs4: Nullable<FloatArray>;
  95372. /**
  95373. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95374. */
  95375. uvs5: Nullable<FloatArray>;
  95376. /**
  95377. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95378. */
  95379. uvs6: Nullable<FloatArray>;
  95380. /**
  95381. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95382. */
  95383. colors: Nullable<FloatArray>;
  95384. /**
  95385. * 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).
  95386. */
  95387. matricesIndices: Nullable<FloatArray>;
  95388. /**
  95389. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95390. */
  95391. matricesWeights: Nullable<FloatArray>;
  95392. /**
  95393. * An array extending the number of possible indices
  95394. */
  95395. matricesIndicesExtra: Nullable<FloatArray>;
  95396. /**
  95397. * An array extending the number of possible weights when the number of indices is extended
  95398. */
  95399. matricesWeightsExtra: Nullable<FloatArray>;
  95400. /**
  95401. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95402. */
  95403. indices: Nullable<IndicesArray>;
  95404. /**
  95405. * Uses the passed data array to set the set the values for the specified kind of data
  95406. * @param data a linear array of floating numbers
  95407. * @param kind the type of data that is being set, eg positions, colors etc
  95408. */
  95409. set(data: FloatArray, kind: string): void;
  95410. /**
  95411. * Associates the vertexData to the passed Mesh.
  95412. * Sets it as updatable or not (default `false`)
  95413. * @param mesh the mesh the vertexData is applied to
  95414. * @param updatable when used and having the value true allows new data to update the vertexData
  95415. * @returns the VertexData
  95416. */
  95417. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95418. /**
  95419. * Associates the vertexData to the passed Geometry.
  95420. * Sets it as updatable or not (default `false`)
  95421. * @param geometry the geometry the vertexData is applied to
  95422. * @param updatable when used and having the value true allows new data to update the vertexData
  95423. * @returns VertexData
  95424. */
  95425. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95426. /**
  95427. * Updates the associated mesh
  95428. * @param mesh the mesh to be updated
  95429. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95430. * @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
  95431. * @returns VertexData
  95432. */
  95433. updateMesh(mesh: Mesh): VertexData;
  95434. /**
  95435. * Updates the associated geometry
  95436. * @param geometry the geometry to be updated
  95437. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95438. * @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
  95439. * @returns VertexData.
  95440. */
  95441. updateGeometry(geometry: Geometry): VertexData;
  95442. private _applyTo;
  95443. private _update;
  95444. /**
  95445. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95446. * @param matrix the transforming matrix
  95447. * @returns the VertexData
  95448. */
  95449. transform(matrix: Matrix): VertexData;
  95450. /**
  95451. * Merges the passed VertexData into the current one
  95452. * @param other the VertexData to be merged into the current one
  95453. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95454. * @returns the modified VertexData
  95455. */
  95456. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95457. private _mergeElement;
  95458. private _validate;
  95459. /**
  95460. * Serializes the VertexData
  95461. * @returns a serialized object
  95462. */
  95463. serialize(): any;
  95464. /**
  95465. * Extracts the vertexData from a mesh
  95466. * @param mesh the mesh from which to extract the VertexData
  95467. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95468. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95469. * @returns the object VertexData associated to the passed mesh
  95470. */
  95471. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95472. /**
  95473. * Extracts the vertexData from the geometry
  95474. * @param geometry the geometry from which to extract the VertexData
  95475. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95476. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95477. * @returns the object VertexData associated to the passed mesh
  95478. */
  95479. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95480. private static _ExtractFrom;
  95481. /**
  95482. * Creates the VertexData for a Ribbon
  95483. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95484. * * pathArray array of paths, each of which an array of successive Vector3
  95485. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95486. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95487. * * 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
  95488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95489. * * 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)
  95490. * * 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)
  95491. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95492. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95493. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95494. * @returns the VertexData of the ribbon
  95495. */
  95496. static CreateRibbon(options: {
  95497. pathArray: Vector3[][];
  95498. closeArray?: boolean;
  95499. closePath?: boolean;
  95500. offset?: number;
  95501. sideOrientation?: number;
  95502. frontUVs?: Vector4;
  95503. backUVs?: Vector4;
  95504. invertUV?: boolean;
  95505. uvs?: Vector2[];
  95506. colors?: Color4[];
  95507. }): VertexData;
  95508. /**
  95509. * Creates the VertexData for a box
  95510. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95511. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95512. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95513. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95514. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95515. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95516. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95518. * * 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)
  95519. * * 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)
  95520. * @returns the VertexData of the box
  95521. */
  95522. static CreateBox(options: {
  95523. size?: number;
  95524. width?: number;
  95525. height?: number;
  95526. depth?: number;
  95527. faceUV?: Vector4[];
  95528. faceColors?: Color4[];
  95529. sideOrientation?: number;
  95530. frontUVs?: Vector4;
  95531. backUVs?: Vector4;
  95532. }): VertexData;
  95533. /**
  95534. * Creates the VertexData for a tiled box
  95535. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95536. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95537. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95538. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95539. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95540. * @returns the VertexData of the box
  95541. */
  95542. static CreateTiledBox(options: {
  95543. pattern?: number;
  95544. width?: number;
  95545. height?: number;
  95546. depth?: number;
  95547. tileSize?: number;
  95548. tileWidth?: number;
  95549. tileHeight?: number;
  95550. alignHorizontal?: number;
  95551. alignVertical?: number;
  95552. faceUV?: Vector4[];
  95553. faceColors?: Color4[];
  95554. sideOrientation?: number;
  95555. }): VertexData;
  95556. /**
  95557. * Creates the VertexData for a tiled plane
  95558. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95559. * * pattern a limited pattern arrangement depending on the number
  95560. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95561. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95562. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95564. * * 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)
  95565. * * 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)
  95566. * @returns the VertexData of the tiled plane
  95567. */
  95568. static CreateTiledPlane(options: {
  95569. pattern?: number;
  95570. tileSize?: number;
  95571. tileWidth?: number;
  95572. tileHeight?: number;
  95573. size?: number;
  95574. width?: number;
  95575. height?: number;
  95576. alignHorizontal?: number;
  95577. alignVertical?: number;
  95578. sideOrientation?: number;
  95579. frontUVs?: Vector4;
  95580. backUVs?: Vector4;
  95581. }): VertexData;
  95582. /**
  95583. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95584. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95585. * * segments sets the number of horizontal strips optional, default 32
  95586. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95587. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95588. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95589. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95590. * * 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
  95591. * * 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
  95592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95593. * * 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)
  95594. * * 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)
  95595. * @returns the VertexData of the ellipsoid
  95596. */
  95597. static CreateSphere(options: {
  95598. segments?: number;
  95599. diameter?: number;
  95600. diameterX?: number;
  95601. diameterY?: number;
  95602. diameterZ?: number;
  95603. arc?: number;
  95604. slice?: number;
  95605. sideOrientation?: number;
  95606. frontUVs?: Vector4;
  95607. backUVs?: Vector4;
  95608. }): VertexData;
  95609. /**
  95610. * Creates the VertexData for a cylinder, cone or prism
  95611. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95612. * * height sets the height (y direction) of the cylinder, optional, default 2
  95613. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95614. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95615. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95616. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95617. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95618. * * 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
  95619. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95621. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95622. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95624. * * 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)
  95625. * * 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)
  95626. * @returns the VertexData of the cylinder, cone or prism
  95627. */
  95628. static CreateCylinder(options: {
  95629. height?: number;
  95630. diameterTop?: number;
  95631. diameterBottom?: number;
  95632. diameter?: number;
  95633. tessellation?: number;
  95634. subdivisions?: number;
  95635. arc?: number;
  95636. faceColors?: Color4[];
  95637. faceUV?: Vector4[];
  95638. hasRings?: boolean;
  95639. enclose?: boolean;
  95640. sideOrientation?: number;
  95641. frontUVs?: Vector4;
  95642. backUVs?: Vector4;
  95643. }): VertexData;
  95644. /**
  95645. * Creates the VertexData for a torus
  95646. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95647. * * diameter the diameter of the torus, optional default 1
  95648. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95649. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95650. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95651. * * 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)
  95652. * * 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)
  95653. * @returns the VertexData of the torus
  95654. */
  95655. static CreateTorus(options: {
  95656. diameter?: number;
  95657. thickness?: number;
  95658. tessellation?: number;
  95659. sideOrientation?: number;
  95660. frontUVs?: Vector4;
  95661. backUVs?: Vector4;
  95662. }): VertexData;
  95663. /**
  95664. * Creates the VertexData of the LineSystem
  95665. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95666. * - lines an array of lines, each line being an array of successive Vector3
  95667. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95668. * @returns the VertexData of the LineSystem
  95669. */
  95670. static CreateLineSystem(options: {
  95671. lines: Vector3[][];
  95672. colors?: Nullable<Color4[][]>;
  95673. }): VertexData;
  95674. /**
  95675. * Create the VertexData for a DashedLines
  95676. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95677. * - points an array successive Vector3
  95678. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95679. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95680. * - dashNb the intended total number of dashes, optional, default 200
  95681. * @returns the VertexData for the DashedLines
  95682. */
  95683. static CreateDashedLines(options: {
  95684. points: Vector3[];
  95685. dashSize?: number;
  95686. gapSize?: number;
  95687. dashNb?: number;
  95688. }): VertexData;
  95689. /**
  95690. * Creates the VertexData for a Ground
  95691. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95692. * - width the width (x direction) of the ground, optional, default 1
  95693. * - height the height (z direction) of the ground, optional, default 1
  95694. * - subdivisions the number of subdivisions per side, optional, default 1
  95695. * @returns the VertexData of the Ground
  95696. */
  95697. static CreateGround(options: {
  95698. width?: number;
  95699. height?: number;
  95700. subdivisions?: number;
  95701. subdivisionsX?: number;
  95702. subdivisionsY?: number;
  95703. }): VertexData;
  95704. /**
  95705. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95706. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95707. * * xmin the ground minimum X coordinate, optional, default -1
  95708. * * zmin the ground minimum Z coordinate, optional, default -1
  95709. * * xmax the ground maximum X coordinate, optional, default 1
  95710. * * zmax the ground maximum Z coordinate, optional, default 1
  95711. * * 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}
  95712. * * 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}
  95713. * @returns the VertexData of the TiledGround
  95714. */
  95715. static CreateTiledGround(options: {
  95716. xmin: number;
  95717. zmin: number;
  95718. xmax: number;
  95719. zmax: number;
  95720. subdivisions?: {
  95721. w: number;
  95722. h: number;
  95723. };
  95724. precision?: {
  95725. w: number;
  95726. h: number;
  95727. };
  95728. }): VertexData;
  95729. /**
  95730. * Creates the VertexData of the Ground designed from a heightmap
  95731. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95732. * * width the width (x direction) of the ground
  95733. * * height the height (z direction) of the ground
  95734. * * subdivisions the number of subdivisions per side
  95735. * * minHeight the minimum altitude on the ground, optional, default 0
  95736. * * maxHeight the maximum altitude on the ground, optional default 1
  95737. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95738. * * buffer the array holding the image color data
  95739. * * bufferWidth the width of image
  95740. * * bufferHeight the height of image
  95741. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95742. * @returns the VertexData of the Ground designed from a heightmap
  95743. */
  95744. static CreateGroundFromHeightMap(options: {
  95745. width: number;
  95746. height: number;
  95747. subdivisions: number;
  95748. minHeight: number;
  95749. maxHeight: number;
  95750. colorFilter: Color3;
  95751. buffer: Uint8Array;
  95752. bufferWidth: number;
  95753. bufferHeight: number;
  95754. alphaFilter: number;
  95755. }): VertexData;
  95756. /**
  95757. * Creates the VertexData for a Plane
  95758. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95759. * * size sets the width and height of the plane to the value of size, optional default 1
  95760. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95761. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95763. * * 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)
  95764. * * 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)
  95765. * @returns the VertexData of the box
  95766. */
  95767. static CreatePlane(options: {
  95768. size?: number;
  95769. width?: number;
  95770. height?: number;
  95771. sideOrientation?: number;
  95772. frontUVs?: Vector4;
  95773. backUVs?: Vector4;
  95774. }): VertexData;
  95775. /**
  95776. * Creates the VertexData of the Disc or regular Polygon
  95777. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95778. * * radius the radius of the disc, optional default 0.5
  95779. * * tessellation the number of polygon sides, optional, default 64
  95780. * * 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
  95781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95782. * * 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)
  95783. * * 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)
  95784. * @returns the VertexData of the box
  95785. */
  95786. static CreateDisc(options: {
  95787. radius?: number;
  95788. tessellation?: number;
  95789. arc?: number;
  95790. sideOrientation?: number;
  95791. frontUVs?: Vector4;
  95792. backUVs?: Vector4;
  95793. }): VertexData;
  95794. /**
  95795. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95796. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95797. * @param polygon a mesh built from polygonTriangulation.build()
  95798. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95799. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95800. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95801. * @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)
  95802. * @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)
  95803. * @returns the VertexData of the Polygon
  95804. */
  95805. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95806. /**
  95807. * Creates the VertexData of the IcoSphere
  95808. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95809. * * radius the radius of the IcoSphere, optional default 1
  95810. * * radiusX allows stretching in the x direction, optional, default radius
  95811. * * radiusY allows stretching in the y direction, optional, default radius
  95812. * * radiusZ allows stretching in the z direction, optional, default radius
  95813. * * flat when true creates a flat shaded mesh, optional, default true
  95814. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95816. * * 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)
  95817. * * 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)
  95818. * @returns the VertexData of the IcoSphere
  95819. */
  95820. static CreateIcoSphere(options: {
  95821. radius?: number;
  95822. radiusX?: number;
  95823. radiusY?: number;
  95824. radiusZ?: number;
  95825. flat?: boolean;
  95826. subdivisions?: number;
  95827. sideOrientation?: number;
  95828. frontUVs?: Vector4;
  95829. backUVs?: Vector4;
  95830. }): VertexData;
  95831. /**
  95832. * Creates the VertexData for a Polyhedron
  95833. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95834. * * type provided types are:
  95835. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95836. * * 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)
  95837. * * size the size of the IcoSphere, optional default 1
  95838. * * sizeX allows stretching in the x direction, optional, default size
  95839. * * sizeY allows stretching in the y direction, optional, default size
  95840. * * sizeZ allows stretching in the z direction, optional, default size
  95841. * * 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
  95842. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95843. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95844. * * flat when true creates a flat shaded mesh, optional, default true
  95845. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95846. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95847. * * 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)
  95848. * * 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)
  95849. * @returns the VertexData of the Polyhedron
  95850. */
  95851. static CreatePolyhedron(options: {
  95852. type?: number;
  95853. size?: number;
  95854. sizeX?: number;
  95855. sizeY?: number;
  95856. sizeZ?: number;
  95857. custom?: any;
  95858. faceUV?: Vector4[];
  95859. faceColors?: Color4[];
  95860. flat?: boolean;
  95861. sideOrientation?: number;
  95862. frontUVs?: Vector4;
  95863. backUVs?: Vector4;
  95864. }): VertexData;
  95865. /**
  95866. * Creates the VertexData for a TorusKnot
  95867. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95868. * * radius the radius of the torus knot, optional, default 2
  95869. * * tube the thickness of the tube, optional, default 0.5
  95870. * * radialSegments the number of sides on each tube segments, optional, default 32
  95871. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95872. * * p the number of windings around the z axis, optional, default 2
  95873. * * q the number of windings around the x axis, optional, default 3
  95874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95875. * * 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)
  95876. * * 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)
  95877. * @returns the VertexData of the Torus Knot
  95878. */
  95879. static CreateTorusKnot(options: {
  95880. radius?: number;
  95881. tube?: number;
  95882. radialSegments?: number;
  95883. tubularSegments?: number;
  95884. p?: number;
  95885. q?: number;
  95886. sideOrientation?: number;
  95887. frontUVs?: Vector4;
  95888. backUVs?: Vector4;
  95889. }): VertexData;
  95890. /**
  95891. * Compute normals for given positions and indices
  95892. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95893. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95894. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95895. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95896. * * facetNormals : optional array of facet normals (vector3)
  95897. * * facetPositions : optional array of facet positions (vector3)
  95898. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95899. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95900. * * bInfo : optional bounding info, required for facetPartitioning computation
  95901. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95902. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95903. * * useRightHandedSystem: optional boolean to for right handed system computation
  95904. * * depthSort : optional boolean to enable the facet depth sort computation
  95905. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95906. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95907. */
  95908. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95909. facetNormals?: any;
  95910. facetPositions?: any;
  95911. facetPartitioning?: any;
  95912. ratio?: number;
  95913. bInfo?: any;
  95914. bbSize?: Vector3;
  95915. subDiv?: any;
  95916. useRightHandedSystem?: boolean;
  95917. depthSort?: boolean;
  95918. distanceTo?: Vector3;
  95919. depthSortedFacets?: any;
  95920. }): void;
  95921. /** @hidden */
  95922. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95923. /**
  95924. * Applies VertexData created from the imported parameters to the geometry
  95925. * @param parsedVertexData the parsed data from an imported file
  95926. * @param geometry the geometry to apply the VertexData to
  95927. */
  95928. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95929. }
  95930. }
  95931. declare module BABYLON {
  95932. /**
  95933. * Defines a target to use with MorphTargetManager
  95934. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95935. */
  95936. export class MorphTarget implements IAnimatable {
  95937. /** defines the name of the target */
  95938. name: string;
  95939. /**
  95940. * Gets or sets the list of animations
  95941. */
  95942. animations: Animation[];
  95943. private _scene;
  95944. private _positions;
  95945. private _normals;
  95946. private _tangents;
  95947. private _uvs;
  95948. private _influence;
  95949. private _uniqueId;
  95950. /**
  95951. * Observable raised when the influence changes
  95952. */
  95953. onInfluenceChanged: Observable<boolean>;
  95954. /** @hidden */
  95955. _onDataLayoutChanged: Observable<void>;
  95956. /**
  95957. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95958. */
  95959. get influence(): number;
  95960. set influence(influence: number);
  95961. /**
  95962. * Gets or sets the id of the morph Target
  95963. */
  95964. id: string;
  95965. private _animationPropertiesOverride;
  95966. /**
  95967. * Gets or sets the animation properties override
  95968. */
  95969. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95970. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95971. /**
  95972. * Creates a new MorphTarget
  95973. * @param name defines the name of the target
  95974. * @param influence defines the influence to use
  95975. * @param scene defines the scene the morphtarget belongs to
  95976. */
  95977. constructor(
  95978. /** defines the name of the target */
  95979. name: string, influence?: number, scene?: Nullable<Scene>);
  95980. /**
  95981. * Gets the unique ID of this manager
  95982. */
  95983. get uniqueId(): number;
  95984. /**
  95985. * Gets a boolean defining if the target contains position data
  95986. */
  95987. get hasPositions(): boolean;
  95988. /**
  95989. * Gets a boolean defining if the target contains normal data
  95990. */
  95991. get hasNormals(): boolean;
  95992. /**
  95993. * Gets a boolean defining if the target contains tangent data
  95994. */
  95995. get hasTangents(): boolean;
  95996. /**
  95997. * Gets a boolean defining if the target contains texture coordinates data
  95998. */
  95999. get hasUVs(): boolean;
  96000. /**
  96001. * Affects position data to this target
  96002. * @param data defines the position data to use
  96003. */
  96004. setPositions(data: Nullable<FloatArray>): void;
  96005. /**
  96006. * Gets the position data stored in this target
  96007. * @returns a FloatArray containing the position data (or null if not present)
  96008. */
  96009. getPositions(): Nullable<FloatArray>;
  96010. /**
  96011. * Affects normal data to this target
  96012. * @param data defines the normal data to use
  96013. */
  96014. setNormals(data: Nullable<FloatArray>): void;
  96015. /**
  96016. * Gets the normal data stored in this target
  96017. * @returns a FloatArray containing the normal data (or null if not present)
  96018. */
  96019. getNormals(): Nullable<FloatArray>;
  96020. /**
  96021. * Affects tangent data to this target
  96022. * @param data defines the tangent data to use
  96023. */
  96024. setTangents(data: Nullable<FloatArray>): void;
  96025. /**
  96026. * Gets the tangent data stored in this target
  96027. * @returns a FloatArray containing the tangent data (or null if not present)
  96028. */
  96029. getTangents(): Nullable<FloatArray>;
  96030. /**
  96031. * Affects texture coordinates data to this target
  96032. * @param data defines the texture coordinates data to use
  96033. */
  96034. setUVs(data: Nullable<FloatArray>): void;
  96035. /**
  96036. * Gets the texture coordinates data stored in this target
  96037. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96038. */
  96039. getUVs(): Nullable<FloatArray>;
  96040. /**
  96041. * Clone the current target
  96042. * @returns a new MorphTarget
  96043. */
  96044. clone(): MorphTarget;
  96045. /**
  96046. * Serializes the current target into a Serialization object
  96047. * @returns the serialized object
  96048. */
  96049. serialize(): any;
  96050. /**
  96051. * Returns the string "MorphTarget"
  96052. * @returns "MorphTarget"
  96053. */
  96054. getClassName(): string;
  96055. /**
  96056. * Creates a new target from serialized data
  96057. * @param serializationObject defines the serialized data to use
  96058. * @returns a new MorphTarget
  96059. */
  96060. static Parse(serializationObject: any): MorphTarget;
  96061. /**
  96062. * Creates a MorphTarget from mesh data
  96063. * @param mesh defines the source mesh
  96064. * @param name defines the name to use for the new target
  96065. * @param influence defines the influence to attach to the target
  96066. * @returns a new MorphTarget
  96067. */
  96068. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96069. }
  96070. }
  96071. declare module BABYLON {
  96072. /**
  96073. * This class is used to deform meshes using morphing between different targets
  96074. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96075. */
  96076. export class MorphTargetManager {
  96077. private _targets;
  96078. private _targetInfluenceChangedObservers;
  96079. private _targetDataLayoutChangedObservers;
  96080. private _activeTargets;
  96081. private _scene;
  96082. private _influences;
  96083. private _supportsNormals;
  96084. private _supportsTangents;
  96085. private _supportsUVs;
  96086. private _vertexCount;
  96087. private _uniqueId;
  96088. private _tempInfluences;
  96089. /**
  96090. * Gets or sets a boolean indicating if normals must be morphed
  96091. */
  96092. enableNormalMorphing: boolean;
  96093. /**
  96094. * Gets or sets a boolean indicating if tangents must be morphed
  96095. */
  96096. enableTangentMorphing: boolean;
  96097. /**
  96098. * Gets or sets a boolean indicating if UV must be morphed
  96099. */
  96100. enableUVMorphing: boolean;
  96101. /**
  96102. * Creates a new MorphTargetManager
  96103. * @param scene defines the current scene
  96104. */
  96105. constructor(scene?: Nullable<Scene>);
  96106. /**
  96107. * Gets the unique ID of this manager
  96108. */
  96109. get uniqueId(): number;
  96110. /**
  96111. * Gets the number of vertices handled by this manager
  96112. */
  96113. get vertexCount(): number;
  96114. /**
  96115. * Gets a boolean indicating if this manager supports morphing of normals
  96116. */
  96117. get supportsNormals(): boolean;
  96118. /**
  96119. * Gets a boolean indicating if this manager supports morphing of tangents
  96120. */
  96121. get supportsTangents(): boolean;
  96122. /**
  96123. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96124. */
  96125. get supportsUVs(): boolean;
  96126. /**
  96127. * Gets the number of targets stored in this manager
  96128. */
  96129. get numTargets(): number;
  96130. /**
  96131. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96132. */
  96133. get numInfluencers(): number;
  96134. /**
  96135. * Gets the list of influences (one per target)
  96136. */
  96137. get influences(): Float32Array;
  96138. /**
  96139. * Gets the active target at specified index. An active target is a target with an influence > 0
  96140. * @param index defines the index to check
  96141. * @returns the requested target
  96142. */
  96143. getActiveTarget(index: number): MorphTarget;
  96144. /**
  96145. * Gets the target at specified index
  96146. * @param index defines the index to check
  96147. * @returns the requested target
  96148. */
  96149. getTarget(index: number): MorphTarget;
  96150. /**
  96151. * Add a new target to this manager
  96152. * @param target defines the target to add
  96153. */
  96154. addTarget(target: MorphTarget): void;
  96155. /**
  96156. * Removes a target from the manager
  96157. * @param target defines the target to remove
  96158. */
  96159. removeTarget(target: MorphTarget): void;
  96160. /**
  96161. * Clone the current manager
  96162. * @returns a new MorphTargetManager
  96163. */
  96164. clone(): MorphTargetManager;
  96165. /**
  96166. * Serializes the current manager into a Serialization object
  96167. * @returns the serialized object
  96168. */
  96169. serialize(): any;
  96170. private _syncActiveTargets;
  96171. /**
  96172. * Syncrhonize the targets with all the meshes using this morph target manager
  96173. */
  96174. synchronize(): void;
  96175. /**
  96176. * Creates a new MorphTargetManager from serialized data
  96177. * @param serializationObject defines the serialized data
  96178. * @param scene defines the hosting scene
  96179. * @returns the new MorphTargetManager
  96180. */
  96181. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96182. }
  96183. }
  96184. declare module BABYLON {
  96185. /**
  96186. * Class used to represent a specific level of detail of a mesh
  96187. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96188. */
  96189. export class MeshLODLevel {
  96190. /** Defines the distance where this level should start being displayed */
  96191. distance: number;
  96192. /** Defines the mesh to use to render this level */
  96193. mesh: Nullable<Mesh>;
  96194. /**
  96195. * Creates a new LOD level
  96196. * @param distance defines the distance where this level should star being displayed
  96197. * @param mesh defines the mesh to use to render this level
  96198. */
  96199. constructor(
  96200. /** Defines the distance where this level should start being displayed */
  96201. distance: number,
  96202. /** Defines the mesh to use to render this level */
  96203. mesh: Nullable<Mesh>);
  96204. }
  96205. }
  96206. declare module BABYLON {
  96207. /**
  96208. * Mesh representing the gorund
  96209. */
  96210. export class GroundMesh extends Mesh {
  96211. /** If octree should be generated */
  96212. generateOctree: boolean;
  96213. private _heightQuads;
  96214. /** @hidden */
  96215. _subdivisionsX: number;
  96216. /** @hidden */
  96217. _subdivisionsY: number;
  96218. /** @hidden */
  96219. _width: number;
  96220. /** @hidden */
  96221. _height: number;
  96222. /** @hidden */
  96223. _minX: number;
  96224. /** @hidden */
  96225. _maxX: number;
  96226. /** @hidden */
  96227. _minZ: number;
  96228. /** @hidden */
  96229. _maxZ: number;
  96230. constructor(name: string, scene: Scene);
  96231. /**
  96232. * "GroundMesh"
  96233. * @returns "GroundMesh"
  96234. */
  96235. getClassName(): string;
  96236. /**
  96237. * The minimum of x and y subdivisions
  96238. */
  96239. get subdivisions(): number;
  96240. /**
  96241. * X subdivisions
  96242. */
  96243. get subdivisionsX(): number;
  96244. /**
  96245. * Y subdivisions
  96246. */
  96247. get subdivisionsY(): number;
  96248. /**
  96249. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96250. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96251. * @param chunksCount the number of subdivisions for x and y
  96252. * @param octreeBlocksSize (Default: 32)
  96253. */
  96254. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96255. /**
  96256. * Returns a height (y) value in the Worl system :
  96257. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96258. * @param x x coordinate
  96259. * @param z z coordinate
  96260. * @returns the ground y position if (x, z) are outside the ground surface.
  96261. */
  96262. getHeightAtCoordinates(x: number, z: number): number;
  96263. /**
  96264. * Returns a normalized vector (Vector3) orthogonal to the ground
  96265. * at the ground coordinates (x, z) expressed in the World system.
  96266. * @param x x coordinate
  96267. * @param z z coordinate
  96268. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96269. */
  96270. getNormalAtCoordinates(x: number, z: number): Vector3;
  96271. /**
  96272. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96273. * at the ground coordinates (x, z) expressed in the World system.
  96274. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96275. * @param x x coordinate
  96276. * @param z z coordinate
  96277. * @param ref vector to store the result
  96278. * @returns the GroundMesh.
  96279. */
  96280. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96281. /**
  96282. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96283. * if the ground has been updated.
  96284. * This can be used in the render loop.
  96285. * @returns the GroundMesh.
  96286. */
  96287. updateCoordinateHeights(): GroundMesh;
  96288. private _getFacetAt;
  96289. private _initHeightQuads;
  96290. private _computeHeightQuads;
  96291. /**
  96292. * Serializes this ground mesh
  96293. * @param serializationObject object to write serialization to
  96294. */
  96295. serialize(serializationObject: any): void;
  96296. /**
  96297. * Parses a serialized ground mesh
  96298. * @param parsedMesh the serialized mesh
  96299. * @param scene the scene to create the ground mesh in
  96300. * @returns the created ground mesh
  96301. */
  96302. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96303. }
  96304. }
  96305. declare module BABYLON {
  96306. /**
  96307. * Interface for Physics-Joint data
  96308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96309. */
  96310. export interface PhysicsJointData {
  96311. /**
  96312. * The main pivot of the joint
  96313. */
  96314. mainPivot?: Vector3;
  96315. /**
  96316. * The connected pivot of the joint
  96317. */
  96318. connectedPivot?: Vector3;
  96319. /**
  96320. * The main axis of the joint
  96321. */
  96322. mainAxis?: Vector3;
  96323. /**
  96324. * The connected axis of the joint
  96325. */
  96326. connectedAxis?: Vector3;
  96327. /**
  96328. * The collision of the joint
  96329. */
  96330. collision?: boolean;
  96331. /**
  96332. * Native Oimo/Cannon/Energy data
  96333. */
  96334. nativeParams?: any;
  96335. }
  96336. /**
  96337. * This is a holder class for the physics joint created by the physics plugin
  96338. * It holds a set of functions to control the underlying joint
  96339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96340. */
  96341. export class PhysicsJoint {
  96342. /**
  96343. * The type of the physics joint
  96344. */
  96345. type: number;
  96346. /**
  96347. * The data for the physics joint
  96348. */
  96349. jointData: PhysicsJointData;
  96350. private _physicsJoint;
  96351. protected _physicsPlugin: IPhysicsEnginePlugin;
  96352. /**
  96353. * Initializes the physics joint
  96354. * @param type The type of the physics joint
  96355. * @param jointData The data for the physics joint
  96356. */
  96357. constructor(
  96358. /**
  96359. * The type of the physics joint
  96360. */
  96361. type: number,
  96362. /**
  96363. * The data for the physics joint
  96364. */
  96365. jointData: PhysicsJointData);
  96366. /**
  96367. * Gets the physics joint
  96368. */
  96369. get physicsJoint(): any;
  96370. /**
  96371. * Sets the physics joint
  96372. */
  96373. set physicsJoint(newJoint: any);
  96374. /**
  96375. * Sets the physics plugin
  96376. */
  96377. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96378. /**
  96379. * Execute a function that is physics-plugin specific.
  96380. * @param {Function} func the function that will be executed.
  96381. * It accepts two parameters: the physics world and the physics joint
  96382. */
  96383. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96384. /**
  96385. * Distance-Joint type
  96386. */
  96387. static DistanceJoint: number;
  96388. /**
  96389. * Hinge-Joint type
  96390. */
  96391. static HingeJoint: number;
  96392. /**
  96393. * Ball-and-Socket joint type
  96394. */
  96395. static BallAndSocketJoint: number;
  96396. /**
  96397. * Wheel-Joint type
  96398. */
  96399. static WheelJoint: number;
  96400. /**
  96401. * Slider-Joint type
  96402. */
  96403. static SliderJoint: number;
  96404. /**
  96405. * Prismatic-Joint type
  96406. */
  96407. static PrismaticJoint: number;
  96408. /**
  96409. * Universal-Joint type
  96410. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96411. */
  96412. static UniversalJoint: number;
  96413. /**
  96414. * Hinge-Joint 2 type
  96415. */
  96416. static Hinge2Joint: number;
  96417. /**
  96418. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96419. */
  96420. static PointToPointJoint: number;
  96421. /**
  96422. * Spring-Joint type
  96423. */
  96424. static SpringJoint: number;
  96425. /**
  96426. * Lock-Joint type
  96427. */
  96428. static LockJoint: number;
  96429. }
  96430. /**
  96431. * A class representing a physics distance joint
  96432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96433. */
  96434. export class DistanceJoint extends PhysicsJoint {
  96435. /**
  96436. *
  96437. * @param jointData The data for the Distance-Joint
  96438. */
  96439. constructor(jointData: DistanceJointData);
  96440. /**
  96441. * Update the predefined distance.
  96442. * @param maxDistance The maximum preferred distance
  96443. * @param minDistance The minimum preferred distance
  96444. */
  96445. updateDistance(maxDistance: number, minDistance?: number): void;
  96446. }
  96447. /**
  96448. * Represents a Motor-Enabled Joint
  96449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96450. */
  96451. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96452. /**
  96453. * Initializes the Motor-Enabled Joint
  96454. * @param type The type of the joint
  96455. * @param jointData The physica joint data for the joint
  96456. */
  96457. constructor(type: number, jointData: PhysicsJointData);
  96458. /**
  96459. * Set the motor values.
  96460. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96461. * @param force the force to apply
  96462. * @param maxForce max force for this motor.
  96463. */
  96464. setMotor(force?: number, maxForce?: number): void;
  96465. /**
  96466. * Set the motor's limits.
  96467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96468. * @param upperLimit The upper limit of the motor
  96469. * @param lowerLimit The lower limit of the motor
  96470. */
  96471. setLimit(upperLimit: number, lowerLimit?: number): void;
  96472. }
  96473. /**
  96474. * This class represents a single physics Hinge-Joint
  96475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96476. */
  96477. export class HingeJoint extends MotorEnabledJoint {
  96478. /**
  96479. * Initializes the Hinge-Joint
  96480. * @param jointData The joint data for the Hinge-Joint
  96481. */
  96482. constructor(jointData: PhysicsJointData);
  96483. /**
  96484. * Set the motor values.
  96485. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96486. * @param {number} force the force to apply
  96487. * @param {number} maxForce max force for this motor.
  96488. */
  96489. setMotor(force?: number, maxForce?: number): void;
  96490. /**
  96491. * Set the motor's limits.
  96492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96493. * @param upperLimit The upper limit of the motor
  96494. * @param lowerLimit The lower limit of the motor
  96495. */
  96496. setLimit(upperLimit: number, lowerLimit?: number): void;
  96497. }
  96498. /**
  96499. * This class represents a dual hinge physics joint (same as wheel joint)
  96500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96501. */
  96502. export class Hinge2Joint extends MotorEnabledJoint {
  96503. /**
  96504. * Initializes the Hinge2-Joint
  96505. * @param jointData The joint data for the Hinge2-Joint
  96506. */
  96507. constructor(jointData: PhysicsJointData);
  96508. /**
  96509. * Set the motor values.
  96510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96511. * @param {number} targetSpeed the speed the motor is to reach
  96512. * @param {number} maxForce max force for this motor.
  96513. * @param {motorIndex} the motor's index, 0 or 1.
  96514. */
  96515. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96516. /**
  96517. * Set the motor limits.
  96518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96519. * @param {number} upperLimit the upper limit
  96520. * @param {number} lowerLimit lower limit
  96521. * @param {motorIndex} the motor's index, 0 or 1.
  96522. */
  96523. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96524. }
  96525. /**
  96526. * Interface for a motor enabled joint
  96527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96528. */
  96529. export interface IMotorEnabledJoint {
  96530. /**
  96531. * Physics joint
  96532. */
  96533. physicsJoint: any;
  96534. /**
  96535. * Sets the motor of the motor-enabled joint
  96536. * @param force The force of the motor
  96537. * @param maxForce The maximum force of the motor
  96538. * @param motorIndex The index of the motor
  96539. */
  96540. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96541. /**
  96542. * Sets the limit of the motor
  96543. * @param upperLimit The upper limit of the motor
  96544. * @param lowerLimit The lower limit of the motor
  96545. * @param motorIndex The index of the motor
  96546. */
  96547. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96548. }
  96549. /**
  96550. * Joint data for a Distance-Joint
  96551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96552. */
  96553. export interface DistanceJointData extends PhysicsJointData {
  96554. /**
  96555. * Max distance the 2 joint objects can be apart
  96556. */
  96557. maxDistance: number;
  96558. }
  96559. /**
  96560. * Joint data from a spring joint
  96561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96562. */
  96563. export interface SpringJointData extends PhysicsJointData {
  96564. /**
  96565. * Length of the spring
  96566. */
  96567. length: number;
  96568. /**
  96569. * Stiffness of the spring
  96570. */
  96571. stiffness: number;
  96572. /**
  96573. * Damping of the spring
  96574. */
  96575. damping: number;
  96576. /** this callback will be called when applying the force to the impostors. */
  96577. forceApplicationCallback: () => void;
  96578. }
  96579. }
  96580. declare module BABYLON {
  96581. /**
  96582. * Holds the data for the raycast result
  96583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96584. */
  96585. export class PhysicsRaycastResult {
  96586. private _hasHit;
  96587. private _hitDistance;
  96588. private _hitNormalWorld;
  96589. private _hitPointWorld;
  96590. private _rayFromWorld;
  96591. private _rayToWorld;
  96592. /**
  96593. * Gets if there was a hit
  96594. */
  96595. get hasHit(): boolean;
  96596. /**
  96597. * Gets the distance from the hit
  96598. */
  96599. get hitDistance(): number;
  96600. /**
  96601. * Gets the hit normal/direction in the world
  96602. */
  96603. get hitNormalWorld(): Vector3;
  96604. /**
  96605. * Gets the hit point in the world
  96606. */
  96607. get hitPointWorld(): Vector3;
  96608. /**
  96609. * Gets the ray "start point" of the ray in the world
  96610. */
  96611. get rayFromWorld(): Vector3;
  96612. /**
  96613. * Gets the ray "end point" of the ray in the world
  96614. */
  96615. get rayToWorld(): Vector3;
  96616. /**
  96617. * Sets the hit data (normal & point in world space)
  96618. * @param hitNormalWorld defines the normal in world space
  96619. * @param hitPointWorld defines the point in world space
  96620. */
  96621. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96622. /**
  96623. * Sets the distance from the start point to the hit point
  96624. * @param distance
  96625. */
  96626. setHitDistance(distance: number): void;
  96627. /**
  96628. * Calculates the distance manually
  96629. */
  96630. calculateHitDistance(): void;
  96631. /**
  96632. * Resets all the values to default
  96633. * @param from The from point on world space
  96634. * @param to The to point on world space
  96635. */
  96636. reset(from?: Vector3, to?: Vector3): void;
  96637. }
  96638. /**
  96639. * Interface for the size containing width and height
  96640. */
  96641. interface IXYZ {
  96642. /**
  96643. * X
  96644. */
  96645. x: number;
  96646. /**
  96647. * Y
  96648. */
  96649. y: number;
  96650. /**
  96651. * Z
  96652. */
  96653. z: number;
  96654. }
  96655. }
  96656. declare module BABYLON {
  96657. /**
  96658. * Interface used to describe a physics joint
  96659. */
  96660. export interface PhysicsImpostorJoint {
  96661. /** Defines the main impostor to which the joint is linked */
  96662. mainImpostor: PhysicsImpostor;
  96663. /** Defines the impostor that is connected to the main impostor using this joint */
  96664. connectedImpostor: PhysicsImpostor;
  96665. /** Defines the joint itself */
  96666. joint: PhysicsJoint;
  96667. }
  96668. /** @hidden */
  96669. export interface IPhysicsEnginePlugin {
  96670. world: any;
  96671. name: string;
  96672. setGravity(gravity: Vector3): void;
  96673. setTimeStep(timeStep: number): void;
  96674. getTimeStep(): number;
  96675. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96676. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96677. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96679. removePhysicsBody(impostor: PhysicsImpostor): void;
  96680. generateJoint(joint: PhysicsImpostorJoint): void;
  96681. removeJoint(joint: PhysicsImpostorJoint): void;
  96682. isSupported(): boolean;
  96683. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96684. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96685. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96686. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96687. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96688. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96689. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96690. getBodyMass(impostor: PhysicsImpostor): number;
  96691. getBodyFriction(impostor: PhysicsImpostor): number;
  96692. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96693. getBodyRestitution(impostor: PhysicsImpostor): number;
  96694. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96695. getBodyPressure?(impostor: PhysicsImpostor): number;
  96696. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96697. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96698. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96699. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96700. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96701. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96702. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96703. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96704. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96705. sleepBody(impostor: PhysicsImpostor): void;
  96706. wakeUpBody(impostor: PhysicsImpostor): void;
  96707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96709. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96711. getRadius(impostor: PhysicsImpostor): number;
  96712. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96714. dispose(): void;
  96715. }
  96716. /**
  96717. * Interface used to define a physics engine
  96718. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96719. */
  96720. export interface IPhysicsEngine {
  96721. /**
  96722. * Gets the gravity vector used by the simulation
  96723. */
  96724. gravity: Vector3;
  96725. /**
  96726. * Sets the gravity vector used by the simulation
  96727. * @param gravity defines the gravity vector to use
  96728. */
  96729. setGravity(gravity: Vector3): void;
  96730. /**
  96731. * Set the time step of the physics engine.
  96732. * Default is 1/60.
  96733. * To slow it down, enter 1/600 for example.
  96734. * To speed it up, 1/30
  96735. * @param newTimeStep the new timestep to apply to this world.
  96736. */
  96737. setTimeStep(newTimeStep: number): void;
  96738. /**
  96739. * Get the time step of the physics engine.
  96740. * @returns the current time step
  96741. */
  96742. getTimeStep(): number;
  96743. /**
  96744. * Set the sub time step of the physics engine.
  96745. * Default is 0 meaning there is no sub steps
  96746. * To increase physics resolution precision, set a small value (like 1 ms)
  96747. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96748. */
  96749. setSubTimeStep(subTimeStep: number): void;
  96750. /**
  96751. * Get the sub time step of the physics engine.
  96752. * @returns the current sub time step
  96753. */
  96754. getSubTimeStep(): number;
  96755. /**
  96756. * Release all resources
  96757. */
  96758. dispose(): void;
  96759. /**
  96760. * Gets the name of the current physics plugin
  96761. * @returns the name of the plugin
  96762. */
  96763. getPhysicsPluginName(): string;
  96764. /**
  96765. * Adding a new impostor for the impostor tracking.
  96766. * This will be done by the impostor itself.
  96767. * @param impostor the impostor to add
  96768. */
  96769. addImpostor(impostor: PhysicsImpostor): void;
  96770. /**
  96771. * Remove an impostor from the engine.
  96772. * This impostor and its mesh will not longer be updated by the physics engine.
  96773. * @param impostor the impostor to remove
  96774. */
  96775. removeImpostor(impostor: PhysicsImpostor): void;
  96776. /**
  96777. * Add a joint to the physics engine
  96778. * @param mainImpostor defines the main impostor to which the joint is added.
  96779. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96780. * @param joint defines the joint that will connect both impostors.
  96781. */
  96782. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96783. /**
  96784. * Removes a joint from the simulation
  96785. * @param mainImpostor defines the impostor used with the joint
  96786. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96787. * @param joint defines the joint to remove
  96788. */
  96789. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96790. /**
  96791. * Gets the current plugin used to run the simulation
  96792. * @returns current plugin
  96793. */
  96794. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96795. /**
  96796. * Gets the list of physic impostors
  96797. * @returns an array of PhysicsImpostor
  96798. */
  96799. getImpostors(): Array<PhysicsImpostor>;
  96800. /**
  96801. * Gets the impostor for a physics enabled object
  96802. * @param object defines the object impersonated by the impostor
  96803. * @returns the PhysicsImpostor or null if not found
  96804. */
  96805. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96806. /**
  96807. * Gets the impostor for a physics body object
  96808. * @param body defines physics body used by the impostor
  96809. * @returns the PhysicsImpostor or null if not found
  96810. */
  96811. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96812. /**
  96813. * Does a raycast in the physics world
  96814. * @param from when should the ray start?
  96815. * @param to when should the ray end?
  96816. * @returns PhysicsRaycastResult
  96817. */
  96818. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96819. /**
  96820. * Called by the scene. No need to call it.
  96821. * @param delta defines the timespam between frames
  96822. */
  96823. _step(delta: number): void;
  96824. }
  96825. }
  96826. declare module BABYLON {
  96827. /**
  96828. * The interface for the physics imposter parameters
  96829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96830. */
  96831. export interface PhysicsImpostorParameters {
  96832. /**
  96833. * The mass of the physics imposter
  96834. */
  96835. mass: number;
  96836. /**
  96837. * The friction of the physics imposter
  96838. */
  96839. friction?: number;
  96840. /**
  96841. * The coefficient of restitution of the physics imposter
  96842. */
  96843. restitution?: number;
  96844. /**
  96845. * The native options of the physics imposter
  96846. */
  96847. nativeOptions?: any;
  96848. /**
  96849. * Specifies if the parent should be ignored
  96850. */
  96851. ignoreParent?: boolean;
  96852. /**
  96853. * Specifies if bi-directional transformations should be disabled
  96854. */
  96855. disableBidirectionalTransformation?: boolean;
  96856. /**
  96857. * The pressure inside the physics imposter, soft object only
  96858. */
  96859. pressure?: number;
  96860. /**
  96861. * The stiffness the physics imposter, soft object only
  96862. */
  96863. stiffness?: number;
  96864. /**
  96865. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96866. */
  96867. velocityIterations?: number;
  96868. /**
  96869. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96870. */
  96871. positionIterations?: number;
  96872. /**
  96873. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96874. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96875. * Add to fix multiple points
  96876. */
  96877. fixedPoints?: number;
  96878. /**
  96879. * The collision margin around a soft object
  96880. */
  96881. margin?: number;
  96882. /**
  96883. * The collision margin around a soft object
  96884. */
  96885. damping?: number;
  96886. /**
  96887. * The path for a rope based on an extrusion
  96888. */
  96889. path?: any;
  96890. /**
  96891. * The shape of an extrusion used for a rope based on an extrusion
  96892. */
  96893. shape?: any;
  96894. }
  96895. /**
  96896. * Interface for a physics-enabled object
  96897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96898. */
  96899. export interface IPhysicsEnabledObject {
  96900. /**
  96901. * The position of the physics-enabled object
  96902. */
  96903. position: Vector3;
  96904. /**
  96905. * The rotation of the physics-enabled object
  96906. */
  96907. rotationQuaternion: Nullable<Quaternion>;
  96908. /**
  96909. * The scale of the physics-enabled object
  96910. */
  96911. scaling: Vector3;
  96912. /**
  96913. * The rotation of the physics-enabled object
  96914. */
  96915. rotation?: Vector3;
  96916. /**
  96917. * The parent of the physics-enabled object
  96918. */
  96919. parent?: any;
  96920. /**
  96921. * The bounding info of the physics-enabled object
  96922. * @returns The bounding info of the physics-enabled object
  96923. */
  96924. getBoundingInfo(): BoundingInfo;
  96925. /**
  96926. * Computes the world matrix
  96927. * @param force Specifies if the world matrix should be computed by force
  96928. * @returns A world matrix
  96929. */
  96930. computeWorldMatrix(force: boolean): Matrix;
  96931. /**
  96932. * Gets the world matrix
  96933. * @returns A world matrix
  96934. */
  96935. getWorldMatrix?(): Matrix;
  96936. /**
  96937. * Gets the child meshes
  96938. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96939. * @returns An array of abstract meshes
  96940. */
  96941. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96942. /**
  96943. * Gets the vertex data
  96944. * @param kind The type of vertex data
  96945. * @returns A nullable array of numbers, or a float32 array
  96946. */
  96947. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96948. /**
  96949. * Gets the indices from the mesh
  96950. * @returns A nullable array of index arrays
  96951. */
  96952. getIndices?(): Nullable<IndicesArray>;
  96953. /**
  96954. * Gets the scene from the mesh
  96955. * @returns the indices array or null
  96956. */
  96957. getScene?(): Scene;
  96958. /**
  96959. * Gets the absolute position from the mesh
  96960. * @returns the absolute position
  96961. */
  96962. getAbsolutePosition(): Vector3;
  96963. /**
  96964. * Gets the absolute pivot point from the mesh
  96965. * @returns the absolute pivot point
  96966. */
  96967. getAbsolutePivotPoint(): Vector3;
  96968. /**
  96969. * Rotates the mesh
  96970. * @param axis The axis of rotation
  96971. * @param amount The amount of rotation
  96972. * @param space The space of the rotation
  96973. * @returns The rotation transform node
  96974. */
  96975. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96976. /**
  96977. * Translates the mesh
  96978. * @param axis The axis of translation
  96979. * @param distance The distance of translation
  96980. * @param space The space of the translation
  96981. * @returns The transform node
  96982. */
  96983. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96984. /**
  96985. * Sets the absolute position of the mesh
  96986. * @param absolutePosition The absolute position of the mesh
  96987. * @returns The transform node
  96988. */
  96989. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96990. /**
  96991. * Gets the class name of the mesh
  96992. * @returns The class name
  96993. */
  96994. getClassName(): string;
  96995. }
  96996. /**
  96997. * Represents a physics imposter
  96998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96999. */
  97000. export class PhysicsImpostor {
  97001. /**
  97002. * The physics-enabled object used as the physics imposter
  97003. */
  97004. object: IPhysicsEnabledObject;
  97005. /**
  97006. * The type of the physics imposter
  97007. */
  97008. type: number;
  97009. private _options;
  97010. private _scene?;
  97011. /**
  97012. * The default object size of the imposter
  97013. */
  97014. static DEFAULT_OBJECT_SIZE: Vector3;
  97015. /**
  97016. * The identity quaternion of the imposter
  97017. */
  97018. static IDENTITY_QUATERNION: Quaternion;
  97019. /** @hidden */
  97020. _pluginData: any;
  97021. private _physicsEngine;
  97022. private _physicsBody;
  97023. private _bodyUpdateRequired;
  97024. private _onBeforePhysicsStepCallbacks;
  97025. private _onAfterPhysicsStepCallbacks;
  97026. /** @hidden */
  97027. _onPhysicsCollideCallbacks: Array<{
  97028. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97029. otherImpostors: Array<PhysicsImpostor>;
  97030. }>;
  97031. private _deltaPosition;
  97032. private _deltaRotation;
  97033. private _deltaRotationConjugated;
  97034. /** @hidden */
  97035. _isFromLine: boolean;
  97036. private _parent;
  97037. private _isDisposed;
  97038. private static _tmpVecs;
  97039. private static _tmpQuat;
  97040. /**
  97041. * Specifies if the physics imposter is disposed
  97042. */
  97043. get isDisposed(): boolean;
  97044. /**
  97045. * Gets the mass of the physics imposter
  97046. */
  97047. get mass(): number;
  97048. set mass(value: number);
  97049. /**
  97050. * Gets the coefficient of friction
  97051. */
  97052. get friction(): number;
  97053. /**
  97054. * Sets the coefficient of friction
  97055. */
  97056. set friction(value: number);
  97057. /**
  97058. * Gets the coefficient of restitution
  97059. */
  97060. get restitution(): number;
  97061. /**
  97062. * Sets the coefficient of restitution
  97063. */
  97064. set restitution(value: number);
  97065. /**
  97066. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97067. */
  97068. get pressure(): number;
  97069. /**
  97070. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97071. */
  97072. set pressure(value: number);
  97073. /**
  97074. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97075. */
  97076. get stiffness(): number;
  97077. /**
  97078. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97079. */
  97080. set stiffness(value: number);
  97081. /**
  97082. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97083. */
  97084. get velocityIterations(): number;
  97085. /**
  97086. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97087. */
  97088. set velocityIterations(value: number);
  97089. /**
  97090. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97091. */
  97092. get positionIterations(): number;
  97093. /**
  97094. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97095. */
  97096. set positionIterations(value: number);
  97097. /**
  97098. * The unique id of the physics imposter
  97099. * set by the physics engine when adding this impostor to the array
  97100. */
  97101. uniqueId: number;
  97102. /**
  97103. * @hidden
  97104. */
  97105. soft: boolean;
  97106. /**
  97107. * @hidden
  97108. */
  97109. segments: number;
  97110. private _joints;
  97111. /**
  97112. * Initializes the physics imposter
  97113. * @param object The physics-enabled object used as the physics imposter
  97114. * @param type The type of the physics imposter
  97115. * @param _options The options for the physics imposter
  97116. * @param _scene The Babylon scene
  97117. */
  97118. constructor(
  97119. /**
  97120. * The physics-enabled object used as the physics imposter
  97121. */
  97122. object: IPhysicsEnabledObject,
  97123. /**
  97124. * The type of the physics imposter
  97125. */
  97126. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97127. /**
  97128. * This function will completly initialize this impostor.
  97129. * It will create a new body - but only if this mesh has no parent.
  97130. * If it has, this impostor will not be used other than to define the impostor
  97131. * of the child mesh.
  97132. * @hidden
  97133. */
  97134. _init(): void;
  97135. private _getPhysicsParent;
  97136. /**
  97137. * Should a new body be generated.
  97138. * @returns boolean specifying if body initialization is required
  97139. */
  97140. isBodyInitRequired(): boolean;
  97141. /**
  97142. * Sets the updated scaling
  97143. * @param updated Specifies if the scaling is updated
  97144. */
  97145. setScalingUpdated(): void;
  97146. /**
  97147. * Force a regeneration of this or the parent's impostor's body.
  97148. * Use under cautious - This will remove all joints already implemented.
  97149. */
  97150. forceUpdate(): void;
  97151. /**
  97152. * Gets the body that holds this impostor. Either its own, or its parent.
  97153. */
  97154. get physicsBody(): any;
  97155. /**
  97156. * Get the parent of the physics imposter
  97157. * @returns Physics imposter or null
  97158. */
  97159. get parent(): Nullable<PhysicsImpostor>;
  97160. /**
  97161. * Sets the parent of the physics imposter
  97162. */
  97163. set parent(value: Nullable<PhysicsImpostor>);
  97164. /**
  97165. * Set the physics body. Used mainly by the physics engine/plugin
  97166. */
  97167. set physicsBody(physicsBody: any);
  97168. /**
  97169. * Resets the update flags
  97170. */
  97171. resetUpdateFlags(): void;
  97172. /**
  97173. * Gets the object extend size
  97174. * @returns the object extend size
  97175. */
  97176. getObjectExtendSize(): Vector3;
  97177. /**
  97178. * Gets the object center
  97179. * @returns The object center
  97180. */
  97181. getObjectCenter(): Vector3;
  97182. /**
  97183. * Get a specific parameter from the options parameters
  97184. * @param paramName The object parameter name
  97185. * @returns The object parameter
  97186. */
  97187. getParam(paramName: string): any;
  97188. /**
  97189. * Sets a specific parameter in the options given to the physics plugin
  97190. * @param paramName The parameter name
  97191. * @param value The value of the parameter
  97192. */
  97193. setParam(paramName: string, value: number): void;
  97194. /**
  97195. * Specifically change the body's mass option. Won't recreate the physics body object
  97196. * @param mass The mass of the physics imposter
  97197. */
  97198. setMass(mass: number): void;
  97199. /**
  97200. * Gets the linear velocity
  97201. * @returns linear velocity or null
  97202. */
  97203. getLinearVelocity(): Nullable<Vector3>;
  97204. /**
  97205. * Sets the linear velocity
  97206. * @param velocity linear velocity or null
  97207. */
  97208. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97209. /**
  97210. * Gets the angular velocity
  97211. * @returns angular velocity or null
  97212. */
  97213. getAngularVelocity(): Nullable<Vector3>;
  97214. /**
  97215. * Sets the angular velocity
  97216. * @param velocity The velocity or null
  97217. */
  97218. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97219. /**
  97220. * Execute a function with the physics plugin native code
  97221. * Provide a function the will have two variables - the world object and the physics body object
  97222. * @param func The function to execute with the physics plugin native code
  97223. */
  97224. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97225. /**
  97226. * Register a function that will be executed before the physics world is stepping forward
  97227. * @param func The function to execute before the physics world is stepped forward
  97228. */
  97229. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97230. /**
  97231. * Unregister a function that will be executed before the physics world is stepping forward
  97232. * @param func The function to execute before the physics world is stepped forward
  97233. */
  97234. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97235. /**
  97236. * Register a function that will be executed after the physics step
  97237. * @param func The function to execute after physics step
  97238. */
  97239. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97240. /**
  97241. * Unregisters a function that will be executed after the physics step
  97242. * @param func The function to execute after physics step
  97243. */
  97244. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97245. /**
  97246. * register a function that will be executed when this impostor collides against a different body
  97247. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97248. * @param func Callback that is executed on collision
  97249. */
  97250. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97251. /**
  97252. * Unregisters the physics imposter on contact
  97253. * @param collideAgainst The physics object to collide against
  97254. * @param func Callback to execute on collision
  97255. */
  97256. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97257. private _tmpQuat;
  97258. private _tmpQuat2;
  97259. /**
  97260. * Get the parent rotation
  97261. * @returns The parent rotation
  97262. */
  97263. getParentsRotation(): Quaternion;
  97264. /**
  97265. * this function is executed by the physics engine.
  97266. */
  97267. beforeStep: () => void;
  97268. /**
  97269. * this function is executed by the physics engine
  97270. */
  97271. afterStep: () => void;
  97272. /**
  97273. * Legacy collision detection event support
  97274. */
  97275. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97276. /**
  97277. * event and body object due to cannon's event-based architecture.
  97278. */
  97279. onCollide: (e: {
  97280. body: any;
  97281. }) => void;
  97282. /**
  97283. * Apply a force
  97284. * @param force The force to apply
  97285. * @param contactPoint The contact point for the force
  97286. * @returns The physics imposter
  97287. */
  97288. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97289. /**
  97290. * Apply an impulse
  97291. * @param force The impulse force
  97292. * @param contactPoint The contact point for the impulse force
  97293. * @returns The physics imposter
  97294. */
  97295. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97296. /**
  97297. * A help function to create a joint
  97298. * @param otherImpostor A physics imposter used to create a joint
  97299. * @param jointType The type of joint
  97300. * @param jointData The data for the joint
  97301. * @returns The physics imposter
  97302. */
  97303. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97304. /**
  97305. * Add a joint to this impostor with a different impostor
  97306. * @param otherImpostor A physics imposter used to add a joint
  97307. * @param joint The joint to add
  97308. * @returns The physics imposter
  97309. */
  97310. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97311. /**
  97312. * Add an anchor to a cloth impostor
  97313. * @param otherImpostor rigid impostor to anchor to
  97314. * @param width ratio across width from 0 to 1
  97315. * @param height ratio up height from 0 to 1
  97316. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97317. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97318. * @returns impostor the soft imposter
  97319. */
  97320. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97321. /**
  97322. * Add a hook to a rope impostor
  97323. * @param otherImpostor rigid impostor to anchor to
  97324. * @param length ratio across rope from 0 to 1
  97325. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97326. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97327. * @returns impostor the rope imposter
  97328. */
  97329. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97330. /**
  97331. * Will keep this body still, in a sleep mode.
  97332. * @returns the physics imposter
  97333. */
  97334. sleep(): PhysicsImpostor;
  97335. /**
  97336. * Wake the body up.
  97337. * @returns The physics imposter
  97338. */
  97339. wakeUp(): PhysicsImpostor;
  97340. /**
  97341. * Clones the physics imposter
  97342. * @param newObject The physics imposter clones to this physics-enabled object
  97343. * @returns A nullable physics imposter
  97344. */
  97345. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97346. /**
  97347. * Disposes the physics imposter
  97348. */
  97349. dispose(): void;
  97350. /**
  97351. * Sets the delta position
  97352. * @param position The delta position amount
  97353. */
  97354. setDeltaPosition(position: Vector3): void;
  97355. /**
  97356. * Sets the delta rotation
  97357. * @param rotation The delta rotation amount
  97358. */
  97359. setDeltaRotation(rotation: Quaternion): void;
  97360. /**
  97361. * Gets the box size of the physics imposter and stores the result in the input parameter
  97362. * @param result Stores the box size
  97363. * @returns The physics imposter
  97364. */
  97365. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97366. /**
  97367. * Gets the radius of the physics imposter
  97368. * @returns Radius of the physics imposter
  97369. */
  97370. getRadius(): number;
  97371. /**
  97372. * Sync a bone with this impostor
  97373. * @param bone The bone to sync to the impostor.
  97374. * @param boneMesh The mesh that the bone is influencing.
  97375. * @param jointPivot The pivot of the joint / bone in local space.
  97376. * @param distToJoint Optional distance from the impostor to the joint.
  97377. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97378. */
  97379. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97380. /**
  97381. * Sync impostor to a bone
  97382. * @param bone The bone that the impostor will be synced to.
  97383. * @param boneMesh The mesh that the bone is influencing.
  97384. * @param jointPivot The pivot of the joint / bone in local space.
  97385. * @param distToJoint Optional distance from the impostor to the joint.
  97386. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97387. * @param boneAxis Optional vector3 axis the bone is aligned with
  97388. */
  97389. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97390. /**
  97391. * No-Imposter type
  97392. */
  97393. static NoImpostor: number;
  97394. /**
  97395. * Sphere-Imposter type
  97396. */
  97397. static SphereImpostor: number;
  97398. /**
  97399. * Box-Imposter type
  97400. */
  97401. static BoxImpostor: number;
  97402. /**
  97403. * Plane-Imposter type
  97404. */
  97405. static PlaneImpostor: number;
  97406. /**
  97407. * Mesh-imposter type
  97408. */
  97409. static MeshImpostor: number;
  97410. /**
  97411. * Capsule-Impostor type (Ammo.js plugin only)
  97412. */
  97413. static CapsuleImpostor: number;
  97414. /**
  97415. * Cylinder-Imposter type
  97416. */
  97417. static CylinderImpostor: number;
  97418. /**
  97419. * Particle-Imposter type
  97420. */
  97421. static ParticleImpostor: number;
  97422. /**
  97423. * Heightmap-Imposter type
  97424. */
  97425. static HeightmapImpostor: number;
  97426. /**
  97427. * ConvexHull-Impostor type (Ammo.js plugin only)
  97428. */
  97429. static ConvexHullImpostor: number;
  97430. /**
  97431. * Custom-Imposter type (Ammo.js plugin only)
  97432. */
  97433. static CustomImpostor: number;
  97434. /**
  97435. * Rope-Imposter type
  97436. */
  97437. static RopeImpostor: number;
  97438. /**
  97439. * Cloth-Imposter type
  97440. */
  97441. static ClothImpostor: number;
  97442. /**
  97443. * Softbody-Imposter type
  97444. */
  97445. static SoftbodyImpostor: number;
  97446. }
  97447. }
  97448. declare module BABYLON {
  97449. /**
  97450. * @hidden
  97451. **/
  97452. export class _CreationDataStorage {
  97453. closePath?: boolean;
  97454. closeArray?: boolean;
  97455. idx: number[];
  97456. dashSize: number;
  97457. gapSize: number;
  97458. path3D: Path3D;
  97459. pathArray: Vector3[][];
  97460. arc: number;
  97461. radius: number;
  97462. cap: number;
  97463. tessellation: number;
  97464. }
  97465. /**
  97466. * @hidden
  97467. **/
  97468. class _InstanceDataStorage {
  97469. visibleInstances: any;
  97470. batchCache: _InstancesBatch;
  97471. instancesBufferSize: number;
  97472. instancesBuffer: Nullable<Buffer>;
  97473. instancesData: Float32Array;
  97474. overridenInstanceCount: number;
  97475. isFrozen: boolean;
  97476. previousBatch: Nullable<_InstancesBatch>;
  97477. hardwareInstancedRendering: boolean;
  97478. sideOrientation: number;
  97479. manualUpdate: boolean;
  97480. }
  97481. /**
  97482. * @hidden
  97483. **/
  97484. export class _InstancesBatch {
  97485. mustReturn: boolean;
  97486. visibleInstances: Nullable<InstancedMesh[]>[];
  97487. renderSelf: boolean[];
  97488. hardwareInstancedRendering: boolean[];
  97489. }
  97490. /**
  97491. * Class used to represent renderable models
  97492. */
  97493. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97494. /**
  97495. * Mesh side orientation : usually the external or front surface
  97496. */
  97497. static readonly FRONTSIDE: number;
  97498. /**
  97499. * Mesh side orientation : usually the internal or back surface
  97500. */
  97501. static readonly BACKSIDE: number;
  97502. /**
  97503. * Mesh side orientation : both internal and external or front and back surfaces
  97504. */
  97505. static readonly DOUBLESIDE: number;
  97506. /**
  97507. * Mesh side orientation : by default, `FRONTSIDE`
  97508. */
  97509. static readonly DEFAULTSIDE: number;
  97510. /**
  97511. * Mesh cap setting : no cap
  97512. */
  97513. static readonly NO_CAP: number;
  97514. /**
  97515. * Mesh cap setting : one cap at the beginning of the mesh
  97516. */
  97517. static readonly CAP_START: number;
  97518. /**
  97519. * Mesh cap setting : one cap at the end of the mesh
  97520. */
  97521. static readonly CAP_END: number;
  97522. /**
  97523. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97524. */
  97525. static readonly CAP_ALL: number;
  97526. /**
  97527. * Mesh pattern setting : no flip or rotate
  97528. */
  97529. static readonly NO_FLIP: number;
  97530. /**
  97531. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97532. */
  97533. static readonly FLIP_TILE: number;
  97534. /**
  97535. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97536. */
  97537. static readonly ROTATE_TILE: number;
  97538. /**
  97539. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97540. */
  97541. static readonly FLIP_ROW: number;
  97542. /**
  97543. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97544. */
  97545. static readonly ROTATE_ROW: number;
  97546. /**
  97547. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97548. */
  97549. static readonly FLIP_N_ROTATE_TILE: number;
  97550. /**
  97551. * Mesh pattern setting : rotate pattern and rotate
  97552. */
  97553. static readonly FLIP_N_ROTATE_ROW: number;
  97554. /**
  97555. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97556. */
  97557. static readonly CENTER: number;
  97558. /**
  97559. * Mesh tile positioning : part tiles on left
  97560. */
  97561. static readonly LEFT: number;
  97562. /**
  97563. * Mesh tile positioning : part tiles on right
  97564. */
  97565. static readonly RIGHT: number;
  97566. /**
  97567. * Mesh tile positioning : part tiles on top
  97568. */
  97569. static readonly TOP: number;
  97570. /**
  97571. * Mesh tile positioning : part tiles on bottom
  97572. */
  97573. static readonly BOTTOM: number;
  97574. /**
  97575. * Gets the default side orientation.
  97576. * @param orientation the orientation to value to attempt to get
  97577. * @returns the default orientation
  97578. * @hidden
  97579. */
  97580. static _GetDefaultSideOrientation(orientation?: number): number;
  97581. private _internalMeshDataInfo;
  97582. /**
  97583. * An event triggered before rendering the mesh
  97584. */
  97585. get onBeforeRenderObservable(): Observable<Mesh>;
  97586. /**
  97587. * An event triggered before binding the mesh
  97588. */
  97589. get onBeforeBindObservable(): Observable<Mesh>;
  97590. /**
  97591. * An event triggered after rendering the mesh
  97592. */
  97593. get onAfterRenderObservable(): Observable<Mesh>;
  97594. /**
  97595. * An event triggered before drawing the mesh
  97596. */
  97597. get onBeforeDrawObservable(): Observable<Mesh>;
  97598. private _onBeforeDrawObserver;
  97599. /**
  97600. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97601. */
  97602. set onBeforeDraw(callback: () => void);
  97603. get hasInstances(): boolean;
  97604. /**
  97605. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97606. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97607. */
  97608. delayLoadState: number;
  97609. /**
  97610. * Gets the list of instances created from this mesh
  97611. * it is not supposed to be modified manually.
  97612. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97613. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97614. */
  97615. instances: InstancedMesh[];
  97616. /**
  97617. * Gets the file containing delay loading data for this mesh
  97618. */
  97619. delayLoadingFile: string;
  97620. /** @hidden */
  97621. _binaryInfo: any;
  97622. /**
  97623. * User defined function used to change how LOD level selection is done
  97624. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97625. */
  97626. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97627. /**
  97628. * Gets or sets the morph target manager
  97629. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97630. */
  97631. get morphTargetManager(): Nullable<MorphTargetManager>;
  97632. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97633. /** @hidden */
  97634. _creationDataStorage: Nullable<_CreationDataStorage>;
  97635. /** @hidden */
  97636. _geometry: Nullable<Geometry>;
  97637. /** @hidden */
  97638. _delayInfo: Array<string>;
  97639. /** @hidden */
  97640. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97641. /** @hidden */
  97642. _instanceDataStorage: _InstanceDataStorage;
  97643. private _effectiveMaterial;
  97644. /** @hidden */
  97645. _shouldGenerateFlatShading: boolean;
  97646. /** @hidden */
  97647. _originalBuilderSideOrientation: number;
  97648. /**
  97649. * Use this property to change the original side orientation defined at construction time
  97650. */
  97651. overrideMaterialSideOrientation: Nullable<number>;
  97652. /**
  97653. * Gets the source mesh (the one used to clone this one from)
  97654. */
  97655. get source(): Nullable<Mesh>;
  97656. /**
  97657. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97658. */
  97659. get isUnIndexed(): boolean;
  97660. set isUnIndexed(value: boolean);
  97661. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97662. get worldMatrixInstancedBuffer(): Float32Array;
  97663. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97664. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97665. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97666. /**
  97667. * @constructor
  97668. * @param name The value used by scene.getMeshByName() to do a lookup.
  97669. * @param scene The scene to add this mesh to.
  97670. * @param parent The parent of this mesh, if it has one
  97671. * @param source An optional Mesh from which geometry is shared, cloned.
  97672. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97673. * When false, achieved by calling a clone(), also passing False.
  97674. * This will make creation of children, recursive.
  97675. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97676. */
  97677. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97678. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97679. doNotInstantiate: boolean;
  97680. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97681. /**
  97682. * Gets the class name
  97683. * @returns the string "Mesh".
  97684. */
  97685. getClassName(): string;
  97686. /** @hidden */
  97687. get _isMesh(): boolean;
  97688. /**
  97689. * Returns a description of this mesh
  97690. * @param fullDetails define if full details about this mesh must be used
  97691. * @returns a descriptive string representing this mesh
  97692. */
  97693. toString(fullDetails?: boolean): string;
  97694. /** @hidden */
  97695. _unBindEffect(): void;
  97696. /**
  97697. * Gets a boolean indicating if this mesh has LOD
  97698. */
  97699. get hasLODLevels(): boolean;
  97700. /**
  97701. * Gets the list of MeshLODLevel associated with the current mesh
  97702. * @returns an array of MeshLODLevel
  97703. */
  97704. getLODLevels(): MeshLODLevel[];
  97705. private _sortLODLevels;
  97706. /**
  97707. * Add a mesh as LOD level triggered at the given distance.
  97708. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97709. * @param distance The distance from the center of the object to show this level
  97710. * @param mesh The mesh to be added as LOD level (can be null)
  97711. * @return This mesh (for chaining)
  97712. */
  97713. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97714. /**
  97715. * Returns the LOD level mesh at the passed distance or null if not found.
  97716. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97717. * @param distance The distance from the center of the object to show this level
  97718. * @returns a Mesh or `null`
  97719. */
  97720. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97721. /**
  97722. * Remove a mesh from the LOD array
  97723. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97724. * @param mesh defines the mesh to be removed
  97725. * @return This mesh (for chaining)
  97726. */
  97727. removeLODLevel(mesh: Mesh): Mesh;
  97728. /**
  97729. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97730. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97731. * @param camera defines the camera to use to compute distance
  97732. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97733. * @return This mesh (for chaining)
  97734. */
  97735. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97736. /**
  97737. * Gets the mesh internal Geometry object
  97738. */
  97739. get geometry(): Nullable<Geometry>;
  97740. /**
  97741. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97742. * @returns the total number of vertices
  97743. */
  97744. getTotalVertices(): number;
  97745. /**
  97746. * Returns the content of an associated vertex buffer
  97747. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97748. * - VertexBuffer.PositionKind
  97749. * - VertexBuffer.UVKind
  97750. * - VertexBuffer.UV2Kind
  97751. * - VertexBuffer.UV3Kind
  97752. * - VertexBuffer.UV4Kind
  97753. * - VertexBuffer.UV5Kind
  97754. * - VertexBuffer.UV6Kind
  97755. * - VertexBuffer.ColorKind
  97756. * - VertexBuffer.MatricesIndicesKind
  97757. * - VertexBuffer.MatricesIndicesExtraKind
  97758. * - VertexBuffer.MatricesWeightsKind
  97759. * - VertexBuffer.MatricesWeightsExtraKind
  97760. * @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
  97761. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97762. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97763. */
  97764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97765. /**
  97766. * Returns the mesh VertexBuffer object from the requested `kind`
  97767. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97768. * - VertexBuffer.PositionKind
  97769. * - VertexBuffer.NormalKind
  97770. * - VertexBuffer.UVKind
  97771. * - VertexBuffer.UV2Kind
  97772. * - VertexBuffer.UV3Kind
  97773. * - VertexBuffer.UV4Kind
  97774. * - VertexBuffer.UV5Kind
  97775. * - VertexBuffer.UV6Kind
  97776. * - VertexBuffer.ColorKind
  97777. * - VertexBuffer.MatricesIndicesKind
  97778. * - VertexBuffer.MatricesIndicesExtraKind
  97779. * - VertexBuffer.MatricesWeightsKind
  97780. * - VertexBuffer.MatricesWeightsExtraKind
  97781. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97782. */
  97783. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97784. /**
  97785. * Tests if a specific vertex buffer is associated with this mesh
  97786. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97787. * - VertexBuffer.PositionKind
  97788. * - VertexBuffer.NormalKind
  97789. * - VertexBuffer.UVKind
  97790. * - VertexBuffer.UV2Kind
  97791. * - VertexBuffer.UV3Kind
  97792. * - VertexBuffer.UV4Kind
  97793. * - VertexBuffer.UV5Kind
  97794. * - VertexBuffer.UV6Kind
  97795. * - VertexBuffer.ColorKind
  97796. * - VertexBuffer.MatricesIndicesKind
  97797. * - VertexBuffer.MatricesIndicesExtraKind
  97798. * - VertexBuffer.MatricesWeightsKind
  97799. * - VertexBuffer.MatricesWeightsExtraKind
  97800. * @returns a boolean
  97801. */
  97802. isVerticesDataPresent(kind: string): boolean;
  97803. /**
  97804. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97805. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97806. * - VertexBuffer.PositionKind
  97807. * - VertexBuffer.UVKind
  97808. * - VertexBuffer.UV2Kind
  97809. * - VertexBuffer.UV3Kind
  97810. * - VertexBuffer.UV4Kind
  97811. * - VertexBuffer.UV5Kind
  97812. * - VertexBuffer.UV6Kind
  97813. * - VertexBuffer.ColorKind
  97814. * - VertexBuffer.MatricesIndicesKind
  97815. * - VertexBuffer.MatricesIndicesExtraKind
  97816. * - VertexBuffer.MatricesWeightsKind
  97817. * - VertexBuffer.MatricesWeightsExtraKind
  97818. * @returns a boolean
  97819. */
  97820. isVertexBufferUpdatable(kind: string): boolean;
  97821. /**
  97822. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97824. * - VertexBuffer.PositionKind
  97825. * - VertexBuffer.NormalKind
  97826. * - VertexBuffer.UVKind
  97827. * - VertexBuffer.UV2Kind
  97828. * - VertexBuffer.UV3Kind
  97829. * - VertexBuffer.UV4Kind
  97830. * - VertexBuffer.UV5Kind
  97831. * - VertexBuffer.UV6Kind
  97832. * - VertexBuffer.ColorKind
  97833. * - VertexBuffer.MatricesIndicesKind
  97834. * - VertexBuffer.MatricesIndicesExtraKind
  97835. * - VertexBuffer.MatricesWeightsKind
  97836. * - VertexBuffer.MatricesWeightsExtraKind
  97837. * @returns an array of strings
  97838. */
  97839. getVerticesDataKinds(): string[];
  97840. /**
  97841. * Returns a positive integer : the total number of indices in this mesh geometry.
  97842. * @returns the numner of indices or zero if the mesh has no geometry.
  97843. */
  97844. getTotalIndices(): number;
  97845. /**
  97846. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97847. * @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.
  97848. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97849. * @returns the indices array or an empty array if the mesh has no geometry
  97850. */
  97851. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97852. get isBlocked(): boolean;
  97853. /**
  97854. * Determine if the current mesh is ready to be rendered
  97855. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97856. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97857. * @returns true if all associated assets are ready (material, textures, shaders)
  97858. */
  97859. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97860. /**
  97861. * 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.
  97862. */
  97863. get areNormalsFrozen(): boolean;
  97864. /**
  97865. * 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.
  97866. * @returns the current mesh
  97867. */
  97868. freezeNormals(): Mesh;
  97869. /**
  97870. * 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
  97871. * @returns the current mesh
  97872. */
  97873. unfreezeNormals(): Mesh;
  97874. /**
  97875. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97876. */
  97877. set overridenInstanceCount(count: number);
  97878. /** @hidden */
  97879. _preActivate(): Mesh;
  97880. /** @hidden */
  97881. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97882. /** @hidden */
  97883. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97884. /**
  97885. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97886. * This means the mesh underlying bounding box and sphere are recomputed.
  97887. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97888. * @returns the current mesh
  97889. */
  97890. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97891. /** @hidden */
  97892. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97893. /**
  97894. * This function will subdivide the mesh into multiple submeshes
  97895. * @param count defines the expected number of submeshes
  97896. */
  97897. subdivide(count: number): void;
  97898. /**
  97899. * Copy a FloatArray into a specific associated vertex buffer
  97900. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97901. * - VertexBuffer.PositionKind
  97902. * - VertexBuffer.UVKind
  97903. * - VertexBuffer.UV2Kind
  97904. * - VertexBuffer.UV3Kind
  97905. * - VertexBuffer.UV4Kind
  97906. * - VertexBuffer.UV5Kind
  97907. * - VertexBuffer.UV6Kind
  97908. * - VertexBuffer.ColorKind
  97909. * - VertexBuffer.MatricesIndicesKind
  97910. * - VertexBuffer.MatricesIndicesExtraKind
  97911. * - VertexBuffer.MatricesWeightsKind
  97912. * - VertexBuffer.MatricesWeightsExtraKind
  97913. * @param data defines the data source
  97914. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97915. * @param stride defines the data stride size (can be null)
  97916. * @returns the current mesh
  97917. */
  97918. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97919. /**
  97920. * Delete a vertex buffer associated with this mesh
  97921. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97922. * - VertexBuffer.PositionKind
  97923. * - VertexBuffer.UVKind
  97924. * - VertexBuffer.UV2Kind
  97925. * - VertexBuffer.UV3Kind
  97926. * - VertexBuffer.UV4Kind
  97927. * - VertexBuffer.UV5Kind
  97928. * - VertexBuffer.UV6Kind
  97929. * - VertexBuffer.ColorKind
  97930. * - VertexBuffer.MatricesIndicesKind
  97931. * - VertexBuffer.MatricesIndicesExtraKind
  97932. * - VertexBuffer.MatricesWeightsKind
  97933. * - VertexBuffer.MatricesWeightsExtraKind
  97934. */
  97935. removeVerticesData(kind: string): void;
  97936. /**
  97937. * Flags an associated vertex buffer as updatable
  97938. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97939. * - VertexBuffer.PositionKind
  97940. * - VertexBuffer.UVKind
  97941. * - VertexBuffer.UV2Kind
  97942. * - VertexBuffer.UV3Kind
  97943. * - VertexBuffer.UV4Kind
  97944. * - VertexBuffer.UV5Kind
  97945. * - VertexBuffer.UV6Kind
  97946. * - VertexBuffer.ColorKind
  97947. * - VertexBuffer.MatricesIndicesKind
  97948. * - VertexBuffer.MatricesIndicesExtraKind
  97949. * - VertexBuffer.MatricesWeightsKind
  97950. * - VertexBuffer.MatricesWeightsExtraKind
  97951. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97952. */
  97953. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97954. /**
  97955. * Sets the mesh global Vertex Buffer
  97956. * @param buffer defines the buffer to use
  97957. * @returns the current mesh
  97958. */
  97959. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97960. /**
  97961. * Update a specific associated vertex buffer
  97962. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97963. * - VertexBuffer.PositionKind
  97964. * - VertexBuffer.UVKind
  97965. * - VertexBuffer.UV2Kind
  97966. * - VertexBuffer.UV3Kind
  97967. * - VertexBuffer.UV4Kind
  97968. * - VertexBuffer.UV5Kind
  97969. * - VertexBuffer.UV6Kind
  97970. * - VertexBuffer.ColorKind
  97971. * - VertexBuffer.MatricesIndicesKind
  97972. * - VertexBuffer.MatricesIndicesExtraKind
  97973. * - VertexBuffer.MatricesWeightsKind
  97974. * - VertexBuffer.MatricesWeightsExtraKind
  97975. * @param data defines the data source
  97976. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97977. * @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)
  97978. * @returns the current mesh
  97979. */
  97980. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97981. /**
  97982. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97983. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97984. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97985. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97986. * @returns the current mesh
  97987. */
  97988. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97989. /**
  97990. * Creates a un-shared specific occurence of the geometry for the mesh.
  97991. * @returns the current mesh
  97992. */
  97993. makeGeometryUnique(): Mesh;
  97994. /**
  97995. * Set the index buffer of this mesh
  97996. * @param indices defines the source data
  97997. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97998. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97999. * @returns the current mesh
  98000. */
  98001. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98002. /**
  98003. * Update the current index buffer
  98004. * @param indices defines the source data
  98005. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98006. * @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)
  98007. * @returns the current mesh
  98008. */
  98009. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98010. /**
  98011. * Invert the geometry to move from a right handed system to a left handed one.
  98012. * @returns the current mesh
  98013. */
  98014. toLeftHanded(): Mesh;
  98015. /** @hidden */
  98016. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98017. /** @hidden */
  98018. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98019. /**
  98020. * Registers for this mesh a javascript function called just before the rendering process
  98021. * @param func defines the function to call before rendering this mesh
  98022. * @returns the current mesh
  98023. */
  98024. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98025. /**
  98026. * Disposes a previously registered javascript function called before the rendering
  98027. * @param func defines the function to remove
  98028. * @returns the current mesh
  98029. */
  98030. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98031. /**
  98032. * Registers for this mesh a javascript function called just after the rendering is complete
  98033. * @param func defines the function to call after rendering this mesh
  98034. * @returns the current mesh
  98035. */
  98036. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98037. /**
  98038. * Disposes a previously registered javascript function called after the rendering.
  98039. * @param func defines the function to remove
  98040. * @returns the current mesh
  98041. */
  98042. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98043. /** @hidden */
  98044. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98045. /** @hidden */
  98046. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98047. /** @hidden */
  98048. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98049. /** @hidden */
  98050. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98051. /** @hidden */
  98052. _rebuild(): void;
  98053. /** @hidden */
  98054. _freeze(): void;
  98055. /** @hidden */
  98056. _unFreeze(): void;
  98057. /**
  98058. * 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
  98059. * @param subMesh defines the subMesh to render
  98060. * @param enableAlphaMode defines if alpha mode can be changed
  98061. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98062. * @returns the current mesh
  98063. */
  98064. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98065. private _onBeforeDraw;
  98066. /**
  98067. * Renormalize the mesh and patch it up if there are no weights
  98068. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98069. * However in the case of zero weights then we set just a single influence to 1.
  98070. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98071. */
  98072. cleanMatrixWeights(): void;
  98073. private normalizeSkinFourWeights;
  98074. private normalizeSkinWeightsAndExtra;
  98075. /**
  98076. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98077. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98078. * the user know there was an issue with importing the mesh
  98079. * @returns a validation object with skinned, valid and report string
  98080. */
  98081. validateSkinning(): {
  98082. skinned: boolean;
  98083. valid: boolean;
  98084. report: string;
  98085. };
  98086. /** @hidden */
  98087. _checkDelayState(): Mesh;
  98088. private _queueLoad;
  98089. /**
  98090. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98091. * A mesh is in the frustum if its bounding box intersects the frustum
  98092. * @param frustumPlanes defines the frustum to test
  98093. * @returns true if the mesh is in the frustum planes
  98094. */
  98095. isInFrustum(frustumPlanes: Plane[]): boolean;
  98096. /**
  98097. * Sets the mesh material by the material or multiMaterial `id` property
  98098. * @param id is a string identifying the material or the multiMaterial
  98099. * @returns the current mesh
  98100. */
  98101. setMaterialByID(id: string): Mesh;
  98102. /**
  98103. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98104. * @returns an array of IAnimatable
  98105. */
  98106. getAnimatables(): IAnimatable[];
  98107. /**
  98108. * Modifies the mesh geometry according to the passed transformation matrix.
  98109. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98110. * The mesh normals are modified using the same transformation.
  98111. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98112. * @param transform defines the transform matrix to use
  98113. * @see http://doc.babylonjs.com/resources/baking_transformations
  98114. * @returns the current mesh
  98115. */
  98116. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98117. /**
  98118. * Modifies the mesh geometry according to its own current World Matrix.
  98119. * The mesh World Matrix is then reset.
  98120. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98121. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98122. * @see http://doc.babylonjs.com/resources/baking_transformations
  98123. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98124. * @returns the current mesh
  98125. */
  98126. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98127. /** @hidden */
  98128. get _positions(): Nullable<Vector3[]>;
  98129. /** @hidden */
  98130. _resetPointsArrayCache(): Mesh;
  98131. /** @hidden */
  98132. _generatePointsArray(): boolean;
  98133. /**
  98134. * Returns a new Mesh object generated from the current mesh properties.
  98135. * This method must not get confused with createInstance()
  98136. * @param name is a string, the name given to the new mesh
  98137. * @param newParent can be any Node object (default `null`)
  98138. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98139. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98140. * @returns a new mesh
  98141. */
  98142. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98143. /**
  98144. * Releases resources associated with this mesh.
  98145. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98146. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98147. */
  98148. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98149. /** @hidden */
  98150. _disposeInstanceSpecificData(): void;
  98151. /**
  98152. * Modifies the mesh geometry according to a displacement map.
  98153. * 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.
  98154. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98155. * @param url is a string, the URL from the image file is to be downloaded.
  98156. * @param minHeight is the lower limit of the displacement.
  98157. * @param maxHeight is the upper limit of the displacement.
  98158. * @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.
  98159. * @param uvOffset is an optional vector2 used to offset UV.
  98160. * @param uvScale is an optional vector2 used to scale UV.
  98161. * @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.
  98162. * @returns the Mesh.
  98163. */
  98164. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98165. /**
  98166. * Modifies the mesh geometry according to a displacementMap buffer.
  98167. * 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.
  98168. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98169. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98170. * @param heightMapWidth is the width of the buffer image.
  98171. * @param heightMapHeight is the height of the buffer image.
  98172. * @param minHeight is the lower limit of the displacement.
  98173. * @param maxHeight is the upper limit of the displacement.
  98174. * @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.
  98175. * @param uvOffset is an optional vector2 used to offset UV.
  98176. * @param uvScale is an optional vector2 used to scale UV.
  98177. * @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.
  98178. * @returns the Mesh.
  98179. */
  98180. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98181. /**
  98182. * Modify the mesh to get a flat shading rendering.
  98183. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98184. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98185. * @returns current mesh
  98186. */
  98187. convertToFlatShadedMesh(): Mesh;
  98188. /**
  98189. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98190. * In other words, more vertices, no more indices and a single bigger VBO.
  98191. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98192. * @returns current mesh
  98193. */
  98194. convertToUnIndexedMesh(): Mesh;
  98195. /**
  98196. * Inverses facet orientations.
  98197. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98198. * @param flipNormals will also inverts the normals
  98199. * @returns current mesh
  98200. */
  98201. flipFaces(flipNormals?: boolean): Mesh;
  98202. /**
  98203. * Increase the number of facets and hence vertices in a mesh
  98204. * Vertex normals are interpolated from existing vertex normals
  98205. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98206. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98207. */
  98208. increaseVertices(numberPerEdge: number): void;
  98209. /**
  98210. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98211. * This will undo any application of covertToFlatShadedMesh
  98212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98213. */
  98214. forceSharedVertices(): void;
  98215. /** @hidden */
  98216. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98217. /** @hidden */
  98218. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98219. /**
  98220. * Creates a new InstancedMesh object from the mesh model.
  98221. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98222. * @param name defines the name of the new instance
  98223. * @returns a new InstancedMesh
  98224. */
  98225. createInstance(name: string): InstancedMesh;
  98226. /**
  98227. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98228. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98229. * @returns the current mesh
  98230. */
  98231. synchronizeInstances(): Mesh;
  98232. /**
  98233. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98234. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98235. * This should be used together with the simplification to avoid disappearing triangles.
  98236. * @param successCallback an optional success callback to be called after the optimization finished.
  98237. * @returns the current mesh
  98238. */
  98239. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98240. /**
  98241. * Serialize current mesh
  98242. * @param serializationObject defines the object which will receive the serialization data
  98243. */
  98244. serialize(serializationObject: any): void;
  98245. /** @hidden */
  98246. _syncGeometryWithMorphTargetManager(): void;
  98247. /** @hidden */
  98248. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98249. /**
  98250. * Returns a new Mesh object parsed from the source provided.
  98251. * @param parsedMesh is the source
  98252. * @param scene defines the hosting scene
  98253. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98254. * @returns a new Mesh
  98255. */
  98256. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98257. /**
  98258. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98260. * @param name defines the name of the mesh to create
  98261. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98262. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98263. * @param closePath creates a seam between the first and the last points of each path of the path array
  98264. * @param offset is taken in account only if the `pathArray` is containing a single path
  98265. * @param scene defines the hosting scene
  98266. * @param updatable defines if the mesh must be flagged as updatable
  98267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98268. * @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)
  98269. * @returns a new Mesh
  98270. */
  98271. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98272. /**
  98273. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98274. * @param name defines the name of the mesh to create
  98275. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98276. * @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
  98277. * @param scene defines the hosting scene
  98278. * @param updatable defines if the mesh must be flagged as updatable
  98279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98280. * @returns a new Mesh
  98281. */
  98282. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98283. /**
  98284. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98285. * @param name defines the name of the mesh to create
  98286. * @param size sets the size (float) of each box side (default 1)
  98287. * @param scene defines the hosting scene
  98288. * @param updatable defines if the mesh must be flagged as updatable
  98289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98290. * @returns a new Mesh
  98291. */
  98292. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98293. /**
  98294. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98295. * @param name defines the name of the mesh to create
  98296. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98297. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98298. * @param scene defines the hosting scene
  98299. * @param updatable defines if the mesh must be flagged as updatable
  98300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98301. * @returns a new Mesh
  98302. */
  98303. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98304. /**
  98305. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98306. * @param name defines the name of the mesh to create
  98307. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98308. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98309. * @param scene defines the hosting scene
  98310. * @returns a new Mesh
  98311. */
  98312. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98313. /**
  98314. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98315. * @param name defines the name of the mesh to create
  98316. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98317. * @param diameterTop set the top cap diameter (floats, default 1)
  98318. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98319. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98320. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98321. * @param scene defines the hosting scene
  98322. * @param updatable defines if the mesh must be flagged as updatable
  98323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98324. * @returns a new Mesh
  98325. */
  98326. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98327. /**
  98328. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98329. * @param name defines the name of the mesh to create
  98330. * @param diameter sets the diameter size (float) of the torus (default 1)
  98331. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98332. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98333. * @param scene defines the hosting scene
  98334. * @param updatable defines if the mesh must be flagged as updatable
  98335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98336. * @returns a new Mesh
  98337. */
  98338. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98339. /**
  98340. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98341. * @param name defines the name of the mesh to create
  98342. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98343. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98344. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98345. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98346. * @param p the number of windings on X axis (positive integers, default 2)
  98347. * @param q the number of windings on Y axis (positive integers, default 3)
  98348. * @param scene defines the hosting scene
  98349. * @param updatable defines if the mesh must be flagged as updatable
  98350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98351. * @returns a new Mesh
  98352. */
  98353. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98354. /**
  98355. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98356. * @param name defines the name of the mesh to create
  98357. * @param points is an array successive Vector3
  98358. * @param scene defines the hosting scene
  98359. * @param updatable defines if the mesh must be flagged as updatable
  98360. * @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).
  98361. * @returns a new Mesh
  98362. */
  98363. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98364. /**
  98365. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98366. * @param name defines the name of the mesh to create
  98367. * @param points is an array successive Vector3
  98368. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98369. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98370. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98371. * @param scene defines the hosting scene
  98372. * @param updatable defines if the mesh must be flagged as updatable
  98373. * @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)
  98374. * @returns a new Mesh
  98375. */
  98376. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98377. /**
  98378. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98379. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98380. * 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.
  98381. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98382. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98383. * Remember you can only change the shape positions, not their number when updating a polygon.
  98384. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98385. * @param name defines the name of the mesh to create
  98386. * @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
  98387. * @param scene defines the hosting scene
  98388. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98389. * @param updatable defines if the mesh must be flagged as updatable
  98390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98391. * @param earcutInjection can be used to inject your own earcut reference
  98392. * @returns a new Mesh
  98393. */
  98394. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98395. /**
  98396. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98398. * @param name defines the name of the mesh to create
  98399. * @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
  98400. * @param depth defines the height of extrusion
  98401. * @param scene defines the hosting scene
  98402. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98403. * @param updatable defines if the mesh must be flagged as updatable
  98404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98405. * @param earcutInjection can be used to inject your own earcut reference
  98406. * @returns a new Mesh
  98407. */
  98408. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98409. /**
  98410. * Creates an extruded shape mesh.
  98411. * 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
  98412. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98414. * @param name defines the name of the mesh to create
  98415. * @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
  98416. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98417. * @param scale is the value to scale the shape
  98418. * @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
  98419. * @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
  98420. * @param scene defines the hosting scene
  98421. * @param updatable defines if the mesh must be flagged as updatable
  98422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98423. * @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)
  98424. * @returns a new Mesh
  98425. */
  98426. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98427. /**
  98428. * Creates an custom extruded shape mesh.
  98429. * The custom extrusion is a parametric shape.
  98430. * It has no predefined shape. Its final shape will depend on the input parameters.
  98431. * Please consider using the same method from the MeshBuilder class instead
  98432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98433. * @param name defines the name of the mesh to create
  98434. * @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
  98435. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98436. * @param scaleFunction is a custom Javascript function called on each path point
  98437. * @param rotationFunction is a custom Javascript function called on each path point
  98438. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98439. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98440. * @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
  98441. * @param scene defines the hosting scene
  98442. * @param updatable defines if the mesh must be flagged as updatable
  98443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98444. * @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)
  98445. * @returns a new Mesh
  98446. */
  98447. 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;
  98448. /**
  98449. * Creates lathe mesh.
  98450. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98451. * Please consider using the same method from the MeshBuilder class instead
  98452. * @param name defines the name of the mesh to create
  98453. * @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
  98454. * @param radius is the radius value of the lathe
  98455. * @param tessellation is the side number of the lathe.
  98456. * @param scene defines the hosting scene
  98457. * @param updatable defines if the mesh must be flagged as updatable
  98458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98459. * @returns a new Mesh
  98460. */
  98461. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98462. /**
  98463. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98464. * @param name defines the name of the mesh to create
  98465. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98466. * @param scene defines the hosting scene
  98467. * @param updatable defines if the mesh must be flagged as updatable
  98468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98469. * @returns a new Mesh
  98470. */
  98471. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98472. /**
  98473. * Creates a ground mesh.
  98474. * Please consider using the same method from the MeshBuilder class instead
  98475. * @param name defines the name of the mesh to create
  98476. * @param width set the width of the ground
  98477. * @param height set the height of the ground
  98478. * @param subdivisions sets the number of subdivisions per side
  98479. * @param scene defines the hosting scene
  98480. * @param updatable defines if the mesh must be flagged as updatable
  98481. * @returns a new Mesh
  98482. */
  98483. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98484. /**
  98485. * Creates a tiled ground mesh.
  98486. * Please consider using the same method from the MeshBuilder class instead
  98487. * @param name defines the name of the mesh to create
  98488. * @param xmin set the ground minimum X coordinate
  98489. * @param zmin set the ground minimum Y coordinate
  98490. * @param xmax set the ground maximum X coordinate
  98491. * @param zmax set the ground maximum Z coordinate
  98492. * @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
  98493. * @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
  98494. * @param scene defines the hosting scene
  98495. * @param updatable defines if the mesh must be flagged as updatable
  98496. * @returns a new Mesh
  98497. */
  98498. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98499. w: number;
  98500. h: number;
  98501. }, precision: {
  98502. w: number;
  98503. h: number;
  98504. }, scene: Scene, updatable?: boolean): Mesh;
  98505. /**
  98506. * Creates a ground mesh from a height map.
  98507. * Please consider using the same method from the MeshBuilder class instead
  98508. * @see http://doc.babylonjs.com/babylon101/height_map
  98509. * @param name defines the name of the mesh to create
  98510. * @param url sets the URL of the height map image resource
  98511. * @param width set the ground width size
  98512. * @param height set the ground height size
  98513. * @param subdivisions sets the number of subdivision per side
  98514. * @param minHeight is the minimum altitude on the ground
  98515. * @param maxHeight is the maximum altitude on the ground
  98516. * @param scene defines the hosting scene
  98517. * @param updatable defines if the mesh must be flagged as updatable
  98518. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98519. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98520. * @returns a new Mesh
  98521. */
  98522. 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;
  98523. /**
  98524. * Creates a tube mesh.
  98525. * The tube is a parametric shape.
  98526. * It has no predefined shape. Its final shape will depend on the input parameters.
  98527. * Please consider using the same method from the MeshBuilder class instead
  98528. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98529. * @param name defines the name of the mesh to create
  98530. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98531. * @param radius sets the tube radius size
  98532. * @param tessellation is the number of sides on the tubular surface
  98533. * @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
  98534. * @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
  98535. * @param scene defines the hosting scene
  98536. * @param updatable defines if the mesh must be flagged as updatable
  98537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98538. * @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)
  98539. * @returns a new Mesh
  98540. */
  98541. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98542. (i: number, distance: number): number;
  98543. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98544. /**
  98545. * Creates a polyhedron mesh.
  98546. * Please consider using the same method from the MeshBuilder class instead.
  98547. * * 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
  98548. * * The parameter `size` (positive float, default 1) sets the polygon size
  98549. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98550. * * 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`
  98551. * * 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
  98552. * * 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)`)
  98553. * * 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
  98554. * * 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
  98555. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98556. * * If you create a double-sided mesh, you can choose what parts of 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
  98557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98558. * @param name defines the name of the mesh to create
  98559. * @param options defines the options used to create the mesh
  98560. * @param scene defines the hosting scene
  98561. * @returns a new Mesh
  98562. */
  98563. static CreatePolyhedron(name: string, options: {
  98564. type?: number;
  98565. size?: number;
  98566. sizeX?: number;
  98567. sizeY?: number;
  98568. sizeZ?: number;
  98569. custom?: any;
  98570. faceUV?: Vector4[];
  98571. faceColors?: Color4[];
  98572. updatable?: boolean;
  98573. sideOrientation?: number;
  98574. }, scene: Scene): Mesh;
  98575. /**
  98576. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98577. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98578. * * 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`)
  98579. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98580. * * 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
  98581. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98582. * * If you create a double-sided mesh, you can choose what parts of 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
  98583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98584. * @param name defines the name of the mesh
  98585. * @param options defines the options used to create the mesh
  98586. * @param scene defines the hosting scene
  98587. * @returns a new Mesh
  98588. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98589. */
  98590. static CreateIcoSphere(name: string, options: {
  98591. radius?: number;
  98592. flat?: boolean;
  98593. subdivisions?: number;
  98594. sideOrientation?: number;
  98595. updatable?: boolean;
  98596. }, scene: Scene): Mesh;
  98597. /**
  98598. * Creates a decal mesh.
  98599. * Please consider using the same method from the MeshBuilder class instead.
  98600. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98601. * @param name defines the name of the mesh
  98602. * @param sourceMesh defines the mesh receiving the decal
  98603. * @param position sets the position of the decal in world coordinates
  98604. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98605. * @param size sets the decal scaling
  98606. * @param angle sets the angle to rotate the decal
  98607. * @returns a new Mesh
  98608. */
  98609. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98610. /**
  98611. * Prepare internal position array for software CPU skinning
  98612. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98613. */
  98614. setPositionsForCPUSkinning(): Float32Array;
  98615. /**
  98616. * Prepare internal normal array for software CPU skinning
  98617. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98618. */
  98619. setNormalsForCPUSkinning(): Float32Array;
  98620. /**
  98621. * Updates the vertex buffer by applying transformation from the bones
  98622. * @param skeleton defines the skeleton to apply to current mesh
  98623. * @returns the current mesh
  98624. */
  98625. applySkeleton(skeleton: Skeleton): Mesh;
  98626. /**
  98627. * 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
  98628. * @param meshes defines the list of meshes to scan
  98629. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98630. */
  98631. static MinMax(meshes: AbstractMesh[]): {
  98632. min: Vector3;
  98633. max: Vector3;
  98634. };
  98635. /**
  98636. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98637. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98638. * @returns a vector3
  98639. */
  98640. static Center(meshesOrMinMaxVector: {
  98641. min: Vector3;
  98642. max: Vector3;
  98643. } | AbstractMesh[]): Vector3;
  98644. /**
  98645. * Merge the array of meshes into a single mesh for performance reasons.
  98646. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98647. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98648. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98649. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98650. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98651. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98652. * @returns a new mesh
  98653. */
  98654. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98655. /** @hidden */
  98656. addInstance(instance: InstancedMesh): void;
  98657. /** @hidden */
  98658. removeInstance(instance: InstancedMesh): void;
  98659. }
  98660. }
  98661. declare module BABYLON {
  98662. /**
  98663. * This is the base class of all the camera used in the application.
  98664. * @see http://doc.babylonjs.com/features/cameras
  98665. */
  98666. export class Camera extends Node {
  98667. /** @hidden */
  98668. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98669. /**
  98670. * This is the default projection mode used by the cameras.
  98671. * It helps recreating a feeling of perspective and better appreciate depth.
  98672. * This is the best way to simulate real life cameras.
  98673. */
  98674. static readonly PERSPECTIVE_CAMERA: number;
  98675. /**
  98676. * This helps creating camera with an orthographic mode.
  98677. * 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.
  98678. */
  98679. static readonly ORTHOGRAPHIC_CAMERA: number;
  98680. /**
  98681. * This is the default FOV mode for perspective cameras.
  98682. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98683. */
  98684. static readonly FOVMODE_VERTICAL_FIXED: number;
  98685. /**
  98686. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98687. */
  98688. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98689. /**
  98690. * This specifies ther is no need for a camera rig.
  98691. * Basically only one eye is rendered corresponding to the camera.
  98692. */
  98693. static readonly RIG_MODE_NONE: number;
  98694. /**
  98695. * Simulates a camera Rig with one blue eye and one red eye.
  98696. * This can be use with 3d blue and red glasses.
  98697. */
  98698. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98699. /**
  98700. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98701. */
  98702. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98703. /**
  98704. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98705. */
  98706. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98707. /**
  98708. * Defines that both eyes of the camera will be rendered over under each other.
  98709. */
  98710. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98711. /**
  98712. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98713. */
  98714. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98715. /**
  98716. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98717. */
  98718. static readonly RIG_MODE_VR: number;
  98719. /**
  98720. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98721. */
  98722. static readonly RIG_MODE_WEBVR: number;
  98723. /**
  98724. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98725. */
  98726. static readonly RIG_MODE_CUSTOM: number;
  98727. /**
  98728. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98729. */
  98730. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98731. /**
  98732. * Define the input manager associated with the camera.
  98733. */
  98734. inputs: CameraInputsManager<Camera>;
  98735. /** @hidden */
  98736. _position: Vector3;
  98737. /**
  98738. * Define the current local position of the camera in the scene
  98739. */
  98740. get position(): Vector3;
  98741. set position(newPosition: Vector3);
  98742. /**
  98743. * The vector the camera should consider as up.
  98744. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98745. */
  98746. upVector: Vector3;
  98747. /**
  98748. * Define the current limit on the left side for an orthographic camera
  98749. * In scene unit
  98750. */
  98751. orthoLeft: Nullable<number>;
  98752. /**
  98753. * Define the current limit on the right side for an orthographic camera
  98754. * In scene unit
  98755. */
  98756. orthoRight: Nullable<number>;
  98757. /**
  98758. * Define the current limit on the bottom side for an orthographic camera
  98759. * In scene unit
  98760. */
  98761. orthoBottom: Nullable<number>;
  98762. /**
  98763. * Define the current limit on the top side for an orthographic camera
  98764. * In scene unit
  98765. */
  98766. orthoTop: Nullable<number>;
  98767. /**
  98768. * Field Of View is set in Radians. (default is 0.8)
  98769. */
  98770. fov: number;
  98771. /**
  98772. * Define the minimum distance the camera can see from.
  98773. * This is important to note that the depth buffer are not infinite and the closer it starts
  98774. * the more your scene might encounter depth fighting issue.
  98775. */
  98776. minZ: number;
  98777. /**
  98778. * Define the maximum distance the camera can see to.
  98779. * This is important to note that the depth buffer are not infinite and the further it end
  98780. * the more your scene might encounter depth fighting issue.
  98781. */
  98782. maxZ: number;
  98783. /**
  98784. * Define the default inertia of the camera.
  98785. * This helps giving a smooth feeling to the camera movement.
  98786. */
  98787. inertia: number;
  98788. /**
  98789. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98790. */
  98791. mode: number;
  98792. /**
  98793. * Define whether the camera is intermediate.
  98794. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98795. */
  98796. isIntermediate: boolean;
  98797. /**
  98798. * Define the viewport of the camera.
  98799. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98800. */
  98801. viewport: Viewport;
  98802. /**
  98803. * Restricts the camera to viewing objects with the same layerMask.
  98804. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98805. */
  98806. layerMask: number;
  98807. /**
  98808. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98809. */
  98810. fovMode: number;
  98811. /**
  98812. * Rig mode of the camera.
  98813. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98814. * This is normally controlled byt the camera themselves as internal use.
  98815. */
  98816. cameraRigMode: number;
  98817. /**
  98818. * Defines the distance between both "eyes" in case of a RIG
  98819. */
  98820. interaxialDistance: number;
  98821. /**
  98822. * Defines if stereoscopic rendering is done side by side or over under.
  98823. */
  98824. isStereoscopicSideBySide: boolean;
  98825. /**
  98826. * 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
  98827. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98828. * else in the scene. (Eg. security camera)
  98829. *
  98830. * 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)
  98831. */
  98832. customRenderTargets: RenderTargetTexture[];
  98833. /**
  98834. * When set, the camera will render to this render target instead of the default canvas
  98835. *
  98836. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98837. */
  98838. outputRenderTarget: Nullable<RenderTargetTexture>;
  98839. /**
  98840. * Observable triggered when the camera view matrix has changed.
  98841. */
  98842. onViewMatrixChangedObservable: Observable<Camera>;
  98843. /**
  98844. * Observable triggered when the camera Projection matrix has changed.
  98845. */
  98846. onProjectionMatrixChangedObservable: Observable<Camera>;
  98847. /**
  98848. * Observable triggered when the inputs have been processed.
  98849. */
  98850. onAfterCheckInputsObservable: Observable<Camera>;
  98851. /**
  98852. * Observable triggered when reset has been called and applied to the camera.
  98853. */
  98854. onRestoreStateObservable: Observable<Camera>;
  98855. /**
  98856. * Is this camera a part of a rig system?
  98857. */
  98858. isRigCamera: boolean;
  98859. /**
  98860. * If isRigCamera set to true this will be set with the parent camera.
  98861. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98862. */
  98863. rigParent?: Camera;
  98864. /** @hidden */
  98865. _cameraRigParams: any;
  98866. /** @hidden */
  98867. _rigCameras: Camera[];
  98868. /** @hidden */
  98869. _rigPostProcess: Nullable<PostProcess>;
  98870. protected _webvrViewMatrix: Matrix;
  98871. /** @hidden */
  98872. _skipRendering: boolean;
  98873. /** @hidden */
  98874. _projectionMatrix: Matrix;
  98875. /** @hidden */
  98876. _postProcesses: Nullable<PostProcess>[];
  98877. /** @hidden */
  98878. _activeMeshes: SmartArray<AbstractMesh>;
  98879. protected _globalPosition: Vector3;
  98880. /** @hidden */
  98881. _computedViewMatrix: Matrix;
  98882. private _doNotComputeProjectionMatrix;
  98883. private _transformMatrix;
  98884. private _frustumPlanes;
  98885. private _refreshFrustumPlanes;
  98886. private _storedFov;
  98887. private _stateStored;
  98888. /**
  98889. * Instantiates a new camera object.
  98890. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98891. * @see http://doc.babylonjs.com/features/cameras
  98892. * @param name Defines the name of the camera in the scene
  98893. * @param position Defines the position of the camera
  98894. * @param scene Defines the scene the camera belongs too
  98895. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98896. */
  98897. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98898. /**
  98899. * Store current camera state (fov, position, etc..)
  98900. * @returns the camera
  98901. */
  98902. storeState(): Camera;
  98903. /**
  98904. * Restores the camera state values if it has been stored. You must call storeState() first
  98905. */
  98906. protected _restoreStateValues(): boolean;
  98907. /**
  98908. * Restored camera state. You must call storeState() first.
  98909. * @returns true if restored and false otherwise
  98910. */
  98911. restoreState(): boolean;
  98912. /**
  98913. * Gets the class name of the camera.
  98914. * @returns the class name
  98915. */
  98916. getClassName(): string;
  98917. /** @hidden */
  98918. readonly _isCamera: boolean;
  98919. /**
  98920. * Gets a string representation of the camera useful for debug purpose.
  98921. * @param fullDetails Defines that a more verboe level of logging is required
  98922. * @returns the string representation
  98923. */
  98924. toString(fullDetails?: boolean): string;
  98925. /**
  98926. * Gets the current world space position of the camera.
  98927. */
  98928. get globalPosition(): Vector3;
  98929. /**
  98930. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98931. * @returns the active meshe list
  98932. */
  98933. getActiveMeshes(): SmartArray<AbstractMesh>;
  98934. /**
  98935. * Check whether a mesh is part of the current active mesh list of the camera
  98936. * @param mesh Defines the mesh to check
  98937. * @returns true if active, false otherwise
  98938. */
  98939. isActiveMesh(mesh: Mesh): boolean;
  98940. /**
  98941. * Is this camera ready to be used/rendered
  98942. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98943. * @return true if the camera is ready
  98944. */
  98945. isReady(completeCheck?: boolean): boolean;
  98946. /** @hidden */
  98947. _initCache(): void;
  98948. /** @hidden */
  98949. _updateCache(ignoreParentClass?: boolean): void;
  98950. /** @hidden */
  98951. _isSynchronized(): boolean;
  98952. /** @hidden */
  98953. _isSynchronizedViewMatrix(): boolean;
  98954. /** @hidden */
  98955. _isSynchronizedProjectionMatrix(): boolean;
  98956. /**
  98957. * Attach the input controls to a specific dom element to get the input from.
  98958. * @param element Defines the element the controls should be listened from
  98959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98960. */
  98961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98962. /**
  98963. * Detach the current controls from the specified dom element.
  98964. * @param element Defines the element to stop listening the inputs from
  98965. */
  98966. detachControl(element: HTMLElement): void;
  98967. /**
  98968. * Update the camera state according to the different inputs gathered during the frame.
  98969. */
  98970. update(): void;
  98971. /** @hidden */
  98972. _checkInputs(): void;
  98973. /** @hidden */
  98974. get rigCameras(): Camera[];
  98975. /**
  98976. * Gets the post process used by the rig cameras
  98977. */
  98978. get rigPostProcess(): Nullable<PostProcess>;
  98979. /**
  98980. * Internal, gets the first post proces.
  98981. * @returns the first post process to be run on this camera.
  98982. */
  98983. _getFirstPostProcess(): Nullable<PostProcess>;
  98984. private _cascadePostProcessesToRigCams;
  98985. /**
  98986. * Attach a post process to the camera.
  98987. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98988. * @param postProcess The post process to attach to the camera
  98989. * @param insertAt The position of the post process in case several of them are in use in the scene
  98990. * @returns the position the post process has been inserted at
  98991. */
  98992. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98993. /**
  98994. * Detach a post process to the camera.
  98995. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98996. * @param postProcess The post process to detach from the camera
  98997. */
  98998. detachPostProcess(postProcess: PostProcess): void;
  98999. /**
  99000. * Gets the current world matrix of the camera
  99001. */
  99002. getWorldMatrix(): Matrix;
  99003. /** @hidden */
  99004. _getViewMatrix(): Matrix;
  99005. /**
  99006. * Gets the current view matrix of the camera.
  99007. * @param force forces the camera to recompute the matrix without looking at the cached state
  99008. * @returns the view matrix
  99009. */
  99010. getViewMatrix(force?: boolean): Matrix;
  99011. /**
  99012. * Freeze the projection matrix.
  99013. * It will prevent the cache check of the camera projection compute and can speed up perf
  99014. * if no parameter of the camera are meant to change
  99015. * @param projection Defines manually a projection if necessary
  99016. */
  99017. freezeProjectionMatrix(projection?: Matrix): void;
  99018. /**
  99019. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99020. */
  99021. unfreezeProjectionMatrix(): void;
  99022. /**
  99023. * Gets the current projection matrix of the camera.
  99024. * @param force forces the camera to recompute the matrix without looking at the cached state
  99025. * @returns the projection matrix
  99026. */
  99027. getProjectionMatrix(force?: boolean): Matrix;
  99028. /**
  99029. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99030. * @returns a Matrix
  99031. */
  99032. getTransformationMatrix(): Matrix;
  99033. private _updateFrustumPlanes;
  99034. /**
  99035. * Checks if a cullable object (mesh...) is in the camera frustum
  99036. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99037. * @param target The object to check
  99038. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99039. * @returns true if the object is in frustum otherwise false
  99040. */
  99041. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99042. /**
  99043. * Checks if a cullable object (mesh...) is in the camera frustum
  99044. * Unlike isInFrustum this cheks the full bounding box
  99045. * @param target The object to check
  99046. * @returns true if the object is in frustum otherwise false
  99047. */
  99048. isCompletelyInFrustum(target: ICullable): boolean;
  99049. /**
  99050. * Gets a ray in the forward direction from the camera.
  99051. * @param length Defines the length of the ray to create
  99052. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99053. * @param origin Defines the start point of the ray which defaults to the camera position
  99054. * @returns the forward ray
  99055. */
  99056. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99057. /**
  99058. * Releases resources associated with this node.
  99059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99061. */
  99062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99063. /** @hidden */
  99064. _isLeftCamera: boolean;
  99065. /**
  99066. * Gets the left camera of a rig setup in case of Rigged Camera
  99067. */
  99068. get isLeftCamera(): boolean;
  99069. /** @hidden */
  99070. _isRightCamera: boolean;
  99071. /**
  99072. * Gets the right camera of a rig setup in case of Rigged Camera
  99073. */
  99074. get isRightCamera(): boolean;
  99075. /**
  99076. * Gets the left camera of a rig setup in case of Rigged Camera
  99077. */
  99078. get leftCamera(): Nullable<FreeCamera>;
  99079. /**
  99080. * Gets the right camera of a rig setup in case of Rigged Camera
  99081. */
  99082. get rightCamera(): Nullable<FreeCamera>;
  99083. /**
  99084. * Gets the left camera target of a rig setup in case of Rigged Camera
  99085. * @returns the target position
  99086. */
  99087. getLeftTarget(): Nullable<Vector3>;
  99088. /**
  99089. * Gets the right camera target of a rig setup in case of Rigged Camera
  99090. * @returns the target position
  99091. */
  99092. getRightTarget(): Nullable<Vector3>;
  99093. /**
  99094. * @hidden
  99095. */
  99096. setCameraRigMode(mode: number, rigParams: any): void;
  99097. /** @hidden */
  99098. static _setStereoscopicRigMode(camera: Camera): void;
  99099. /** @hidden */
  99100. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99101. /** @hidden */
  99102. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99103. /** @hidden */
  99104. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99105. /** @hidden */
  99106. _getVRProjectionMatrix(): Matrix;
  99107. protected _updateCameraRotationMatrix(): void;
  99108. protected _updateWebVRCameraRotationMatrix(): void;
  99109. /**
  99110. * This function MUST be overwritten by the different WebVR cameras available.
  99111. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99112. * @hidden
  99113. */
  99114. _getWebVRProjectionMatrix(): Matrix;
  99115. /**
  99116. * This function MUST be overwritten by the different WebVR cameras available.
  99117. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99118. * @hidden
  99119. */
  99120. _getWebVRViewMatrix(): Matrix;
  99121. /** @hidden */
  99122. setCameraRigParameter(name: string, value: any): void;
  99123. /**
  99124. * needs to be overridden by children so sub has required properties to be copied
  99125. * @hidden
  99126. */
  99127. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99128. /**
  99129. * May need to be overridden by children
  99130. * @hidden
  99131. */
  99132. _updateRigCameras(): void;
  99133. /** @hidden */
  99134. _setupInputs(): void;
  99135. /**
  99136. * Serialiaze the camera setup to a json represention
  99137. * @returns the JSON representation
  99138. */
  99139. serialize(): any;
  99140. /**
  99141. * Clones the current camera.
  99142. * @param name The cloned camera name
  99143. * @returns the cloned camera
  99144. */
  99145. clone(name: string): Camera;
  99146. /**
  99147. * Gets the direction of the camera relative to a given local axis.
  99148. * @param localAxis Defines the reference axis to provide a relative direction.
  99149. * @return the direction
  99150. */
  99151. getDirection(localAxis: Vector3): Vector3;
  99152. /**
  99153. * Returns the current camera absolute rotation
  99154. */
  99155. get absoluteRotation(): Quaternion;
  99156. /**
  99157. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99158. * @param localAxis Defines the reference axis to provide a relative direction.
  99159. * @param result Defines the vector to store the result in
  99160. */
  99161. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99162. /**
  99163. * Gets a camera constructor for a given camera type
  99164. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99165. * @param name The name of the camera the result will be able to instantiate
  99166. * @param scene The scene the result will construct the camera in
  99167. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99168. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99169. * @returns a factory method to construc the camera
  99170. */
  99171. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99172. /**
  99173. * Compute the world matrix of the camera.
  99174. * @returns the camera world matrix
  99175. */
  99176. computeWorldMatrix(): Matrix;
  99177. /**
  99178. * Parse a JSON and creates the camera from the parsed information
  99179. * @param parsedCamera The JSON to parse
  99180. * @param scene The scene to instantiate the camera in
  99181. * @returns the newly constructed camera
  99182. */
  99183. static Parse(parsedCamera: any, scene: Scene): Camera;
  99184. }
  99185. }
  99186. declare module BABYLON {
  99187. /**
  99188. * Class containing static functions to help procedurally build meshes
  99189. */
  99190. export class DiscBuilder {
  99191. /**
  99192. * Creates a plane polygonal mesh. By default, this is a disc
  99193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99194. * * 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
  99195. * * 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
  99196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99199. * @param name defines the name of the mesh
  99200. * @param options defines the options used to create the mesh
  99201. * @param scene defines the hosting scene
  99202. * @returns the plane polygonal mesh
  99203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99204. */
  99205. static CreateDisc(name: string, options: {
  99206. radius?: number;
  99207. tessellation?: number;
  99208. arc?: number;
  99209. updatable?: boolean;
  99210. sideOrientation?: number;
  99211. frontUVs?: Vector4;
  99212. backUVs?: Vector4;
  99213. }, scene?: Nullable<Scene>): Mesh;
  99214. }
  99215. }
  99216. declare module BABYLON {
  99217. /**
  99218. * This represents all the required information to add a fresnel effect on a material:
  99219. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99220. */
  99221. export class FresnelParameters {
  99222. private _isEnabled;
  99223. /**
  99224. * Define if the fresnel effect is enable or not.
  99225. */
  99226. get isEnabled(): boolean;
  99227. set isEnabled(value: boolean);
  99228. /**
  99229. * Define the color used on edges (grazing angle)
  99230. */
  99231. leftColor: Color3;
  99232. /**
  99233. * Define the color used on center
  99234. */
  99235. rightColor: Color3;
  99236. /**
  99237. * Define bias applied to computed fresnel term
  99238. */
  99239. bias: number;
  99240. /**
  99241. * Defined the power exponent applied to fresnel term
  99242. */
  99243. power: number;
  99244. /**
  99245. * Clones the current fresnel and its valuues
  99246. * @returns a clone fresnel configuration
  99247. */
  99248. clone(): FresnelParameters;
  99249. /**
  99250. * Serializes the current fresnel parameters to a JSON representation.
  99251. * @return the JSON serialization
  99252. */
  99253. serialize(): any;
  99254. /**
  99255. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99256. * @param parsedFresnelParameters Define the JSON representation
  99257. * @returns the parsed parameters
  99258. */
  99259. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Base class of materials working in push mode in babylon JS
  99265. * @hidden
  99266. */
  99267. export class PushMaterial extends Material {
  99268. protected _activeEffect: Effect;
  99269. protected _normalMatrix: Matrix;
  99270. /**
  99271. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99272. * This means that the material can keep using a previous shader while a new one is being compiled.
  99273. * This is mostly used when shader parallel compilation is supported (true by default)
  99274. */
  99275. allowShaderHotSwapping: boolean;
  99276. constructor(name: string, scene: Scene);
  99277. getEffect(): Effect;
  99278. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99279. /**
  99280. * Binds the given world matrix to the active effect
  99281. *
  99282. * @param world the matrix to bind
  99283. */
  99284. bindOnlyWorldMatrix(world: Matrix): void;
  99285. /**
  99286. * Binds the given normal matrix to the active effect
  99287. *
  99288. * @param normalMatrix the matrix to bind
  99289. */
  99290. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99291. bind(world: Matrix, mesh?: Mesh): void;
  99292. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99293. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99294. }
  99295. }
  99296. declare module BABYLON {
  99297. /**
  99298. * This groups all the flags used to control the materials channel.
  99299. */
  99300. export class MaterialFlags {
  99301. private static _DiffuseTextureEnabled;
  99302. /**
  99303. * Are diffuse textures enabled in the application.
  99304. */
  99305. static get DiffuseTextureEnabled(): boolean;
  99306. static set DiffuseTextureEnabled(value: boolean);
  99307. private static _AmbientTextureEnabled;
  99308. /**
  99309. * Are ambient textures enabled in the application.
  99310. */
  99311. static get AmbientTextureEnabled(): boolean;
  99312. static set AmbientTextureEnabled(value: boolean);
  99313. private static _OpacityTextureEnabled;
  99314. /**
  99315. * Are opacity textures enabled in the application.
  99316. */
  99317. static get OpacityTextureEnabled(): boolean;
  99318. static set OpacityTextureEnabled(value: boolean);
  99319. private static _ReflectionTextureEnabled;
  99320. /**
  99321. * Are reflection textures enabled in the application.
  99322. */
  99323. static get ReflectionTextureEnabled(): boolean;
  99324. static set ReflectionTextureEnabled(value: boolean);
  99325. private static _EmissiveTextureEnabled;
  99326. /**
  99327. * Are emissive textures enabled in the application.
  99328. */
  99329. static get EmissiveTextureEnabled(): boolean;
  99330. static set EmissiveTextureEnabled(value: boolean);
  99331. private static _SpecularTextureEnabled;
  99332. /**
  99333. * Are specular textures enabled in the application.
  99334. */
  99335. static get SpecularTextureEnabled(): boolean;
  99336. static set SpecularTextureEnabled(value: boolean);
  99337. private static _BumpTextureEnabled;
  99338. /**
  99339. * Are bump textures enabled in the application.
  99340. */
  99341. static get BumpTextureEnabled(): boolean;
  99342. static set BumpTextureEnabled(value: boolean);
  99343. private static _LightmapTextureEnabled;
  99344. /**
  99345. * Are lightmap textures enabled in the application.
  99346. */
  99347. static get LightmapTextureEnabled(): boolean;
  99348. static set LightmapTextureEnabled(value: boolean);
  99349. private static _RefractionTextureEnabled;
  99350. /**
  99351. * Are refraction textures enabled in the application.
  99352. */
  99353. static get RefractionTextureEnabled(): boolean;
  99354. static set RefractionTextureEnabled(value: boolean);
  99355. private static _ColorGradingTextureEnabled;
  99356. /**
  99357. * Are color grading textures enabled in the application.
  99358. */
  99359. static get ColorGradingTextureEnabled(): boolean;
  99360. static set ColorGradingTextureEnabled(value: boolean);
  99361. private static _FresnelEnabled;
  99362. /**
  99363. * Are fresnels enabled in the application.
  99364. */
  99365. static get FresnelEnabled(): boolean;
  99366. static set FresnelEnabled(value: boolean);
  99367. private static _ClearCoatTextureEnabled;
  99368. /**
  99369. * Are clear coat textures enabled in the application.
  99370. */
  99371. static get ClearCoatTextureEnabled(): boolean;
  99372. static set ClearCoatTextureEnabled(value: boolean);
  99373. private static _ClearCoatBumpTextureEnabled;
  99374. /**
  99375. * Are clear coat bump textures enabled in the application.
  99376. */
  99377. static get ClearCoatBumpTextureEnabled(): boolean;
  99378. static set ClearCoatBumpTextureEnabled(value: boolean);
  99379. private static _ClearCoatTintTextureEnabled;
  99380. /**
  99381. * Are clear coat tint textures enabled in the application.
  99382. */
  99383. static get ClearCoatTintTextureEnabled(): boolean;
  99384. static set ClearCoatTintTextureEnabled(value: boolean);
  99385. private static _SheenTextureEnabled;
  99386. /**
  99387. * Are sheen textures enabled in the application.
  99388. */
  99389. static get SheenTextureEnabled(): boolean;
  99390. static set SheenTextureEnabled(value: boolean);
  99391. private static _AnisotropicTextureEnabled;
  99392. /**
  99393. * Are anisotropic textures enabled in the application.
  99394. */
  99395. static get AnisotropicTextureEnabled(): boolean;
  99396. static set AnisotropicTextureEnabled(value: boolean);
  99397. private static _ThicknessTextureEnabled;
  99398. /**
  99399. * Are thickness textures enabled in the application.
  99400. */
  99401. static get ThicknessTextureEnabled(): boolean;
  99402. static set ThicknessTextureEnabled(value: boolean);
  99403. }
  99404. }
  99405. declare module BABYLON {
  99406. /** @hidden */
  99407. export var defaultFragmentDeclaration: {
  99408. name: string;
  99409. shader: string;
  99410. };
  99411. }
  99412. declare module BABYLON {
  99413. /** @hidden */
  99414. export var defaultUboDeclaration: {
  99415. name: string;
  99416. shader: string;
  99417. };
  99418. }
  99419. declare module BABYLON {
  99420. /** @hidden */
  99421. export var lightFragmentDeclaration: {
  99422. name: string;
  99423. shader: string;
  99424. };
  99425. }
  99426. declare module BABYLON {
  99427. /** @hidden */
  99428. export var lightUboDeclaration: {
  99429. name: string;
  99430. shader: string;
  99431. };
  99432. }
  99433. declare module BABYLON {
  99434. /** @hidden */
  99435. export var lightsFragmentFunctions: {
  99436. name: string;
  99437. shader: string;
  99438. };
  99439. }
  99440. declare module BABYLON {
  99441. /** @hidden */
  99442. export var shadowsFragmentFunctions: {
  99443. name: string;
  99444. shader: string;
  99445. };
  99446. }
  99447. declare module BABYLON {
  99448. /** @hidden */
  99449. export var fresnelFunction: {
  99450. name: string;
  99451. shader: string;
  99452. };
  99453. }
  99454. declare module BABYLON {
  99455. /** @hidden */
  99456. export var reflectionFunction: {
  99457. name: string;
  99458. shader: string;
  99459. };
  99460. }
  99461. declare module BABYLON {
  99462. /** @hidden */
  99463. export var bumpFragmentFunctions: {
  99464. name: string;
  99465. shader: string;
  99466. };
  99467. }
  99468. declare module BABYLON {
  99469. /** @hidden */
  99470. export var logDepthDeclaration: {
  99471. name: string;
  99472. shader: string;
  99473. };
  99474. }
  99475. declare module BABYLON {
  99476. /** @hidden */
  99477. export var bumpFragment: {
  99478. name: string;
  99479. shader: string;
  99480. };
  99481. }
  99482. declare module BABYLON {
  99483. /** @hidden */
  99484. export var depthPrePass: {
  99485. name: string;
  99486. shader: string;
  99487. };
  99488. }
  99489. declare module BABYLON {
  99490. /** @hidden */
  99491. export var lightFragment: {
  99492. name: string;
  99493. shader: string;
  99494. };
  99495. }
  99496. declare module BABYLON {
  99497. /** @hidden */
  99498. export var logDepthFragment: {
  99499. name: string;
  99500. shader: string;
  99501. };
  99502. }
  99503. declare module BABYLON {
  99504. /** @hidden */
  99505. export var defaultPixelShader: {
  99506. name: string;
  99507. shader: string;
  99508. };
  99509. }
  99510. declare module BABYLON {
  99511. /** @hidden */
  99512. export var defaultVertexDeclaration: {
  99513. name: string;
  99514. shader: string;
  99515. };
  99516. }
  99517. declare module BABYLON {
  99518. /** @hidden */
  99519. export var bumpVertexDeclaration: {
  99520. name: string;
  99521. shader: string;
  99522. };
  99523. }
  99524. declare module BABYLON {
  99525. /** @hidden */
  99526. export var bumpVertex: {
  99527. name: string;
  99528. shader: string;
  99529. };
  99530. }
  99531. declare module BABYLON {
  99532. /** @hidden */
  99533. export var fogVertex: {
  99534. name: string;
  99535. shader: string;
  99536. };
  99537. }
  99538. declare module BABYLON {
  99539. /** @hidden */
  99540. export var shadowsVertex: {
  99541. name: string;
  99542. shader: string;
  99543. };
  99544. }
  99545. declare module BABYLON {
  99546. /** @hidden */
  99547. export var pointCloudVertex: {
  99548. name: string;
  99549. shader: string;
  99550. };
  99551. }
  99552. declare module BABYLON {
  99553. /** @hidden */
  99554. export var logDepthVertex: {
  99555. name: string;
  99556. shader: string;
  99557. };
  99558. }
  99559. declare module BABYLON {
  99560. /** @hidden */
  99561. export var defaultVertexShader: {
  99562. name: string;
  99563. shader: string;
  99564. };
  99565. }
  99566. declare module BABYLON {
  99567. /** @hidden */
  99568. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99569. MAINUV1: boolean;
  99570. MAINUV2: boolean;
  99571. DIFFUSE: boolean;
  99572. DIFFUSEDIRECTUV: number;
  99573. AMBIENT: boolean;
  99574. AMBIENTDIRECTUV: number;
  99575. OPACITY: boolean;
  99576. OPACITYDIRECTUV: number;
  99577. OPACITYRGB: boolean;
  99578. REFLECTION: boolean;
  99579. EMISSIVE: boolean;
  99580. EMISSIVEDIRECTUV: number;
  99581. SPECULAR: boolean;
  99582. SPECULARDIRECTUV: number;
  99583. BUMP: boolean;
  99584. BUMPDIRECTUV: number;
  99585. PARALLAX: boolean;
  99586. PARALLAXOCCLUSION: boolean;
  99587. SPECULAROVERALPHA: boolean;
  99588. CLIPPLANE: boolean;
  99589. CLIPPLANE2: boolean;
  99590. CLIPPLANE3: boolean;
  99591. CLIPPLANE4: boolean;
  99592. CLIPPLANE5: boolean;
  99593. CLIPPLANE6: boolean;
  99594. ALPHATEST: boolean;
  99595. DEPTHPREPASS: boolean;
  99596. ALPHAFROMDIFFUSE: boolean;
  99597. POINTSIZE: boolean;
  99598. FOG: boolean;
  99599. SPECULARTERM: boolean;
  99600. DIFFUSEFRESNEL: boolean;
  99601. OPACITYFRESNEL: boolean;
  99602. REFLECTIONFRESNEL: boolean;
  99603. REFRACTIONFRESNEL: boolean;
  99604. EMISSIVEFRESNEL: boolean;
  99605. FRESNEL: boolean;
  99606. NORMAL: boolean;
  99607. UV1: boolean;
  99608. UV2: boolean;
  99609. VERTEXCOLOR: boolean;
  99610. VERTEXALPHA: boolean;
  99611. NUM_BONE_INFLUENCERS: number;
  99612. BonesPerMesh: number;
  99613. BONETEXTURE: boolean;
  99614. INSTANCES: boolean;
  99615. GLOSSINESS: boolean;
  99616. ROUGHNESS: boolean;
  99617. EMISSIVEASILLUMINATION: boolean;
  99618. LINKEMISSIVEWITHDIFFUSE: boolean;
  99619. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99620. LIGHTMAP: boolean;
  99621. LIGHTMAPDIRECTUV: number;
  99622. OBJECTSPACE_NORMALMAP: boolean;
  99623. USELIGHTMAPASSHADOWMAP: boolean;
  99624. REFLECTIONMAP_3D: boolean;
  99625. REFLECTIONMAP_SPHERICAL: boolean;
  99626. REFLECTIONMAP_PLANAR: boolean;
  99627. REFLECTIONMAP_CUBIC: boolean;
  99628. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99629. REFLECTIONMAP_PROJECTION: boolean;
  99630. REFLECTIONMAP_SKYBOX: boolean;
  99631. REFLECTIONMAP_EXPLICIT: boolean;
  99632. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99633. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99634. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99635. INVERTCUBICMAP: boolean;
  99636. LOGARITHMICDEPTH: boolean;
  99637. REFRACTION: boolean;
  99638. REFRACTIONMAP_3D: boolean;
  99639. REFLECTIONOVERALPHA: boolean;
  99640. TWOSIDEDLIGHTING: boolean;
  99641. SHADOWFLOAT: boolean;
  99642. MORPHTARGETS: boolean;
  99643. MORPHTARGETS_NORMAL: boolean;
  99644. MORPHTARGETS_TANGENT: boolean;
  99645. MORPHTARGETS_UV: boolean;
  99646. NUM_MORPH_INFLUENCERS: number;
  99647. NONUNIFORMSCALING: boolean;
  99648. PREMULTIPLYALPHA: boolean;
  99649. IMAGEPROCESSING: boolean;
  99650. VIGNETTE: boolean;
  99651. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99652. VIGNETTEBLENDMODEOPAQUE: boolean;
  99653. TONEMAPPING: boolean;
  99654. TONEMAPPING_ACES: boolean;
  99655. CONTRAST: boolean;
  99656. COLORCURVES: boolean;
  99657. COLORGRADING: boolean;
  99658. COLORGRADING3D: boolean;
  99659. SAMPLER3DGREENDEPTH: boolean;
  99660. SAMPLER3DBGRMAP: boolean;
  99661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99662. MULTIVIEW: boolean;
  99663. /**
  99664. * If the reflection texture on this material is in linear color space
  99665. * @hidden
  99666. */
  99667. IS_REFLECTION_LINEAR: boolean;
  99668. /**
  99669. * If the refraction texture on this material is in linear color space
  99670. * @hidden
  99671. */
  99672. IS_REFRACTION_LINEAR: boolean;
  99673. EXPOSURE: boolean;
  99674. constructor();
  99675. setReflectionMode(modeToEnable: string): void;
  99676. }
  99677. /**
  99678. * This is the default material used in Babylon. It is the best trade off between quality
  99679. * and performances.
  99680. * @see http://doc.babylonjs.com/babylon101/materials
  99681. */
  99682. export class StandardMaterial extends PushMaterial {
  99683. private _diffuseTexture;
  99684. /**
  99685. * The basic texture of the material as viewed under a light.
  99686. */
  99687. diffuseTexture: Nullable<BaseTexture>;
  99688. private _ambientTexture;
  99689. /**
  99690. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99691. */
  99692. ambientTexture: Nullable<BaseTexture>;
  99693. private _opacityTexture;
  99694. /**
  99695. * Define the transparency of the material from a texture.
  99696. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99697. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99698. */
  99699. opacityTexture: Nullable<BaseTexture>;
  99700. private _reflectionTexture;
  99701. /**
  99702. * Define the texture used to display the reflection.
  99703. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99704. */
  99705. reflectionTexture: Nullable<BaseTexture>;
  99706. private _emissiveTexture;
  99707. /**
  99708. * Define texture of the material as if self lit.
  99709. * This will be mixed in the final result even in the absence of light.
  99710. */
  99711. emissiveTexture: Nullable<BaseTexture>;
  99712. private _specularTexture;
  99713. /**
  99714. * Define how the color and intensity of the highlight given by the light in the material.
  99715. */
  99716. specularTexture: Nullable<BaseTexture>;
  99717. private _bumpTexture;
  99718. /**
  99719. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99720. * 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.
  99721. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99722. */
  99723. bumpTexture: Nullable<BaseTexture>;
  99724. private _lightmapTexture;
  99725. /**
  99726. * Complex lighting can be computationally expensive to compute at runtime.
  99727. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99728. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99729. */
  99730. lightmapTexture: Nullable<BaseTexture>;
  99731. private _refractionTexture;
  99732. /**
  99733. * Define the texture used to display the refraction.
  99734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99735. */
  99736. refractionTexture: Nullable<BaseTexture>;
  99737. /**
  99738. * The color of the material lit by the environmental background lighting.
  99739. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99740. */
  99741. ambientColor: Color3;
  99742. /**
  99743. * The basic color of the material as viewed under a light.
  99744. */
  99745. diffuseColor: Color3;
  99746. /**
  99747. * Define how the color and intensity of the highlight given by the light in the material.
  99748. */
  99749. specularColor: Color3;
  99750. /**
  99751. * Define the color of the material as if self lit.
  99752. * This will be mixed in the final result even in the absence of light.
  99753. */
  99754. emissiveColor: Color3;
  99755. /**
  99756. * Defines how sharp are the highlights in the material.
  99757. * The bigger the value the sharper giving a more glossy feeling to the result.
  99758. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99759. */
  99760. specularPower: number;
  99761. private _useAlphaFromDiffuseTexture;
  99762. /**
  99763. * Does the transparency come from the diffuse texture alpha channel.
  99764. */
  99765. useAlphaFromDiffuseTexture: boolean;
  99766. private _useEmissiveAsIllumination;
  99767. /**
  99768. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99769. */
  99770. useEmissiveAsIllumination: boolean;
  99771. private _linkEmissiveWithDiffuse;
  99772. /**
  99773. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99774. * the emissive level when the final color is close to one.
  99775. */
  99776. linkEmissiveWithDiffuse: boolean;
  99777. private _useSpecularOverAlpha;
  99778. /**
  99779. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99780. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99781. */
  99782. useSpecularOverAlpha: boolean;
  99783. private _useReflectionOverAlpha;
  99784. /**
  99785. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99786. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99787. */
  99788. useReflectionOverAlpha: boolean;
  99789. private _disableLighting;
  99790. /**
  99791. * Does lights from the scene impacts this material.
  99792. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99793. */
  99794. disableLighting: boolean;
  99795. private _useObjectSpaceNormalMap;
  99796. /**
  99797. * Allows using an object space normal map (instead of tangent space).
  99798. */
  99799. useObjectSpaceNormalMap: boolean;
  99800. private _useParallax;
  99801. /**
  99802. * Is parallax enabled or not.
  99803. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99804. */
  99805. useParallax: boolean;
  99806. private _useParallaxOcclusion;
  99807. /**
  99808. * Is parallax occlusion enabled or not.
  99809. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99810. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99811. */
  99812. useParallaxOcclusion: boolean;
  99813. /**
  99814. * 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.
  99815. */
  99816. parallaxScaleBias: number;
  99817. private _roughness;
  99818. /**
  99819. * Helps to define how blurry the reflections should appears in the material.
  99820. */
  99821. roughness: number;
  99822. /**
  99823. * In case of refraction, define the value of the index of refraction.
  99824. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99825. */
  99826. indexOfRefraction: number;
  99827. /**
  99828. * Invert the refraction texture alongside the y axis.
  99829. * It can be useful with procedural textures or probe for instance.
  99830. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99831. */
  99832. invertRefractionY: boolean;
  99833. /**
  99834. * Defines the alpha limits in alpha test mode.
  99835. */
  99836. alphaCutOff: number;
  99837. private _useLightmapAsShadowmap;
  99838. /**
  99839. * In case of light mapping, define whether the map contains light or shadow informations.
  99840. */
  99841. useLightmapAsShadowmap: boolean;
  99842. private _diffuseFresnelParameters;
  99843. /**
  99844. * Define the diffuse fresnel parameters of the material.
  99845. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99846. */
  99847. diffuseFresnelParameters: FresnelParameters;
  99848. private _opacityFresnelParameters;
  99849. /**
  99850. * Define the opacity fresnel parameters of the material.
  99851. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99852. */
  99853. opacityFresnelParameters: FresnelParameters;
  99854. private _reflectionFresnelParameters;
  99855. /**
  99856. * Define the reflection fresnel parameters of the material.
  99857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99858. */
  99859. reflectionFresnelParameters: FresnelParameters;
  99860. private _refractionFresnelParameters;
  99861. /**
  99862. * Define the refraction fresnel parameters of the material.
  99863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99864. */
  99865. refractionFresnelParameters: FresnelParameters;
  99866. private _emissiveFresnelParameters;
  99867. /**
  99868. * Define the emissive fresnel parameters of the material.
  99869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99870. */
  99871. emissiveFresnelParameters: FresnelParameters;
  99872. private _useReflectionFresnelFromSpecular;
  99873. /**
  99874. * If true automatically deducts the fresnels values from the material specularity.
  99875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99876. */
  99877. useReflectionFresnelFromSpecular: boolean;
  99878. private _useGlossinessFromSpecularMapAlpha;
  99879. /**
  99880. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99881. */
  99882. useGlossinessFromSpecularMapAlpha: boolean;
  99883. private _maxSimultaneousLights;
  99884. /**
  99885. * Defines the maximum number of lights that can be used in the material
  99886. */
  99887. maxSimultaneousLights: number;
  99888. private _invertNormalMapX;
  99889. /**
  99890. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99891. */
  99892. invertNormalMapX: boolean;
  99893. private _invertNormalMapY;
  99894. /**
  99895. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99896. */
  99897. invertNormalMapY: boolean;
  99898. private _twoSidedLighting;
  99899. /**
  99900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99901. */
  99902. twoSidedLighting: boolean;
  99903. /**
  99904. * Default configuration related to image processing available in the standard Material.
  99905. */
  99906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99907. /**
  99908. * Gets the image processing configuration used either in this material.
  99909. */
  99910. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99911. /**
  99912. * Sets the Default image processing configuration used either in the this material.
  99913. *
  99914. * If sets to null, the scene one is in use.
  99915. */
  99916. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99917. /**
  99918. * Keep track of the image processing observer to allow dispose and replace.
  99919. */
  99920. private _imageProcessingObserver;
  99921. /**
  99922. * Attaches a new image processing configuration to the Standard Material.
  99923. * @param configuration
  99924. */
  99925. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99926. /**
  99927. * Gets wether the color curves effect is enabled.
  99928. */
  99929. get cameraColorCurvesEnabled(): boolean;
  99930. /**
  99931. * Sets wether the color curves effect is enabled.
  99932. */
  99933. set cameraColorCurvesEnabled(value: boolean);
  99934. /**
  99935. * Gets wether the color grading effect is enabled.
  99936. */
  99937. get cameraColorGradingEnabled(): boolean;
  99938. /**
  99939. * Gets wether the color grading effect is enabled.
  99940. */
  99941. set cameraColorGradingEnabled(value: boolean);
  99942. /**
  99943. * Gets wether tonemapping is enabled or not.
  99944. */
  99945. get cameraToneMappingEnabled(): boolean;
  99946. /**
  99947. * Sets wether tonemapping is enabled or not
  99948. */
  99949. set cameraToneMappingEnabled(value: boolean);
  99950. /**
  99951. * The camera exposure used on this material.
  99952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99953. * This corresponds to a photographic exposure.
  99954. */
  99955. get cameraExposure(): number;
  99956. /**
  99957. * The camera exposure used on this material.
  99958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99959. * This corresponds to a photographic exposure.
  99960. */
  99961. set cameraExposure(value: number);
  99962. /**
  99963. * Gets The camera contrast used on this material.
  99964. */
  99965. get cameraContrast(): number;
  99966. /**
  99967. * Sets The camera contrast used on this material.
  99968. */
  99969. set cameraContrast(value: number);
  99970. /**
  99971. * Gets the Color Grading 2D Lookup Texture.
  99972. */
  99973. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99974. /**
  99975. * Sets the Color Grading 2D Lookup Texture.
  99976. */
  99977. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99978. /**
  99979. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99980. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99981. * 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;
  99982. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99983. */
  99984. get cameraColorCurves(): Nullable<ColorCurves>;
  99985. /**
  99986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99988. * 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;
  99989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99990. */
  99991. set cameraColorCurves(value: Nullable<ColorCurves>);
  99992. /**
  99993. * Custom callback helping to override the default shader used in the material.
  99994. */
  99995. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99996. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99997. protected _worldViewProjectionMatrix: Matrix;
  99998. protected _globalAmbientColor: Color3;
  99999. protected _useLogarithmicDepth: boolean;
  100000. protected _rebuildInParallel: boolean;
  100001. /**
  100002. * Instantiates a new standard material.
  100003. * This is the default material used in Babylon. It is the best trade off between quality
  100004. * and performances.
  100005. * @see http://doc.babylonjs.com/babylon101/materials
  100006. * @param name Define the name of the material in the scene
  100007. * @param scene Define the scene the material belong to
  100008. */
  100009. constructor(name: string, scene: Scene);
  100010. /**
  100011. * Gets a boolean indicating that current material needs to register RTT
  100012. */
  100013. get hasRenderTargetTextures(): boolean;
  100014. /**
  100015. * Gets the current class name of the material e.g. "StandardMaterial"
  100016. * Mainly use in serialization.
  100017. * @returns the class name
  100018. */
  100019. getClassName(): string;
  100020. /**
  100021. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100022. * You can try switching to logarithmic depth.
  100023. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100024. */
  100025. get useLogarithmicDepth(): boolean;
  100026. set useLogarithmicDepth(value: boolean);
  100027. /**
  100028. * Specifies if the material will require alpha blending
  100029. * @returns a boolean specifying if alpha blending is needed
  100030. */
  100031. needAlphaBlending(): boolean;
  100032. /**
  100033. * Specifies if this material should be rendered in alpha test mode
  100034. * @returns a boolean specifying if an alpha test is needed.
  100035. */
  100036. needAlphaTesting(): boolean;
  100037. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100038. /**
  100039. * Get the texture used for alpha test purpose.
  100040. * @returns the diffuse texture in case of the standard material.
  100041. */
  100042. getAlphaTestTexture(): Nullable<BaseTexture>;
  100043. /**
  100044. * Get if the submesh is ready to be used and all its information available.
  100045. * Child classes can use it to update shaders
  100046. * @param mesh defines the mesh to check
  100047. * @param subMesh defines which submesh to check
  100048. * @param useInstances specifies that instances should be used
  100049. * @returns a boolean indicating that the submesh is ready or not
  100050. */
  100051. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100052. /**
  100053. * Builds the material UBO layouts.
  100054. * Used internally during the effect preparation.
  100055. */
  100056. buildUniformLayout(): void;
  100057. /**
  100058. * Unbinds the material from the mesh
  100059. */
  100060. unbind(): void;
  100061. /**
  100062. * Binds the submesh to this material by preparing the effect and shader to draw
  100063. * @param world defines the world transformation matrix
  100064. * @param mesh defines the mesh containing the submesh
  100065. * @param subMesh defines the submesh to bind the material to
  100066. */
  100067. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100068. /**
  100069. * Get the list of animatables in the material.
  100070. * @returns the list of animatables object used in the material
  100071. */
  100072. getAnimatables(): IAnimatable[];
  100073. /**
  100074. * Gets the active textures from the material
  100075. * @returns an array of textures
  100076. */
  100077. getActiveTextures(): BaseTexture[];
  100078. /**
  100079. * Specifies if the material uses a texture
  100080. * @param texture defines the texture to check against the material
  100081. * @returns a boolean specifying if the material uses the texture
  100082. */
  100083. hasTexture(texture: BaseTexture): boolean;
  100084. /**
  100085. * Disposes the material
  100086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100087. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100088. */
  100089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100090. /**
  100091. * Makes a duplicate of the material, and gives it a new name
  100092. * @param name defines the new name for the duplicated material
  100093. * @returns the cloned material
  100094. */
  100095. clone(name: string): StandardMaterial;
  100096. /**
  100097. * Serializes this material in a JSON representation
  100098. * @returns the serialized material object
  100099. */
  100100. serialize(): any;
  100101. /**
  100102. * Creates a standard material from parsed material data
  100103. * @param source defines the JSON representation of the material
  100104. * @param scene defines the hosting scene
  100105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100106. * @returns a new standard material
  100107. */
  100108. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100109. /**
  100110. * Are diffuse textures enabled in the application.
  100111. */
  100112. static get DiffuseTextureEnabled(): boolean;
  100113. static set DiffuseTextureEnabled(value: boolean);
  100114. /**
  100115. * Are ambient textures enabled in the application.
  100116. */
  100117. static get AmbientTextureEnabled(): boolean;
  100118. static set AmbientTextureEnabled(value: boolean);
  100119. /**
  100120. * Are opacity textures enabled in the application.
  100121. */
  100122. static get OpacityTextureEnabled(): boolean;
  100123. static set OpacityTextureEnabled(value: boolean);
  100124. /**
  100125. * Are reflection textures enabled in the application.
  100126. */
  100127. static get ReflectionTextureEnabled(): boolean;
  100128. static set ReflectionTextureEnabled(value: boolean);
  100129. /**
  100130. * Are emissive textures enabled in the application.
  100131. */
  100132. static get EmissiveTextureEnabled(): boolean;
  100133. static set EmissiveTextureEnabled(value: boolean);
  100134. /**
  100135. * Are specular textures enabled in the application.
  100136. */
  100137. static get SpecularTextureEnabled(): boolean;
  100138. static set SpecularTextureEnabled(value: boolean);
  100139. /**
  100140. * Are bump textures enabled in the application.
  100141. */
  100142. static get BumpTextureEnabled(): boolean;
  100143. static set BumpTextureEnabled(value: boolean);
  100144. /**
  100145. * Are lightmap textures enabled in the application.
  100146. */
  100147. static get LightmapTextureEnabled(): boolean;
  100148. static set LightmapTextureEnabled(value: boolean);
  100149. /**
  100150. * Are refraction textures enabled in the application.
  100151. */
  100152. static get RefractionTextureEnabled(): boolean;
  100153. static set RefractionTextureEnabled(value: boolean);
  100154. /**
  100155. * Are color grading textures enabled in the application.
  100156. */
  100157. static get ColorGradingTextureEnabled(): boolean;
  100158. static set ColorGradingTextureEnabled(value: boolean);
  100159. /**
  100160. * Are fresnels enabled in the application.
  100161. */
  100162. static get FresnelEnabled(): boolean;
  100163. static set FresnelEnabled(value: boolean);
  100164. }
  100165. }
  100166. declare module BABYLON {
  100167. /**
  100168. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100169. *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.
  100170. * The SPS is also a particle system. It provides some methods to manage the particles.
  100171. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100172. *
  100173. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100174. */
  100175. export class SolidParticleSystem implements IDisposable {
  100176. /**
  100177. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100178. * Example : var p = SPS.particles[i];
  100179. */
  100180. particles: SolidParticle[];
  100181. /**
  100182. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100183. */
  100184. nbParticles: number;
  100185. /**
  100186. * If the particles must ever face the camera (default false). Useful for planar particles.
  100187. */
  100188. billboard: boolean;
  100189. /**
  100190. * Recompute normals when adding a shape
  100191. */
  100192. recomputeNormals: boolean;
  100193. /**
  100194. * This a counter ofr your own usage. It's not set by any SPS functions.
  100195. */
  100196. counter: number;
  100197. /**
  100198. * The SPS name. This name is also given to the underlying mesh.
  100199. */
  100200. name: string;
  100201. /**
  100202. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100203. */
  100204. mesh: Mesh;
  100205. /**
  100206. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100207. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100208. */
  100209. vars: any;
  100210. /**
  100211. * This array is populated when the SPS is set as 'pickable'.
  100212. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100213. * Each element of this array is an object `{idx: int, faceId: int}`.
  100214. * `idx` is the picked particle index in the `SPS.particles` array
  100215. * `faceId` is the picked face index counted within this particle.
  100216. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100217. */
  100218. pickedParticles: {
  100219. idx: number;
  100220. faceId: number;
  100221. }[];
  100222. /**
  100223. * This array is populated when `enableDepthSort` is set to true.
  100224. * Each element of this array is an instance of the class DepthSortedParticle.
  100225. */
  100226. depthSortedParticles: DepthSortedParticle[];
  100227. /**
  100228. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100229. * @hidden
  100230. */
  100231. _bSphereOnly: boolean;
  100232. /**
  100233. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100234. * @hidden
  100235. */
  100236. _bSphereRadiusFactor: number;
  100237. private _scene;
  100238. private _positions;
  100239. private _indices;
  100240. private _normals;
  100241. private _colors;
  100242. private _uvs;
  100243. private _indices32;
  100244. private _positions32;
  100245. private _normals32;
  100246. private _fixedNormal32;
  100247. private _colors32;
  100248. private _uvs32;
  100249. private _index;
  100250. private _updatable;
  100251. private _pickable;
  100252. private _isVisibilityBoxLocked;
  100253. private _alwaysVisible;
  100254. private _depthSort;
  100255. private _expandable;
  100256. private _shapeCounter;
  100257. private _copy;
  100258. private _color;
  100259. private _computeParticleColor;
  100260. private _computeParticleTexture;
  100261. private _computeParticleRotation;
  100262. private _computeParticleVertex;
  100263. private _computeBoundingBox;
  100264. private _depthSortParticles;
  100265. private _camera;
  100266. private _mustUnrotateFixedNormals;
  100267. private _particlesIntersect;
  100268. private _needs32Bits;
  100269. private _isNotBuilt;
  100270. private _lastParticleId;
  100271. private _idxOfId;
  100272. private _multimaterialEnabled;
  100273. private _useModelMaterial;
  100274. private _indicesByMaterial;
  100275. private _materialIndexes;
  100276. private _depthSortFunction;
  100277. private _materialSortFunction;
  100278. private _materials;
  100279. private _multimaterial;
  100280. private _materialIndexesById;
  100281. private _defaultMaterial;
  100282. private _autoUpdateSubMeshes;
  100283. /**
  100284. * Creates a SPS (Solid Particle System) object.
  100285. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100286. * @param scene (Scene) is the scene in which the SPS is added.
  100287. * @param options defines the options of the sps e.g.
  100288. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100289. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100290. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100291. * * 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.
  100292. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100293. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100294. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100295. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100296. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100297. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100298. */
  100299. constructor(name: string, scene: Scene, options?: {
  100300. updatable?: boolean;
  100301. isPickable?: boolean;
  100302. enableDepthSort?: boolean;
  100303. particleIntersection?: boolean;
  100304. boundingSphereOnly?: boolean;
  100305. bSphereRadiusFactor?: number;
  100306. expandable?: boolean;
  100307. useModelMaterial?: boolean;
  100308. enableMultiMaterial?: boolean;
  100309. });
  100310. /**
  100311. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100312. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100313. * @returns the created mesh
  100314. */
  100315. buildMesh(): Mesh;
  100316. /**
  100317. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100318. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100319. * Thus the particles generated from `digest()` have their property `position` set yet.
  100320. * @param mesh ( Mesh ) is the mesh to be digested
  100321. * @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
  100322. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100323. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100324. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100325. * @returns the current SPS
  100326. */
  100327. digest(mesh: Mesh, options?: {
  100328. facetNb?: number;
  100329. number?: number;
  100330. delta?: number;
  100331. storage?: [];
  100332. }): SolidParticleSystem;
  100333. /**
  100334. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100335. * @hidden
  100336. */
  100337. private _unrotateFixedNormals;
  100338. /**
  100339. * Resets the temporary working copy particle
  100340. * @hidden
  100341. */
  100342. private _resetCopy;
  100343. /**
  100344. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100345. * @param p the current index in the positions array to be updated
  100346. * @param ind the current index in the indices array
  100347. * @param shape a Vector3 array, the shape geometry
  100348. * @param positions the positions array to be updated
  100349. * @param meshInd the shape indices array
  100350. * @param indices the indices array to be updated
  100351. * @param meshUV the shape uv array
  100352. * @param uvs the uv array to be updated
  100353. * @param meshCol the shape color array
  100354. * @param colors the color array to be updated
  100355. * @param meshNor the shape normals array
  100356. * @param normals the normals array to be updated
  100357. * @param idx the particle index
  100358. * @param idxInShape the particle index in its shape
  100359. * @param options the addShape() method passed options
  100360. * @model the particle model
  100361. * @hidden
  100362. */
  100363. private _meshBuilder;
  100364. /**
  100365. * Returns a shape Vector3 array from positions float array
  100366. * @param positions float array
  100367. * @returns a vector3 array
  100368. * @hidden
  100369. */
  100370. private _posToShape;
  100371. /**
  100372. * Returns a shapeUV array from a float uvs (array deep copy)
  100373. * @param uvs as a float array
  100374. * @returns a shapeUV array
  100375. * @hidden
  100376. */
  100377. private _uvsToShapeUV;
  100378. /**
  100379. * Adds a new particle object in the particles array
  100380. * @param idx particle index in particles array
  100381. * @param id particle id
  100382. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100383. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100384. * @param model particle ModelShape object
  100385. * @param shapeId model shape identifier
  100386. * @param idxInShape index of the particle in the current model
  100387. * @param bInfo model bounding info object
  100388. * @param storage target storage array, if any
  100389. * @hidden
  100390. */
  100391. private _addParticle;
  100392. /**
  100393. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100394. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100395. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100396. * @param nb (positive integer) the number of particles to be created from this model
  100397. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100398. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100399. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100400. * @returns the number of shapes in the system
  100401. */
  100402. addShape(mesh: Mesh, nb: number, options?: {
  100403. positionFunction?: any;
  100404. vertexFunction?: any;
  100405. storage?: [];
  100406. }): number;
  100407. /**
  100408. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100409. * @hidden
  100410. */
  100411. private _rebuildParticle;
  100412. /**
  100413. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100414. * @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.
  100415. * @returns the SPS.
  100416. */
  100417. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100418. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100419. * Returns an array with the removed particles.
  100420. * 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.
  100421. * The SPS can't be empty so at least one particle needs to remain in place.
  100422. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100423. * @param start index of the first particle to remove
  100424. * @param end index of the last particle to remove (included)
  100425. * @returns an array populated with the removed particles
  100426. */
  100427. removeParticles(start: number, end: number): SolidParticle[];
  100428. /**
  100429. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100430. * @param solidParticleArray an array populated with Solid Particles objects
  100431. * @returns the SPS
  100432. */
  100433. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100434. /**
  100435. * Creates a new particle and modifies the SPS mesh geometry :
  100436. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100437. * - calls _addParticle() to populate the particle array
  100438. * factorized code from addShape() and insertParticlesFromArray()
  100439. * @param idx particle index in the particles array
  100440. * @param i particle index in its shape
  100441. * @param modelShape particle ModelShape object
  100442. * @param shape shape vertex array
  100443. * @param meshInd shape indices array
  100444. * @param meshUV shape uv array
  100445. * @param meshCol shape color array
  100446. * @param meshNor shape normals array
  100447. * @param bbInfo shape bounding info
  100448. * @param storage target particle storage
  100449. * @options addShape() passed options
  100450. * @hidden
  100451. */
  100452. private _insertNewParticle;
  100453. /**
  100454. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100455. * This method calls `updateParticle()` for each particle of the SPS.
  100456. * For an animated SPS, it is usually called within the render loop.
  100457. * 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.
  100458. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100459. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100460. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100461. * @returns the SPS.
  100462. */
  100463. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100464. /**
  100465. * Disposes the SPS.
  100466. */
  100467. dispose(): void;
  100468. /**
  100469. * Returns a SolidParticle object from its identifier : particle.id
  100470. * @param id (integer) the particle Id
  100471. * @returns the searched particle or null if not found in the SPS.
  100472. */
  100473. getParticleById(id: number): Nullable<SolidParticle>;
  100474. /**
  100475. * Returns a new array populated with the particles having the passed shapeId.
  100476. * @param shapeId (integer) the shape identifier
  100477. * @returns a new solid particle array
  100478. */
  100479. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100480. /**
  100481. * Populates the passed array "ref" with the particles having the passed shapeId.
  100482. * @param shapeId the shape identifier
  100483. * @returns the SPS
  100484. * @param ref
  100485. */
  100486. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100487. /**
  100488. * Computes the required SubMeshes according the materials assigned to the particles.
  100489. * @returns the solid particle system.
  100490. * Does nothing if called before the SPS mesh is built.
  100491. */
  100492. computeSubMeshes(): SolidParticleSystem;
  100493. /**
  100494. * Sorts the solid particles by material when MultiMaterial is enabled.
  100495. * Updates the indices32 array.
  100496. * Updates the indicesByMaterial array.
  100497. * Updates the mesh indices array.
  100498. * @returns the SPS
  100499. * @hidden
  100500. */
  100501. private _sortParticlesByMaterial;
  100502. /**
  100503. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100504. * @hidden
  100505. */
  100506. private _setMaterialIndexesById;
  100507. /**
  100508. * Returns an array with unique values of Materials from the passed array
  100509. * @param array the material array to be checked and filtered
  100510. * @hidden
  100511. */
  100512. private _filterUniqueMaterialId;
  100513. /**
  100514. * Sets a new Standard Material as _defaultMaterial if not already set.
  100515. * @hidden
  100516. */
  100517. private _setDefaultMaterial;
  100518. /**
  100519. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100520. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100521. * @returns the SPS.
  100522. */
  100523. refreshVisibleSize(): SolidParticleSystem;
  100524. /**
  100525. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100526. * @param size the size (float) of the visibility box
  100527. * note : this doesn't lock the SPS mesh bounding box.
  100528. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100529. */
  100530. setVisibilityBox(size: number): void;
  100531. /**
  100532. * Gets whether the SPS as always visible or not
  100533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100534. */
  100535. get isAlwaysVisible(): boolean;
  100536. /**
  100537. * Sets the SPS as always visible or not
  100538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100539. */
  100540. set isAlwaysVisible(val: boolean);
  100541. /**
  100542. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100543. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100544. */
  100545. set isVisibilityBoxLocked(val: boolean);
  100546. /**
  100547. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100548. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100549. */
  100550. get isVisibilityBoxLocked(): boolean;
  100551. /**
  100552. * Tells to `setParticles()` to compute the particle rotations or not.
  100553. * Default value : true. The SPS is faster when it's set to false.
  100554. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100555. */
  100556. set computeParticleRotation(val: boolean);
  100557. /**
  100558. * Tells to `setParticles()` to compute the particle colors or not.
  100559. * Default value : true. The SPS is faster when it's set to false.
  100560. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100561. */
  100562. set computeParticleColor(val: boolean);
  100563. set computeParticleTexture(val: boolean);
  100564. /**
  100565. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100566. * Default value : false. The SPS is faster when it's set to false.
  100567. * Note : the particle custom vertex positions aren't stored values.
  100568. */
  100569. set computeParticleVertex(val: boolean);
  100570. /**
  100571. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100572. */
  100573. set computeBoundingBox(val: boolean);
  100574. /**
  100575. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100576. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100577. * Default : `true`
  100578. */
  100579. set depthSortParticles(val: boolean);
  100580. /**
  100581. * Gets if `setParticles()` computes the particle rotations or not.
  100582. * Default value : true. The SPS is faster when it's set to false.
  100583. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100584. */
  100585. get computeParticleRotation(): boolean;
  100586. /**
  100587. * Gets if `setParticles()` computes the particle colors or not.
  100588. * Default value : true. The SPS is faster when it's set to false.
  100589. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100590. */
  100591. get computeParticleColor(): boolean;
  100592. /**
  100593. * Gets if `setParticles()` computes the particle textures or not.
  100594. * Default value : true. The SPS is faster when it's set to false.
  100595. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100596. */
  100597. get computeParticleTexture(): boolean;
  100598. /**
  100599. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100600. * Default value : false. The SPS is faster when it's set to false.
  100601. * Note : the particle custom vertex positions aren't stored values.
  100602. */
  100603. get computeParticleVertex(): boolean;
  100604. /**
  100605. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100606. */
  100607. get computeBoundingBox(): boolean;
  100608. /**
  100609. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100610. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100611. * Default : `true`
  100612. */
  100613. get depthSortParticles(): boolean;
  100614. /**
  100615. * Gets if the SPS is created as expandable at construction time.
  100616. * Default : `false`
  100617. */
  100618. get expandable(): boolean;
  100619. /**
  100620. * Gets if the SPS supports the Multi Materials
  100621. */
  100622. get multimaterialEnabled(): boolean;
  100623. /**
  100624. * Gets if the SPS uses the model materials for its own multimaterial.
  100625. */
  100626. get useModelMaterial(): boolean;
  100627. /**
  100628. * The SPS used material array.
  100629. */
  100630. get materials(): Material[];
  100631. /**
  100632. * Sets the SPS MultiMaterial from the passed materials.
  100633. * Note : the passed array is internally copied and not used then by reference.
  100634. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100635. */
  100636. setMultiMaterial(materials: Material[]): void;
  100637. /**
  100638. * The SPS computed multimaterial object
  100639. */
  100640. get multimaterial(): MultiMaterial;
  100641. set multimaterial(mm: MultiMaterial);
  100642. /**
  100643. * If the subMeshes must be updated on the next call to setParticles()
  100644. */
  100645. get autoUpdateSubMeshes(): boolean;
  100646. set autoUpdateSubMeshes(val: boolean);
  100647. /**
  100648. * This function does nothing. It may be overwritten to set all the particle first values.
  100649. * The SPS doesn't call this function, you may have to call it by your own.
  100650. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100651. */
  100652. initParticles(): void;
  100653. /**
  100654. * This function does nothing. It may be overwritten to recycle a particle.
  100655. * The SPS doesn't call this function, you may have to call it by your own.
  100656. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100657. * @param particle The particle to recycle
  100658. * @returns the recycled particle
  100659. */
  100660. recycleParticle(particle: SolidParticle): SolidParticle;
  100661. /**
  100662. * Updates a particle : this function should be overwritten by the user.
  100663. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100664. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100665. * @example : just set a particle position or velocity and recycle conditions
  100666. * @param particle The particle to update
  100667. * @returns the updated particle
  100668. */
  100669. updateParticle(particle: SolidParticle): SolidParticle;
  100670. /**
  100671. * Updates a vertex of a particle : it can be overwritten by the user.
  100672. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100673. * @param particle the current particle
  100674. * @param vertex the current index of the current particle
  100675. * @param pt the index of the current vertex in the particle shape
  100676. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100677. * @example : just set a vertex particle position
  100678. * @returns the updated vertex
  100679. */
  100680. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100681. /**
  100682. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100683. * This does nothing and may be overwritten by the user.
  100684. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100685. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100686. * @param update the boolean update value actually passed to setParticles()
  100687. */
  100688. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100689. /**
  100690. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100691. * This will be passed three parameters.
  100692. * This does nothing and may be overwritten by the user.
  100693. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100694. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100695. * @param update the boolean update value actually passed to setParticles()
  100696. */
  100697. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100698. }
  100699. }
  100700. declare module BABYLON {
  100701. /**
  100702. * Represents one particle of a solid particle system.
  100703. */
  100704. export class SolidParticle {
  100705. /**
  100706. * particle global index
  100707. */
  100708. idx: number;
  100709. /**
  100710. * particle identifier
  100711. */
  100712. id: number;
  100713. /**
  100714. * The color of the particle
  100715. */
  100716. color: Nullable<Color4>;
  100717. /**
  100718. * The world space position of the particle.
  100719. */
  100720. position: Vector3;
  100721. /**
  100722. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100723. */
  100724. rotation: Vector3;
  100725. /**
  100726. * The world space rotation quaternion of the particle.
  100727. */
  100728. rotationQuaternion: Nullable<Quaternion>;
  100729. /**
  100730. * The scaling of the particle.
  100731. */
  100732. scaling: Vector3;
  100733. /**
  100734. * The uvs of the particle.
  100735. */
  100736. uvs: Vector4;
  100737. /**
  100738. * The current speed of the particle.
  100739. */
  100740. velocity: Vector3;
  100741. /**
  100742. * The pivot point in the particle local space.
  100743. */
  100744. pivot: Vector3;
  100745. /**
  100746. * Must the particle be translated from its pivot point in its local space ?
  100747. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100748. * Default : false
  100749. */
  100750. translateFromPivot: boolean;
  100751. /**
  100752. * Is the particle active or not ?
  100753. */
  100754. alive: boolean;
  100755. /**
  100756. * Is the particle visible or not ?
  100757. */
  100758. isVisible: boolean;
  100759. /**
  100760. * Index of this particle in the global "positions" array (Internal use)
  100761. * @hidden
  100762. */
  100763. _pos: number;
  100764. /**
  100765. * @hidden Index of this particle in the global "indices" array (Internal use)
  100766. */
  100767. _ind: number;
  100768. /**
  100769. * @hidden ModelShape of this particle (Internal use)
  100770. */
  100771. _model: ModelShape;
  100772. /**
  100773. * ModelShape id of this particle
  100774. */
  100775. shapeId: number;
  100776. /**
  100777. * Index of the particle in its shape id
  100778. */
  100779. idxInShape: number;
  100780. /**
  100781. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100782. */
  100783. _modelBoundingInfo: BoundingInfo;
  100784. /**
  100785. * @hidden Particle BoundingInfo object (Internal use)
  100786. */
  100787. _boundingInfo: BoundingInfo;
  100788. /**
  100789. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100790. */
  100791. _sps: SolidParticleSystem;
  100792. /**
  100793. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100794. */
  100795. _stillInvisible: boolean;
  100796. /**
  100797. * @hidden Last computed particle rotation matrix
  100798. */
  100799. _rotationMatrix: number[];
  100800. /**
  100801. * Parent particle Id, if any.
  100802. * Default null.
  100803. */
  100804. parentId: Nullable<number>;
  100805. /**
  100806. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100807. */
  100808. materialIndex: Nullable<number>;
  100809. /**
  100810. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100811. * The possible values are :
  100812. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100813. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100815. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100816. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100817. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100818. * */
  100819. cullingStrategy: number;
  100820. /**
  100821. * @hidden Internal global position in the SPS.
  100822. */
  100823. _globalPosition: Vector3;
  100824. /**
  100825. * Creates a Solid Particle object.
  100826. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100827. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100828. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100829. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100830. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100831. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100832. * @param shapeId (integer) is the model shape identifier in the SPS.
  100833. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100834. * @param sps defines the sps it is associated to
  100835. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100836. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100837. */
  100838. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100839. /**
  100840. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100841. * @param target the particle target
  100842. * @returns the current particle
  100843. */
  100844. copyToRef(target: SolidParticle): SolidParticle;
  100845. /**
  100846. * Legacy support, changed scale to scaling
  100847. */
  100848. get scale(): Vector3;
  100849. /**
  100850. * Legacy support, changed scale to scaling
  100851. */
  100852. set scale(scale: Vector3);
  100853. /**
  100854. * Legacy support, changed quaternion to rotationQuaternion
  100855. */
  100856. get quaternion(): Nullable<Quaternion>;
  100857. /**
  100858. * Legacy support, changed quaternion to rotationQuaternion
  100859. */
  100860. set quaternion(q: Nullable<Quaternion>);
  100861. /**
  100862. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100863. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100864. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100865. * @returns true if it intersects
  100866. */
  100867. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100868. /**
  100869. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100870. * A particle is in the frustum if its bounding box intersects the frustum
  100871. * @param frustumPlanes defines the frustum to test
  100872. * @returns true if the particle is in the frustum planes
  100873. */
  100874. isInFrustum(frustumPlanes: Plane[]): boolean;
  100875. /**
  100876. * get the rotation matrix of the particle
  100877. * @hidden
  100878. */
  100879. getRotationMatrix(m: Matrix): void;
  100880. }
  100881. /**
  100882. * Represents the shape of the model used by one particle of a solid particle system.
  100883. * SPS internal tool, don't use it manually.
  100884. */
  100885. export class ModelShape {
  100886. /**
  100887. * The shape id
  100888. * @hidden
  100889. */
  100890. shapeID: number;
  100891. /**
  100892. * flat array of model positions (internal use)
  100893. * @hidden
  100894. */
  100895. _shape: Vector3[];
  100896. /**
  100897. * flat array of model UVs (internal use)
  100898. * @hidden
  100899. */
  100900. _shapeUV: number[];
  100901. /**
  100902. * color array of the model
  100903. * @hidden
  100904. */
  100905. _shapeColors: number[];
  100906. /**
  100907. * indices array of the model
  100908. * @hidden
  100909. */
  100910. _indices: number[];
  100911. /**
  100912. * normals array of the model
  100913. * @hidden
  100914. */
  100915. _normals: number[];
  100916. /**
  100917. * length of the shape in the model indices array (internal use)
  100918. * @hidden
  100919. */
  100920. _indicesLength: number;
  100921. /**
  100922. * Custom position function (internal use)
  100923. * @hidden
  100924. */
  100925. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100926. /**
  100927. * Custom vertex function (internal use)
  100928. * @hidden
  100929. */
  100930. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100931. /**
  100932. * Model material (internal use)
  100933. * @hidden
  100934. */
  100935. _material: Nullable<Material>;
  100936. /**
  100937. * 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.
  100938. * SPS internal tool, don't use it manually.
  100939. * @hidden
  100940. */
  100941. 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>);
  100942. }
  100943. /**
  100944. * Represents a Depth Sorted Particle in the solid particle system.
  100945. * @hidden
  100946. */
  100947. export class DepthSortedParticle {
  100948. /**
  100949. * Index of the particle in the "indices" array
  100950. */
  100951. ind: number;
  100952. /**
  100953. * Length of the particle shape in the "indices" array
  100954. */
  100955. indicesLength: number;
  100956. /**
  100957. * Squared distance from the particle to the camera
  100958. */
  100959. sqDistance: number;
  100960. /**
  100961. * Material index when used with MultiMaterials
  100962. */
  100963. materialIndex: number;
  100964. /**
  100965. * Creates a new sorted particle
  100966. * @param materialIndex
  100967. */
  100968. constructor(ind: number, indLength: number, materialIndex: number);
  100969. }
  100970. }
  100971. declare module BABYLON {
  100972. /**
  100973. * @hidden
  100974. */
  100975. export class _MeshCollisionData {
  100976. _checkCollisions: boolean;
  100977. _collisionMask: number;
  100978. _collisionGroup: number;
  100979. _collider: Nullable<Collider>;
  100980. _oldPositionForCollisions: Vector3;
  100981. _diffPositionForCollisions: Vector3;
  100982. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100983. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100984. }
  100985. }
  100986. declare module BABYLON {
  100987. /** @hidden */
  100988. class _FacetDataStorage {
  100989. facetPositions: Vector3[];
  100990. facetNormals: Vector3[];
  100991. facetPartitioning: number[][];
  100992. facetNb: number;
  100993. partitioningSubdivisions: number;
  100994. partitioningBBoxRatio: number;
  100995. facetDataEnabled: boolean;
  100996. facetParameters: any;
  100997. bbSize: Vector3;
  100998. subDiv: {
  100999. max: number;
  101000. X: number;
  101001. Y: number;
  101002. Z: number;
  101003. };
  101004. facetDepthSort: boolean;
  101005. facetDepthSortEnabled: boolean;
  101006. depthSortedIndices: IndicesArray;
  101007. depthSortedFacets: {
  101008. ind: number;
  101009. sqDistance: number;
  101010. }[];
  101011. facetDepthSortFunction: (f1: {
  101012. ind: number;
  101013. sqDistance: number;
  101014. }, f2: {
  101015. ind: number;
  101016. sqDistance: number;
  101017. }) => number;
  101018. facetDepthSortFrom: Vector3;
  101019. facetDepthSortOrigin: Vector3;
  101020. invertedMatrix: Matrix;
  101021. }
  101022. /**
  101023. * @hidden
  101024. **/
  101025. class _InternalAbstractMeshDataInfo {
  101026. _hasVertexAlpha: boolean;
  101027. _useVertexColors: boolean;
  101028. _numBoneInfluencers: number;
  101029. _applyFog: boolean;
  101030. _receiveShadows: boolean;
  101031. _facetData: _FacetDataStorage;
  101032. _visibility: number;
  101033. _skeleton: Nullable<Skeleton>;
  101034. _layerMask: number;
  101035. _computeBonesUsingShaders: boolean;
  101036. _isActive: boolean;
  101037. _onlyForInstances: boolean;
  101038. _isActiveIntermediate: boolean;
  101039. _onlyForInstancesIntermediate: boolean;
  101040. _actAsRegularMesh: boolean;
  101041. }
  101042. /**
  101043. * Class used to store all common mesh properties
  101044. */
  101045. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101046. /** No occlusion */
  101047. static OCCLUSION_TYPE_NONE: number;
  101048. /** Occlusion set to optimisitic */
  101049. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101050. /** Occlusion set to strict */
  101051. static OCCLUSION_TYPE_STRICT: number;
  101052. /** Use an accurante occlusion algorithm */
  101053. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101054. /** Use a conservative occlusion algorithm */
  101055. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101056. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101057. * Test order :
  101058. * Is the bounding sphere outside the frustum ?
  101059. * If not, are the bounding box vertices outside the frustum ?
  101060. * It not, then the cullable object is in the frustum.
  101061. */
  101062. static readonly CULLINGSTRATEGY_STANDARD: number;
  101063. /** Culling strategy : Bounding Sphere Only.
  101064. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101065. * It's also less accurate than the standard because some not visible objects can still be selected.
  101066. * Test : is the bounding sphere outside the frustum ?
  101067. * If not, then the cullable object is in the frustum.
  101068. */
  101069. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101070. /** Culling strategy : Optimistic Inclusion.
  101071. * This in an inclusion test first, then the standard exclusion test.
  101072. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101073. * 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.
  101074. * Anyway, it's as accurate as the standard strategy.
  101075. * Test :
  101076. * Is the cullable object bounding sphere center in the frustum ?
  101077. * If not, apply the default culling strategy.
  101078. */
  101079. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101080. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101081. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101082. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101083. * 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.
  101084. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101085. * Test :
  101086. * Is the cullable object bounding sphere center in the frustum ?
  101087. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101088. */
  101089. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101090. /**
  101091. * No billboard
  101092. */
  101093. static get BILLBOARDMODE_NONE(): number;
  101094. /** Billboard on X axis */
  101095. static get BILLBOARDMODE_X(): number;
  101096. /** Billboard on Y axis */
  101097. static get BILLBOARDMODE_Y(): number;
  101098. /** Billboard on Z axis */
  101099. static get BILLBOARDMODE_Z(): number;
  101100. /** Billboard on all axes */
  101101. static get BILLBOARDMODE_ALL(): number;
  101102. /** Billboard on using position instead of orientation */
  101103. static get BILLBOARDMODE_USE_POSITION(): number;
  101104. /** @hidden */
  101105. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101106. /**
  101107. * The culling strategy to use to check whether the mesh must be rendered or not.
  101108. * This value can be changed at any time and will be used on the next render mesh selection.
  101109. * The possible values are :
  101110. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101111. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101114. * Please read each static variable documentation to get details about the culling process.
  101115. * */
  101116. cullingStrategy: number;
  101117. /**
  101118. * Gets the number of facets in the mesh
  101119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101120. */
  101121. get facetNb(): number;
  101122. /**
  101123. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101125. */
  101126. get partitioningSubdivisions(): number;
  101127. set partitioningSubdivisions(nb: number);
  101128. /**
  101129. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101130. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101132. */
  101133. get partitioningBBoxRatio(): number;
  101134. set partitioningBBoxRatio(ratio: number);
  101135. /**
  101136. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101137. * Works only for updatable meshes.
  101138. * Doesn't work with multi-materials
  101139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101140. */
  101141. get mustDepthSortFacets(): boolean;
  101142. set mustDepthSortFacets(sort: boolean);
  101143. /**
  101144. * The location (Vector3) where the facet depth sort must be computed from.
  101145. * By default, the active camera position.
  101146. * Used only when facet depth sort is enabled
  101147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101148. */
  101149. get facetDepthSortFrom(): Vector3;
  101150. set facetDepthSortFrom(location: Vector3);
  101151. /**
  101152. * gets a boolean indicating if facetData is enabled
  101153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101154. */
  101155. get isFacetDataEnabled(): boolean;
  101156. /** @hidden */
  101157. _updateNonUniformScalingState(value: boolean): boolean;
  101158. /**
  101159. * An event triggered when this mesh collides with another one
  101160. */
  101161. onCollideObservable: Observable<AbstractMesh>;
  101162. /** Set a function to call when this mesh collides with another one */
  101163. set onCollide(callback: () => void);
  101164. /**
  101165. * An event triggered when the collision's position changes
  101166. */
  101167. onCollisionPositionChangeObservable: Observable<Vector3>;
  101168. /** Set a function to call when the collision's position changes */
  101169. set onCollisionPositionChange(callback: () => void);
  101170. /**
  101171. * An event triggered when material is changed
  101172. */
  101173. onMaterialChangedObservable: Observable<AbstractMesh>;
  101174. /**
  101175. * Gets or sets the orientation for POV movement & rotation
  101176. */
  101177. definedFacingForward: boolean;
  101178. /** @hidden */
  101179. _occlusionQuery: Nullable<WebGLQuery>;
  101180. /** @hidden */
  101181. _renderingGroup: Nullable<RenderingGroup>;
  101182. /**
  101183. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101184. */
  101185. get visibility(): number;
  101186. /**
  101187. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101188. */
  101189. set visibility(value: number);
  101190. /** Gets or sets the alpha index used to sort transparent meshes
  101191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101192. */
  101193. alphaIndex: number;
  101194. /**
  101195. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101196. */
  101197. isVisible: boolean;
  101198. /**
  101199. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101200. */
  101201. isPickable: boolean;
  101202. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101203. showSubMeshesBoundingBox: boolean;
  101204. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101206. */
  101207. isBlocker: boolean;
  101208. /**
  101209. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101210. */
  101211. enablePointerMoveEvents: boolean;
  101212. /**
  101213. * Specifies the rendering group id for this mesh (0 by default)
  101214. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101215. */
  101216. renderingGroupId: number;
  101217. private _material;
  101218. /** Gets or sets current material */
  101219. get material(): Nullable<Material>;
  101220. set material(value: Nullable<Material>);
  101221. /**
  101222. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101223. * @see http://doc.babylonjs.com/babylon101/shadows
  101224. */
  101225. get receiveShadows(): boolean;
  101226. set receiveShadows(value: boolean);
  101227. /** Defines color to use when rendering outline */
  101228. outlineColor: Color3;
  101229. /** Define width to use when rendering outline */
  101230. outlineWidth: number;
  101231. /** Defines color to use when rendering overlay */
  101232. overlayColor: Color3;
  101233. /** Defines alpha to use when rendering overlay */
  101234. overlayAlpha: number;
  101235. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101236. get hasVertexAlpha(): boolean;
  101237. set hasVertexAlpha(value: boolean);
  101238. /** 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) */
  101239. get useVertexColors(): boolean;
  101240. set useVertexColors(value: boolean);
  101241. /**
  101242. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101243. */
  101244. get computeBonesUsingShaders(): boolean;
  101245. set computeBonesUsingShaders(value: boolean);
  101246. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101247. get numBoneInfluencers(): number;
  101248. set numBoneInfluencers(value: number);
  101249. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101250. get applyFog(): boolean;
  101251. set applyFog(value: boolean);
  101252. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101253. useOctreeForRenderingSelection: boolean;
  101254. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101255. useOctreeForPicking: boolean;
  101256. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101257. useOctreeForCollisions: boolean;
  101258. /**
  101259. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101260. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101261. */
  101262. get layerMask(): number;
  101263. set layerMask(value: number);
  101264. /**
  101265. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101266. */
  101267. alwaysSelectAsActiveMesh: boolean;
  101268. /**
  101269. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101270. */
  101271. doNotSyncBoundingInfo: boolean;
  101272. /**
  101273. * Gets or sets the current action manager
  101274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101275. */
  101276. actionManager: Nullable<AbstractActionManager>;
  101277. private _meshCollisionData;
  101278. /**
  101279. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101281. */
  101282. ellipsoid: Vector3;
  101283. /**
  101284. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101285. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101286. */
  101287. ellipsoidOffset: Vector3;
  101288. /**
  101289. * Gets or sets a collision mask used to mask collisions (default is -1).
  101290. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101291. */
  101292. get collisionMask(): number;
  101293. set collisionMask(mask: number);
  101294. /**
  101295. * Gets or sets the current collision group mask (-1 by default).
  101296. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101297. */
  101298. get collisionGroup(): number;
  101299. set collisionGroup(mask: number);
  101300. /**
  101301. * Defines edge width used when edgesRenderer is enabled
  101302. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101303. */
  101304. edgesWidth: number;
  101305. /**
  101306. * Defines edge color used when edgesRenderer is enabled
  101307. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101308. */
  101309. edgesColor: Color4;
  101310. /** @hidden */
  101311. _edgesRenderer: Nullable<IEdgesRenderer>;
  101312. /** @hidden */
  101313. _masterMesh: Nullable<AbstractMesh>;
  101314. /** @hidden */
  101315. _boundingInfo: Nullable<BoundingInfo>;
  101316. /** @hidden */
  101317. _renderId: number;
  101318. /**
  101319. * Gets or sets the list of subMeshes
  101320. * @see http://doc.babylonjs.com/how_to/multi_materials
  101321. */
  101322. subMeshes: SubMesh[];
  101323. /** @hidden */
  101324. _intersectionsInProgress: AbstractMesh[];
  101325. /** @hidden */
  101326. _unIndexed: boolean;
  101327. /** @hidden */
  101328. _lightSources: Light[];
  101329. /** Gets the list of lights affecting that mesh */
  101330. get lightSources(): Light[];
  101331. /** @hidden */
  101332. get _positions(): Nullable<Vector3[]>;
  101333. /** @hidden */
  101334. _waitingData: {
  101335. lods: Nullable<any>;
  101336. actions: Nullable<any>;
  101337. freezeWorldMatrix: Nullable<boolean>;
  101338. };
  101339. /** @hidden */
  101340. _bonesTransformMatrices: Nullable<Float32Array>;
  101341. /** @hidden */
  101342. _transformMatrixTexture: Nullable<RawTexture>;
  101343. /**
  101344. * Gets or sets a skeleton to apply skining transformations
  101345. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101346. */
  101347. set skeleton(value: Nullable<Skeleton>);
  101348. get skeleton(): Nullable<Skeleton>;
  101349. /**
  101350. * An event triggered when the mesh is rebuilt.
  101351. */
  101352. onRebuildObservable: Observable<AbstractMesh>;
  101353. /**
  101354. * Creates a new AbstractMesh
  101355. * @param name defines the name of the mesh
  101356. * @param scene defines the hosting scene
  101357. */
  101358. constructor(name: string, scene?: Nullable<Scene>);
  101359. /**
  101360. * Returns the string "AbstractMesh"
  101361. * @returns "AbstractMesh"
  101362. */
  101363. getClassName(): string;
  101364. /**
  101365. * Gets a string representation of the current mesh
  101366. * @param fullDetails defines a boolean indicating if full details must be included
  101367. * @returns a string representation of the current mesh
  101368. */
  101369. toString(fullDetails?: boolean): string;
  101370. /**
  101371. * @hidden
  101372. */
  101373. protected _getEffectiveParent(): Nullable<Node>;
  101374. /** @hidden */
  101375. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101376. /** @hidden */
  101377. _rebuild(): void;
  101378. /** @hidden */
  101379. _resyncLightSources(): void;
  101380. /** @hidden */
  101381. _resyncLightSource(light: Light): void;
  101382. /** @hidden */
  101383. _unBindEffect(): void;
  101384. /** @hidden */
  101385. _removeLightSource(light: Light, dispose: boolean): void;
  101386. private _markSubMeshesAsDirty;
  101387. /** @hidden */
  101388. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101389. /** @hidden */
  101390. _markSubMeshesAsAttributesDirty(): void;
  101391. /** @hidden */
  101392. _markSubMeshesAsMiscDirty(): void;
  101393. /**
  101394. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101395. */
  101396. get scaling(): Vector3;
  101397. set scaling(newScaling: Vector3);
  101398. /**
  101399. * Returns true if the mesh is blocked. Implemented by child classes
  101400. */
  101401. get isBlocked(): boolean;
  101402. /**
  101403. * Returns the mesh itself by default. Implemented by child classes
  101404. * @param camera defines the camera to use to pick the right LOD level
  101405. * @returns the currentAbstractMesh
  101406. */
  101407. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101408. /**
  101409. * Returns 0 by default. Implemented by child classes
  101410. * @returns an integer
  101411. */
  101412. getTotalVertices(): number;
  101413. /**
  101414. * Returns a positive integer : the total number of indices in this mesh geometry.
  101415. * @returns the numner of indices or zero if the mesh has no geometry.
  101416. */
  101417. getTotalIndices(): number;
  101418. /**
  101419. * Returns null by default. Implemented by child classes
  101420. * @returns null
  101421. */
  101422. getIndices(): Nullable<IndicesArray>;
  101423. /**
  101424. * Returns the array of the requested vertex data kind. Implemented by child classes
  101425. * @param kind defines the vertex data kind to use
  101426. * @returns null
  101427. */
  101428. getVerticesData(kind: string): Nullable<FloatArray>;
  101429. /**
  101430. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101431. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101432. * Note that a new underlying VertexBuffer object is created each call.
  101433. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101434. * @param kind defines vertex data kind:
  101435. * * VertexBuffer.PositionKind
  101436. * * VertexBuffer.UVKind
  101437. * * VertexBuffer.UV2Kind
  101438. * * VertexBuffer.UV3Kind
  101439. * * VertexBuffer.UV4Kind
  101440. * * VertexBuffer.UV5Kind
  101441. * * VertexBuffer.UV6Kind
  101442. * * VertexBuffer.ColorKind
  101443. * * VertexBuffer.MatricesIndicesKind
  101444. * * VertexBuffer.MatricesIndicesExtraKind
  101445. * * VertexBuffer.MatricesWeightsKind
  101446. * * VertexBuffer.MatricesWeightsExtraKind
  101447. * @param data defines the data source
  101448. * @param updatable defines if the data must be flagged as updatable (or static)
  101449. * @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
  101450. * @returns the current mesh
  101451. */
  101452. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101453. /**
  101454. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101455. * If the mesh has no geometry, it is simply returned as it is.
  101456. * @param kind defines vertex data kind:
  101457. * * VertexBuffer.PositionKind
  101458. * * VertexBuffer.UVKind
  101459. * * VertexBuffer.UV2Kind
  101460. * * VertexBuffer.UV3Kind
  101461. * * VertexBuffer.UV4Kind
  101462. * * VertexBuffer.UV5Kind
  101463. * * VertexBuffer.UV6Kind
  101464. * * VertexBuffer.ColorKind
  101465. * * VertexBuffer.MatricesIndicesKind
  101466. * * VertexBuffer.MatricesIndicesExtraKind
  101467. * * VertexBuffer.MatricesWeightsKind
  101468. * * VertexBuffer.MatricesWeightsExtraKind
  101469. * @param data defines the data source
  101470. * @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
  101471. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101472. * @returns the current mesh
  101473. */
  101474. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101475. /**
  101476. * Sets the mesh indices,
  101477. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101478. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101479. * @param totalVertices Defines the total number of vertices
  101480. * @returns the current mesh
  101481. */
  101482. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101483. /**
  101484. * Gets a boolean indicating if specific vertex data is present
  101485. * @param kind defines the vertex data kind to use
  101486. * @returns true is data kind is present
  101487. */
  101488. isVerticesDataPresent(kind: string): boolean;
  101489. /**
  101490. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101491. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101492. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101493. * @returns a BoundingInfo
  101494. */
  101495. getBoundingInfo(): BoundingInfo;
  101496. /**
  101497. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101498. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101499. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101500. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101501. * @returns the current mesh
  101502. */
  101503. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101504. /**
  101505. * Overwrite the current bounding info
  101506. * @param boundingInfo defines the new bounding info
  101507. * @returns the current mesh
  101508. */
  101509. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101510. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101511. get useBones(): boolean;
  101512. /** @hidden */
  101513. _preActivate(): void;
  101514. /** @hidden */
  101515. _preActivateForIntermediateRendering(renderId: number): void;
  101516. /** @hidden */
  101517. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101518. /** @hidden */
  101519. _postActivate(): void;
  101520. /** @hidden */
  101521. _freeze(): void;
  101522. /** @hidden */
  101523. _unFreeze(): void;
  101524. /**
  101525. * Gets the current world matrix
  101526. * @returns a Matrix
  101527. */
  101528. getWorldMatrix(): Matrix;
  101529. /** @hidden */
  101530. _getWorldMatrixDeterminant(): number;
  101531. /**
  101532. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101533. */
  101534. get isAnInstance(): boolean;
  101535. /**
  101536. * Gets a boolean indicating if this mesh has instances
  101537. */
  101538. get hasInstances(): boolean;
  101539. /**
  101540. * Perform relative position change from the point of view of behind the front of the mesh.
  101541. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101542. * Supports definition of mesh facing forward or backward
  101543. * @param amountRight defines the distance on the right axis
  101544. * @param amountUp defines the distance on the up axis
  101545. * @param amountForward defines the distance on the forward axis
  101546. * @returns the current mesh
  101547. */
  101548. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101549. /**
  101550. * Calculate relative position change from the point of view of behind the front of the mesh.
  101551. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101552. * Supports definition of mesh facing forward or backward
  101553. * @param amountRight defines the distance on the right axis
  101554. * @param amountUp defines the distance on the up axis
  101555. * @param amountForward defines the distance on the forward axis
  101556. * @returns the new displacement vector
  101557. */
  101558. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101559. /**
  101560. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101561. * Supports definition of mesh facing forward or backward
  101562. * @param flipBack defines the flip
  101563. * @param twirlClockwise defines the twirl
  101564. * @param tiltRight defines the tilt
  101565. * @returns the current mesh
  101566. */
  101567. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101568. /**
  101569. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101570. * Supports definition of mesh facing forward or backward.
  101571. * @param flipBack defines the flip
  101572. * @param twirlClockwise defines the twirl
  101573. * @param tiltRight defines the tilt
  101574. * @returns the new rotation vector
  101575. */
  101576. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101577. /**
  101578. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101579. * This means the mesh underlying bounding box and sphere are recomputed.
  101580. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101581. * @returns the current mesh
  101582. */
  101583. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101584. /** @hidden */
  101585. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101586. /** @hidden */
  101587. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101588. /** @hidden */
  101589. _updateBoundingInfo(): AbstractMesh;
  101590. /** @hidden */
  101591. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101592. /** @hidden */
  101593. protected _afterComputeWorldMatrix(): void;
  101594. /** @hidden */
  101595. get _effectiveMesh(): AbstractMesh;
  101596. /**
  101597. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101598. * A mesh is in the frustum if its bounding box intersects the frustum
  101599. * @param frustumPlanes defines the frustum to test
  101600. * @returns true if the mesh is in the frustum planes
  101601. */
  101602. isInFrustum(frustumPlanes: Plane[]): boolean;
  101603. /**
  101604. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101605. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101606. * @param frustumPlanes defines the frustum to test
  101607. * @returns true if the mesh is completely in the frustum planes
  101608. */
  101609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101610. /**
  101611. * True if the mesh intersects another mesh or a SolidParticle object
  101612. * @param mesh defines a target mesh or SolidParticle to test
  101613. * @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)
  101614. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101615. * @returns true if there is an intersection
  101616. */
  101617. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101618. /**
  101619. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101620. * @param point defines the point to test
  101621. * @returns true if there is an intersection
  101622. */
  101623. intersectsPoint(point: Vector3): boolean;
  101624. /**
  101625. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101627. */
  101628. get checkCollisions(): boolean;
  101629. set checkCollisions(collisionEnabled: boolean);
  101630. /**
  101631. * Gets Collider object used to compute collisions (not physics)
  101632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101633. */
  101634. get collider(): Nullable<Collider>;
  101635. /**
  101636. * Move the mesh using collision engine
  101637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101638. * @param displacement defines the requested displacement vector
  101639. * @returns the current mesh
  101640. */
  101641. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101642. private _onCollisionPositionChange;
  101643. /** @hidden */
  101644. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101645. /** @hidden */
  101646. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101647. /** @hidden */
  101648. _checkCollision(collider: Collider): AbstractMesh;
  101649. /** @hidden */
  101650. _generatePointsArray(): boolean;
  101651. /**
  101652. * Checks if the passed Ray intersects with the mesh
  101653. * @param ray defines the ray to use
  101654. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101656. * @returns the picking info
  101657. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101658. */
  101659. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101660. /**
  101661. * Clones the current mesh
  101662. * @param name defines the mesh name
  101663. * @param newParent defines the new mesh parent
  101664. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101665. * @returns the new mesh
  101666. */
  101667. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101668. /**
  101669. * Disposes all the submeshes of the current meshnp
  101670. * @returns the current mesh
  101671. */
  101672. releaseSubMeshes(): AbstractMesh;
  101673. /**
  101674. * Releases resources associated with this abstract mesh.
  101675. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101676. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101677. */
  101678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101679. /**
  101680. * Adds the passed mesh as a child to the current mesh
  101681. * @param mesh defines the child mesh
  101682. * @returns the current mesh
  101683. */
  101684. addChild(mesh: AbstractMesh): AbstractMesh;
  101685. /**
  101686. * Removes the passed mesh from the current mesh children list
  101687. * @param mesh defines the child mesh
  101688. * @returns the current mesh
  101689. */
  101690. removeChild(mesh: AbstractMesh): AbstractMesh;
  101691. /** @hidden */
  101692. private _initFacetData;
  101693. /**
  101694. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101695. * This method can be called within the render loop.
  101696. * 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
  101697. * @returns the current mesh
  101698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101699. */
  101700. updateFacetData(): AbstractMesh;
  101701. /**
  101702. * Returns the facetLocalNormals array.
  101703. * The normals are expressed in the mesh local spac
  101704. * @returns an array of Vector3
  101705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101706. */
  101707. getFacetLocalNormals(): Vector3[];
  101708. /**
  101709. * Returns the facetLocalPositions array.
  101710. * The facet positions are expressed in the mesh local space
  101711. * @returns an array of Vector3
  101712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101713. */
  101714. getFacetLocalPositions(): Vector3[];
  101715. /**
  101716. * Returns the facetLocalPartioning array
  101717. * @returns an array of array of numbers
  101718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101719. */
  101720. getFacetLocalPartitioning(): number[][];
  101721. /**
  101722. * Returns the i-th facet position in the world system.
  101723. * This method allocates a new Vector3 per call
  101724. * @param i defines the facet index
  101725. * @returns a new Vector3
  101726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101727. */
  101728. getFacetPosition(i: number): Vector3;
  101729. /**
  101730. * Sets the reference Vector3 with the i-th facet position in the world system
  101731. * @param i defines the facet index
  101732. * @param ref defines the target vector
  101733. * @returns the current mesh
  101734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101735. */
  101736. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101737. /**
  101738. * Returns the i-th facet normal in the world system.
  101739. * This method allocates a new Vector3 per call
  101740. * @param i defines the facet index
  101741. * @returns a new Vector3
  101742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101743. */
  101744. getFacetNormal(i: number): Vector3;
  101745. /**
  101746. * Sets the reference Vector3 with the i-th facet normal in the world system
  101747. * @param i defines the facet index
  101748. * @param ref defines the target vector
  101749. * @returns the current mesh
  101750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101751. */
  101752. getFacetNormalToRef(i: number, ref: Vector3): this;
  101753. /**
  101754. * 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)
  101755. * @param x defines x coordinate
  101756. * @param y defines y coordinate
  101757. * @param z defines z coordinate
  101758. * @returns the array of facet indexes
  101759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101760. */
  101761. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101762. /**
  101763. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101764. * @param projected sets as the (x,y,z) world projection on the facet
  101765. * @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
  101766. * @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
  101767. * @param x defines x coordinate
  101768. * @param y defines y coordinate
  101769. * @param z defines z coordinate
  101770. * @returns the face index if found (or null instead)
  101771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101772. */
  101773. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101774. /**
  101775. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101776. * @param projected sets as the (x,y,z) local projection on the facet
  101777. * @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
  101778. * @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
  101779. * @param x defines x coordinate
  101780. * @param y defines y coordinate
  101781. * @param z defines z coordinate
  101782. * @returns the face index if found (or null instead)
  101783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101784. */
  101785. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101786. /**
  101787. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101788. * @returns the parameters
  101789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101790. */
  101791. getFacetDataParameters(): any;
  101792. /**
  101793. * Disables the feature FacetData and frees the related memory
  101794. * @returns the current mesh
  101795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101796. */
  101797. disableFacetData(): AbstractMesh;
  101798. /**
  101799. * Updates the AbstractMesh indices array
  101800. * @param indices defines the data source
  101801. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101802. * @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)
  101803. * @returns the current mesh
  101804. */
  101805. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101806. /**
  101807. * Creates new normals data for the mesh
  101808. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101809. * @returns the current mesh
  101810. */
  101811. createNormals(updatable: boolean): AbstractMesh;
  101812. /**
  101813. * Align the mesh with a normal
  101814. * @param normal defines the normal to use
  101815. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101816. * @returns the current mesh
  101817. */
  101818. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101819. /** @hidden */
  101820. _checkOcclusionQuery(): boolean;
  101821. /**
  101822. * Disables the mesh edge rendering mode
  101823. * @returns the currentAbstractMesh
  101824. */
  101825. disableEdgesRendering(): AbstractMesh;
  101826. /**
  101827. * Enables the edge rendering mode on the mesh.
  101828. * This mode makes the mesh edges visible
  101829. * @param epsilon defines the maximal distance between two angles to detect a face
  101830. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101831. * @returns the currentAbstractMesh
  101832. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101833. */
  101834. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101835. }
  101836. }
  101837. declare module BABYLON {
  101838. /**
  101839. * Interface used to define ActionEvent
  101840. */
  101841. export interface IActionEvent {
  101842. /** The mesh or sprite that triggered the action */
  101843. source: any;
  101844. /** The X mouse cursor position at the time of the event */
  101845. pointerX: number;
  101846. /** The Y mouse cursor position at the time of the event */
  101847. pointerY: number;
  101848. /** The mesh that is currently pointed at (can be null) */
  101849. meshUnderPointer: Nullable<AbstractMesh>;
  101850. /** the original (browser) event that triggered the ActionEvent */
  101851. sourceEvent?: any;
  101852. /** additional data for the event */
  101853. additionalData?: any;
  101854. }
  101855. /**
  101856. * ActionEvent is the event being sent when an action is triggered.
  101857. */
  101858. export class ActionEvent implements IActionEvent {
  101859. /** The mesh or sprite that triggered the action */
  101860. source: any;
  101861. /** The X mouse cursor position at the time of the event */
  101862. pointerX: number;
  101863. /** The Y mouse cursor position at the time of the event */
  101864. pointerY: number;
  101865. /** The mesh that is currently pointed at (can be null) */
  101866. meshUnderPointer: Nullable<AbstractMesh>;
  101867. /** the original (browser) event that triggered the ActionEvent */
  101868. sourceEvent?: any;
  101869. /** additional data for the event */
  101870. additionalData?: any;
  101871. /**
  101872. * Creates a new ActionEvent
  101873. * @param source The mesh or sprite that triggered the action
  101874. * @param pointerX The X mouse cursor position at the time of the event
  101875. * @param pointerY The Y mouse cursor position at the time of the event
  101876. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101877. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101878. * @param additionalData additional data for the event
  101879. */
  101880. constructor(
  101881. /** The mesh or sprite that triggered the action */
  101882. source: any,
  101883. /** The X mouse cursor position at the time of the event */
  101884. pointerX: number,
  101885. /** The Y mouse cursor position at the time of the event */
  101886. pointerY: number,
  101887. /** The mesh that is currently pointed at (can be null) */
  101888. meshUnderPointer: Nullable<AbstractMesh>,
  101889. /** the original (browser) event that triggered the ActionEvent */
  101890. sourceEvent?: any,
  101891. /** additional data for the event */
  101892. additionalData?: any);
  101893. /**
  101894. * Helper function to auto-create an ActionEvent from a source mesh.
  101895. * @param source The source mesh that triggered the event
  101896. * @param evt The original (browser) event
  101897. * @param additionalData additional data for the event
  101898. * @returns the new ActionEvent
  101899. */
  101900. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101901. /**
  101902. * Helper function to auto-create an ActionEvent from a source sprite
  101903. * @param source The source sprite that triggered the event
  101904. * @param scene Scene associated with the sprite
  101905. * @param evt The original (browser) event
  101906. * @param additionalData additional data for the event
  101907. * @returns the new ActionEvent
  101908. */
  101909. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101910. /**
  101911. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101912. * @param scene the scene where the event occurred
  101913. * @param evt The original (browser) event
  101914. * @returns the new ActionEvent
  101915. */
  101916. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101917. /**
  101918. * Helper function to auto-create an ActionEvent from a primitive
  101919. * @param prim defines the target primitive
  101920. * @param pointerPos defines the pointer position
  101921. * @param evt The original (browser) event
  101922. * @param additionalData additional data for the event
  101923. * @returns the new ActionEvent
  101924. */
  101925. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101926. }
  101927. }
  101928. declare module BABYLON {
  101929. /**
  101930. * Abstract class used to decouple action Manager from scene and meshes.
  101931. * Do not instantiate.
  101932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101933. */
  101934. export abstract class AbstractActionManager implements IDisposable {
  101935. /** Gets the list of active triggers */
  101936. static Triggers: {
  101937. [key: string]: number;
  101938. };
  101939. /** Gets the cursor to use when hovering items */
  101940. hoverCursor: string;
  101941. /** Gets the list of actions */
  101942. actions: IAction[];
  101943. /**
  101944. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101945. */
  101946. isRecursive: boolean;
  101947. /**
  101948. * Releases all associated resources
  101949. */
  101950. abstract dispose(): void;
  101951. /**
  101952. * Does this action manager has pointer triggers
  101953. */
  101954. abstract get hasPointerTriggers(): boolean;
  101955. /**
  101956. * Does this action manager has pick triggers
  101957. */
  101958. abstract get hasPickTriggers(): boolean;
  101959. /**
  101960. * Process a specific trigger
  101961. * @param trigger defines the trigger to process
  101962. * @param evt defines the event details to be processed
  101963. */
  101964. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101965. /**
  101966. * Does this action manager handles actions of any of the given triggers
  101967. * @param triggers defines the triggers to be tested
  101968. * @return a boolean indicating whether one (or more) of the triggers is handled
  101969. */
  101970. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101971. /**
  101972. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101973. * speed.
  101974. * @param triggerA defines the trigger to be tested
  101975. * @param triggerB defines the trigger to be tested
  101976. * @return a boolean indicating whether one (or more) of the triggers is handled
  101977. */
  101978. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101979. /**
  101980. * Does this action manager handles actions of a given trigger
  101981. * @param trigger defines the trigger to be tested
  101982. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101983. * @return whether the trigger is handled
  101984. */
  101985. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101986. /**
  101987. * Serialize this manager to a JSON object
  101988. * @param name defines the property name to store this manager
  101989. * @returns a JSON representation of this manager
  101990. */
  101991. abstract serialize(name: string): any;
  101992. /**
  101993. * Registers an action to this action manager
  101994. * @param action defines the action to be registered
  101995. * @return the action amended (prepared) after registration
  101996. */
  101997. abstract registerAction(action: IAction): Nullable<IAction>;
  101998. /**
  101999. * Unregisters an action to this action manager
  102000. * @param action defines the action to be unregistered
  102001. * @return a boolean indicating whether the action has been unregistered
  102002. */
  102003. abstract unregisterAction(action: IAction): Boolean;
  102004. /**
  102005. * Does exist one action manager with at least one trigger
  102006. **/
  102007. static get HasTriggers(): boolean;
  102008. /**
  102009. * Does exist one action manager with at least one pick trigger
  102010. **/
  102011. static get HasPickTriggers(): boolean;
  102012. /**
  102013. * Does exist one action manager that handles actions of a given trigger
  102014. * @param trigger defines the trigger to be tested
  102015. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102016. **/
  102017. static HasSpecificTrigger(trigger: number): boolean;
  102018. }
  102019. }
  102020. declare module BABYLON {
  102021. /**
  102022. * Defines how a node can be built from a string name.
  102023. */
  102024. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102025. /**
  102026. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102027. */
  102028. export class Node implements IBehaviorAware<Node> {
  102029. /** @hidden */
  102030. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102031. private static _NodeConstructors;
  102032. /**
  102033. * Add a new node constructor
  102034. * @param type defines the type name of the node to construct
  102035. * @param constructorFunc defines the constructor function
  102036. */
  102037. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102038. /**
  102039. * Returns a node constructor based on type name
  102040. * @param type defines the type name
  102041. * @param name defines the new node name
  102042. * @param scene defines the hosting scene
  102043. * @param options defines optional options to transmit to constructors
  102044. * @returns the new constructor or null
  102045. */
  102046. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102047. /**
  102048. * Gets or sets the name of the node
  102049. */
  102050. name: string;
  102051. /**
  102052. * Gets or sets the id of the node
  102053. */
  102054. id: string;
  102055. /**
  102056. * Gets or sets the unique id of the node
  102057. */
  102058. uniqueId: number;
  102059. /**
  102060. * Gets or sets a string used to store user defined state for the node
  102061. */
  102062. state: string;
  102063. /**
  102064. * Gets or sets an object used to store user defined information for the node
  102065. */
  102066. metadata: any;
  102067. /**
  102068. * For internal use only. Please do not use.
  102069. */
  102070. reservedDataStore: any;
  102071. /**
  102072. * List of inspectable custom properties (used by the Inspector)
  102073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102074. */
  102075. inspectableCustomProperties: IInspectable[];
  102076. private _doNotSerialize;
  102077. /**
  102078. * Gets or sets a boolean used to define if the node must be serialized
  102079. */
  102080. get doNotSerialize(): boolean;
  102081. set doNotSerialize(value: boolean);
  102082. /** @hidden */
  102083. _isDisposed: boolean;
  102084. /**
  102085. * Gets a list of Animations associated with the node
  102086. */
  102087. animations: Animation[];
  102088. protected _ranges: {
  102089. [name: string]: Nullable<AnimationRange>;
  102090. };
  102091. /**
  102092. * Callback raised when the node is ready to be used
  102093. */
  102094. onReady: Nullable<(node: Node) => void>;
  102095. private _isEnabled;
  102096. private _isParentEnabled;
  102097. private _isReady;
  102098. /** @hidden */
  102099. _currentRenderId: number;
  102100. private _parentUpdateId;
  102101. /** @hidden */
  102102. _childUpdateId: number;
  102103. /** @hidden */
  102104. _waitingParentId: Nullable<string>;
  102105. /** @hidden */
  102106. _scene: Scene;
  102107. /** @hidden */
  102108. _cache: any;
  102109. private _parentNode;
  102110. private _children;
  102111. /** @hidden */
  102112. _worldMatrix: Matrix;
  102113. /** @hidden */
  102114. _worldMatrixDeterminant: number;
  102115. /** @hidden */
  102116. _worldMatrixDeterminantIsDirty: boolean;
  102117. /** @hidden */
  102118. private _sceneRootNodesIndex;
  102119. /**
  102120. * Gets a boolean indicating if the node has been disposed
  102121. * @returns true if the node was disposed
  102122. */
  102123. isDisposed(): boolean;
  102124. /**
  102125. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102126. * @see https://doc.babylonjs.com/how_to/parenting
  102127. */
  102128. set parent(parent: Nullable<Node>);
  102129. get parent(): Nullable<Node>;
  102130. /** @hidden */
  102131. _addToSceneRootNodes(): void;
  102132. /** @hidden */
  102133. _removeFromSceneRootNodes(): void;
  102134. private _animationPropertiesOverride;
  102135. /**
  102136. * Gets or sets the animation properties override
  102137. */
  102138. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102139. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102140. /**
  102141. * Gets a string idenfifying the name of the class
  102142. * @returns "Node" string
  102143. */
  102144. getClassName(): string;
  102145. /** @hidden */
  102146. readonly _isNode: boolean;
  102147. /**
  102148. * An event triggered when the mesh is disposed
  102149. */
  102150. onDisposeObservable: Observable<Node>;
  102151. private _onDisposeObserver;
  102152. /**
  102153. * Sets a callback that will be raised when the node will be disposed
  102154. */
  102155. set onDispose(callback: () => void);
  102156. /**
  102157. * Creates a new Node
  102158. * @param name the name and id to be given to this node
  102159. * @param scene the scene this node will be added to
  102160. */
  102161. constructor(name: string, scene?: Nullable<Scene>);
  102162. /**
  102163. * Gets the scene of the node
  102164. * @returns a scene
  102165. */
  102166. getScene(): Scene;
  102167. /**
  102168. * Gets the engine of the node
  102169. * @returns a Engine
  102170. */
  102171. getEngine(): Engine;
  102172. private _behaviors;
  102173. /**
  102174. * Attach a behavior to the node
  102175. * @see http://doc.babylonjs.com/features/behaviour
  102176. * @param behavior defines the behavior to attach
  102177. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102178. * @returns the current Node
  102179. */
  102180. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102181. /**
  102182. * Remove an attached behavior
  102183. * @see http://doc.babylonjs.com/features/behaviour
  102184. * @param behavior defines the behavior to attach
  102185. * @returns the current Node
  102186. */
  102187. removeBehavior(behavior: Behavior<Node>): Node;
  102188. /**
  102189. * Gets the list of attached behaviors
  102190. * @see http://doc.babylonjs.com/features/behaviour
  102191. */
  102192. get behaviors(): Behavior<Node>[];
  102193. /**
  102194. * Gets an attached behavior by name
  102195. * @param name defines the name of the behavior to look for
  102196. * @see http://doc.babylonjs.com/features/behaviour
  102197. * @returns null if behavior was not found else the requested behavior
  102198. */
  102199. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102200. /**
  102201. * Returns the latest update of the World matrix
  102202. * @returns a Matrix
  102203. */
  102204. getWorldMatrix(): Matrix;
  102205. /** @hidden */
  102206. _getWorldMatrixDeterminant(): number;
  102207. /**
  102208. * Returns directly the latest state of the mesh World matrix.
  102209. * A Matrix is returned.
  102210. */
  102211. get worldMatrixFromCache(): Matrix;
  102212. /** @hidden */
  102213. _initCache(): void;
  102214. /** @hidden */
  102215. updateCache(force?: boolean): void;
  102216. /** @hidden */
  102217. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102218. /** @hidden */
  102219. _updateCache(ignoreParentClass?: boolean): void;
  102220. /** @hidden */
  102221. _isSynchronized(): boolean;
  102222. /** @hidden */
  102223. _markSyncedWithParent(): void;
  102224. /** @hidden */
  102225. isSynchronizedWithParent(): boolean;
  102226. /** @hidden */
  102227. isSynchronized(): boolean;
  102228. /**
  102229. * Is this node ready to be used/rendered
  102230. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102231. * @return true if the node is ready
  102232. */
  102233. isReady(completeCheck?: boolean): boolean;
  102234. /**
  102235. * Is this node enabled?
  102236. * 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
  102237. * @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
  102238. * @return whether this node (and its parent) is enabled
  102239. */
  102240. isEnabled(checkAncestors?: boolean): boolean;
  102241. /** @hidden */
  102242. protected _syncParentEnabledState(): void;
  102243. /**
  102244. * Set the enabled state of this node
  102245. * @param value defines the new enabled state
  102246. */
  102247. setEnabled(value: boolean): void;
  102248. /**
  102249. * Is this node a descendant of the given node?
  102250. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102251. * @param ancestor defines the parent node to inspect
  102252. * @returns a boolean indicating if this node is a descendant of the given node
  102253. */
  102254. isDescendantOf(ancestor: Node): boolean;
  102255. /** @hidden */
  102256. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102257. /**
  102258. * Will return all nodes that have this node as ascendant
  102259. * @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
  102260. * @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
  102261. * @return all children nodes of all types
  102262. */
  102263. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102264. /**
  102265. * Get all child-meshes of this node
  102266. * @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)
  102267. * @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
  102268. * @returns an array of AbstractMesh
  102269. */
  102270. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102271. /**
  102272. * Get all direct children of this node
  102273. * @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
  102274. * @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)
  102275. * @returns an array of Node
  102276. */
  102277. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102278. /** @hidden */
  102279. _setReady(state: boolean): void;
  102280. /**
  102281. * Get an animation by name
  102282. * @param name defines the name of the animation to look for
  102283. * @returns null if not found else the requested animation
  102284. */
  102285. getAnimationByName(name: string): Nullable<Animation>;
  102286. /**
  102287. * Creates an animation range for this node
  102288. * @param name defines the name of the range
  102289. * @param from defines the starting key
  102290. * @param to defines the end key
  102291. */
  102292. createAnimationRange(name: string, from: number, to: number): void;
  102293. /**
  102294. * Delete a specific animation range
  102295. * @param name defines the name of the range to delete
  102296. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102297. */
  102298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102299. /**
  102300. * Get an animation range by name
  102301. * @param name defines the name of the animation range to look for
  102302. * @returns null if not found else the requested animation range
  102303. */
  102304. getAnimationRange(name: string): Nullable<AnimationRange>;
  102305. /**
  102306. * Gets the list of all animation ranges defined on this node
  102307. * @returns an array
  102308. */
  102309. getAnimationRanges(): Nullable<AnimationRange>[];
  102310. /**
  102311. * Will start the animation sequence
  102312. * @param name defines the range frames for animation sequence
  102313. * @param loop defines if the animation should loop (false by default)
  102314. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102315. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102316. * @returns the object created for this animation. If range does not exist, it will return null
  102317. */
  102318. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102319. /**
  102320. * Serialize animation ranges into a JSON compatible object
  102321. * @returns serialization object
  102322. */
  102323. serializeAnimationRanges(): any;
  102324. /**
  102325. * Computes the world matrix of the node
  102326. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102327. * @returns the world matrix
  102328. */
  102329. computeWorldMatrix(force?: boolean): Matrix;
  102330. /**
  102331. * Releases resources associated with this node.
  102332. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102333. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102334. */
  102335. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102336. /**
  102337. * Parse animation range data from a serialization object and store them into a given node
  102338. * @param node defines where to store the animation ranges
  102339. * @param parsedNode defines the serialization object to read data from
  102340. * @param scene defines the hosting scene
  102341. */
  102342. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102343. /**
  102344. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102345. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102346. * @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
  102347. * @returns the new bounding vectors
  102348. */
  102349. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102350. min: Vector3;
  102351. max: Vector3;
  102352. };
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /**
  102357. * @hidden
  102358. */
  102359. export class _IAnimationState {
  102360. key: number;
  102361. repeatCount: number;
  102362. workValue?: any;
  102363. loopMode?: number;
  102364. offsetValue?: any;
  102365. highLimitValue?: any;
  102366. }
  102367. /**
  102368. * Class used to store any kind of animation
  102369. */
  102370. export class Animation {
  102371. /**Name of the animation */
  102372. name: string;
  102373. /**Property to animate */
  102374. targetProperty: string;
  102375. /**The frames per second of the animation */
  102376. framePerSecond: number;
  102377. /**The data type of the animation */
  102378. dataType: number;
  102379. /**The loop mode of the animation */
  102380. loopMode?: number | undefined;
  102381. /**Specifies if blending should be enabled */
  102382. enableBlending?: boolean | undefined;
  102383. /**
  102384. * Use matrix interpolation instead of using direct key value when animating matrices
  102385. */
  102386. static AllowMatricesInterpolation: boolean;
  102387. /**
  102388. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102389. */
  102390. static AllowMatrixDecomposeForInterpolation: boolean;
  102391. /**
  102392. * Stores the key frames of the animation
  102393. */
  102394. private _keys;
  102395. /**
  102396. * Stores the easing function of the animation
  102397. */
  102398. private _easingFunction;
  102399. /**
  102400. * @hidden Internal use only
  102401. */
  102402. _runtimeAnimations: RuntimeAnimation[];
  102403. /**
  102404. * The set of event that will be linked to this animation
  102405. */
  102406. private _events;
  102407. /**
  102408. * Stores an array of target property paths
  102409. */
  102410. targetPropertyPath: string[];
  102411. /**
  102412. * Stores the blending speed of the animation
  102413. */
  102414. blendingSpeed: number;
  102415. /**
  102416. * Stores the animation ranges for the animation
  102417. */
  102418. private _ranges;
  102419. /**
  102420. * @hidden Internal use
  102421. */
  102422. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102423. /**
  102424. * Sets up an animation
  102425. * @param property The property to animate
  102426. * @param animationType The animation type to apply
  102427. * @param framePerSecond The frames per second of the animation
  102428. * @param easingFunction The easing function used in the animation
  102429. * @returns The created animation
  102430. */
  102431. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102432. /**
  102433. * Create and start an animation on a node
  102434. * @param name defines the name of the global animation that will be run on all nodes
  102435. * @param node defines the root node where the animation will take place
  102436. * @param targetProperty defines property to animate
  102437. * @param framePerSecond defines the number of frame per second yo use
  102438. * @param totalFrame defines the number of frames in total
  102439. * @param from defines the initial value
  102440. * @param to defines the final value
  102441. * @param loopMode defines which loop mode you want to use (off by default)
  102442. * @param easingFunction defines the easing function to use (linear by default)
  102443. * @param onAnimationEnd defines the callback to call when animation end
  102444. * @returns the animatable created for this animation
  102445. */
  102446. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102447. /**
  102448. * Create and start an animation on a node and its descendants
  102449. * @param name defines the name of the global animation that will be run on all nodes
  102450. * @param node defines the root node where the animation will take place
  102451. * @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
  102452. * @param targetProperty defines property to animate
  102453. * @param framePerSecond defines the number of frame per second to use
  102454. * @param totalFrame defines the number of frames in total
  102455. * @param from defines the initial value
  102456. * @param to defines the final value
  102457. * @param loopMode defines which loop mode you want to use (off by default)
  102458. * @param easingFunction defines the easing function to use (linear by default)
  102459. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102460. * @returns the list of animatables created for all nodes
  102461. * @example https://www.babylonjs-playground.com/#MH0VLI
  102462. */
  102463. 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[]>;
  102464. /**
  102465. * Creates a new animation, merges it with the existing animations and starts it
  102466. * @param name Name of the animation
  102467. * @param node Node which contains the scene that begins the animations
  102468. * @param targetProperty Specifies which property to animate
  102469. * @param framePerSecond The frames per second of the animation
  102470. * @param totalFrame The total number of frames
  102471. * @param from The frame at the beginning of the animation
  102472. * @param to The frame at the end of the animation
  102473. * @param loopMode Specifies the loop mode of the animation
  102474. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102475. * @param onAnimationEnd Callback to run once the animation is complete
  102476. * @returns Nullable animation
  102477. */
  102478. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102479. /**
  102480. * Transition property of an host to the target Value
  102481. * @param property The property to transition
  102482. * @param targetValue The target Value of the property
  102483. * @param host The object where the property to animate belongs
  102484. * @param scene Scene used to run the animation
  102485. * @param frameRate Framerate (in frame/s) to use
  102486. * @param transition The transition type we want to use
  102487. * @param duration The duration of the animation, in milliseconds
  102488. * @param onAnimationEnd Callback trigger at the end of the animation
  102489. * @returns Nullable animation
  102490. */
  102491. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102492. /**
  102493. * Return the array of runtime animations currently using this animation
  102494. */
  102495. get runtimeAnimations(): RuntimeAnimation[];
  102496. /**
  102497. * Specifies if any of the runtime animations are currently running
  102498. */
  102499. get hasRunningRuntimeAnimations(): boolean;
  102500. /**
  102501. * Initializes the animation
  102502. * @param name Name of the animation
  102503. * @param targetProperty Property to animate
  102504. * @param framePerSecond The frames per second of the animation
  102505. * @param dataType The data type of the animation
  102506. * @param loopMode The loop mode of the animation
  102507. * @param enableBlending Specifies if blending should be enabled
  102508. */
  102509. constructor(
  102510. /**Name of the animation */
  102511. name: string,
  102512. /**Property to animate */
  102513. targetProperty: string,
  102514. /**The frames per second of the animation */
  102515. framePerSecond: number,
  102516. /**The data type of the animation */
  102517. dataType: number,
  102518. /**The loop mode of the animation */
  102519. loopMode?: number | undefined,
  102520. /**Specifies if blending should be enabled */
  102521. enableBlending?: boolean | undefined);
  102522. /**
  102523. * Converts the animation to a string
  102524. * @param fullDetails support for multiple levels of logging within scene loading
  102525. * @returns String form of the animation
  102526. */
  102527. toString(fullDetails?: boolean): string;
  102528. /**
  102529. * Add an event to this animation
  102530. * @param event Event to add
  102531. */
  102532. addEvent(event: AnimationEvent): void;
  102533. /**
  102534. * Remove all events found at the given frame
  102535. * @param frame The frame to remove events from
  102536. */
  102537. removeEvents(frame: number): void;
  102538. /**
  102539. * Retrieves all the events from the animation
  102540. * @returns Events from the animation
  102541. */
  102542. getEvents(): AnimationEvent[];
  102543. /**
  102544. * Creates an animation range
  102545. * @param name Name of the animation range
  102546. * @param from Starting frame of the animation range
  102547. * @param to Ending frame of the animation
  102548. */
  102549. createRange(name: string, from: number, to: number): void;
  102550. /**
  102551. * Deletes an animation range by name
  102552. * @param name Name of the animation range to delete
  102553. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102554. */
  102555. deleteRange(name: string, deleteFrames?: boolean): void;
  102556. /**
  102557. * Gets the animation range by name, or null if not defined
  102558. * @param name Name of the animation range
  102559. * @returns Nullable animation range
  102560. */
  102561. getRange(name: string): Nullable<AnimationRange>;
  102562. /**
  102563. * Gets the key frames from the animation
  102564. * @returns The key frames of the animation
  102565. */
  102566. getKeys(): Array<IAnimationKey>;
  102567. /**
  102568. * Gets the highest frame rate of the animation
  102569. * @returns Highest frame rate of the animation
  102570. */
  102571. getHighestFrame(): number;
  102572. /**
  102573. * Gets the easing function of the animation
  102574. * @returns Easing function of the animation
  102575. */
  102576. getEasingFunction(): IEasingFunction;
  102577. /**
  102578. * Sets the easing function of the animation
  102579. * @param easingFunction A custom mathematical formula for animation
  102580. */
  102581. setEasingFunction(easingFunction: EasingFunction): void;
  102582. /**
  102583. * Interpolates a scalar linearly
  102584. * @param startValue Start value of the animation curve
  102585. * @param endValue End value of the animation curve
  102586. * @param gradient Scalar amount to interpolate
  102587. * @returns Interpolated scalar value
  102588. */
  102589. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102590. /**
  102591. * Interpolates a scalar cubically
  102592. * @param startValue Start value of the animation curve
  102593. * @param outTangent End tangent of the animation
  102594. * @param endValue End value of the animation curve
  102595. * @param inTangent Start tangent of the animation curve
  102596. * @param gradient Scalar amount to interpolate
  102597. * @returns Interpolated scalar value
  102598. */
  102599. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102600. /**
  102601. * Interpolates a quaternion using a spherical linear interpolation
  102602. * @param startValue Start value of the animation curve
  102603. * @param endValue End value of the animation curve
  102604. * @param gradient Scalar amount to interpolate
  102605. * @returns Interpolated quaternion value
  102606. */
  102607. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102608. /**
  102609. * Interpolates a quaternion cubically
  102610. * @param startValue Start value of the animation curve
  102611. * @param outTangent End tangent of the animation curve
  102612. * @param endValue End value of the animation curve
  102613. * @param inTangent Start tangent of the animation curve
  102614. * @param gradient Scalar amount to interpolate
  102615. * @returns Interpolated quaternion value
  102616. */
  102617. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102618. /**
  102619. * Interpolates a Vector3 linearl
  102620. * @param startValue Start value of the animation curve
  102621. * @param endValue End value of the animation curve
  102622. * @param gradient Scalar amount to interpolate
  102623. * @returns Interpolated scalar value
  102624. */
  102625. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102626. /**
  102627. * Interpolates a Vector3 cubically
  102628. * @param startValue Start value of the animation curve
  102629. * @param outTangent End tangent of the animation
  102630. * @param endValue End value of the animation curve
  102631. * @param inTangent Start tangent of the animation curve
  102632. * @param gradient Scalar amount to interpolate
  102633. * @returns InterpolatedVector3 value
  102634. */
  102635. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102636. /**
  102637. * Interpolates a Vector2 linearly
  102638. * @param startValue Start value of the animation curve
  102639. * @param endValue End value of the animation curve
  102640. * @param gradient Scalar amount to interpolate
  102641. * @returns Interpolated Vector2 value
  102642. */
  102643. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102644. /**
  102645. * Interpolates a Vector2 cubically
  102646. * @param startValue Start value of the animation curve
  102647. * @param outTangent End tangent of the animation
  102648. * @param endValue End value of the animation curve
  102649. * @param inTangent Start tangent of the animation curve
  102650. * @param gradient Scalar amount to interpolate
  102651. * @returns Interpolated Vector2 value
  102652. */
  102653. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102654. /**
  102655. * Interpolates a size linearly
  102656. * @param startValue Start value of the animation curve
  102657. * @param endValue End value of the animation curve
  102658. * @param gradient Scalar amount to interpolate
  102659. * @returns Interpolated Size value
  102660. */
  102661. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102662. /**
  102663. * Interpolates a Color3 linearly
  102664. * @param startValue Start value of the animation curve
  102665. * @param endValue End value of the animation curve
  102666. * @param gradient Scalar amount to interpolate
  102667. * @returns Interpolated Color3 value
  102668. */
  102669. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102670. /**
  102671. * Interpolates a Color4 linearly
  102672. * @param startValue Start value of the animation curve
  102673. * @param endValue End value of the animation curve
  102674. * @param gradient Scalar amount to interpolate
  102675. * @returns Interpolated Color3 value
  102676. */
  102677. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102678. /**
  102679. * @hidden Internal use only
  102680. */
  102681. _getKeyValue(value: any): any;
  102682. /**
  102683. * @hidden Internal use only
  102684. */
  102685. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102686. /**
  102687. * Defines the function to use to interpolate matrices
  102688. * @param startValue defines the start matrix
  102689. * @param endValue defines the end matrix
  102690. * @param gradient defines the gradient between both matrices
  102691. * @param result defines an optional target matrix where to store the interpolation
  102692. * @returns the interpolated matrix
  102693. */
  102694. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102695. /**
  102696. * Makes a copy of the animation
  102697. * @returns Cloned animation
  102698. */
  102699. clone(): Animation;
  102700. /**
  102701. * Sets the key frames of the animation
  102702. * @param values The animation key frames to set
  102703. */
  102704. setKeys(values: Array<IAnimationKey>): void;
  102705. /**
  102706. * Serializes the animation to an object
  102707. * @returns Serialized object
  102708. */
  102709. serialize(): any;
  102710. /**
  102711. * Float animation type
  102712. */
  102713. static readonly ANIMATIONTYPE_FLOAT: number;
  102714. /**
  102715. * Vector3 animation type
  102716. */
  102717. static readonly ANIMATIONTYPE_VECTOR3: number;
  102718. /**
  102719. * Quaternion animation type
  102720. */
  102721. static readonly ANIMATIONTYPE_QUATERNION: number;
  102722. /**
  102723. * Matrix animation type
  102724. */
  102725. static readonly ANIMATIONTYPE_MATRIX: number;
  102726. /**
  102727. * Color3 animation type
  102728. */
  102729. static readonly ANIMATIONTYPE_COLOR3: number;
  102730. /**
  102731. * Color3 animation type
  102732. */
  102733. static readonly ANIMATIONTYPE_COLOR4: number;
  102734. /**
  102735. * Vector2 animation type
  102736. */
  102737. static readonly ANIMATIONTYPE_VECTOR2: number;
  102738. /**
  102739. * Size animation type
  102740. */
  102741. static readonly ANIMATIONTYPE_SIZE: number;
  102742. /**
  102743. * Relative Loop Mode
  102744. */
  102745. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102746. /**
  102747. * Cycle Loop Mode
  102748. */
  102749. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102750. /**
  102751. * Constant Loop Mode
  102752. */
  102753. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102754. /** @hidden */
  102755. static _UniversalLerp(left: any, right: any, amount: number): any;
  102756. /**
  102757. * Parses an animation object and creates an animation
  102758. * @param parsedAnimation Parsed animation object
  102759. * @returns Animation object
  102760. */
  102761. static Parse(parsedAnimation: any): Animation;
  102762. /**
  102763. * Appends the serialized animations from the source animations
  102764. * @param source Source containing the animations
  102765. * @param destination Target to store the animations
  102766. */
  102767. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102768. }
  102769. }
  102770. declare module BABYLON {
  102771. /**
  102772. * Interface containing an array of animations
  102773. */
  102774. export interface IAnimatable {
  102775. /**
  102776. * Array of animations
  102777. */
  102778. animations: Nullable<Array<Animation>>;
  102779. }
  102780. }
  102781. declare module BABYLON {
  102782. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102783. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102784. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102785. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102786. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102787. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102788. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102789. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102790. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102791. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102792. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102793. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102794. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102795. /**
  102796. * Decorator used to define property that can be serialized as reference to a camera
  102797. * @param sourceName defines the name of the property to decorate
  102798. */
  102799. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102800. /**
  102801. * Class used to help serialization objects
  102802. */
  102803. export class SerializationHelper {
  102804. /** @hidden */
  102805. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102806. /** @hidden */
  102807. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102808. /** @hidden */
  102809. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102810. /** @hidden */
  102811. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102812. /**
  102813. * Appends the serialized animations from the source animations
  102814. * @param source Source containing the animations
  102815. * @param destination Target to store the animations
  102816. */
  102817. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102818. /**
  102819. * Static function used to serialized a specific entity
  102820. * @param entity defines the entity to serialize
  102821. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102822. * @returns a JSON compatible object representing the serialization of the entity
  102823. */
  102824. static Serialize<T>(entity: T, serializationObject?: any): any;
  102825. /**
  102826. * Creates a new entity from a serialization data object
  102827. * @param creationFunction defines a function used to instanciated the new entity
  102828. * @param source defines the source serialization data
  102829. * @param scene defines the hosting scene
  102830. * @param rootUrl defines the root url for resources
  102831. * @returns a new entity
  102832. */
  102833. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102834. /**
  102835. * Clones an object
  102836. * @param creationFunction defines the function used to instanciate the new object
  102837. * @param source defines the source object
  102838. * @returns the cloned object
  102839. */
  102840. static Clone<T>(creationFunction: () => T, source: T): T;
  102841. /**
  102842. * Instanciates a new object based on a source one (some data will be shared between both object)
  102843. * @param creationFunction defines the function used to instanciate the new object
  102844. * @param source defines the source object
  102845. * @returns the new object
  102846. */
  102847. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102848. }
  102849. }
  102850. declare module BABYLON {
  102851. /**
  102852. * Class used to manipulate GUIDs
  102853. */
  102854. export class GUID {
  102855. /**
  102856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102857. * Be aware Math.random() could cause collisions, but:
  102858. * "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"
  102859. * @returns a pseudo random id
  102860. */
  102861. static RandomId(): string;
  102862. }
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * Base class of all the textures in babylon.
  102867. * It groups all the common properties the materials, post process, lights... might need
  102868. * in order to make a correct use of the texture.
  102869. */
  102870. export class BaseTexture implements IAnimatable {
  102871. /**
  102872. * Default anisotropic filtering level for the application.
  102873. * It is set to 4 as a good tradeoff between perf and quality.
  102874. */
  102875. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102876. /**
  102877. * Gets or sets the unique id of the texture
  102878. */
  102879. uniqueId: number;
  102880. /**
  102881. * Define the name of the texture.
  102882. */
  102883. name: string;
  102884. /**
  102885. * Gets or sets an object used to store user defined information.
  102886. */
  102887. metadata: any;
  102888. /**
  102889. * For internal use only. Please do not use.
  102890. */
  102891. reservedDataStore: any;
  102892. private _hasAlpha;
  102893. /**
  102894. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102895. */
  102896. set hasAlpha(value: boolean);
  102897. get hasAlpha(): boolean;
  102898. /**
  102899. * Defines if the alpha value should be determined via the rgb values.
  102900. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102901. */
  102902. getAlphaFromRGB: boolean;
  102903. /**
  102904. * Intensity or strength of the texture.
  102905. * It is commonly used by materials to fine tune the intensity of the texture
  102906. */
  102907. level: number;
  102908. /**
  102909. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102910. * This is part of the texture as textures usually maps to one uv set.
  102911. */
  102912. coordinatesIndex: number;
  102913. private _coordinatesMode;
  102914. /**
  102915. * How a texture is mapped.
  102916. *
  102917. * | Value | Type | Description |
  102918. * | ----- | ----------------------------------- | ----------- |
  102919. * | 0 | EXPLICIT_MODE | |
  102920. * | 1 | SPHERICAL_MODE | |
  102921. * | 2 | PLANAR_MODE | |
  102922. * | 3 | CUBIC_MODE | |
  102923. * | 4 | PROJECTION_MODE | |
  102924. * | 5 | SKYBOX_MODE | |
  102925. * | 6 | INVCUBIC_MODE | |
  102926. * | 7 | EQUIRECTANGULAR_MODE | |
  102927. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102928. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102929. */
  102930. set coordinatesMode(value: number);
  102931. get coordinatesMode(): number;
  102932. /**
  102933. * | Value | Type | Description |
  102934. * | ----- | ------------------ | ----------- |
  102935. * | 0 | CLAMP_ADDRESSMODE | |
  102936. * | 1 | WRAP_ADDRESSMODE | |
  102937. * | 2 | MIRROR_ADDRESSMODE | |
  102938. */
  102939. wrapU: number;
  102940. /**
  102941. * | Value | Type | Description |
  102942. * | ----- | ------------------ | ----------- |
  102943. * | 0 | CLAMP_ADDRESSMODE | |
  102944. * | 1 | WRAP_ADDRESSMODE | |
  102945. * | 2 | MIRROR_ADDRESSMODE | |
  102946. */
  102947. wrapV: number;
  102948. /**
  102949. * | Value | Type | Description |
  102950. * | ----- | ------------------ | ----------- |
  102951. * | 0 | CLAMP_ADDRESSMODE | |
  102952. * | 1 | WRAP_ADDRESSMODE | |
  102953. * | 2 | MIRROR_ADDRESSMODE | |
  102954. */
  102955. wrapR: number;
  102956. /**
  102957. * With compliant hardware and browser (supporting anisotropic filtering)
  102958. * this defines the level of anisotropic filtering in the texture.
  102959. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102960. */
  102961. anisotropicFilteringLevel: number;
  102962. /**
  102963. * Define if the texture is a cube texture or if false a 2d texture.
  102964. */
  102965. get isCube(): boolean;
  102966. set isCube(value: boolean);
  102967. /**
  102968. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102969. */
  102970. get is3D(): boolean;
  102971. set is3D(value: boolean);
  102972. /**
  102973. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102974. */
  102975. get is2DArray(): boolean;
  102976. set is2DArray(value: boolean);
  102977. /**
  102978. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102979. * HDR texture are usually stored in linear space.
  102980. * This only impacts the PBR and Background materials
  102981. */
  102982. gammaSpace: boolean;
  102983. /**
  102984. * Gets or sets whether or not the texture contains RGBD data.
  102985. */
  102986. get isRGBD(): boolean;
  102987. set isRGBD(value: boolean);
  102988. /**
  102989. * Is Z inverted in the texture (useful in a cube texture).
  102990. */
  102991. invertZ: boolean;
  102992. /**
  102993. * Are mip maps generated for this texture or not.
  102994. */
  102995. get noMipmap(): boolean;
  102996. /**
  102997. * @hidden
  102998. */
  102999. lodLevelInAlpha: boolean;
  103000. /**
  103001. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103002. */
  103003. get lodGenerationOffset(): number;
  103004. set lodGenerationOffset(value: number);
  103005. /**
  103006. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103007. */
  103008. get lodGenerationScale(): number;
  103009. set lodGenerationScale(value: number);
  103010. /**
  103011. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103012. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103013. * average roughness values.
  103014. */
  103015. get linearSpecularLOD(): boolean;
  103016. set linearSpecularLOD(value: boolean);
  103017. /**
  103018. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103019. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103020. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103021. */
  103022. get irradianceTexture(): Nullable<BaseTexture>;
  103023. set irradianceTexture(value: Nullable<BaseTexture>);
  103024. /**
  103025. * Define if the texture is a render target.
  103026. */
  103027. isRenderTarget: boolean;
  103028. /**
  103029. * Define the unique id of the texture in the scene.
  103030. */
  103031. get uid(): string;
  103032. /**
  103033. * Return a string representation of the texture.
  103034. * @returns the texture as a string
  103035. */
  103036. toString(): string;
  103037. /**
  103038. * Get the class name of the texture.
  103039. * @returns "BaseTexture"
  103040. */
  103041. getClassName(): string;
  103042. /**
  103043. * Define the list of animation attached to the texture.
  103044. */
  103045. animations: Animation[];
  103046. /**
  103047. * An event triggered when the texture is disposed.
  103048. */
  103049. onDisposeObservable: Observable<BaseTexture>;
  103050. private _onDisposeObserver;
  103051. /**
  103052. * Callback triggered when the texture has been disposed.
  103053. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103054. */
  103055. set onDispose(callback: () => void);
  103056. /**
  103057. * Define the current state of the loading sequence when in delayed load mode.
  103058. */
  103059. delayLoadState: number;
  103060. private _scene;
  103061. /** @hidden */
  103062. _texture: Nullable<InternalTexture>;
  103063. private _uid;
  103064. /**
  103065. * Define if the texture is preventinga material to render or not.
  103066. * If not and the texture is not ready, the engine will use a default black texture instead.
  103067. */
  103068. get isBlocking(): boolean;
  103069. /**
  103070. * Instantiates a new BaseTexture.
  103071. * Base class of all the textures in babylon.
  103072. * It groups all the common properties the materials, post process, lights... might need
  103073. * in order to make a correct use of the texture.
  103074. * @param scene Define the scene the texture blongs to
  103075. */
  103076. constructor(scene: Nullable<Scene>);
  103077. /**
  103078. * Get the scene the texture belongs to.
  103079. * @returns the scene or null if undefined
  103080. */
  103081. getScene(): Nullable<Scene>;
  103082. /**
  103083. * Get the texture transform matrix used to offset tile the texture for istance.
  103084. * @returns the transformation matrix
  103085. */
  103086. getTextureMatrix(): Matrix;
  103087. /**
  103088. * Get the texture reflection matrix used to rotate/transform the reflection.
  103089. * @returns the reflection matrix
  103090. */
  103091. getReflectionTextureMatrix(): Matrix;
  103092. /**
  103093. * Get the underlying lower level texture from Babylon.
  103094. * @returns the insternal texture
  103095. */
  103096. getInternalTexture(): Nullable<InternalTexture>;
  103097. /**
  103098. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103099. * @returns true if ready or not blocking
  103100. */
  103101. isReadyOrNotBlocking(): boolean;
  103102. /**
  103103. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103104. * @returns true if fully ready
  103105. */
  103106. isReady(): boolean;
  103107. private _cachedSize;
  103108. /**
  103109. * Get the size of the texture.
  103110. * @returns the texture size.
  103111. */
  103112. getSize(): ISize;
  103113. /**
  103114. * Get the base size of the texture.
  103115. * It can be different from the size if the texture has been resized for POT for instance
  103116. * @returns the base size
  103117. */
  103118. getBaseSize(): ISize;
  103119. /**
  103120. * Update the sampling mode of the texture.
  103121. * Default is Trilinear mode.
  103122. *
  103123. * | Value | Type | Description |
  103124. * | ----- | ------------------ | ----------- |
  103125. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103126. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103127. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103128. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103129. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103130. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103131. * | 7 | NEAREST_LINEAR | |
  103132. * | 8 | NEAREST_NEAREST | |
  103133. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103134. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103135. * | 11 | LINEAR_LINEAR | |
  103136. * | 12 | LINEAR_NEAREST | |
  103137. *
  103138. * > _mag_: magnification filter (close to the viewer)
  103139. * > _min_: minification filter (far from the viewer)
  103140. * > _mip_: filter used between mip map levels
  103141. *@param samplingMode Define the new sampling mode of the texture
  103142. */
  103143. updateSamplingMode(samplingMode: number): void;
  103144. /**
  103145. * Scales the texture if is `canRescale()`
  103146. * @param ratio the resize factor we want to use to rescale
  103147. */
  103148. scale(ratio: number): void;
  103149. /**
  103150. * Get if the texture can rescale.
  103151. */
  103152. get canRescale(): boolean;
  103153. /** @hidden */
  103154. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103155. /** @hidden */
  103156. _rebuild(): void;
  103157. /**
  103158. * Triggers the load sequence in delayed load mode.
  103159. */
  103160. delayLoad(): void;
  103161. /**
  103162. * Clones the texture.
  103163. * @returns the cloned texture
  103164. */
  103165. clone(): Nullable<BaseTexture>;
  103166. /**
  103167. * Get the texture underlying type (INT, FLOAT...)
  103168. */
  103169. get textureType(): number;
  103170. /**
  103171. * Get the texture underlying format (RGB, RGBA...)
  103172. */
  103173. get textureFormat(): number;
  103174. /**
  103175. * Indicates that textures need to be re-calculated for all materials
  103176. */
  103177. protected _markAllSubMeshesAsTexturesDirty(): void;
  103178. /**
  103179. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103180. * This will returns an RGBA array buffer containing either in values (0-255) or
  103181. * float values (0-1) depending of the underlying buffer type.
  103182. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103183. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103184. * @param buffer defines a user defined buffer to fill with data (can be null)
  103185. * @returns The Array buffer containing the pixels data.
  103186. */
  103187. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103188. /**
  103189. * Release and destroy the underlying lower level texture aka internalTexture.
  103190. */
  103191. releaseInternalTexture(): void;
  103192. /** @hidden */
  103193. get _lodTextureHigh(): Nullable<BaseTexture>;
  103194. /** @hidden */
  103195. get _lodTextureMid(): Nullable<BaseTexture>;
  103196. /** @hidden */
  103197. get _lodTextureLow(): Nullable<BaseTexture>;
  103198. /**
  103199. * Dispose the texture and release its associated resources.
  103200. */
  103201. dispose(): void;
  103202. /**
  103203. * Serialize the texture into a JSON representation that can be parsed later on.
  103204. * @returns the JSON representation of the texture
  103205. */
  103206. serialize(): any;
  103207. /**
  103208. * Helper function to be called back once a list of texture contains only ready textures.
  103209. * @param textures Define the list of textures to wait for
  103210. * @param callback Define the callback triggered once the entire list will be ready
  103211. */
  103212. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103213. }
  103214. }
  103215. declare module BABYLON {
  103216. /**
  103217. * Options to be used when creating an effect.
  103218. */
  103219. export interface IEffectCreationOptions {
  103220. /**
  103221. * Atrributes that will be used in the shader.
  103222. */
  103223. attributes: string[];
  103224. /**
  103225. * Uniform varible names that will be set in the shader.
  103226. */
  103227. uniformsNames: string[];
  103228. /**
  103229. * Uniform buffer variable names that will be set in the shader.
  103230. */
  103231. uniformBuffersNames: string[];
  103232. /**
  103233. * Sampler texture variable names that will be set in the shader.
  103234. */
  103235. samplers: string[];
  103236. /**
  103237. * Define statements that will be set in the shader.
  103238. */
  103239. defines: any;
  103240. /**
  103241. * Possible fallbacks for this effect to improve performance when needed.
  103242. */
  103243. fallbacks: Nullable<IEffectFallbacks>;
  103244. /**
  103245. * Callback that will be called when the shader is compiled.
  103246. */
  103247. onCompiled: Nullable<(effect: Effect) => void>;
  103248. /**
  103249. * Callback that will be called if an error occurs during shader compilation.
  103250. */
  103251. onError: Nullable<(effect: Effect, errors: string) => void>;
  103252. /**
  103253. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103254. */
  103255. indexParameters?: any;
  103256. /**
  103257. * Max number of lights that can be used in the shader.
  103258. */
  103259. maxSimultaneousLights?: number;
  103260. /**
  103261. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103262. */
  103263. transformFeedbackVaryings?: Nullable<string[]>;
  103264. }
  103265. /**
  103266. * Effect containing vertex and fragment shader that can be executed on an object.
  103267. */
  103268. export class Effect implements IDisposable {
  103269. /**
  103270. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103271. */
  103272. static ShadersRepository: string;
  103273. /**
  103274. * Name of the effect.
  103275. */
  103276. name: any;
  103277. /**
  103278. * String container all the define statements that should be set on the shader.
  103279. */
  103280. defines: string;
  103281. /**
  103282. * Callback that will be called when the shader is compiled.
  103283. */
  103284. onCompiled: Nullable<(effect: Effect) => void>;
  103285. /**
  103286. * Callback that will be called if an error occurs during shader compilation.
  103287. */
  103288. onError: Nullable<(effect: Effect, errors: string) => void>;
  103289. /**
  103290. * Callback that will be called when effect is bound.
  103291. */
  103292. onBind: Nullable<(effect: Effect) => void>;
  103293. /**
  103294. * Unique ID of the effect.
  103295. */
  103296. uniqueId: number;
  103297. /**
  103298. * Observable that will be called when the shader is compiled.
  103299. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103300. */
  103301. onCompileObservable: Observable<Effect>;
  103302. /**
  103303. * Observable that will be called if an error occurs during shader compilation.
  103304. */
  103305. onErrorObservable: Observable<Effect>;
  103306. /** @hidden */
  103307. _onBindObservable: Nullable<Observable<Effect>>;
  103308. /**
  103309. * @hidden
  103310. * Specifies if the effect was previously ready
  103311. */
  103312. _wasPreviouslyReady: boolean;
  103313. /**
  103314. * Observable that will be called when effect is bound.
  103315. */
  103316. get onBindObservable(): Observable<Effect>;
  103317. /** @hidden */
  103318. _bonesComputationForcedToCPU: boolean;
  103319. private static _uniqueIdSeed;
  103320. private _engine;
  103321. private _uniformBuffersNames;
  103322. private _uniformsNames;
  103323. private _samplerList;
  103324. private _samplers;
  103325. private _isReady;
  103326. private _compilationError;
  103327. private _allFallbacksProcessed;
  103328. private _attributesNames;
  103329. private _attributes;
  103330. private _attributeLocationByName;
  103331. private _uniforms;
  103332. /**
  103333. * Key for the effect.
  103334. * @hidden
  103335. */
  103336. _key: string;
  103337. private _indexParameters;
  103338. private _fallbacks;
  103339. private _vertexSourceCode;
  103340. private _fragmentSourceCode;
  103341. private _vertexSourceCodeOverride;
  103342. private _fragmentSourceCodeOverride;
  103343. private _transformFeedbackVaryings;
  103344. /**
  103345. * Compiled shader to webGL program.
  103346. * @hidden
  103347. */
  103348. _pipelineContext: Nullable<IPipelineContext>;
  103349. private _valueCache;
  103350. private static _baseCache;
  103351. /**
  103352. * Instantiates an effect.
  103353. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103354. * @param baseName Name of the effect.
  103355. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103356. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103357. * @param samplers List of sampler variables that will be passed to the shader.
  103358. * @param engine Engine to be used to render the effect
  103359. * @param defines Define statements to be added to the shader.
  103360. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103361. * @param onCompiled Callback that will be called when the shader is compiled.
  103362. * @param onError Callback that will be called if an error occurs during shader compilation.
  103363. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103364. */
  103365. 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);
  103366. private _useFinalCode;
  103367. /**
  103368. * Unique key for this effect
  103369. */
  103370. get key(): string;
  103371. /**
  103372. * If the effect has been compiled and prepared.
  103373. * @returns if the effect is compiled and prepared.
  103374. */
  103375. isReady(): boolean;
  103376. private _isReadyInternal;
  103377. /**
  103378. * The engine the effect was initialized with.
  103379. * @returns the engine.
  103380. */
  103381. getEngine(): Engine;
  103382. /**
  103383. * The pipeline context for this effect
  103384. * @returns the associated pipeline context
  103385. */
  103386. getPipelineContext(): Nullable<IPipelineContext>;
  103387. /**
  103388. * The set of names of attribute variables for the shader.
  103389. * @returns An array of attribute names.
  103390. */
  103391. getAttributesNames(): string[];
  103392. /**
  103393. * Returns the attribute at the given index.
  103394. * @param index The index of the attribute.
  103395. * @returns The location of the attribute.
  103396. */
  103397. getAttributeLocation(index: number): number;
  103398. /**
  103399. * Returns the attribute based on the name of the variable.
  103400. * @param name of the attribute to look up.
  103401. * @returns the attribute location.
  103402. */
  103403. getAttributeLocationByName(name: string): number;
  103404. /**
  103405. * The number of attributes.
  103406. * @returns the numnber of attributes.
  103407. */
  103408. getAttributesCount(): number;
  103409. /**
  103410. * Gets the index of a uniform variable.
  103411. * @param uniformName of the uniform to look up.
  103412. * @returns the index.
  103413. */
  103414. getUniformIndex(uniformName: string): number;
  103415. /**
  103416. * Returns the attribute based on the name of the variable.
  103417. * @param uniformName of the uniform to look up.
  103418. * @returns the location of the uniform.
  103419. */
  103420. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103421. /**
  103422. * Returns an array of sampler variable names
  103423. * @returns The array of sampler variable neames.
  103424. */
  103425. getSamplers(): string[];
  103426. /**
  103427. * The error from the last compilation.
  103428. * @returns the error string.
  103429. */
  103430. getCompilationError(): string;
  103431. /**
  103432. * Gets a boolean indicating that all fallbacks were used during compilation
  103433. * @returns true if all fallbacks were used
  103434. */
  103435. allFallbacksProcessed(): boolean;
  103436. /**
  103437. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103438. * @param func The callback to be used.
  103439. */
  103440. executeWhenCompiled(func: (effect: Effect) => void): void;
  103441. private _checkIsReady;
  103442. private _loadShader;
  103443. /**
  103444. * Recompiles the webGL program
  103445. * @param vertexSourceCode The source code for the vertex shader.
  103446. * @param fragmentSourceCode The source code for the fragment shader.
  103447. * @param onCompiled Callback called when completed.
  103448. * @param onError Callback called on error.
  103449. * @hidden
  103450. */
  103451. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103452. /**
  103453. * Prepares the effect
  103454. * @hidden
  103455. */
  103456. _prepareEffect(): void;
  103457. private _processCompilationErrors;
  103458. /**
  103459. * Checks if the effect is supported. (Must be called after compilation)
  103460. */
  103461. get isSupported(): boolean;
  103462. /**
  103463. * Binds a texture to the engine to be used as output of the shader.
  103464. * @param channel Name of the output variable.
  103465. * @param texture Texture to bind.
  103466. * @hidden
  103467. */
  103468. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103469. /**
  103470. * Sets a texture on the engine to be used in the shader.
  103471. * @param channel Name of the sampler variable.
  103472. * @param texture Texture to set.
  103473. */
  103474. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103475. /**
  103476. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103477. * @param channel Name of the sampler variable.
  103478. * @param texture Texture to set.
  103479. */
  103480. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103481. /**
  103482. * Sets an array of textures on the engine to be used in the shader.
  103483. * @param channel Name of the variable.
  103484. * @param textures Textures to set.
  103485. */
  103486. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103487. /**
  103488. * 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)
  103489. * @param channel Name of the sampler variable.
  103490. * @param postProcess Post process to get the input texture from.
  103491. */
  103492. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103493. /**
  103494. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103495. * 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)
  103496. * @param channel Name of the sampler variable.
  103497. * @param postProcess Post process to get the output texture from.
  103498. */
  103499. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103500. /** @hidden */
  103501. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103502. /** @hidden */
  103503. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103504. /** @hidden */
  103505. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103506. /** @hidden */
  103507. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103508. /**
  103509. * Binds a buffer to a uniform.
  103510. * @param buffer Buffer to bind.
  103511. * @param name Name of the uniform variable to bind to.
  103512. */
  103513. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103514. /**
  103515. * Binds block to a uniform.
  103516. * @param blockName Name of the block to bind.
  103517. * @param index Index to bind.
  103518. */
  103519. bindUniformBlock(blockName: string, index: number): void;
  103520. /**
  103521. * Sets an interger value on a uniform variable.
  103522. * @param uniformName Name of the variable.
  103523. * @param value Value to be set.
  103524. * @returns this effect.
  103525. */
  103526. setInt(uniformName: string, value: number): Effect;
  103527. /**
  103528. * Sets an int array on a uniform variable.
  103529. * @param uniformName Name of the variable.
  103530. * @param array array to be set.
  103531. * @returns this effect.
  103532. */
  103533. setIntArray(uniformName: string, array: Int32Array): Effect;
  103534. /**
  103535. * 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)
  103536. * @param uniformName Name of the variable.
  103537. * @param array array to be set.
  103538. * @returns this effect.
  103539. */
  103540. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103541. /**
  103542. * 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)
  103543. * @param uniformName Name of the variable.
  103544. * @param array array to be set.
  103545. * @returns this effect.
  103546. */
  103547. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103548. /**
  103549. * 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)
  103550. * @param uniformName Name of the variable.
  103551. * @param array array to be set.
  103552. * @returns this effect.
  103553. */
  103554. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103555. /**
  103556. * Sets an float array on a uniform variable.
  103557. * @param uniformName Name of the variable.
  103558. * @param array array to be set.
  103559. * @returns this effect.
  103560. */
  103561. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103562. /**
  103563. * 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)
  103564. * @param uniformName Name of the variable.
  103565. * @param array array to be set.
  103566. * @returns this effect.
  103567. */
  103568. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103569. /**
  103570. * 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)
  103571. * @param uniformName Name of the variable.
  103572. * @param array array to be set.
  103573. * @returns this effect.
  103574. */
  103575. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103576. /**
  103577. * 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)
  103578. * @param uniformName Name of the variable.
  103579. * @param array array to be set.
  103580. * @returns this effect.
  103581. */
  103582. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103583. /**
  103584. * Sets an array on a uniform variable.
  103585. * @param uniformName Name of the variable.
  103586. * @param array array to be set.
  103587. * @returns this effect.
  103588. */
  103589. setArray(uniformName: string, array: number[]): Effect;
  103590. /**
  103591. * 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)
  103592. * @param uniformName Name of the variable.
  103593. * @param array array to be set.
  103594. * @returns this effect.
  103595. */
  103596. setArray2(uniformName: string, array: number[]): Effect;
  103597. /**
  103598. * 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)
  103599. * @param uniformName Name of the variable.
  103600. * @param array array to be set.
  103601. * @returns this effect.
  103602. */
  103603. setArray3(uniformName: string, array: number[]): Effect;
  103604. /**
  103605. * 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)
  103606. * @param uniformName Name of the variable.
  103607. * @param array array to be set.
  103608. * @returns this effect.
  103609. */
  103610. setArray4(uniformName: string, array: number[]): Effect;
  103611. /**
  103612. * Sets matrices on a uniform variable.
  103613. * @param uniformName Name of the variable.
  103614. * @param matrices matrices to be set.
  103615. * @returns this effect.
  103616. */
  103617. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103618. /**
  103619. * Sets matrix on a uniform variable.
  103620. * @param uniformName Name of the variable.
  103621. * @param matrix matrix to be set.
  103622. * @returns this effect.
  103623. */
  103624. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103625. /**
  103626. * 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)
  103627. * @param uniformName Name of the variable.
  103628. * @param matrix matrix to be set.
  103629. * @returns this effect.
  103630. */
  103631. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103632. /**
  103633. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103634. * @param uniformName Name of the variable.
  103635. * @param matrix matrix to be set.
  103636. * @returns this effect.
  103637. */
  103638. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103639. /**
  103640. * Sets a float on a uniform variable.
  103641. * @param uniformName Name of the variable.
  103642. * @param value value to be set.
  103643. * @returns this effect.
  103644. */
  103645. setFloat(uniformName: string, value: number): Effect;
  103646. /**
  103647. * Sets a boolean on a uniform variable.
  103648. * @param uniformName Name of the variable.
  103649. * @param bool value to be set.
  103650. * @returns this effect.
  103651. */
  103652. setBool(uniformName: string, bool: boolean): Effect;
  103653. /**
  103654. * Sets a Vector2 on a uniform variable.
  103655. * @param uniformName Name of the variable.
  103656. * @param vector2 vector2 to be set.
  103657. * @returns this effect.
  103658. */
  103659. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103660. /**
  103661. * Sets a float2 on a uniform variable.
  103662. * @param uniformName Name of the variable.
  103663. * @param x First float in float2.
  103664. * @param y Second float in float2.
  103665. * @returns this effect.
  103666. */
  103667. setFloat2(uniformName: string, x: number, y: number): Effect;
  103668. /**
  103669. * Sets a Vector3 on a uniform variable.
  103670. * @param uniformName Name of the variable.
  103671. * @param vector3 Value to be set.
  103672. * @returns this effect.
  103673. */
  103674. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103675. /**
  103676. * Sets a float3 on a uniform variable.
  103677. * @param uniformName Name of the variable.
  103678. * @param x First float in float3.
  103679. * @param y Second float in float3.
  103680. * @param z Third float in float3.
  103681. * @returns this effect.
  103682. */
  103683. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103684. /**
  103685. * Sets a Vector4 on a uniform variable.
  103686. * @param uniformName Name of the variable.
  103687. * @param vector4 Value to be set.
  103688. * @returns this effect.
  103689. */
  103690. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103691. /**
  103692. * Sets a float4 on a uniform variable.
  103693. * @param uniformName Name of the variable.
  103694. * @param x First float in float4.
  103695. * @param y Second float in float4.
  103696. * @param z Third float in float4.
  103697. * @param w Fourth float in float4.
  103698. * @returns this effect.
  103699. */
  103700. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103701. /**
  103702. * Sets a Color3 on a uniform variable.
  103703. * @param uniformName Name of the variable.
  103704. * @param color3 Value to be set.
  103705. * @returns this effect.
  103706. */
  103707. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103708. /**
  103709. * Sets a Color4 on a uniform variable.
  103710. * @param uniformName Name of the variable.
  103711. * @param color3 Value to be set.
  103712. * @param alpha Alpha value to be set.
  103713. * @returns this effect.
  103714. */
  103715. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103716. /**
  103717. * Sets a Color4 on a uniform variable
  103718. * @param uniformName defines the name of the variable
  103719. * @param color4 defines the value to be set
  103720. * @returns this effect.
  103721. */
  103722. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103723. /** Release all associated resources */
  103724. dispose(): void;
  103725. /**
  103726. * This function will add a new shader to the shader store
  103727. * @param name the name of the shader
  103728. * @param pixelShader optional pixel shader content
  103729. * @param vertexShader optional vertex shader content
  103730. */
  103731. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103732. /**
  103733. * Store of each shader (The can be looked up using effect.key)
  103734. */
  103735. static ShadersStore: {
  103736. [key: string]: string;
  103737. };
  103738. /**
  103739. * Store of each included file for a shader (The can be looked up using effect.key)
  103740. */
  103741. static IncludesShadersStore: {
  103742. [key: string]: string;
  103743. };
  103744. /**
  103745. * Resets the cache of effects.
  103746. */
  103747. static ResetCache(): void;
  103748. }
  103749. }
  103750. declare module BABYLON {
  103751. /**
  103752. * Interface used to describe the capabilities of the engine relatively to the current browser
  103753. */
  103754. export interface EngineCapabilities {
  103755. /** Maximum textures units per fragment shader */
  103756. maxTexturesImageUnits: number;
  103757. /** Maximum texture units per vertex shader */
  103758. maxVertexTextureImageUnits: number;
  103759. /** Maximum textures units in the entire pipeline */
  103760. maxCombinedTexturesImageUnits: number;
  103761. /** Maximum texture size */
  103762. maxTextureSize: number;
  103763. /** Maximum texture samples */
  103764. maxSamples?: number;
  103765. /** Maximum cube texture size */
  103766. maxCubemapTextureSize: number;
  103767. /** Maximum render texture size */
  103768. maxRenderTextureSize: number;
  103769. /** Maximum number of vertex attributes */
  103770. maxVertexAttribs: number;
  103771. /** Maximum number of varyings */
  103772. maxVaryingVectors: number;
  103773. /** Maximum number of uniforms per vertex shader */
  103774. maxVertexUniformVectors: number;
  103775. /** Maximum number of uniforms per fragment shader */
  103776. maxFragmentUniformVectors: number;
  103777. /** Defines if standard derivates (dx/dy) are supported */
  103778. standardDerivatives: boolean;
  103779. /** Defines if s3tc texture compression is supported */
  103780. s3tc?: WEBGL_compressed_texture_s3tc;
  103781. /** Defines if pvrtc texture compression is supported */
  103782. pvrtc: any;
  103783. /** Defines if etc1 texture compression is supported */
  103784. etc1: any;
  103785. /** Defines if etc2 texture compression is supported */
  103786. etc2: any;
  103787. /** Defines if astc texture compression is supported */
  103788. astc: any;
  103789. /** Defines if float textures are supported */
  103790. textureFloat: boolean;
  103791. /** Defines if vertex array objects are supported */
  103792. vertexArrayObject: boolean;
  103793. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103794. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103795. /** Gets the maximum level of anisotropy supported */
  103796. maxAnisotropy: number;
  103797. /** Defines if instancing is supported */
  103798. instancedArrays: boolean;
  103799. /** Defines if 32 bits indices are supported */
  103800. uintIndices: boolean;
  103801. /** Defines if high precision shaders are supported */
  103802. highPrecisionShaderSupported: boolean;
  103803. /** Defines if depth reading in the fragment shader is supported */
  103804. fragmentDepthSupported: boolean;
  103805. /** Defines if float texture linear filtering is supported*/
  103806. textureFloatLinearFiltering: boolean;
  103807. /** Defines if rendering to float textures is supported */
  103808. textureFloatRender: boolean;
  103809. /** Defines if half float textures are supported*/
  103810. textureHalfFloat: boolean;
  103811. /** Defines if half float texture linear filtering is supported*/
  103812. textureHalfFloatLinearFiltering: boolean;
  103813. /** Defines if rendering to half float textures is supported */
  103814. textureHalfFloatRender: boolean;
  103815. /** Defines if textureLOD shader command is supported */
  103816. textureLOD: boolean;
  103817. /** Defines if draw buffers extension is supported */
  103818. drawBuffersExtension: boolean;
  103819. /** Defines if depth textures are supported */
  103820. depthTextureExtension: boolean;
  103821. /** Defines if float color buffer are supported */
  103822. colorBufferFloat: boolean;
  103823. /** Gets disjoint timer query extension (null if not supported) */
  103824. timerQuery?: EXT_disjoint_timer_query;
  103825. /** Defines if timestamp can be used with timer query */
  103826. canUseTimestampForTimerQuery: boolean;
  103827. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103828. multiview?: any;
  103829. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103830. oculusMultiview?: any;
  103831. /** Function used to let the system compiles shaders in background */
  103832. parallelShaderCompile?: {
  103833. COMPLETION_STATUS_KHR: number;
  103834. };
  103835. /** Max number of texture samples for MSAA */
  103836. maxMSAASamples: number;
  103837. /** Defines if the blend min max extension is supported */
  103838. blendMinMax: boolean;
  103839. }
  103840. }
  103841. declare module BABYLON {
  103842. /**
  103843. * @hidden
  103844. **/
  103845. export class DepthCullingState {
  103846. private _isDepthTestDirty;
  103847. private _isDepthMaskDirty;
  103848. private _isDepthFuncDirty;
  103849. private _isCullFaceDirty;
  103850. private _isCullDirty;
  103851. private _isZOffsetDirty;
  103852. private _isFrontFaceDirty;
  103853. private _depthTest;
  103854. private _depthMask;
  103855. private _depthFunc;
  103856. private _cull;
  103857. private _cullFace;
  103858. private _zOffset;
  103859. private _frontFace;
  103860. /**
  103861. * Initializes the state.
  103862. */
  103863. constructor();
  103864. get isDirty(): boolean;
  103865. get zOffset(): number;
  103866. set zOffset(value: number);
  103867. get cullFace(): Nullable<number>;
  103868. set cullFace(value: Nullable<number>);
  103869. get cull(): Nullable<boolean>;
  103870. set cull(value: Nullable<boolean>);
  103871. get depthFunc(): Nullable<number>;
  103872. set depthFunc(value: Nullable<number>);
  103873. get depthMask(): boolean;
  103874. set depthMask(value: boolean);
  103875. get depthTest(): boolean;
  103876. set depthTest(value: boolean);
  103877. get frontFace(): Nullable<number>;
  103878. set frontFace(value: Nullable<number>);
  103879. reset(): void;
  103880. apply(gl: WebGLRenderingContext): void;
  103881. }
  103882. }
  103883. declare module BABYLON {
  103884. /**
  103885. * @hidden
  103886. **/
  103887. export class StencilState {
  103888. /** 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 */
  103889. static readonly ALWAYS: number;
  103890. /** Passed to stencilOperation to specify that stencil value must be kept */
  103891. static readonly KEEP: number;
  103892. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103893. static readonly REPLACE: number;
  103894. private _isStencilTestDirty;
  103895. private _isStencilMaskDirty;
  103896. private _isStencilFuncDirty;
  103897. private _isStencilOpDirty;
  103898. private _stencilTest;
  103899. private _stencilMask;
  103900. private _stencilFunc;
  103901. private _stencilFuncRef;
  103902. private _stencilFuncMask;
  103903. private _stencilOpStencilFail;
  103904. private _stencilOpDepthFail;
  103905. private _stencilOpStencilDepthPass;
  103906. get isDirty(): boolean;
  103907. get stencilFunc(): number;
  103908. set stencilFunc(value: number);
  103909. get stencilFuncRef(): number;
  103910. set stencilFuncRef(value: number);
  103911. get stencilFuncMask(): number;
  103912. set stencilFuncMask(value: number);
  103913. get stencilOpStencilFail(): number;
  103914. set stencilOpStencilFail(value: number);
  103915. get stencilOpDepthFail(): number;
  103916. set stencilOpDepthFail(value: number);
  103917. get stencilOpStencilDepthPass(): number;
  103918. set stencilOpStencilDepthPass(value: number);
  103919. get stencilMask(): number;
  103920. set stencilMask(value: number);
  103921. get stencilTest(): boolean;
  103922. set stencilTest(value: boolean);
  103923. constructor();
  103924. reset(): void;
  103925. apply(gl: WebGLRenderingContext): void;
  103926. }
  103927. }
  103928. declare module BABYLON {
  103929. /**
  103930. * @hidden
  103931. **/
  103932. export class AlphaState {
  103933. private _isAlphaBlendDirty;
  103934. private _isBlendFunctionParametersDirty;
  103935. private _isBlendEquationParametersDirty;
  103936. private _isBlendConstantsDirty;
  103937. private _alphaBlend;
  103938. private _blendFunctionParameters;
  103939. private _blendEquationParameters;
  103940. private _blendConstants;
  103941. /**
  103942. * Initializes the state.
  103943. */
  103944. constructor();
  103945. get isDirty(): boolean;
  103946. get alphaBlend(): boolean;
  103947. set alphaBlend(value: boolean);
  103948. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103949. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103950. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103951. reset(): void;
  103952. apply(gl: WebGLRenderingContext): void;
  103953. }
  103954. }
  103955. declare module BABYLON {
  103956. /** @hidden */
  103957. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103958. attributeProcessor(attribute: string): string;
  103959. varyingProcessor(varying: string, isFragment: boolean): string;
  103960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103961. }
  103962. }
  103963. declare module BABYLON {
  103964. /**
  103965. * Interface for attribute information associated with buffer instanciation
  103966. */
  103967. export interface InstancingAttributeInfo {
  103968. /**
  103969. * Name of the GLSL attribute
  103970. * if attribute index is not specified, this is used to retrieve the index from the effect
  103971. */
  103972. attributeName: string;
  103973. /**
  103974. * Index/offset of the attribute in the vertex shader
  103975. * if not specified, this will be computes from the name.
  103976. */
  103977. index?: number;
  103978. /**
  103979. * size of the attribute, 1, 2, 3 or 4
  103980. */
  103981. attributeSize: number;
  103982. /**
  103983. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103984. */
  103985. offset: number;
  103986. /**
  103987. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103988. * default to 1
  103989. */
  103990. divisor?: number;
  103991. /**
  103992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103993. * default is FLOAT
  103994. */
  103995. attributeType?: number;
  103996. /**
  103997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103998. */
  103999. normalized?: boolean;
  104000. }
  104001. }
  104002. declare module BABYLON {
  104003. interface ThinEngine {
  104004. /**
  104005. * Update a video texture
  104006. * @param texture defines the texture to update
  104007. * @param video defines the video element to use
  104008. * @param invertY defines if data must be stored with Y axis inverted
  104009. */
  104010. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104011. }
  104012. }
  104013. declare module BABYLON {
  104014. /**
  104015. * Settings for finer control over video usage
  104016. */
  104017. export interface VideoTextureSettings {
  104018. /**
  104019. * Applies `autoplay` to video, if specified
  104020. */
  104021. autoPlay?: boolean;
  104022. /**
  104023. * Applies `loop` to video, if specified
  104024. */
  104025. loop?: boolean;
  104026. /**
  104027. * Automatically updates internal texture from video at every frame in the render loop
  104028. */
  104029. autoUpdateTexture: boolean;
  104030. /**
  104031. * Image src displayed during the video loading or until the user interacts with the video.
  104032. */
  104033. poster?: string;
  104034. }
  104035. /**
  104036. * If you want to display a video in your scene, this is the special texture for that.
  104037. * This special texture works similar to other textures, with the exception of a few parameters.
  104038. * @see https://doc.babylonjs.com/how_to/video_texture
  104039. */
  104040. export class VideoTexture extends Texture {
  104041. /**
  104042. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104043. */
  104044. readonly autoUpdateTexture: boolean;
  104045. /**
  104046. * The video instance used by the texture internally
  104047. */
  104048. readonly video: HTMLVideoElement;
  104049. private _onUserActionRequestedObservable;
  104050. /**
  104051. * Event triggerd when a dom action is required by the user to play the video.
  104052. * This happens due to recent changes in browser policies preventing video to auto start.
  104053. */
  104054. get onUserActionRequestedObservable(): Observable<Texture>;
  104055. private _generateMipMaps;
  104056. private _engine;
  104057. private _stillImageCaptured;
  104058. private _displayingPosterTexture;
  104059. private _settings;
  104060. private _createInternalTextureOnEvent;
  104061. private _frameId;
  104062. private _currentSrc;
  104063. /**
  104064. * Creates a video texture.
  104065. * If you want to display a video in your scene, this is the special texture for that.
  104066. * This special texture works similar to other textures, with the exception of a few parameters.
  104067. * @see https://doc.babylonjs.com/how_to/video_texture
  104068. * @param name optional name, will detect from video source, if not defined
  104069. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104070. * @param scene is obviously the current scene.
  104071. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104072. * @param invertY is false by default but can be used to invert video on Y axis
  104073. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104074. * @param settings allows finer control over video usage
  104075. */
  104076. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104077. private _getName;
  104078. private _getVideo;
  104079. private _createInternalTexture;
  104080. private reset;
  104081. /**
  104082. * @hidden Internal method to initiate `update`.
  104083. */
  104084. _rebuild(): void;
  104085. /**
  104086. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104087. */
  104088. update(): void;
  104089. /**
  104090. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104091. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104092. */
  104093. updateTexture(isVisible: boolean): void;
  104094. protected _updateInternalTexture: () => void;
  104095. /**
  104096. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104097. * @param url New url.
  104098. */
  104099. updateURL(url: string): void;
  104100. /**
  104101. * Clones the texture.
  104102. * @returns the cloned texture
  104103. */
  104104. clone(): VideoTexture;
  104105. /**
  104106. * Dispose the texture and release its associated resources.
  104107. */
  104108. dispose(): void;
  104109. /**
  104110. * Creates a video texture straight from a stream.
  104111. * @param scene Define the scene the texture should be created in
  104112. * @param stream Define the stream the texture should be created from
  104113. * @returns The created video texture as a promise
  104114. */
  104115. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104116. /**
  104117. * Creates a video texture straight from your WebCam video feed.
  104118. * @param scene Define the scene the texture should be created in
  104119. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104120. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104121. * @returns The created video texture as a promise
  104122. */
  104123. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104124. minWidth: number;
  104125. maxWidth: number;
  104126. minHeight: number;
  104127. maxHeight: number;
  104128. deviceId: string;
  104129. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104130. /**
  104131. * Creates a video texture straight from your WebCam video feed.
  104132. * @param scene Define the scene the texture should be created in
  104133. * @param onReady Define a callback to triggered once the texture will be ready
  104134. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104135. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104136. */
  104137. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104138. minWidth: number;
  104139. maxWidth: number;
  104140. minHeight: number;
  104141. maxHeight: number;
  104142. deviceId: string;
  104143. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104144. }
  104145. }
  104146. declare module BABYLON {
  104147. /**
  104148. * Defines the interface used by objects working like Scene
  104149. * @hidden
  104150. */
  104151. export interface ISceneLike {
  104152. _addPendingData(data: any): void;
  104153. _removePendingData(data: any): void;
  104154. offlineProvider: IOfflineProvider;
  104155. }
  104156. /** Interface defining initialization parameters for Engine class */
  104157. export interface EngineOptions extends WebGLContextAttributes {
  104158. /**
  104159. * Defines if the engine should no exceed a specified device ratio
  104160. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104161. */
  104162. limitDeviceRatio?: number;
  104163. /**
  104164. * Defines if webvr should be enabled automatically
  104165. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104166. */
  104167. autoEnableWebVR?: boolean;
  104168. /**
  104169. * Defines if webgl2 should be turned off even if supported
  104170. * @see http://doc.babylonjs.com/features/webgl2
  104171. */
  104172. disableWebGL2Support?: boolean;
  104173. /**
  104174. * Defines if webaudio should be initialized as well
  104175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104176. */
  104177. audioEngine?: boolean;
  104178. /**
  104179. * Defines if animations should run using a deterministic lock step
  104180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104181. */
  104182. deterministicLockstep?: boolean;
  104183. /** Defines the maximum steps to use with deterministic lock step mode */
  104184. lockstepMaxSteps?: number;
  104185. /** Defines the seconds between each deterministic lock step */
  104186. timeStep?: number;
  104187. /**
  104188. * Defines that engine should ignore context lost events
  104189. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104190. */
  104191. doNotHandleContextLost?: boolean;
  104192. /**
  104193. * Defines that engine should ignore modifying touch action attribute and style
  104194. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104195. */
  104196. doNotHandleTouchAction?: boolean;
  104197. /**
  104198. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104199. */
  104200. useHighPrecisionFloats?: boolean;
  104201. }
  104202. /**
  104203. * The base engine class (root of all engines)
  104204. */
  104205. export class ThinEngine {
  104206. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104207. static ExceptionList: ({
  104208. key: string;
  104209. capture: string;
  104210. captureConstraint: number;
  104211. targets: string[];
  104212. } | {
  104213. key: string;
  104214. capture: null;
  104215. captureConstraint: null;
  104216. targets: string[];
  104217. })[];
  104218. /** @hidden */
  104219. static _TextureLoaders: IInternalTextureLoader[];
  104220. /**
  104221. * Returns the current npm package of the sdk
  104222. */
  104223. static get NpmPackage(): string;
  104224. /**
  104225. * Returns the current version of the framework
  104226. */
  104227. static get Version(): string;
  104228. /**
  104229. * Returns a string describing the current engine
  104230. */
  104231. get description(): string;
  104232. /**
  104233. * Gets or sets the epsilon value used by collision engine
  104234. */
  104235. static CollisionsEpsilon: number;
  104236. /**
  104237. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104238. */
  104239. static get ShadersRepository(): string;
  104240. static set ShadersRepository(value: string);
  104241. /** @hidden */
  104242. _shaderProcessor: IShaderProcessor;
  104243. /**
  104244. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104245. */
  104246. forcePOTTextures: boolean;
  104247. /**
  104248. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104249. */
  104250. isFullscreen: boolean;
  104251. /**
  104252. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104253. */
  104254. cullBackFaces: boolean;
  104255. /**
  104256. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104257. */
  104258. renderEvenInBackground: boolean;
  104259. /**
  104260. * Gets or sets a boolean indicating that cache can be kept between frames
  104261. */
  104262. preventCacheWipeBetweenFrames: boolean;
  104263. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104264. validateShaderPrograms: boolean;
  104265. /**
  104266. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104267. * This can provide greater z depth for distant objects.
  104268. */
  104269. useReverseDepthBuffer: boolean;
  104270. /**
  104271. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104272. */
  104273. disableUniformBuffers: boolean;
  104274. /** @hidden */
  104275. _uniformBuffers: UniformBuffer[];
  104276. /**
  104277. * Gets a boolean indicating that the engine supports uniform buffers
  104278. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104279. */
  104280. get supportsUniformBuffers(): boolean;
  104281. /** @hidden */
  104282. _gl: WebGLRenderingContext;
  104283. /** @hidden */
  104284. _webGLVersion: number;
  104285. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104286. protected _windowIsBackground: boolean;
  104287. protected _creationOptions: EngineOptions;
  104288. protected _highPrecisionShadersAllowed: boolean;
  104289. /** @hidden */
  104290. get _shouldUseHighPrecisionShader(): boolean;
  104291. /**
  104292. * Gets a boolean indicating that only power of 2 textures are supported
  104293. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104294. */
  104295. get needPOTTextures(): boolean;
  104296. /** @hidden */
  104297. _badOS: boolean;
  104298. /** @hidden */
  104299. _badDesktopOS: boolean;
  104300. private _hardwareScalingLevel;
  104301. /** @hidden */
  104302. _caps: EngineCapabilities;
  104303. private _isStencilEnable;
  104304. private _glVersion;
  104305. private _glRenderer;
  104306. private _glVendor;
  104307. /** @hidden */
  104308. _videoTextureSupported: boolean;
  104309. protected _renderingQueueLaunched: boolean;
  104310. protected _activeRenderLoops: (() => void)[];
  104311. /**
  104312. * Observable signaled when a context lost event is raised
  104313. */
  104314. onContextLostObservable: Observable<ThinEngine>;
  104315. /**
  104316. * Observable signaled when a context restored event is raised
  104317. */
  104318. onContextRestoredObservable: Observable<ThinEngine>;
  104319. private _onContextLost;
  104320. private _onContextRestored;
  104321. protected _contextWasLost: boolean;
  104322. /** @hidden */
  104323. _doNotHandleContextLost: boolean;
  104324. /**
  104325. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104327. */
  104328. get doNotHandleContextLost(): boolean;
  104329. set doNotHandleContextLost(value: boolean);
  104330. /**
  104331. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104332. */
  104333. disableVertexArrayObjects: boolean;
  104334. /** @hidden */
  104335. protected _colorWrite: boolean;
  104336. /** @hidden */
  104337. protected _colorWriteChanged: boolean;
  104338. /** @hidden */
  104339. protected _depthCullingState: DepthCullingState;
  104340. /** @hidden */
  104341. protected _stencilState: StencilState;
  104342. /** @hidden */
  104343. _alphaState: AlphaState;
  104344. /** @hidden */
  104345. _alphaMode: number;
  104346. /** @hidden */
  104347. _alphaEquation: number;
  104348. /** @hidden */
  104349. _internalTexturesCache: InternalTexture[];
  104350. /** @hidden */
  104351. protected _activeChannel: number;
  104352. private _currentTextureChannel;
  104353. /** @hidden */
  104354. protected _boundTexturesCache: {
  104355. [key: string]: Nullable<InternalTexture>;
  104356. };
  104357. /** @hidden */
  104358. protected _currentEffect: Nullable<Effect>;
  104359. /** @hidden */
  104360. protected _currentProgram: Nullable<WebGLProgram>;
  104361. private _compiledEffects;
  104362. private _vertexAttribArraysEnabled;
  104363. /** @hidden */
  104364. protected _cachedViewport: Nullable<IViewportLike>;
  104365. private _cachedVertexArrayObject;
  104366. /** @hidden */
  104367. protected _cachedVertexBuffers: any;
  104368. /** @hidden */
  104369. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104370. /** @hidden */
  104371. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104372. /** @hidden */
  104373. _currentRenderTarget: Nullable<InternalTexture>;
  104374. private _uintIndicesCurrentlySet;
  104375. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104376. /** @hidden */
  104377. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104378. private _currentBufferPointers;
  104379. private _currentInstanceLocations;
  104380. private _currentInstanceBuffers;
  104381. private _textureUnits;
  104382. /** @hidden */
  104383. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104384. /** @hidden */
  104385. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104386. /** @hidden */
  104387. _boundRenderFunction: any;
  104388. private _vaoRecordInProgress;
  104389. private _mustWipeVertexAttributes;
  104390. private _emptyTexture;
  104391. private _emptyCubeTexture;
  104392. private _emptyTexture3D;
  104393. private _emptyTexture2DArray;
  104394. /** @hidden */
  104395. _frameHandler: number;
  104396. private _nextFreeTextureSlots;
  104397. private _maxSimultaneousTextures;
  104398. private _activeRequests;
  104399. protected _texturesSupported: string[];
  104400. /** @hidden */
  104401. _textureFormatInUse: Nullable<string>;
  104402. protected get _supportsHardwareTextureRescaling(): boolean;
  104403. /**
  104404. * Gets the list of texture formats supported
  104405. */
  104406. get texturesSupported(): Array<string>;
  104407. /**
  104408. * Gets the list of texture formats in use
  104409. */
  104410. get textureFormatInUse(): Nullable<string>;
  104411. /**
  104412. * Gets the current viewport
  104413. */
  104414. get currentViewport(): Nullable<IViewportLike>;
  104415. /**
  104416. * Gets the default empty texture
  104417. */
  104418. get emptyTexture(): InternalTexture;
  104419. /**
  104420. * Gets the default empty 3D texture
  104421. */
  104422. get emptyTexture3D(): InternalTexture;
  104423. /**
  104424. * Gets the default empty 2D array texture
  104425. */
  104426. get emptyTexture2DArray(): InternalTexture;
  104427. /**
  104428. * Gets the default empty cube texture
  104429. */
  104430. get emptyCubeTexture(): InternalTexture;
  104431. /**
  104432. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104433. */
  104434. readonly premultipliedAlpha: boolean;
  104435. /**
  104436. * Observable event triggered before each texture is initialized
  104437. */
  104438. onBeforeTextureInitObservable: Observable<Texture>;
  104439. /**
  104440. * Creates a new engine
  104441. * @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
  104442. * @param antialias defines enable antialiasing (default: false)
  104443. * @param options defines further options to be sent to the getContext() function
  104444. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104445. */
  104446. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104447. private _rebuildInternalTextures;
  104448. private _rebuildEffects;
  104449. /**
  104450. * Gets a boolean indicating if all created effects are ready
  104451. * @returns true if all effects are ready
  104452. */
  104453. areAllEffectsReady(): boolean;
  104454. protected _rebuildBuffers(): void;
  104455. private _initGLContext;
  104456. /**
  104457. * Gets version of the current webGL context
  104458. */
  104459. get webGLVersion(): number;
  104460. /**
  104461. * Gets a string idenfifying the name of the class
  104462. * @returns "Engine" string
  104463. */
  104464. getClassName(): string;
  104465. /**
  104466. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104467. */
  104468. get isStencilEnable(): boolean;
  104469. /** @hidden */
  104470. _prepareWorkingCanvas(): void;
  104471. /**
  104472. * Reset the texture cache to empty state
  104473. */
  104474. resetTextureCache(): void;
  104475. /**
  104476. * Gets an object containing information about the current webGL context
  104477. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104478. */
  104479. getGlInfo(): {
  104480. vendor: string;
  104481. renderer: string;
  104482. version: string;
  104483. };
  104484. /**
  104485. * Defines the hardware scaling level.
  104486. * By default the hardware scaling level is computed from the window device ratio.
  104487. * 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.
  104488. * @param level defines the level to use
  104489. */
  104490. setHardwareScalingLevel(level: number): void;
  104491. /**
  104492. * Gets the current hardware scaling level.
  104493. * By default the hardware scaling level is computed from the window device ratio.
  104494. * 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.
  104495. * @returns a number indicating the current hardware scaling level
  104496. */
  104497. getHardwareScalingLevel(): number;
  104498. /**
  104499. * Gets the list of loaded textures
  104500. * @returns an array containing all loaded textures
  104501. */
  104502. getLoadedTexturesCache(): InternalTexture[];
  104503. /**
  104504. * Gets the object containing all engine capabilities
  104505. * @returns the EngineCapabilities object
  104506. */
  104507. getCaps(): EngineCapabilities;
  104508. /**
  104509. * stop executing a render loop function and remove it from the execution array
  104510. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104511. */
  104512. stopRenderLoop(renderFunction?: () => void): void;
  104513. /** @hidden */
  104514. _renderLoop(): void;
  104515. /**
  104516. * Gets the HTML canvas attached with the current webGL context
  104517. * @returns a HTML canvas
  104518. */
  104519. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104520. /**
  104521. * Gets host window
  104522. * @returns the host window object
  104523. */
  104524. getHostWindow(): Nullable<Window>;
  104525. /**
  104526. * Gets the current render width
  104527. * @param useScreen defines if screen size must be used (or the current render target if any)
  104528. * @returns a number defining the current render width
  104529. */
  104530. getRenderWidth(useScreen?: boolean): number;
  104531. /**
  104532. * Gets the current render height
  104533. * @param useScreen defines if screen size must be used (or the current render target if any)
  104534. * @returns a number defining the current render height
  104535. */
  104536. getRenderHeight(useScreen?: boolean): number;
  104537. /**
  104538. * Can be used to override the current requestAnimationFrame requester.
  104539. * @hidden
  104540. */
  104541. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104542. /**
  104543. * Register and execute a render loop. The engine can have more than one render function
  104544. * @param renderFunction defines the function to continuously execute
  104545. */
  104546. runRenderLoop(renderFunction: () => void): void;
  104547. /**
  104548. * Clear the current render buffer or the current render target (if any is set up)
  104549. * @param color defines the color to use
  104550. * @param backBuffer defines if the back buffer must be cleared
  104551. * @param depth defines if the depth buffer must be cleared
  104552. * @param stencil defines if the stencil buffer must be cleared
  104553. */
  104554. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104555. private _viewportCached;
  104556. /** @hidden */
  104557. _viewport(x: number, y: number, width: number, height: number): void;
  104558. /**
  104559. * Set the WebGL's viewport
  104560. * @param viewport defines the viewport element to be used
  104561. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104562. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104563. */
  104564. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104565. /**
  104566. * Begin a new frame
  104567. */
  104568. beginFrame(): void;
  104569. /**
  104570. * Enf the current frame
  104571. */
  104572. endFrame(): void;
  104573. /**
  104574. * Resize the view according to the canvas' size
  104575. */
  104576. resize(): void;
  104577. /**
  104578. * Force a specific size of the canvas
  104579. * @param width defines the new canvas' width
  104580. * @param height defines the new canvas' height
  104581. */
  104582. setSize(width: number, height: number): void;
  104583. /**
  104584. * Binds the frame buffer to the specified texture.
  104585. * @param texture The texture to render to or null for the default canvas
  104586. * @param faceIndex The face of the texture to render to in case of cube texture
  104587. * @param requiredWidth The width of the target to render to
  104588. * @param requiredHeight The height of the target to render to
  104589. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104590. * @param lodLevel defines the lod level to bind to the frame buffer
  104591. * @param layer defines the 2d array index to bind to frame buffer to
  104592. */
  104593. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104594. /** @hidden */
  104595. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104596. /**
  104597. * Unbind the current render target texture from the webGL context
  104598. * @param texture defines the render target texture to unbind
  104599. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104600. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104601. */
  104602. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104603. /**
  104604. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104605. */
  104606. flushFramebuffer(): void;
  104607. /**
  104608. * Unbind the current render target and bind the default framebuffer
  104609. */
  104610. restoreDefaultFramebuffer(): void;
  104611. /** @hidden */
  104612. protected _resetVertexBufferBinding(): void;
  104613. /**
  104614. * Creates a vertex buffer
  104615. * @param data the data for the vertex buffer
  104616. * @returns the new WebGL static buffer
  104617. */
  104618. createVertexBuffer(data: DataArray): DataBuffer;
  104619. private _createVertexBuffer;
  104620. /**
  104621. * Creates a dynamic vertex buffer
  104622. * @param data the data for the dynamic vertex buffer
  104623. * @returns the new WebGL dynamic buffer
  104624. */
  104625. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104626. protected _resetIndexBufferBinding(): void;
  104627. /**
  104628. * Creates a new index buffer
  104629. * @param indices defines the content of the index buffer
  104630. * @param updatable defines if the index buffer must be updatable
  104631. * @returns a new webGL buffer
  104632. */
  104633. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104634. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104635. /**
  104636. * Bind a webGL buffer to the webGL context
  104637. * @param buffer defines the buffer to bind
  104638. */
  104639. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104640. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104641. private bindBuffer;
  104642. /**
  104643. * update the bound buffer with the given data
  104644. * @param data defines the data to update
  104645. */
  104646. updateArrayBuffer(data: Float32Array): void;
  104647. private _vertexAttribPointer;
  104648. /** @hidden */
  104649. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104650. private _bindVertexBuffersAttributes;
  104651. /**
  104652. * Records a vertex array object
  104653. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104654. * @param vertexBuffers defines the list of vertex buffers to store
  104655. * @param indexBuffer defines the index buffer to store
  104656. * @param effect defines the effect to store
  104657. * @returns the new vertex array object
  104658. */
  104659. recordVertexArrayObject(vertexBuffers: {
  104660. [key: string]: VertexBuffer;
  104661. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104662. /**
  104663. * Bind a specific vertex array object
  104664. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104665. * @param vertexArrayObject defines the vertex array object to bind
  104666. * @param indexBuffer defines the index buffer to bind
  104667. */
  104668. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104669. /**
  104670. * Bind webGl buffers directly to the webGL context
  104671. * @param vertexBuffer defines the vertex buffer to bind
  104672. * @param indexBuffer defines the index buffer to bind
  104673. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104674. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104675. * @param effect defines the effect associated with the vertex buffer
  104676. */
  104677. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104678. private _unbindVertexArrayObject;
  104679. /**
  104680. * Bind a list of vertex buffers to the webGL context
  104681. * @param vertexBuffers defines the list of vertex buffers to bind
  104682. * @param indexBuffer defines the index buffer to bind
  104683. * @param effect defines the effect associated with the vertex buffers
  104684. */
  104685. bindBuffers(vertexBuffers: {
  104686. [key: string]: Nullable<VertexBuffer>;
  104687. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104688. /**
  104689. * Unbind all instance attributes
  104690. */
  104691. unbindInstanceAttributes(): void;
  104692. /**
  104693. * Release and free the memory of a vertex array object
  104694. * @param vao defines the vertex array object to delete
  104695. */
  104696. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104697. /** @hidden */
  104698. _releaseBuffer(buffer: DataBuffer): boolean;
  104699. protected _deleteBuffer(buffer: DataBuffer): void;
  104700. /**
  104701. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104702. * @param instancesBuffer defines the webGL buffer to update and bind
  104703. * @param data defines the data to store in the buffer
  104704. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104705. */
  104706. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104707. /**
  104708. * Bind the content of a webGL buffer used with instantiation
  104709. * @param instancesBuffer defines the webGL buffer to bind
  104710. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104711. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104712. */
  104713. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104714. /**
  104715. * Disable the instance attribute corresponding to the name in parameter
  104716. * @param name defines the name of the attribute to disable
  104717. */
  104718. disableInstanceAttributeByName(name: string): void;
  104719. /**
  104720. * Disable the instance attribute corresponding to the location in parameter
  104721. * @param attributeLocation defines the attribute location of the attribute to disable
  104722. */
  104723. disableInstanceAttribute(attributeLocation: number): void;
  104724. /**
  104725. * Disable the attribute corresponding to the location in parameter
  104726. * @param attributeLocation defines the attribute location of the attribute to disable
  104727. */
  104728. disableAttributeByIndex(attributeLocation: number): void;
  104729. /**
  104730. * Send a draw order
  104731. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104732. * @param indexStart defines the starting index
  104733. * @param indexCount defines the number of index to draw
  104734. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104735. */
  104736. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104737. /**
  104738. * Draw a list of points
  104739. * @param verticesStart defines the index of first vertex to draw
  104740. * @param verticesCount defines the count of vertices to draw
  104741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104742. */
  104743. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104744. /**
  104745. * Draw a list of unindexed primitives
  104746. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104747. * @param verticesStart defines the index of first vertex to draw
  104748. * @param verticesCount defines the count of vertices to draw
  104749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104750. */
  104751. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104752. /**
  104753. * Draw a list of indexed primitives
  104754. * @param fillMode defines the primitive to use
  104755. * @param indexStart defines the starting index
  104756. * @param indexCount defines the number of index to draw
  104757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104758. */
  104759. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104760. /**
  104761. * Draw a list of unindexed primitives
  104762. * @param fillMode defines the primitive to use
  104763. * @param verticesStart defines the index of first vertex to draw
  104764. * @param verticesCount defines the count of vertices to draw
  104765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104766. */
  104767. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104768. private _drawMode;
  104769. /** @hidden */
  104770. protected _reportDrawCall(): void;
  104771. /** @hidden */
  104772. _releaseEffect(effect: Effect): void;
  104773. /** @hidden */
  104774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104775. /**
  104776. * Create a new effect (used to store vertex/fragment shaders)
  104777. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104778. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104779. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104780. * @param samplers defines an array of string used to represent textures
  104781. * @param defines defines the string containing the defines to use to compile the shaders
  104782. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104783. * @param onCompiled defines a function to call when the effect creation is successful
  104784. * @param onError defines a function to call when the effect creation has failed
  104785. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104786. * @returns the new Effect
  104787. */
  104788. 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;
  104789. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104790. private _compileShader;
  104791. private _compileRawShader;
  104792. /**
  104793. * Directly creates a webGL program
  104794. * @param pipelineContext defines the pipeline context to attach to
  104795. * @param vertexCode defines the vertex shader code to use
  104796. * @param fragmentCode defines the fragment shader code to use
  104797. * @param context defines the webGL context to use (if not set, the current one will be used)
  104798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104799. * @returns the new webGL program
  104800. */
  104801. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104802. /**
  104803. * Creates a webGL program
  104804. * @param pipelineContext defines the pipeline context to attach to
  104805. * @param vertexCode defines the vertex shader code to use
  104806. * @param fragmentCode defines the fragment shader code to use
  104807. * @param defines defines the string containing the defines to use to compile the shaders
  104808. * @param context defines the webGL context to use (if not set, the current one will be used)
  104809. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104810. * @returns the new webGL program
  104811. */
  104812. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104813. /**
  104814. * Creates a new pipeline context
  104815. * @returns the new pipeline
  104816. */
  104817. createPipelineContext(): IPipelineContext;
  104818. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104819. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104820. /** @hidden */
  104821. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104822. /** @hidden */
  104823. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104824. /** @hidden */
  104825. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104826. /**
  104827. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104828. * @param pipelineContext defines the pipeline context to use
  104829. * @param uniformsNames defines the list of uniform names
  104830. * @returns an array of webGL uniform locations
  104831. */
  104832. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104833. /**
  104834. * Gets the lsit of active attributes for a given webGL program
  104835. * @param pipelineContext defines the pipeline context to use
  104836. * @param attributesNames defines the list of attribute names to get
  104837. * @returns an array of indices indicating the offset of each attribute
  104838. */
  104839. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104840. /**
  104841. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104842. * @param effect defines the effect to activate
  104843. */
  104844. enableEffect(effect: Nullable<Effect>): void;
  104845. /**
  104846. * Set the value of an uniform to a number (int)
  104847. * @param uniform defines the webGL uniform location where to store the value
  104848. * @param value defines the int number to store
  104849. */
  104850. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104851. /**
  104852. * Set the value of an uniform to an array of int32
  104853. * @param uniform defines the webGL uniform location where to store the value
  104854. * @param array defines the array of int32 to store
  104855. */
  104856. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104857. /**
  104858. * Set the value of an uniform to an array of int32 (stored as vec2)
  104859. * @param uniform defines the webGL uniform location where to store the value
  104860. * @param array defines the array of int32 to store
  104861. */
  104862. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104863. /**
  104864. * Set the value of an uniform to an array of int32 (stored as vec3)
  104865. * @param uniform defines the webGL uniform location where to store the value
  104866. * @param array defines the array of int32 to store
  104867. */
  104868. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104869. /**
  104870. * Set the value of an uniform to an array of int32 (stored as vec4)
  104871. * @param uniform defines the webGL uniform location where to store the value
  104872. * @param array defines the array of int32 to store
  104873. */
  104874. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104875. /**
  104876. * Set the value of an uniform to an array of number
  104877. * @param uniform defines the webGL uniform location where to store the value
  104878. * @param array defines the array of number to store
  104879. */
  104880. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104881. /**
  104882. * Set the value of an uniform to an array of number (stored as vec2)
  104883. * @param uniform defines the webGL uniform location where to store the value
  104884. * @param array defines the array of number to store
  104885. */
  104886. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104887. /**
  104888. * Set the value of an uniform to an array of number (stored as vec3)
  104889. * @param uniform defines the webGL uniform location where to store the value
  104890. * @param array defines the array of number to store
  104891. */
  104892. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104893. /**
  104894. * Set the value of an uniform to an array of number (stored as vec4)
  104895. * @param uniform defines the webGL uniform location where to store the value
  104896. * @param array defines the array of number to store
  104897. */
  104898. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104899. /**
  104900. * Set the value of an uniform to an array of float32 (stored as matrices)
  104901. * @param uniform defines the webGL uniform location where to store the value
  104902. * @param matrices defines the array of float32 to store
  104903. */
  104904. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104905. /**
  104906. * Set the value of an uniform to a matrix (3x3)
  104907. * @param uniform defines the webGL uniform location where to store the value
  104908. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104909. */
  104910. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104911. /**
  104912. * Set the value of an uniform to a matrix (2x2)
  104913. * @param uniform defines the webGL uniform location where to store the value
  104914. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104915. */
  104916. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104917. /**
  104918. * Set the value of an uniform to a number (float)
  104919. * @param uniform defines the webGL uniform location where to store the value
  104920. * @param value defines the float number to store
  104921. */
  104922. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104923. /**
  104924. * Set the value of an uniform to a vec2
  104925. * @param uniform defines the webGL uniform location where to store the value
  104926. * @param x defines the 1st component of the value
  104927. * @param y defines the 2nd component of the value
  104928. */
  104929. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104930. /**
  104931. * Set the value of an uniform to a vec3
  104932. * @param uniform defines the webGL uniform location where to store the value
  104933. * @param x defines the 1st component of the value
  104934. * @param y defines the 2nd component of the value
  104935. * @param z defines the 3rd component of the value
  104936. */
  104937. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104938. /**
  104939. * Set the value of an uniform to a vec4
  104940. * @param uniform defines the webGL uniform location where to store the value
  104941. * @param x defines the 1st component of the value
  104942. * @param y defines the 2nd component of the value
  104943. * @param z defines the 3rd component of the value
  104944. * @param w defines the 4th component of the value
  104945. */
  104946. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104947. /**
  104948. * Apply all cached states (depth, culling, stencil and alpha)
  104949. */
  104950. applyStates(): void;
  104951. /**
  104952. * Enable or disable color writing
  104953. * @param enable defines the state to set
  104954. */
  104955. setColorWrite(enable: boolean): void;
  104956. /**
  104957. * Gets a boolean indicating if color writing is enabled
  104958. * @returns the current color writing state
  104959. */
  104960. getColorWrite(): boolean;
  104961. /**
  104962. * Gets the depth culling state manager
  104963. */
  104964. get depthCullingState(): DepthCullingState;
  104965. /**
  104966. * Gets the alpha state manager
  104967. */
  104968. get alphaState(): AlphaState;
  104969. /**
  104970. * Gets the stencil state manager
  104971. */
  104972. get stencilState(): StencilState;
  104973. /**
  104974. * Clears the list of texture accessible through engine.
  104975. * This can help preventing texture load conflict due to name collision.
  104976. */
  104977. clearInternalTexturesCache(): void;
  104978. /**
  104979. * Force the entire cache to be cleared
  104980. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104981. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104982. */
  104983. wipeCaches(bruteForce?: boolean): void;
  104984. /** @hidden */
  104985. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104986. min: number;
  104987. mag: number;
  104988. };
  104989. /** @hidden */
  104990. _createTexture(): WebGLTexture;
  104991. /**
  104992. * Usually called from Texture.ts.
  104993. * Passed information to create a WebGLTexture
  104994. * @param urlArg defines a value which contains one of the following:
  104995. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104996. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104997. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104999. * @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)
  105000. * @param scene needed for loading to the correct scene
  105001. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105002. * @param onLoad optional callback to be called upon successful completion
  105003. * @param onError optional callback to be called upon failure
  105004. * @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
  105005. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105006. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105007. * @param forcedExtension defines the extension to use to pick the right loader
  105008. * @param mimeType defines an optional mime type
  105009. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105010. */
  105011. 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;
  105012. /**
  105013. * Loads an image as an HTMLImageElement.
  105014. * @param input url string, ArrayBuffer, or Blob to load
  105015. * @param onLoad callback called when the image successfully loads
  105016. * @param onError callback called when the image fails to load
  105017. * @param offlineProvider offline provider for caching
  105018. * @param mimeType optional mime type
  105019. * @returns the HTMLImageElement of the loaded image
  105020. * @hidden
  105021. */
  105022. 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>;
  105023. /**
  105024. * @hidden
  105025. */
  105026. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105027. /**
  105028. * Creates a raw texture
  105029. * @param data defines the data to store in the texture
  105030. * @param width defines the width of the texture
  105031. * @param height defines the height of the texture
  105032. * @param format defines the format of the data
  105033. * @param generateMipMaps defines if the engine should generate the mip levels
  105034. * @param invertY defines if data must be stored with Y axis inverted
  105035. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105036. * @param compression defines the compression used (null by default)
  105037. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105038. * @returns the raw texture inside an InternalTexture
  105039. */
  105040. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105041. /**
  105042. * Creates a new raw cube texture
  105043. * @param data defines the array of data to use to create each face
  105044. * @param size defines the size of the textures
  105045. * @param format defines the format of the data
  105046. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105047. * @param generateMipMaps defines if the engine should generate the mip levels
  105048. * @param invertY defines if data must be stored with Y axis inverted
  105049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105050. * @param compression defines the compression used (null by default)
  105051. * @returns the cube texture as an InternalTexture
  105052. */
  105053. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105054. /**
  105055. * Creates a new raw 3D texture
  105056. * @param data defines the data used to create the texture
  105057. * @param width defines the width of the texture
  105058. * @param height defines the height of the texture
  105059. * @param depth defines the depth of the texture
  105060. * @param format defines the format of the texture
  105061. * @param generateMipMaps defines if the engine must generate mip levels
  105062. * @param invertY defines if data must be stored with Y axis inverted
  105063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105064. * @param compression defines the compressed used (can be null)
  105065. * @param textureType defines the compressed used (can be null)
  105066. * @returns a new raw 3D texture (stored in an InternalTexture)
  105067. */
  105068. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105069. /**
  105070. * Creates a new raw 2D array texture
  105071. * @param data defines the data used to create the texture
  105072. * @param width defines the width of the texture
  105073. * @param height defines the height of the texture
  105074. * @param depth defines the number of layers of the texture
  105075. * @param format defines the format of the texture
  105076. * @param generateMipMaps defines if the engine must generate mip levels
  105077. * @param invertY defines if data must be stored with Y axis inverted
  105078. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105079. * @param compression defines the compressed used (can be null)
  105080. * @param textureType defines the compressed used (can be null)
  105081. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105082. */
  105083. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105084. private _unpackFlipYCached;
  105085. /**
  105086. * In case you are sharing the context with other applications, it might
  105087. * be interested to not cache the unpack flip y state to ensure a consistent
  105088. * value would be set.
  105089. */
  105090. enableUnpackFlipYCached: boolean;
  105091. /** @hidden */
  105092. _unpackFlipY(value: boolean): void;
  105093. /** @hidden */
  105094. _getUnpackAlignement(): number;
  105095. private _getTextureTarget;
  105096. /**
  105097. * Update the sampling mode of a given texture
  105098. * @param samplingMode defines the required sampling mode
  105099. * @param texture defines the texture to update
  105100. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105101. */
  105102. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105103. /**
  105104. * Update the sampling mode of a given texture
  105105. * @param texture defines the texture to update
  105106. * @param wrapU defines the texture wrap mode of the u coordinates
  105107. * @param wrapV defines the texture wrap mode of the v coordinates
  105108. * @param wrapR defines the texture wrap mode of the r coordinates
  105109. */
  105110. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105111. /** @hidden */
  105112. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105113. width: number;
  105114. height: number;
  105115. layers?: number;
  105116. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105117. /** @hidden */
  105118. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105119. /** @hidden */
  105120. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105121. /**
  105122. * Update a portion of an internal texture
  105123. * @param texture defines the texture to update
  105124. * @param imageData defines the data to store into the texture
  105125. * @param xOffset defines the x coordinates of the update rectangle
  105126. * @param yOffset defines the y coordinates of the update rectangle
  105127. * @param width defines the width of the update rectangle
  105128. * @param height defines the height of the update rectangle
  105129. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105130. * @param lod defines the lod level to update (0 by default)
  105131. */
  105132. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105133. /** @hidden */
  105134. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105135. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105136. private _prepareWebGLTexture;
  105137. /** @hidden */
  105138. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105139. private _getDepthStencilBuffer;
  105140. /** @hidden */
  105141. _releaseFramebufferObjects(texture: InternalTexture): void;
  105142. /** @hidden */
  105143. _releaseTexture(texture: InternalTexture): void;
  105144. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105145. protected _setProgram(program: WebGLProgram): void;
  105146. protected _boundUniforms: {
  105147. [key: number]: WebGLUniformLocation;
  105148. };
  105149. /**
  105150. * Binds an effect to the webGL context
  105151. * @param effect defines the effect to bind
  105152. */
  105153. bindSamplers(effect: Effect): void;
  105154. private _activateCurrentTexture;
  105155. /** @hidden */
  105156. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105157. /** @hidden */
  105158. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105159. /**
  105160. * Unbind all textures from the webGL context
  105161. */
  105162. unbindAllTextures(): void;
  105163. /**
  105164. * Sets a texture to the according uniform.
  105165. * @param channel The texture channel
  105166. * @param uniform The uniform to set
  105167. * @param texture The texture to apply
  105168. */
  105169. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105170. private _bindSamplerUniformToChannel;
  105171. private _getTextureWrapMode;
  105172. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105173. /**
  105174. * Sets an array of texture to the webGL context
  105175. * @param channel defines the channel where the texture array must be set
  105176. * @param uniform defines the associated uniform location
  105177. * @param textures defines the array of textures to bind
  105178. */
  105179. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105180. /** @hidden */
  105181. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105182. private _setTextureParameterFloat;
  105183. private _setTextureParameterInteger;
  105184. /**
  105185. * Unbind all vertex attributes from the webGL context
  105186. */
  105187. unbindAllAttributes(): void;
  105188. /**
  105189. * 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
  105190. */
  105191. releaseEffects(): void;
  105192. /**
  105193. * Dispose and release all associated resources
  105194. */
  105195. dispose(): void;
  105196. /**
  105197. * Attach a new callback raised when context lost event is fired
  105198. * @param callback defines the callback to call
  105199. */
  105200. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105201. /**
  105202. * Attach a new callback raised when context restored event is fired
  105203. * @param callback defines the callback to call
  105204. */
  105205. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105206. /**
  105207. * Get the current error code of the webGL context
  105208. * @returns the error code
  105209. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105210. */
  105211. getError(): number;
  105212. private _canRenderToFloatFramebuffer;
  105213. private _canRenderToHalfFloatFramebuffer;
  105214. private _canRenderToFramebuffer;
  105215. /** @hidden */
  105216. _getWebGLTextureType(type: number): number;
  105217. /** @hidden */
  105218. _getInternalFormat(format: number): number;
  105219. /** @hidden */
  105220. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105221. /** @hidden */
  105222. _getRGBAMultiSampleBufferFormat(type: number): number;
  105223. /** @hidden */
  105224. _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;
  105225. /**
  105226. * Loads a file from a url
  105227. * @param url url to load
  105228. * @param onSuccess callback called when the file successfully loads
  105229. * @param onProgress callback called while file is loading (if the server supports this mode)
  105230. * @param offlineProvider defines the offline provider for caching
  105231. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105232. * @param onError callback called when the file fails to load
  105233. * @returns a file request object
  105234. * @hidden
  105235. */
  105236. 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;
  105237. /**
  105238. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105239. * @param x defines the x coordinate of the rectangle where pixels must be read
  105240. * @param y defines the y coordinate of the rectangle where pixels must be read
  105241. * @param width defines the width of the rectangle where pixels must be read
  105242. * @param height defines the height of the rectangle where pixels must be read
  105243. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105244. * @returns a Uint8Array containing RGBA colors
  105245. */
  105246. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105247. private static _isSupported;
  105248. /**
  105249. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105250. * @returns true if the engine can be created
  105251. * @ignorenaming
  105252. */
  105253. static isSupported(): boolean;
  105254. /**
  105255. * Find the next highest power of two.
  105256. * @param x Number to start search from.
  105257. * @return Next highest power of two.
  105258. */
  105259. static CeilingPOT(x: number): number;
  105260. /**
  105261. * Find the next lowest power of two.
  105262. * @param x Number to start search from.
  105263. * @return Next lowest power of two.
  105264. */
  105265. static FloorPOT(x: number): number;
  105266. /**
  105267. * Find the nearest power of two.
  105268. * @param x Number to start search from.
  105269. * @return Next nearest power of two.
  105270. */
  105271. static NearestPOT(x: number): number;
  105272. /**
  105273. * Get the closest exponent of two
  105274. * @param value defines the value to approximate
  105275. * @param max defines the maximum value to return
  105276. * @param mode defines how to define the closest value
  105277. * @returns closest exponent of two of the given value
  105278. */
  105279. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105280. /**
  105281. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105282. * @param func - the function to be called
  105283. * @param requester - the object that will request the next frame. Falls back to window.
  105284. * @returns frame number
  105285. */
  105286. static QueueNewFrame(func: () => void, requester?: any): number;
  105287. /**
  105288. * Gets host document
  105289. * @returns the host document object
  105290. */
  105291. getHostDocument(): Nullable<Document>;
  105292. }
  105293. }
  105294. declare module BABYLON {
  105295. /**
  105296. * Class representing spherical harmonics coefficients to the 3rd degree
  105297. */
  105298. export class SphericalHarmonics {
  105299. /**
  105300. * Defines whether or not the harmonics have been prescaled for rendering.
  105301. */
  105302. preScaled: boolean;
  105303. /**
  105304. * The l0,0 coefficients of the spherical harmonics
  105305. */
  105306. l00: Vector3;
  105307. /**
  105308. * The l1,-1 coefficients of the spherical harmonics
  105309. */
  105310. l1_1: Vector3;
  105311. /**
  105312. * The l1,0 coefficients of the spherical harmonics
  105313. */
  105314. l10: Vector3;
  105315. /**
  105316. * The l1,1 coefficients of the spherical harmonics
  105317. */
  105318. l11: Vector3;
  105319. /**
  105320. * The l2,-2 coefficients of the spherical harmonics
  105321. */
  105322. l2_2: Vector3;
  105323. /**
  105324. * The l2,-1 coefficients of the spherical harmonics
  105325. */
  105326. l2_1: Vector3;
  105327. /**
  105328. * The l2,0 coefficients of the spherical harmonics
  105329. */
  105330. l20: Vector3;
  105331. /**
  105332. * The l2,1 coefficients of the spherical harmonics
  105333. */
  105334. l21: Vector3;
  105335. /**
  105336. * The l2,2 coefficients of the spherical harmonics
  105337. */
  105338. l22: Vector3;
  105339. /**
  105340. * Adds a light to the spherical harmonics
  105341. * @param direction the direction of the light
  105342. * @param color the color of the light
  105343. * @param deltaSolidAngle the delta solid angle of the light
  105344. */
  105345. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105346. /**
  105347. * Scales the spherical harmonics by the given amount
  105348. * @param scale the amount to scale
  105349. */
  105350. scaleInPlace(scale: number): void;
  105351. /**
  105352. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105353. *
  105354. * ```
  105355. * E_lm = A_l * L_lm
  105356. * ```
  105357. *
  105358. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105359. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105360. * the scaling factors are given in equation 9.
  105361. */
  105362. convertIncidentRadianceToIrradiance(): void;
  105363. /**
  105364. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105365. *
  105366. * ```
  105367. * L = (1/pi) * E * rho
  105368. * ```
  105369. *
  105370. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105371. */
  105372. convertIrradianceToLambertianRadiance(): void;
  105373. /**
  105374. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105375. * required operations at run time.
  105376. *
  105377. * This is simply done by scaling back the SH with Ylm constants parameter.
  105378. * The trigonometric part being applied by the shader at run time.
  105379. */
  105380. preScaleForRendering(): void;
  105381. /**
  105382. * Constructs a spherical harmonics from an array.
  105383. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105384. * @returns the spherical harmonics
  105385. */
  105386. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105387. /**
  105388. * Gets the spherical harmonics from polynomial
  105389. * @param polynomial the spherical polynomial
  105390. * @returns the spherical harmonics
  105391. */
  105392. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105393. }
  105394. /**
  105395. * Class representing spherical polynomial coefficients to the 3rd degree
  105396. */
  105397. export class SphericalPolynomial {
  105398. private _harmonics;
  105399. /**
  105400. * The spherical harmonics used to create the polynomials.
  105401. */
  105402. get preScaledHarmonics(): SphericalHarmonics;
  105403. /**
  105404. * The x coefficients of the spherical polynomial
  105405. */
  105406. x: Vector3;
  105407. /**
  105408. * The y coefficients of the spherical polynomial
  105409. */
  105410. y: Vector3;
  105411. /**
  105412. * The z coefficients of the spherical polynomial
  105413. */
  105414. z: Vector3;
  105415. /**
  105416. * The xx coefficients of the spherical polynomial
  105417. */
  105418. xx: Vector3;
  105419. /**
  105420. * The yy coefficients of the spherical polynomial
  105421. */
  105422. yy: Vector3;
  105423. /**
  105424. * The zz coefficients of the spherical polynomial
  105425. */
  105426. zz: Vector3;
  105427. /**
  105428. * The xy coefficients of the spherical polynomial
  105429. */
  105430. xy: Vector3;
  105431. /**
  105432. * The yz coefficients of the spherical polynomial
  105433. */
  105434. yz: Vector3;
  105435. /**
  105436. * The zx coefficients of the spherical polynomial
  105437. */
  105438. zx: Vector3;
  105439. /**
  105440. * Adds an ambient color to the spherical polynomial
  105441. * @param color the color to add
  105442. */
  105443. addAmbient(color: Color3): void;
  105444. /**
  105445. * Scales the spherical polynomial by the given amount
  105446. * @param scale the amount to scale
  105447. */
  105448. scaleInPlace(scale: number): void;
  105449. /**
  105450. * Gets the spherical polynomial from harmonics
  105451. * @param harmonics the spherical harmonics
  105452. * @returns the spherical polynomial
  105453. */
  105454. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105455. /**
  105456. * Constructs a spherical polynomial from an array.
  105457. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105458. * @returns the spherical polynomial
  105459. */
  105460. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105461. }
  105462. }
  105463. declare module BABYLON {
  105464. /**
  105465. * Defines the source of the internal texture
  105466. */
  105467. export enum InternalTextureSource {
  105468. /**
  105469. * The source of the texture data is unknown
  105470. */
  105471. Unknown = 0,
  105472. /**
  105473. * Texture data comes from an URL
  105474. */
  105475. Url = 1,
  105476. /**
  105477. * Texture data is only used for temporary storage
  105478. */
  105479. Temp = 2,
  105480. /**
  105481. * Texture data comes from raw data (ArrayBuffer)
  105482. */
  105483. Raw = 3,
  105484. /**
  105485. * Texture content is dynamic (video or dynamic texture)
  105486. */
  105487. Dynamic = 4,
  105488. /**
  105489. * Texture content is generated by rendering to it
  105490. */
  105491. RenderTarget = 5,
  105492. /**
  105493. * Texture content is part of a multi render target process
  105494. */
  105495. MultiRenderTarget = 6,
  105496. /**
  105497. * Texture data comes from a cube data file
  105498. */
  105499. Cube = 7,
  105500. /**
  105501. * Texture data comes from a raw cube data
  105502. */
  105503. CubeRaw = 8,
  105504. /**
  105505. * Texture data come from a prefiltered cube data file
  105506. */
  105507. CubePrefiltered = 9,
  105508. /**
  105509. * Texture content is raw 3D data
  105510. */
  105511. Raw3D = 10,
  105512. /**
  105513. * Texture content is raw 2D array data
  105514. */
  105515. Raw2DArray = 11,
  105516. /**
  105517. * Texture content is a depth texture
  105518. */
  105519. Depth = 12,
  105520. /**
  105521. * Texture data comes from a raw cube data encoded with RGBD
  105522. */
  105523. CubeRawRGBD = 13
  105524. }
  105525. /**
  105526. * Class used to store data associated with WebGL texture data for the engine
  105527. * This class should not be used directly
  105528. */
  105529. export class InternalTexture {
  105530. /** @hidden */
  105531. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105532. /**
  105533. * Defines if the texture is ready
  105534. */
  105535. isReady: boolean;
  105536. /**
  105537. * Defines if the texture is a cube texture
  105538. */
  105539. isCube: boolean;
  105540. /**
  105541. * Defines if the texture contains 3D data
  105542. */
  105543. is3D: boolean;
  105544. /**
  105545. * Defines if the texture contains 2D array data
  105546. */
  105547. is2DArray: boolean;
  105548. /**
  105549. * Defines if the texture contains multiview data
  105550. */
  105551. isMultiview: boolean;
  105552. /**
  105553. * Gets the URL used to load this texture
  105554. */
  105555. url: string;
  105556. /**
  105557. * Gets the sampling mode of the texture
  105558. */
  105559. samplingMode: number;
  105560. /**
  105561. * Gets a boolean indicating if the texture needs mipmaps generation
  105562. */
  105563. generateMipMaps: boolean;
  105564. /**
  105565. * Gets the number of samples used by the texture (WebGL2+ only)
  105566. */
  105567. samples: number;
  105568. /**
  105569. * Gets the type of the texture (int, float...)
  105570. */
  105571. type: number;
  105572. /**
  105573. * Gets the format of the texture (RGB, RGBA...)
  105574. */
  105575. format: number;
  105576. /**
  105577. * Observable called when the texture is loaded
  105578. */
  105579. onLoadedObservable: Observable<InternalTexture>;
  105580. /**
  105581. * Gets the width of the texture
  105582. */
  105583. width: number;
  105584. /**
  105585. * Gets the height of the texture
  105586. */
  105587. height: number;
  105588. /**
  105589. * Gets the depth of the texture
  105590. */
  105591. depth: number;
  105592. /**
  105593. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105594. */
  105595. baseWidth: number;
  105596. /**
  105597. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105598. */
  105599. baseHeight: number;
  105600. /**
  105601. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105602. */
  105603. baseDepth: number;
  105604. /**
  105605. * Gets a boolean indicating if the texture is inverted on Y axis
  105606. */
  105607. invertY: boolean;
  105608. /** @hidden */
  105609. _invertVScale: boolean;
  105610. /** @hidden */
  105611. _associatedChannel: number;
  105612. /** @hidden */
  105613. _source: InternalTextureSource;
  105614. /** @hidden */
  105615. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105616. /** @hidden */
  105617. _bufferView: Nullable<ArrayBufferView>;
  105618. /** @hidden */
  105619. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105620. /** @hidden */
  105621. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105622. /** @hidden */
  105623. _size: number;
  105624. /** @hidden */
  105625. _extension: string;
  105626. /** @hidden */
  105627. _files: Nullable<string[]>;
  105628. /** @hidden */
  105629. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105630. /** @hidden */
  105631. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105632. /** @hidden */
  105633. _framebuffer: Nullable<WebGLFramebuffer>;
  105634. /** @hidden */
  105635. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105636. /** @hidden */
  105637. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105638. /** @hidden */
  105639. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105640. /** @hidden */
  105641. _attachments: Nullable<number[]>;
  105642. /** @hidden */
  105643. _cachedCoordinatesMode: Nullable<number>;
  105644. /** @hidden */
  105645. _cachedWrapU: Nullable<number>;
  105646. /** @hidden */
  105647. _cachedWrapV: Nullable<number>;
  105648. /** @hidden */
  105649. _cachedWrapR: Nullable<number>;
  105650. /** @hidden */
  105651. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105652. /** @hidden */
  105653. _isDisabled: boolean;
  105654. /** @hidden */
  105655. _compression: Nullable<string>;
  105656. /** @hidden */
  105657. _generateStencilBuffer: boolean;
  105658. /** @hidden */
  105659. _generateDepthBuffer: boolean;
  105660. /** @hidden */
  105661. _comparisonFunction: number;
  105662. /** @hidden */
  105663. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105664. /** @hidden */
  105665. _lodGenerationScale: number;
  105666. /** @hidden */
  105667. _lodGenerationOffset: number;
  105668. /** @hidden */
  105669. _depthStencilTexture: Nullable<InternalTexture>;
  105670. /** @hidden */
  105671. _colorTextureArray: Nullable<WebGLTexture>;
  105672. /** @hidden */
  105673. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105674. /** @hidden */
  105675. _lodTextureHigh: Nullable<BaseTexture>;
  105676. /** @hidden */
  105677. _lodTextureMid: Nullable<BaseTexture>;
  105678. /** @hidden */
  105679. _lodTextureLow: Nullable<BaseTexture>;
  105680. /** @hidden */
  105681. _isRGBD: boolean;
  105682. /** @hidden */
  105683. _linearSpecularLOD: boolean;
  105684. /** @hidden */
  105685. _irradianceTexture: Nullable<BaseTexture>;
  105686. /** @hidden */
  105687. _webGLTexture: Nullable<WebGLTexture>;
  105688. /** @hidden */
  105689. _references: number;
  105690. private _engine;
  105691. /**
  105692. * Gets the Engine the texture belongs to.
  105693. * @returns The babylon engine
  105694. */
  105695. getEngine(): ThinEngine;
  105696. /**
  105697. * Gets the data source type of the texture
  105698. */
  105699. get source(): InternalTextureSource;
  105700. /**
  105701. * Creates a new InternalTexture
  105702. * @param engine defines the engine to use
  105703. * @param source defines the type of data that will be used
  105704. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105705. */
  105706. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105707. /**
  105708. * Increments the number of references (ie. the number of Texture that point to it)
  105709. */
  105710. incrementReferences(): void;
  105711. /**
  105712. * Change the size of the texture (not the size of the content)
  105713. * @param width defines the new width
  105714. * @param height defines the new height
  105715. * @param depth defines the new depth (1 by default)
  105716. */
  105717. updateSize(width: int, height: int, depth?: int): void;
  105718. /** @hidden */
  105719. _rebuild(): void;
  105720. /** @hidden */
  105721. _swapAndDie(target: InternalTexture): void;
  105722. /**
  105723. * Dispose the current allocated resources
  105724. */
  105725. dispose(): void;
  105726. }
  105727. }
  105728. declare module BABYLON {
  105729. /**
  105730. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105732. */
  105733. export class Analyser {
  105734. /**
  105735. * Gets or sets the smoothing
  105736. * @ignorenaming
  105737. */
  105738. SMOOTHING: number;
  105739. /**
  105740. * Gets or sets the FFT table size
  105741. * @ignorenaming
  105742. */
  105743. FFT_SIZE: number;
  105744. /**
  105745. * Gets or sets the bar graph amplitude
  105746. * @ignorenaming
  105747. */
  105748. BARGRAPHAMPLITUDE: number;
  105749. /**
  105750. * Gets or sets the position of the debug canvas
  105751. * @ignorenaming
  105752. */
  105753. DEBUGCANVASPOS: {
  105754. x: number;
  105755. y: number;
  105756. };
  105757. /**
  105758. * Gets or sets the debug canvas size
  105759. * @ignorenaming
  105760. */
  105761. DEBUGCANVASSIZE: {
  105762. width: number;
  105763. height: number;
  105764. };
  105765. private _byteFreqs;
  105766. private _byteTime;
  105767. private _floatFreqs;
  105768. private _webAudioAnalyser;
  105769. private _debugCanvas;
  105770. private _debugCanvasContext;
  105771. private _scene;
  105772. private _registerFunc;
  105773. private _audioEngine;
  105774. /**
  105775. * Creates a new analyser
  105776. * @param scene defines hosting scene
  105777. */
  105778. constructor(scene: Scene);
  105779. /**
  105780. * Get the number of data values you will have to play with for the visualization
  105781. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105782. * @returns a number
  105783. */
  105784. getFrequencyBinCount(): number;
  105785. /**
  105786. * Gets the current frequency data as a byte array
  105787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105788. * @returns a Uint8Array
  105789. */
  105790. getByteFrequencyData(): Uint8Array;
  105791. /**
  105792. * Gets the current waveform as a byte array
  105793. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105794. * @returns a Uint8Array
  105795. */
  105796. getByteTimeDomainData(): Uint8Array;
  105797. /**
  105798. * Gets the current frequency data as a float array
  105799. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105800. * @returns a Float32Array
  105801. */
  105802. getFloatFrequencyData(): Float32Array;
  105803. /**
  105804. * Renders the debug canvas
  105805. */
  105806. drawDebugCanvas(): void;
  105807. /**
  105808. * Stops rendering the debug canvas and removes it
  105809. */
  105810. stopDebugCanvas(): void;
  105811. /**
  105812. * Connects two audio nodes
  105813. * @param inputAudioNode defines first node to connect
  105814. * @param outputAudioNode defines second node to connect
  105815. */
  105816. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105817. /**
  105818. * Releases all associated resources
  105819. */
  105820. dispose(): void;
  105821. }
  105822. }
  105823. declare module BABYLON {
  105824. /**
  105825. * This represents an audio engine and it is responsible
  105826. * to play, synchronize and analyse sounds throughout the application.
  105827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105828. */
  105829. export interface IAudioEngine extends IDisposable {
  105830. /**
  105831. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105832. */
  105833. readonly canUseWebAudio: boolean;
  105834. /**
  105835. * Gets the current AudioContext if available.
  105836. */
  105837. readonly audioContext: Nullable<AudioContext>;
  105838. /**
  105839. * The master gain node defines the global audio volume of your audio engine.
  105840. */
  105841. readonly masterGain: GainNode;
  105842. /**
  105843. * Gets whether or not mp3 are supported by your browser.
  105844. */
  105845. readonly isMP3supported: boolean;
  105846. /**
  105847. * Gets whether or not ogg are supported by your browser.
  105848. */
  105849. readonly isOGGsupported: boolean;
  105850. /**
  105851. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105852. * @ignoreNaming
  105853. */
  105854. WarnedWebAudioUnsupported: boolean;
  105855. /**
  105856. * Defines if the audio engine relies on a custom unlocked button.
  105857. * In this case, the embedded button will not be displayed.
  105858. */
  105859. useCustomUnlockedButton: boolean;
  105860. /**
  105861. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105862. */
  105863. readonly unlocked: boolean;
  105864. /**
  105865. * Event raised when audio has been unlocked on the browser.
  105866. */
  105867. onAudioUnlockedObservable: Observable<AudioEngine>;
  105868. /**
  105869. * Event raised when audio has been locked on the browser.
  105870. */
  105871. onAudioLockedObservable: Observable<AudioEngine>;
  105872. /**
  105873. * Flags the audio engine in Locked state.
  105874. * This happens due to new browser policies preventing audio to autoplay.
  105875. */
  105876. lock(): void;
  105877. /**
  105878. * Unlocks the audio engine once a user action has been done on the dom.
  105879. * This is helpful to resume play once browser policies have been satisfied.
  105880. */
  105881. unlock(): void;
  105882. }
  105883. /**
  105884. * This represents the default audio engine used in babylon.
  105885. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105887. */
  105888. export class AudioEngine implements IAudioEngine {
  105889. private _audioContext;
  105890. private _audioContextInitialized;
  105891. private _muteButton;
  105892. private _hostElement;
  105893. /**
  105894. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105895. */
  105896. canUseWebAudio: boolean;
  105897. /**
  105898. * The master gain node defines the global audio volume of your audio engine.
  105899. */
  105900. masterGain: GainNode;
  105901. /**
  105902. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105903. * @ignoreNaming
  105904. */
  105905. WarnedWebAudioUnsupported: boolean;
  105906. /**
  105907. * Gets whether or not mp3 are supported by your browser.
  105908. */
  105909. isMP3supported: boolean;
  105910. /**
  105911. * Gets whether or not ogg are supported by your browser.
  105912. */
  105913. isOGGsupported: boolean;
  105914. /**
  105915. * Gets whether audio has been unlocked on the device.
  105916. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105917. * a user interaction has happened.
  105918. */
  105919. unlocked: boolean;
  105920. /**
  105921. * Defines if the audio engine relies on a custom unlocked button.
  105922. * In this case, the embedded button will not be displayed.
  105923. */
  105924. useCustomUnlockedButton: boolean;
  105925. /**
  105926. * Event raised when audio has been unlocked on the browser.
  105927. */
  105928. onAudioUnlockedObservable: Observable<AudioEngine>;
  105929. /**
  105930. * Event raised when audio has been locked on the browser.
  105931. */
  105932. onAudioLockedObservable: Observable<AudioEngine>;
  105933. /**
  105934. * Gets the current AudioContext if available.
  105935. */
  105936. get audioContext(): Nullable<AudioContext>;
  105937. private _connectedAnalyser;
  105938. /**
  105939. * Instantiates a new audio engine.
  105940. *
  105941. * There should be only one per page as some browsers restrict the number
  105942. * of audio contexts you can create.
  105943. * @param hostElement defines the host element where to display the mute icon if necessary
  105944. */
  105945. constructor(hostElement?: Nullable<HTMLElement>);
  105946. /**
  105947. * Flags the audio engine in Locked state.
  105948. * This happens due to new browser policies preventing audio to autoplay.
  105949. */
  105950. lock(): void;
  105951. /**
  105952. * Unlocks the audio engine once a user action has been done on the dom.
  105953. * This is helpful to resume play once browser policies have been satisfied.
  105954. */
  105955. unlock(): void;
  105956. private _resumeAudioContext;
  105957. private _initializeAudioContext;
  105958. private _tryToRun;
  105959. private _triggerRunningState;
  105960. private _triggerSuspendedState;
  105961. private _displayMuteButton;
  105962. private _moveButtonToTopLeft;
  105963. private _onResize;
  105964. private _hideMuteButton;
  105965. /**
  105966. * Destroy and release the resources associated with the audio ccontext.
  105967. */
  105968. dispose(): void;
  105969. /**
  105970. * Gets the global volume sets on the master gain.
  105971. * @returns the global volume if set or -1 otherwise
  105972. */
  105973. getGlobalVolume(): number;
  105974. /**
  105975. * Sets the global volume of your experience (sets on the master gain).
  105976. * @param newVolume Defines the new global volume of the application
  105977. */
  105978. setGlobalVolume(newVolume: number): void;
  105979. /**
  105980. * Connect the audio engine to an audio analyser allowing some amazing
  105981. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105983. * @param analyser The analyser to connect to the engine
  105984. */
  105985. connectToAnalyser(analyser: Analyser): void;
  105986. }
  105987. }
  105988. declare module BABYLON {
  105989. /**
  105990. * Interface used to present a loading screen while loading a scene
  105991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105992. */
  105993. export interface ILoadingScreen {
  105994. /**
  105995. * Function called to display the loading screen
  105996. */
  105997. displayLoadingUI: () => void;
  105998. /**
  105999. * Function called to hide the loading screen
  106000. */
  106001. hideLoadingUI: () => void;
  106002. /**
  106003. * Gets or sets the color to use for the background
  106004. */
  106005. loadingUIBackgroundColor: string;
  106006. /**
  106007. * Gets or sets the text to display while loading
  106008. */
  106009. loadingUIText: string;
  106010. }
  106011. /**
  106012. * Class used for the default loading screen
  106013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106014. */
  106015. export class DefaultLoadingScreen implements ILoadingScreen {
  106016. private _renderingCanvas;
  106017. private _loadingText;
  106018. private _loadingDivBackgroundColor;
  106019. private _loadingDiv;
  106020. private _loadingTextDiv;
  106021. /** Gets or sets the logo url to use for the default loading screen */
  106022. static DefaultLogoUrl: string;
  106023. /** Gets or sets the spinner url to use for the default loading screen */
  106024. static DefaultSpinnerUrl: string;
  106025. /**
  106026. * Creates a new default loading screen
  106027. * @param _renderingCanvas defines the canvas used to render the scene
  106028. * @param _loadingText defines the default text to display
  106029. * @param _loadingDivBackgroundColor defines the default background color
  106030. */
  106031. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106032. /**
  106033. * Function called to display the loading screen
  106034. */
  106035. displayLoadingUI(): void;
  106036. /**
  106037. * Function called to hide the loading screen
  106038. */
  106039. hideLoadingUI(): void;
  106040. /**
  106041. * Gets or sets the text to display while loading
  106042. */
  106043. set loadingUIText(text: string);
  106044. get loadingUIText(): string;
  106045. /**
  106046. * Gets or sets the color to use for the background
  106047. */
  106048. get loadingUIBackgroundColor(): string;
  106049. set loadingUIBackgroundColor(color: string);
  106050. private _resizeLoadingUI;
  106051. }
  106052. }
  106053. declare module BABYLON {
  106054. /**
  106055. * Interface for any object that can request an animation frame
  106056. */
  106057. export interface ICustomAnimationFrameRequester {
  106058. /**
  106059. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106060. */
  106061. renderFunction?: Function;
  106062. /**
  106063. * Called to request the next frame to render to
  106064. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106065. */
  106066. requestAnimationFrame: Function;
  106067. /**
  106068. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106069. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106070. */
  106071. requestID?: number;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106077. */
  106078. export class PerformanceMonitor {
  106079. private _enabled;
  106080. private _rollingFrameTime;
  106081. private _lastFrameTimeMs;
  106082. /**
  106083. * constructor
  106084. * @param frameSampleSize The number of samples required to saturate the sliding window
  106085. */
  106086. constructor(frameSampleSize?: number);
  106087. /**
  106088. * Samples current frame
  106089. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106090. */
  106091. sampleFrame(timeMs?: number): void;
  106092. /**
  106093. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106094. */
  106095. get averageFrameTime(): number;
  106096. /**
  106097. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106098. */
  106099. get averageFrameTimeVariance(): number;
  106100. /**
  106101. * Returns the frame time of the most recent frame
  106102. */
  106103. get instantaneousFrameTime(): number;
  106104. /**
  106105. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106106. */
  106107. get averageFPS(): number;
  106108. /**
  106109. * Returns the average framerate in frames per second using the most recent frame time
  106110. */
  106111. get instantaneousFPS(): number;
  106112. /**
  106113. * Returns true if enough samples have been taken to completely fill the sliding window
  106114. */
  106115. get isSaturated(): boolean;
  106116. /**
  106117. * Enables contributions to the sliding window sample set
  106118. */
  106119. enable(): void;
  106120. /**
  106121. * Disables contributions to the sliding window sample set
  106122. * Samples will not be interpolated over the disabled period
  106123. */
  106124. disable(): void;
  106125. /**
  106126. * Returns true if sampling is enabled
  106127. */
  106128. get isEnabled(): boolean;
  106129. /**
  106130. * Resets performance monitor
  106131. */
  106132. reset(): void;
  106133. }
  106134. /**
  106135. * RollingAverage
  106136. *
  106137. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106138. */
  106139. export class RollingAverage {
  106140. /**
  106141. * Current average
  106142. */
  106143. average: number;
  106144. /**
  106145. * Current variance
  106146. */
  106147. variance: number;
  106148. protected _samples: Array<number>;
  106149. protected _sampleCount: number;
  106150. protected _pos: number;
  106151. protected _m2: number;
  106152. /**
  106153. * constructor
  106154. * @param length The number of samples required to saturate the sliding window
  106155. */
  106156. constructor(length: number);
  106157. /**
  106158. * Adds a sample to the sample set
  106159. * @param v The sample value
  106160. */
  106161. add(v: number): void;
  106162. /**
  106163. * Returns previously added values or null if outside of history or outside the sliding window domain
  106164. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106165. * @return Value previously recorded with add() or null if outside of range
  106166. */
  106167. history(i: number): number;
  106168. /**
  106169. * Returns true if enough samples have been taken to completely fill the sliding window
  106170. * @return true if sample-set saturated
  106171. */
  106172. isSaturated(): boolean;
  106173. /**
  106174. * Resets the rolling average (equivalent to 0 samples taken so far)
  106175. */
  106176. reset(): void;
  106177. /**
  106178. * Wraps a value around the sample range boundaries
  106179. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106180. * @return Wrapped position in sample range
  106181. */
  106182. protected _wrapPosition(i: number): number;
  106183. }
  106184. }
  106185. declare module BABYLON {
  106186. /**
  106187. * This class is used to track a performance counter which is number based.
  106188. * The user has access to many properties which give statistics of different nature.
  106189. *
  106190. * The implementer can track two kinds of Performance Counter: time and count.
  106191. * 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.
  106192. * 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.
  106193. */
  106194. export class PerfCounter {
  106195. /**
  106196. * Gets or sets a global boolean to turn on and off all the counters
  106197. */
  106198. static Enabled: boolean;
  106199. /**
  106200. * Returns the smallest value ever
  106201. */
  106202. get min(): number;
  106203. /**
  106204. * Returns the biggest value ever
  106205. */
  106206. get max(): number;
  106207. /**
  106208. * Returns the average value since the performance counter is running
  106209. */
  106210. get average(): number;
  106211. /**
  106212. * Returns the average value of the last second the counter was monitored
  106213. */
  106214. get lastSecAverage(): number;
  106215. /**
  106216. * Returns the current value
  106217. */
  106218. get current(): number;
  106219. /**
  106220. * Gets the accumulated total
  106221. */
  106222. get total(): number;
  106223. /**
  106224. * Gets the total value count
  106225. */
  106226. get count(): number;
  106227. /**
  106228. * Creates a new counter
  106229. */
  106230. constructor();
  106231. /**
  106232. * Call this method to start monitoring a new frame.
  106233. * 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.
  106234. */
  106235. fetchNewFrame(): void;
  106236. /**
  106237. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106238. * @param newCount the count value to add to the monitored count
  106239. * @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.
  106240. */
  106241. addCount(newCount: number, fetchResult: boolean): void;
  106242. /**
  106243. * Start monitoring this performance counter
  106244. */
  106245. beginMonitoring(): void;
  106246. /**
  106247. * Compute the time lapsed since the previous beginMonitoring() call.
  106248. * @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
  106249. */
  106250. endMonitoring(newFrame?: boolean): void;
  106251. private _fetchResult;
  106252. private _startMonitoringTime;
  106253. private _min;
  106254. private _max;
  106255. private _average;
  106256. private _current;
  106257. private _totalValueCount;
  106258. private _totalAccumulated;
  106259. private _lastSecAverage;
  106260. private _lastSecAccumulated;
  106261. private _lastSecTime;
  106262. private _lastSecValueCount;
  106263. }
  106264. }
  106265. declare module BABYLON {
  106266. interface ThinEngine {
  106267. /**
  106268. * Sets alpha constants used by some alpha blending modes
  106269. * @param r defines the red component
  106270. * @param g defines the green component
  106271. * @param b defines the blue component
  106272. * @param a defines the alpha component
  106273. */
  106274. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106275. /**
  106276. * Sets the current alpha mode
  106277. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106278. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106280. */
  106281. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106282. /**
  106283. * Gets the current alpha mode
  106284. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106285. * @returns the current alpha mode
  106286. */
  106287. getAlphaMode(): number;
  106288. /**
  106289. * Sets the current alpha equation
  106290. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106291. */
  106292. setAlphaEquation(equation: number): void;
  106293. /**
  106294. * Gets the current alpha equation.
  106295. * @returns the current alpha equation
  106296. */
  106297. getAlphaEquation(): number;
  106298. }
  106299. }
  106300. declare module BABYLON {
  106301. /**
  106302. * Defines the interface used by display changed events
  106303. */
  106304. export interface IDisplayChangedEventArgs {
  106305. /** Gets the vrDisplay object (if any) */
  106306. vrDisplay: Nullable<any>;
  106307. /** Gets a boolean indicating if webVR is supported */
  106308. vrSupported: boolean;
  106309. }
  106310. /**
  106311. * Defines the interface used by objects containing a viewport (like a camera)
  106312. */
  106313. interface IViewportOwnerLike {
  106314. /**
  106315. * Gets or sets the viewport
  106316. */
  106317. viewport: IViewportLike;
  106318. }
  106319. /**
  106320. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106321. */
  106322. export class Engine extends ThinEngine {
  106323. /** Defines that alpha blending is disabled */
  106324. static readonly ALPHA_DISABLE: number;
  106325. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106326. static readonly ALPHA_ADD: number;
  106327. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106328. static readonly ALPHA_COMBINE: number;
  106329. /** Defines that alpha blending to DEST - SRC * DEST */
  106330. static readonly ALPHA_SUBTRACT: number;
  106331. /** Defines that alpha blending to SRC * DEST */
  106332. static readonly ALPHA_MULTIPLY: number;
  106333. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106334. static readonly ALPHA_MAXIMIZED: number;
  106335. /** Defines that alpha blending to SRC + DEST */
  106336. static readonly ALPHA_ONEONE: number;
  106337. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106338. static readonly ALPHA_PREMULTIPLIED: number;
  106339. /**
  106340. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106341. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106342. */
  106343. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106344. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106345. static readonly ALPHA_INTERPOLATE: number;
  106346. /**
  106347. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106348. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106349. */
  106350. static readonly ALPHA_SCREENMODE: number;
  106351. /** Defines that the ressource is not delayed*/
  106352. static readonly DELAYLOADSTATE_NONE: number;
  106353. /** Defines that the ressource was successfully delay loaded */
  106354. static readonly DELAYLOADSTATE_LOADED: number;
  106355. /** Defines that the ressource is currently delay loading */
  106356. static readonly DELAYLOADSTATE_LOADING: number;
  106357. /** Defines that the ressource is delayed and has not started loading */
  106358. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106360. static readonly NEVER: number;
  106361. /** 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 */
  106362. static readonly ALWAYS: number;
  106363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106364. static readonly LESS: number;
  106365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106366. static readonly EQUAL: number;
  106367. /** 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 */
  106368. static readonly LEQUAL: number;
  106369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106370. static readonly GREATER: number;
  106371. /** 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 */
  106372. static readonly GEQUAL: number;
  106373. /** 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 */
  106374. static readonly NOTEQUAL: number;
  106375. /** Passed to stencilOperation to specify that stencil value must be kept */
  106376. static readonly KEEP: number;
  106377. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106378. static readonly REPLACE: number;
  106379. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106380. static readonly INCR: number;
  106381. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106382. static readonly DECR: number;
  106383. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106384. static readonly INVERT: number;
  106385. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106386. static readonly INCR_WRAP: number;
  106387. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106388. static readonly DECR_WRAP: number;
  106389. /** Texture is not repeating outside of 0..1 UVs */
  106390. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106391. /** Texture is repeating outside of 0..1 UVs */
  106392. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106393. /** Texture is repeating and mirrored */
  106394. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106395. /** ALPHA */
  106396. static readonly TEXTUREFORMAT_ALPHA: number;
  106397. /** LUMINANCE */
  106398. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106399. /** LUMINANCE_ALPHA */
  106400. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106401. /** RGB */
  106402. static readonly TEXTUREFORMAT_RGB: number;
  106403. /** RGBA */
  106404. static readonly TEXTUREFORMAT_RGBA: number;
  106405. /** RED */
  106406. static readonly TEXTUREFORMAT_RED: number;
  106407. /** RED (2nd reference) */
  106408. static readonly TEXTUREFORMAT_R: number;
  106409. /** RG */
  106410. static readonly TEXTUREFORMAT_RG: number;
  106411. /** RED_INTEGER */
  106412. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106413. /** RED_INTEGER (2nd reference) */
  106414. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106415. /** RG_INTEGER */
  106416. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106417. /** RGB_INTEGER */
  106418. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106419. /** RGBA_INTEGER */
  106420. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106421. /** UNSIGNED_BYTE */
  106422. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106423. /** UNSIGNED_BYTE (2nd reference) */
  106424. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106425. /** FLOAT */
  106426. static readonly TEXTURETYPE_FLOAT: number;
  106427. /** HALF_FLOAT */
  106428. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106429. /** BYTE */
  106430. static readonly TEXTURETYPE_BYTE: number;
  106431. /** SHORT */
  106432. static readonly TEXTURETYPE_SHORT: number;
  106433. /** UNSIGNED_SHORT */
  106434. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106435. /** INT */
  106436. static readonly TEXTURETYPE_INT: number;
  106437. /** UNSIGNED_INT */
  106438. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106439. /** UNSIGNED_SHORT_4_4_4_4 */
  106440. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106441. /** UNSIGNED_SHORT_5_5_5_1 */
  106442. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106443. /** UNSIGNED_SHORT_5_6_5 */
  106444. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106445. /** UNSIGNED_INT_2_10_10_10_REV */
  106446. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106447. /** UNSIGNED_INT_24_8 */
  106448. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106449. /** UNSIGNED_INT_10F_11F_11F_REV */
  106450. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106451. /** UNSIGNED_INT_5_9_9_9_REV */
  106452. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106453. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106454. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106455. /** nearest is mag = nearest and min = nearest and mip = linear */
  106456. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106457. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106458. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106459. /** Trilinear is mag = linear and min = linear and mip = linear */
  106460. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106461. /** nearest is mag = nearest and min = nearest and mip = linear */
  106462. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106463. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106464. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106465. /** Trilinear is mag = linear and min = linear and mip = linear */
  106466. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106467. /** mag = nearest and min = nearest and mip = nearest */
  106468. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106469. /** mag = nearest and min = linear and mip = nearest */
  106470. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106471. /** mag = nearest and min = linear and mip = linear */
  106472. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106473. /** mag = nearest and min = linear and mip = none */
  106474. static readonly TEXTURE_NEAREST_LINEAR: number;
  106475. /** mag = nearest and min = nearest and mip = none */
  106476. static readonly TEXTURE_NEAREST_NEAREST: number;
  106477. /** mag = linear and min = nearest and mip = nearest */
  106478. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106479. /** mag = linear and min = nearest and mip = linear */
  106480. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106481. /** mag = linear and min = linear and mip = none */
  106482. static readonly TEXTURE_LINEAR_LINEAR: number;
  106483. /** mag = linear and min = nearest and mip = none */
  106484. static readonly TEXTURE_LINEAR_NEAREST: number;
  106485. /** Explicit coordinates mode */
  106486. static readonly TEXTURE_EXPLICIT_MODE: number;
  106487. /** Spherical coordinates mode */
  106488. static readonly TEXTURE_SPHERICAL_MODE: number;
  106489. /** Planar coordinates mode */
  106490. static readonly TEXTURE_PLANAR_MODE: number;
  106491. /** Cubic coordinates mode */
  106492. static readonly TEXTURE_CUBIC_MODE: number;
  106493. /** Projection coordinates mode */
  106494. static readonly TEXTURE_PROJECTION_MODE: number;
  106495. /** Skybox coordinates mode */
  106496. static readonly TEXTURE_SKYBOX_MODE: number;
  106497. /** Inverse Cubic coordinates mode */
  106498. static readonly TEXTURE_INVCUBIC_MODE: number;
  106499. /** Equirectangular coordinates mode */
  106500. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106501. /** Equirectangular Fixed coordinates mode */
  106502. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106503. /** Equirectangular Fixed Mirrored coordinates mode */
  106504. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106505. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106506. static readonly SCALEMODE_FLOOR: number;
  106507. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106508. static readonly SCALEMODE_NEAREST: number;
  106509. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106510. static readonly SCALEMODE_CEILING: number;
  106511. /**
  106512. * Returns the current npm package of the sdk
  106513. */
  106514. static get NpmPackage(): string;
  106515. /**
  106516. * Returns the current version of the framework
  106517. */
  106518. static get Version(): string;
  106519. /** Gets the list of created engines */
  106520. static get Instances(): Engine[];
  106521. /**
  106522. * Gets the latest created engine
  106523. */
  106524. static get LastCreatedEngine(): Nullable<Engine>;
  106525. /**
  106526. * Gets the latest created scene
  106527. */
  106528. static get LastCreatedScene(): Nullable<Scene>;
  106529. /**
  106530. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106531. * @param flag defines which part of the materials must be marked as dirty
  106532. * @param predicate defines a predicate used to filter which materials should be affected
  106533. */
  106534. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106535. /**
  106536. * Method called to create the default loading screen.
  106537. * This can be overriden in your own app.
  106538. * @param canvas The rendering canvas element
  106539. * @returns The loading screen
  106540. */
  106541. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106542. /**
  106543. * Method called to create the default rescale post process on each engine.
  106544. */
  106545. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106546. /**
  106547. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106548. **/
  106549. enableOfflineSupport: boolean;
  106550. /**
  106551. * 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)
  106552. **/
  106553. disableManifestCheck: boolean;
  106554. /**
  106555. * Gets the list of created scenes
  106556. */
  106557. scenes: Scene[];
  106558. /**
  106559. * Event raised when a new scene is created
  106560. */
  106561. onNewSceneAddedObservable: Observable<Scene>;
  106562. /**
  106563. * Gets the list of created postprocesses
  106564. */
  106565. postProcesses: PostProcess[];
  106566. /**
  106567. * Gets a boolean indicating if the pointer is currently locked
  106568. */
  106569. isPointerLock: boolean;
  106570. /**
  106571. * Observable event triggered each time the rendering canvas is resized
  106572. */
  106573. onResizeObservable: Observable<Engine>;
  106574. /**
  106575. * Observable event triggered each time the canvas loses focus
  106576. */
  106577. onCanvasBlurObservable: Observable<Engine>;
  106578. /**
  106579. * Observable event triggered each time the canvas gains focus
  106580. */
  106581. onCanvasFocusObservable: Observable<Engine>;
  106582. /**
  106583. * Observable event triggered each time the canvas receives pointerout event
  106584. */
  106585. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106586. /**
  106587. * Observable raised when the engine begins a new frame
  106588. */
  106589. onBeginFrameObservable: Observable<Engine>;
  106590. /**
  106591. * If set, will be used to request the next animation frame for the render loop
  106592. */
  106593. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106594. /**
  106595. * Observable raised when the engine ends the current frame
  106596. */
  106597. onEndFrameObservable: Observable<Engine>;
  106598. /**
  106599. * Observable raised when the engine is about to compile a shader
  106600. */
  106601. onBeforeShaderCompilationObservable: Observable<Engine>;
  106602. /**
  106603. * Observable raised when the engine has jsut compiled a shader
  106604. */
  106605. onAfterShaderCompilationObservable: Observable<Engine>;
  106606. /**
  106607. * Gets the audio engine
  106608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106609. * @ignorenaming
  106610. */
  106611. static audioEngine: IAudioEngine;
  106612. /**
  106613. * Default AudioEngine factory responsible of creating the Audio Engine.
  106614. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106615. */
  106616. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106617. /**
  106618. * Default offline support factory responsible of creating a tool used to store data locally.
  106619. * By default, this will create a Database object if the workload has been embedded.
  106620. */
  106621. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106622. private _loadingScreen;
  106623. private _pointerLockRequested;
  106624. private _dummyFramebuffer;
  106625. private _rescalePostProcess;
  106626. private _deterministicLockstep;
  106627. private _lockstepMaxSteps;
  106628. private _timeStep;
  106629. protected get _supportsHardwareTextureRescaling(): boolean;
  106630. private _fps;
  106631. private _deltaTime;
  106632. /** @hidden */
  106633. _drawCalls: PerfCounter;
  106634. /** 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 */
  106635. canvasTabIndex: number;
  106636. /**
  106637. * Turn this value on if you want to pause FPS computation when in background
  106638. */
  106639. disablePerformanceMonitorInBackground: boolean;
  106640. private _performanceMonitor;
  106641. /**
  106642. * Gets the performance monitor attached to this engine
  106643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106644. */
  106645. get performanceMonitor(): PerformanceMonitor;
  106646. private _onFocus;
  106647. private _onBlur;
  106648. private _onCanvasPointerOut;
  106649. private _onCanvasBlur;
  106650. private _onCanvasFocus;
  106651. private _onFullscreenChange;
  106652. private _onPointerLockChange;
  106653. /**
  106654. * Gets the HTML element used to attach event listeners
  106655. * @returns a HTML element
  106656. */
  106657. getInputElement(): Nullable<HTMLElement>;
  106658. /**
  106659. * Creates a new engine
  106660. * @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
  106661. * @param antialias defines enable antialiasing (default: false)
  106662. * @param options defines further options to be sent to the getContext() function
  106663. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106664. */
  106665. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106666. /**
  106667. * Gets current aspect ratio
  106668. * @param viewportOwner defines the camera to use to get the aspect ratio
  106669. * @param useScreen defines if screen size must be used (or the current render target if any)
  106670. * @returns a number defining the aspect ratio
  106671. */
  106672. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106673. /**
  106674. * Gets current screen aspect ratio
  106675. * @returns a number defining the aspect ratio
  106676. */
  106677. getScreenAspectRatio(): number;
  106678. /**
  106679. * Gets the client rect of the HTML canvas attached with the current webGL context
  106680. * @returns a client rectanglee
  106681. */
  106682. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106683. /**
  106684. * Gets the client rect of the HTML element used for events
  106685. * @returns a client rectanglee
  106686. */
  106687. getInputElementClientRect(): Nullable<ClientRect>;
  106688. /**
  106689. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106690. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106691. * @returns true if engine is in deterministic lock step mode
  106692. */
  106693. isDeterministicLockStep(): boolean;
  106694. /**
  106695. * Gets the max steps when engine is running in deterministic lock step
  106696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106697. * @returns the max steps
  106698. */
  106699. getLockstepMaxSteps(): number;
  106700. /**
  106701. * Returns the time in ms between steps when using deterministic lock step.
  106702. * @returns time step in (ms)
  106703. */
  106704. getTimeStep(): number;
  106705. /**
  106706. * Force the mipmap generation for the given render target texture
  106707. * @param texture defines the render target texture to use
  106708. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106709. */
  106710. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106711. /** States */
  106712. /**
  106713. * Set various states to the webGL context
  106714. * @param culling defines backface culling state
  106715. * @param zOffset defines the value to apply to zOffset (0 by default)
  106716. * @param force defines if states must be applied even if cache is up to date
  106717. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106718. */
  106719. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106720. /**
  106721. * Set the z offset to apply to current rendering
  106722. * @param value defines the offset to apply
  106723. */
  106724. setZOffset(value: number): void;
  106725. /**
  106726. * Gets the current value of the zOffset
  106727. * @returns the current zOffset state
  106728. */
  106729. getZOffset(): number;
  106730. /**
  106731. * Enable or disable depth buffering
  106732. * @param enable defines the state to set
  106733. */
  106734. setDepthBuffer(enable: boolean): void;
  106735. /**
  106736. * Gets a boolean indicating if depth writing is enabled
  106737. * @returns the current depth writing state
  106738. */
  106739. getDepthWrite(): boolean;
  106740. /**
  106741. * Enable or disable depth writing
  106742. * @param enable defines the state to set
  106743. */
  106744. setDepthWrite(enable: boolean): void;
  106745. /**
  106746. * Gets a boolean indicating if stencil buffer is enabled
  106747. * @returns the current stencil buffer state
  106748. */
  106749. getStencilBuffer(): boolean;
  106750. /**
  106751. * Enable or disable the stencil buffer
  106752. * @param enable defines if the stencil buffer must be enabled or disabled
  106753. */
  106754. setStencilBuffer(enable: boolean): void;
  106755. /**
  106756. * Gets the current stencil mask
  106757. * @returns a number defining the new stencil mask to use
  106758. */
  106759. getStencilMask(): number;
  106760. /**
  106761. * Sets the current stencil mask
  106762. * @param mask defines the new stencil mask to use
  106763. */
  106764. setStencilMask(mask: number): void;
  106765. /**
  106766. * Gets the current stencil function
  106767. * @returns a number defining the stencil function to use
  106768. */
  106769. getStencilFunction(): number;
  106770. /**
  106771. * Gets the current stencil reference value
  106772. * @returns a number defining the stencil reference value to use
  106773. */
  106774. getStencilFunctionReference(): number;
  106775. /**
  106776. * Gets the current stencil mask
  106777. * @returns a number defining the stencil mask to use
  106778. */
  106779. getStencilFunctionMask(): number;
  106780. /**
  106781. * Sets the current stencil function
  106782. * @param stencilFunc defines the new stencil function to use
  106783. */
  106784. setStencilFunction(stencilFunc: number): void;
  106785. /**
  106786. * Sets the current stencil reference
  106787. * @param reference defines the new stencil reference to use
  106788. */
  106789. setStencilFunctionReference(reference: number): void;
  106790. /**
  106791. * Sets the current stencil mask
  106792. * @param mask defines the new stencil mask to use
  106793. */
  106794. setStencilFunctionMask(mask: number): void;
  106795. /**
  106796. * Gets the current stencil operation when stencil fails
  106797. * @returns a number defining stencil operation to use when stencil fails
  106798. */
  106799. getStencilOperationFail(): number;
  106800. /**
  106801. * Gets the current stencil operation when depth fails
  106802. * @returns a number defining stencil operation to use when depth fails
  106803. */
  106804. getStencilOperationDepthFail(): number;
  106805. /**
  106806. * Gets the current stencil operation when stencil passes
  106807. * @returns a number defining stencil operation to use when stencil passes
  106808. */
  106809. getStencilOperationPass(): number;
  106810. /**
  106811. * Sets the stencil operation to use when stencil fails
  106812. * @param operation defines the stencil operation to use when stencil fails
  106813. */
  106814. setStencilOperationFail(operation: number): void;
  106815. /**
  106816. * Sets the stencil operation to use when depth fails
  106817. * @param operation defines the stencil operation to use when depth fails
  106818. */
  106819. setStencilOperationDepthFail(operation: number): void;
  106820. /**
  106821. * Sets the stencil operation to use when stencil passes
  106822. * @param operation defines the stencil operation to use when stencil passes
  106823. */
  106824. setStencilOperationPass(operation: number): void;
  106825. /**
  106826. * Sets a boolean indicating if the dithering state is enabled or disabled
  106827. * @param value defines the dithering state
  106828. */
  106829. setDitheringState(value: boolean): void;
  106830. /**
  106831. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106832. * @param value defines the rasterizer state
  106833. */
  106834. setRasterizerState(value: boolean): void;
  106835. /**
  106836. * Gets the current depth function
  106837. * @returns a number defining the depth function
  106838. */
  106839. getDepthFunction(): Nullable<number>;
  106840. /**
  106841. * Sets the current depth function
  106842. * @param depthFunc defines the function to use
  106843. */
  106844. setDepthFunction(depthFunc: number): void;
  106845. /**
  106846. * Sets the current depth function to GREATER
  106847. */
  106848. setDepthFunctionToGreater(): void;
  106849. /**
  106850. * Sets the current depth function to GEQUAL
  106851. */
  106852. setDepthFunctionToGreaterOrEqual(): void;
  106853. /**
  106854. * Sets the current depth function to LESS
  106855. */
  106856. setDepthFunctionToLess(): void;
  106857. /**
  106858. * Sets the current depth function to LEQUAL
  106859. */
  106860. setDepthFunctionToLessOrEqual(): void;
  106861. private _cachedStencilBuffer;
  106862. private _cachedStencilFunction;
  106863. private _cachedStencilMask;
  106864. private _cachedStencilOperationPass;
  106865. private _cachedStencilOperationFail;
  106866. private _cachedStencilOperationDepthFail;
  106867. private _cachedStencilReference;
  106868. /**
  106869. * Caches the the state of the stencil buffer
  106870. */
  106871. cacheStencilState(): void;
  106872. /**
  106873. * Restores the state of the stencil buffer
  106874. */
  106875. restoreStencilState(): void;
  106876. /**
  106877. * Directly set the WebGL Viewport
  106878. * @param x defines the x coordinate of the viewport (in screen space)
  106879. * @param y defines the y coordinate of the viewport (in screen space)
  106880. * @param width defines the width of the viewport (in screen space)
  106881. * @param height defines the height of the viewport (in screen space)
  106882. * @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
  106883. */
  106884. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106885. /**
  106886. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106887. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106888. * @param y defines the y-coordinate of the corner of the clear rectangle
  106889. * @param width defines the width of the clear rectangle
  106890. * @param height defines the height of the clear rectangle
  106891. * @param clearColor defines the clear color
  106892. */
  106893. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106894. /**
  106895. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106896. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106897. * @param y defines the y-coordinate of the corner of the clear rectangle
  106898. * @param width defines the width of the clear rectangle
  106899. * @param height defines the height of the clear rectangle
  106900. */
  106901. enableScissor(x: number, y: number, width: number, height: number): void;
  106902. /**
  106903. * Disable previously set scissor test rectangle
  106904. */
  106905. disableScissor(): void;
  106906. protected _reportDrawCall(): void;
  106907. /**
  106908. * Initializes a webVR display and starts listening to display change events
  106909. * The onVRDisplayChangedObservable will be notified upon these changes
  106910. * @returns The onVRDisplayChangedObservable
  106911. */
  106912. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106913. /** @hidden */
  106914. _prepareVRComponent(): void;
  106915. /** @hidden */
  106916. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106917. /** @hidden */
  106918. _submitVRFrame(): void;
  106919. /**
  106920. * Call this function to leave webVR mode
  106921. * Will do nothing if webVR is not supported or if there is no webVR device
  106922. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106923. */
  106924. disableVR(): void;
  106925. /**
  106926. * Gets a boolean indicating that the system is in VR mode and is presenting
  106927. * @returns true if VR mode is engaged
  106928. */
  106929. isVRPresenting(): boolean;
  106930. /** @hidden */
  106931. _requestVRFrame(): void;
  106932. /** @hidden */
  106933. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106934. /**
  106935. * Gets the source code of the vertex shader associated with a specific webGL program
  106936. * @param program defines the program to use
  106937. * @returns a string containing the source code of the vertex shader associated with the program
  106938. */
  106939. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106940. /**
  106941. * Gets the source code of the fragment shader associated with a specific webGL program
  106942. * @param program defines the program to use
  106943. * @returns a string containing the source code of the fragment shader associated with the program
  106944. */
  106945. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106946. /**
  106947. * Sets a depth stencil texture from a render target to the according uniform.
  106948. * @param channel The texture channel
  106949. * @param uniform The uniform to set
  106950. * @param texture The render target texture containing the depth stencil texture to apply
  106951. */
  106952. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106953. /**
  106954. * Sets a texture to the webGL context from a postprocess
  106955. * @param channel defines the channel to use
  106956. * @param postProcess defines the source postprocess
  106957. */
  106958. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106959. /**
  106960. * Binds the output of the passed in post process to the texture channel specified
  106961. * @param channel The channel the texture should be bound to
  106962. * @param postProcess The post process which's output should be bound
  106963. */
  106964. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106965. /** @hidden */
  106966. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106967. protected _rebuildBuffers(): void;
  106968. /** @hidden */
  106969. _renderFrame(): void;
  106970. _renderLoop(): void;
  106971. /** @hidden */
  106972. _renderViews(): boolean;
  106973. /**
  106974. * Toggle full screen mode
  106975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106976. */
  106977. switchFullscreen(requestPointerLock: boolean): void;
  106978. /**
  106979. * Enters full screen mode
  106980. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106981. */
  106982. enterFullscreen(requestPointerLock: boolean): void;
  106983. /**
  106984. * Exits full screen mode
  106985. */
  106986. exitFullscreen(): void;
  106987. /**
  106988. * Enters Pointerlock mode
  106989. */
  106990. enterPointerlock(): void;
  106991. /**
  106992. * Exits Pointerlock mode
  106993. */
  106994. exitPointerlock(): void;
  106995. /**
  106996. * Begin a new frame
  106997. */
  106998. beginFrame(): void;
  106999. /**
  107000. * Enf the current frame
  107001. */
  107002. endFrame(): void;
  107003. resize(): void;
  107004. /**
  107005. * Force a specific size of the canvas
  107006. * @param width defines the new canvas' width
  107007. * @param height defines the new canvas' height
  107008. */
  107009. setSize(width: number, height: number): void;
  107010. /**
  107011. * Updates a dynamic vertex buffer.
  107012. * @param vertexBuffer the vertex buffer to update
  107013. * @param data the data used to update the vertex buffer
  107014. * @param byteOffset the byte offset of the data
  107015. * @param byteLength the byte length of the data
  107016. */
  107017. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107018. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107019. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107020. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107021. _releaseTexture(texture: InternalTexture): void;
  107022. /**
  107023. * @hidden
  107024. * Rescales a texture
  107025. * @param source input texutre
  107026. * @param destination destination texture
  107027. * @param scene scene to use to render the resize
  107028. * @param internalFormat format to use when resizing
  107029. * @param onComplete callback to be called when resize has completed
  107030. */
  107031. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107032. /**
  107033. * Gets the current framerate
  107034. * @returns a number representing the framerate
  107035. */
  107036. getFps(): number;
  107037. /**
  107038. * Gets the time spent between current and previous frame
  107039. * @returns a number representing the delta time in ms
  107040. */
  107041. getDeltaTime(): number;
  107042. private _measureFps;
  107043. /** @hidden */
  107044. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107045. /**
  107046. * Update a dynamic index buffer
  107047. * @param indexBuffer defines the target index buffer
  107048. * @param indices defines the data to update
  107049. * @param offset defines the offset in the target index buffer where update should start
  107050. */
  107051. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107052. /**
  107053. * Updates the sample count of a render target texture
  107054. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107055. * @param texture defines the texture to update
  107056. * @param samples defines the sample count to set
  107057. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107058. */
  107059. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107060. /**
  107061. * Updates a depth texture Comparison Mode and Function.
  107062. * If the comparison Function is equal to 0, the mode will be set to none.
  107063. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107064. * @param texture The texture to set the comparison function for
  107065. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107066. */
  107067. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107068. /**
  107069. * Creates a webGL buffer to use with instanciation
  107070. * @param capacity defines the size of the buffer
  107071. * @returns the webGL buffer
  107072. */
  107073. createInstancesBuffer(capacity: number): DataBuffer;
  107074. /**
  107075. * Delete a webGL buffer used with instanciation
  107076. * @param buffer defines the webGL buffer to delete
  107077. */
  107078. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107079. private _clientWaitAsync;
  107080. /** @hidden */
  107081. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107082. /** @hidden */
  107083. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107084. dispose(): void;
  107085. private _disableTouchAction;
  107086. /**
  107087. * Display the loading screen
  107088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107089. */
  107090. displayLoadingUI(): void;
  107091. /**
  107092. * Hide the loading screen
  107093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107094. */
  107095. hideLoadingUI(): void;
  107096. /**
  107097. * Gets the current loading screen object
  107098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107099. */
  107100. get loadingScreen(): ILoadingScreen;
  107101. /**
  107102. * Sets the current loading screen object
  107103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107104. */
  107105. set loadingScreen(loadingScreen: ILoadingScreen);
  107106. /**
  107107. * Sets the current loading screen text
  107108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107109. */
  107110. set loadingUIText(text: string);
  107111. /**
  107112. * Sets the current loading screen background color
  107113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107114. */
  107115. set loadingUIBackgroundColor(color: string);
  107116. /** Pointerlock and fullscreen */
  107117. /**
  107118. * Ask the browser to promote the current element to pointerlock mode
  107119. * @param element defines the DOM element to promote
  107120. */
  107121. static _RequestPointerlock(element: HTMLElement): void;
  107122. /**
  107123. * Asks the browser to exit pointerlock mode
  107124. */
  107125. static _ExitPointerlock(): void;
  107126. /**
  107127. * Ask the browser to promote the current element to fullscreen rendering mode
  107128. * @param element defines the DOM element to promote
  107129. */
  107130. static _RequestFullscreen(element: HTMLElement): void;
  107131. /**
  107132. * Asks the browser to exit fullscreen mode
  107133. */
  107134. static _ExitFullscreen(): void;
  107135. }
  107136. }
  107137. declare module BABYLON {
  107138. /**
  107139. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107140. * during the life time of the application.
  107141. */
  107142. export class EngineStore {
  107143. /** Gets the list of created engines */
  107144. static Instances: Engine[];
  107145. /** @hidden */
  107146. static _LastCreatedScene: Nullable<Scene>;
  107147. /**
  107148. * Gets the latest created engine
  107149. */
  107150. static get LastCreatedEngine(): Nullable<Engine>;
  107151. /**
  107152. * Gets the latest created scene
  107153. */
  107154. static get LastCreatedScene(): Nullable<Scene>;
  107155. /**
  107156. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107157. * @ignorenaming
  107158. */
  107159. static UseFallbackTexture: boolean;
  107160. /**
  107161. * Texture content used if a texture cannot loaded
  107162. * @ignorenaming
  107163. */
  107164. static FallbackTexture: string;
  107165. }
  107166. }
  107167. declare module BABYLON {
  107168. /**
  107169. * Helper class that provides a small promise polyfill
  107170. */
  107171. export class PromisePolyfill {
  107172. /**
  107173. * Static function used to check if the polyfill is required
  107174. * If this is the case then the function will inject the polyfill to window.Promise
  107175. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107176. */
  107177. static Apply(force?: boolean): void;
  107178. }
  107179. }
  107180. declare module BABYLON {
  107181. /**
  107182. * Interface for screenshot methods with describe argument called `size` as object with options
  107183. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107184. */
  107185. export interface IScreenshotSize {
  107186. /**
  107187. * number in pixels for canvas height
  107188. */
  107189. height?: number;
  107190. /**
  107191. * multiplier allowing render at a higher or lower resolution
  107192. * If value is defined then height and width will be ignored and taken from camera
  107193. */
  107194. precision?: number;
  107195. /**
  107196. * number in pixels for canvas width
  107197. */
  107198. width?: number;
  107199. }
  107200. }
  107201. declare module BABYLON {
  107202. interface IColor4Like {
  107203. r: float;
  107204. g: float;
  107205. b: float;
  107206. a: float;
  107207. }
  107208. /**
  107209. * Class containing a set of static utilities functions
  107210. */
  107211. export class Tools {
  107212. /**
  107213. * Gets or sets the base URL to use to load assets
  107214. */
  107215. static get BaseUrl(): string;
  107216. static set BaseUrl(value: string);
  107217. /**
  107218. * Enable/Disable Custom HTTP Request Headers globally.
  107219. * default = false
  107220. * @see CustomRequestHeaders
  107221. */
  107222. static UseCustomRequestHeaders: boolean;
  107223. /**
  107224. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107225. * i.e. when loading files, where the server/service expects an Authorization header
  107226. */
  107227. static CustomRequestHeaders: {
  107228. [key: string]: string;
  107229. };
  107230. /**
  107231. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107232. */
  107233. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107234. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107235. /**
  107236. * Default behaviour for cors in the application.
  107237. * It can be a string if the expected behavior is identical in the entire app.
  107238. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107239. */
  107240. static CorsBehavior: string | ((url: string | string[]) => string);
  107241. /**
  107242. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107243. * @ignorenaming
  107244. */
  107245. static get UseFallbackTexture(): boolean;
  107246. static set UseFallbackTexture(value: boolean);
  107247. /**
  107248. * Use this object to register external classes like custom textures or material
  107249. * to allow the laoders to instantiate them
  107250. */
  107251. static get RegisteredExternalClasses(): {
  107252. [key: string]: Object;
  107253. };
  107254. static set RegisteredExternalClasses(classes: {
  107255. [key: string]: Object;
  107256. });
  107257. /**
  107258. * Texture content used if a texture cannot loaded
  107259. * @ignorenaming
  107260. */
  107261. static get fallbackTexture(): string;
  107262. static set fallbackTexture(value: string);
  107263. /**
  107264. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107265. * @param u defines the coordinate on X axis
  107266. * @param v defines the coordinate on Y axis
  107267. * @param width defines the width of the source data
  107268. * @param height defines the height of the source data
  107269. * @param pixels defines the source byte array
  107270. * @param color defines the output color
  107271. */
  107272. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107273. /**
  107274. * Interpolates between a and b via alpha
  107275. * @param a The lower value (returned when alpha = 0)
  107276. * @param b The upper value (returned when alpha = 1)
  107277. * @param alpha The interpolation-factor
  107278. * @return The mixed value
  107279. */
  107280. static Mix(a: number, b: number, alpha: number): number;
  107281. /**
  107282. * Tries to instantiate a new object from a given class name
  107283. * @param className defines the class name to instantiate
  107284. * @returns the new object or null if the system was not able to do the instantiation
  107285. */
  107286. static Instantiate(className: string): any;
  107287. /**
  107288. * Provides a slice function that will work even on IE
  107289. * @param data defines the array to slice
  107290. * @param start defines the start of the data (optional)
  107291. * @param end defines the end of the data (optional)
  107292. * @returns the new sliced array
  107293. */
  107294. static Slice<T>(data: T, start?: number, end?: number): T;
  107295. /**
  107296. * Polyfill for setImmediate
  107297. * @param action defines the action to execute after the current execution block
  107298. */
  107299. static SetImmediate(action: () => void): void;
  107300. /**
  107301. * Function indicating if a number is an exponent of 2
  107302. * @param value defines the value to test
  107303. * @returns true if the value is an exponent of 2
  107304. */
  107305. static IsExponentOfTwo(value: number): boolean;
  107306. private static _tmpFloatArray;
  107307. /**
  107308. * Returns the nearest 32-bit single precision float representation of a Number
  107309. * @param value A Number. If the parameter is of a different type, it will get converted
  107310. * to a number or to NaN if it cannot be converted
  107311. * @returns number
  107312. */
  107313. static FloatRound(value: number): number;
  107314. /**
  107315. * Extracts the filename from a path
  107316. * @param path defines the path to use
  107317. * @returns the filename
  107318. */
  107319. static GetFilename(path: string): string;
  107320. /**
  107321. * Extracts the "folder" part of a path (everything before the filename).
  107322. * @param uri The URI to extract the info from
  107323. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107324. * @returns The "folder" part of the path
  107325. */
  107326. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107327. /**
  107328. * Extracts text content from a DOM element hierarchy
  107329. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107330. */
  107331. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107332. /**
  107333. * Convert an angle in radians to degrees
  107334. * @param angle defines the angle to convert
  107335. * @returns the angle in degrees
  107336. */
  107337. static ToDegrees(angle: number): number;
  107338. /**
  107339. * Convert an angle in degrees to radians
  107340. * @param angle defines the angle to convert
  107341. * @returns the angle in radians
  107342. */
  107343. static ToRadians(angle: number): number;
  107344. /**
  107345. * Returns an array if obj is not an array
  107346. * @param obj defines the object to evaluate as an array
  107347. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107348. * @returns either obj directly if obj is an array or a new array containing obj
  107349. */
  107350. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107351. /**
  107352. * Gets the pointer prefix to use
  107353. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107354. */
  107355. static GetPointerPrefix(): string;
  107356. /**
  107357. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107358. * @param url define the url we are trying
  107359. * @param element define the dom element where to configure the cors policy
  107360. */
  107361. static SetCorsBehavior(url: string | string[], element: {
  107362. crossOrigin: string | null;
  107363. }): void;
  107364. /**
  107365. * Removes unwanted characters from an url
  107366. * @param url defines the url to clean
  107367. * @returns the cleaned url
  107368. */
  107369. static CleanUrl(url: string): string;
  107370. /**
  107371. * Gets or sets a function used to pre-process url before using them to load assets
  107372. */
  107373. static get PreprocessUrl(): (url: string) => string;
  107374. static set PreprocessUrl(processor: (url: string) => string);
  107375. /**
  107376. * Loads an image as an HTMLImageElement.
  107377. * @param input url string, ArrayBuffer, or Blob to load
  107378. * @param onLoad callback called when the image successfully loads
  107379. * @param onError callback called when the image fails to load
  107380. * @param offlineProvider offline provider for caching
  107381. * @param mimeType optional mime type
  107382. * @returns the HTMLImageElement of the loaded image
  107383. */
  107384. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107385. /**
  107386. * Loads a file from a url
  107387. * @param url url string, ArrayBuffer, or Blob to load
  107388. * @param onSuccess callback called when the file successfully loads
  107389. * @param onProgress callback called while file is loading (if the server supports this mode)
  107390. * @param offlineProvider defines the offline provider for caching
  107391. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107392. * @param onError callback called when the file fails to load
  107393. * @returns a file request object
  107394. */
  107395. 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;
  107396. /**
  107397. * Loads a file from a url
  107398. * @param url the file url to load
  107399. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107400. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107401. */
  107402. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107403. /**
  107404. * Load a script (identified by an url). When the url returns, the
  107405. * content of this file is added into a new script element, attached to the DOM (body element)
  107406. * @param scriptUrl defines the url of the script to laod
  107407. * @param onSuccess defines the callback called when the script is loaded
  107408. * @param onError defines the callback to call if an error occurs
  107409. * @param scriptId defines the id of the script element
  107410. */
  107411. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107412. /**
  107413. * Load an asynchronous script (identified by an url). When the url returns, the
  107414. * content of this file is added into a new script element, attached to the DOM (body element)
  107415. * @param scriptUrl defines the url of the script to laod
  107416. * @param scriptId defines the id of the script element
  107417. * @returns a promise request object
  107418. */
  107419. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107420. /**
  107421. * Loads a file from a blob
  107422. * @param fileToLoad defines the blob to use
  107423. * @param callback defines the callback to call when data is loaded
  107424. * @param progressCallback defines the callback to call during loading process
  107425. * @returns a file request object
  107426. */
  107427. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107428. /**
  107429. * Reads a file from a File object
  107430. * @param file defines the file to load
  107431. * @param onSuccess defines the callback to call when data is loaded
  107432. * @param onProgress defines the callback to call during loading process
  107433. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107434. * @param onError defines the callback to call when an error occurs
  107435. * @returns a file request object
  107436. */
  107437. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107438. /**
  107439. * Creates a data url from a given string content
  107440. * @param content defines the content to convert
  107441. * @returns the new data url link
  107442. */
  107443. static FileAsURL(content: string): string;
  107444. /**
  107445. * Format the given number to a specific decimal format
  107446. * @param value defines the number to format
  107447. * @param decimals defines the number of decimals to use
  107448. * @returns the formatted string
  107449. */
  107450. static Format(value: number, decimals?: number): string;
  107451. /**
  107452. * Tries to copy an object by duplicating every property
  107453. * @param source defines the source object
  107454. * @param destination defines the target object
  107455. * @param doNotCopyList defines a list of properties to avoid
  107456. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107457. */
  107458. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107459. /**
  107460. * Gets a boolean indicating if the given object has no own property
  107461. * @param obj defines the object to test
  107462. * @returns true if object has no own property
  107463. */
  107464. static IsEmpty(obj: any): boolean;
  107465. /**
  107466. * Function used to register events at window level
  107467. * @param windowElement defines the Window object to use
  107468. * @param events defines the events to register
  107469. */
  107470. static RegisterTopRootEvents(windowElement: Window, events: {
  107471. name: string;
  107472. handler: Nullable<(e: FocusEvent) => any>;
  107473. }[]): void;
  107474. /**
  107475. * Function used to unregister events from window level
  107476. * @param windowElement defines the Window object to use
  107477. * @param events defines the events to unregister
  107478. */
  107479. static UnregisterTopRootEvents(windowElement: Window, events: {
  107480. name: string;
  107481. handler: Nullable<(e: FocusEvent) => any>;
  107482. }[]): void;
  107483. /**
  107484. * @ignore
  107485. */
  107486. static _ScreenshotCanvas: HTMLCanvasElement;
  107487. /**
  107488. * Dumps the current bound framebuffer
  107489. * @param width defines the rendering width
  107490. * @param height defines the rendering height
  107491. * @param engine defines the hosting engine
  107492. * @param successCallback defines the callback triggered once the data are available
  107493. * @param mimeType defines the mime type of the result
  107494. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107495. */
  107496. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107497. /**
  107498. * Converts the canvas data to blob.
  107499. * This acts as a polyfill for browsers not supporting the to blob function.
  107500. * @param canvas Defines the canvas to extract the data from
  107501. * @param successCallback Defines the callback triggered once the data are available
  107502. * @param mimeType Defines the mime type of the result
  107503. */
  107504. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107505. /**
  107506. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107507. * @param successCallback defines the callback triggered once the data are available
  107508. * @param mimeType defines the mime type of the result
  107509. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107510. */
  107511. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107512. /**
  107513. * Downloads a blob in the browser
  107514. * @param blob defines the blob to download
  107515. * @param fileName defines the name of the downloaded file
  107516. */
  107517. static Download(blob: Blob, fileName: string): void;
  107518. /**
  107519. * Captures a screenshot of the current rendering
  107520. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107521. * @param engine defines the rendering engine
  107522. * @param camera defines the source camera
  107523. * @param size This parameter can be set to a single number or to an object with the
  107524. * following (optional) properties: precision, width, height. If a single number is passed,
  107525. * it will be used for both width and height. If an object is passed, the screenshot size
  107526. * will be derived from the parameters. The precision property is a multiplier allowing
  107527. * rendering at a higher or lower resolution
  107528. * @param successCallback defines the callback receives a single parameter which contains the
  107529. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107530. * src parameter of an <img> to display it
  107531. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107532. * Check your browser for supported MIME types
  107533. */
  107534. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107535. /**
  107536. * Captures a screenshot of the current rendering
  107537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107538. * @param engine defines the rendering engine
  107539. * @param camera defines the source camera
  107540. * @param size This parameter can be set to a single number or to an object with the
  107541. * following (optional) properties: precision, width, height. If a single number is passed,
  107542. * it will be used for both width and height. If an object is passed, the screenshot size
  107543. * will be derived from the parameters. The precision property is a multiplier allowing
  107544. * rendering at a higher or lower resolution
  107545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107546. * Check your browser for supported MIME types
  107547. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107548. * to the src parameter of an <img> to display it
  107549. */
  107550. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107551. /**
  107552. * Generates an image screenshot from the specified camera.
  107553. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107554. * @param engine The engine to use for rendering
  107555. * @param camera The camera to use for rendering
  107556. * @param size This parameter can be set to a single number or to an object with the
  107557. * following (optional) properties: precision, width, height. If a single number is passed,
  107558. * it will be used for both width and height. If an object is passed, the screenshot size
  107559. * will be derived from the parameters. The precision property is a multiplier allowing
  107560. * rendering at a higher or lower resolution
  107561. * @param successCallback The callback receives a single parameter which contains the
  107562. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107563. * src parameter of an <img> to display it
  107564. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107565. * Check your browser for supported MIME types
  107566. * @param samples Texture samples (default: 1)
  107567. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107568. * @param fileName A name for for the downloaded file.
  107569. */
  107570. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107571. /**
  107572. * Generates an image screenshot from the specified camera.
  107573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107574. * @param engine The engine to use for rendering
  107575. * @param camera The camera to use for rendering
  107576. * @param size This parameter can be set to a single number or to an object with the
  107577. * following (optional) properties: precision, width, height. If a single number is passed,
  107578. * it will be used for both width and height. If an object is passed, the screenshot size
  107579. * will be derived from the parameters. The precision property is a multiplier allowing
  107580. * rendering at a higher or lower resolution
  107581. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107582. * Check your browser for supported MIME types
  107583. * @param samples Texture samples (default: 1)
  107584. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107585. * @param fileName A name for for the downloaded file.
  107586. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107587. * to the src parameter of an <img> to display it
  107588. */
  107589. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107590. /**
  107591. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107592. * Be aware Math.random() could cause collisions, but:
  107593. * "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"
  107594. * @returns a pseudo random id
  107595. */
  107596. static RandomId(): string;
  107597. /**
  107598. * Test if the given uri is a base64 string
  107599. * @param uri The uri to test
  107600. * @return True if the uri is a base64 string or false otherwise
  107601. */
  107602. static IsBase64(uri: string): boolean;
  107603. /**
  107604. * Decode the given base64 uri.
  107605. * @param uri The uri to decode
  107606. * @return The decoded base64 data.
  107607. */
  107608. static DecodeBase64(uri: string): ArrayBuffer;
  107609. /**
  107610. * Gets the absolute url.
  107611. * @param url the input url
  107612. * @return the absolute url
  107613. */
  107614. static GetAbsoluteUrl(url: string): string;
  107615. /**
  107616. * No log
  107617. */
  107618. static readonly NoneLogLevel: number;
  107619. /**
  107620. * Only message logs
  107621. */
  107622. static readonly MessageLogLevel: number;
  107623. /**
  107624. * Only warning logs
  107625. */
  107626. static readonly WarningLogLevel: number;
  107627. /**
  107628. * Only error logs
  107629. */
  107630. static readonly ErrorLogLevel: number;
  107631. /**
  107632. * All logs
  107633. */
  107634. static readonly AllLogLevel: number;
  107635. /**
  107636. * Gets a value indicating the number of loading errors
  107637. * @ignorenaming
  107638. */
  107639. static get errorsCount(): number;
  107640. /**
  107641. * Callback called when a new log is added
  107642. */
  107643. static OnNewCacheEntry: (entry: string) => void;
  107644. /**
  107645. * Log a message to the console
  107646. * @param message defines the message to log
  107647. */
  107648. static Log(message: string): void;
  107649. /**
  107650. * Write a warning message to the console
  107651. * @param message defines the message to log
  107652. */
  107653. static Warn(message: string): void;
  107654. /**
  107655. * Write an error message to the console
  107656. * @param message defines the message to log
  107657. */
  107658. static Error(message: string): void;
  107659. /**
  107660. * Gets current log cache (list of logs)
  107661. */
  107662. static get LogCache(): string;
  107663. /**
  107664. * Clears the log cache
  107665. */
  107666. static ClearLogCache(): void;
  107667. /**
  107668. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107669. */
  107670. static set LogLevels(level: number);
  107671. /**
  107672. * Checks if the window object exists
  107673. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107674. */
  107675. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107676. /**
  107677. * No performance log
  107678. */
  107679. static readonly PerformanceNoneLogLevel: number;
  107680. /**
  107681. * Use user marks to log performance
  107682. */
  107683. static readonly PerformanceUserMarkLogLevel: number;
  107684. /**
  107685. * Log performance to the console
  107686. */
  107687. static readonly PerformanceConsoleLogLevel: number;
  107688. private static _performance;
  107689. /**
  107690. * Sets the current performance log level
  107691. */
  107692. static set PerformanceLogLevel(level: number);
  107693. private static _StartPerformanceCounterDisabled;
  107694. private static _EndPerformanceCounterDisabled;
  107695. private static _StartUserMark;
  107696. private static _EndUserMark;
  107697. private static _StartPerformanceConsole;
  107698. private static _EndPerformanceConsole;
  107699. /**
  107700. * Starts a performance counter
  107701. */
  107702. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107703. /**
  107704. * Ends a specific performance coutner
  107705. */
  107706. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107707. /**
  107708. * Gets either window.performance.now() if supported or Date.now() else
  107709. */
  107710. static get Now(): number;
  107711. /**
  107712. * This method will return the name of the class used to create the instance of the given object.
  107713. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107714. * @param object the object to get the class name from
  107715. * @param isType defines if the object is actually a type
  107716. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107717. */
  107718. static GetClassName(object: any, isType?: boolean): string;
  107719. /**
  107720. * Gets the first element of an array satisfying a given predicate
  107721. * @param array defines the array to browse
  107722. * @param predicate defines the predicate to use
  107723. * @returns null if not found or the element
  107724. */
  107725. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107726. /**
  107727. * This method will return the name of the full name of the class, including its owning module (if any).
  107728. * 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).
  107729. * @param object the object to get the class name from
  107730. * @param isType defines if the object is actually a type
  107731. * @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.
  107732. * @ignorenaming
  107733. */
  107734. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107735. /**
  107736. * Returns a promise that resolves after the given amount of time.
  107737. * @param delay Number of milliseconds to delay
  107738. * @returns Promise that resolves after the given amount of time
  107739. */
  107740. static DelayAsync(delay: number): Promise<void>;
  107741. /**
  107742. * Utility function to detect if the current user agent is Safari
  107743. * @returns whether or not the current user agent is safari
  107744. */
  107745. static IsSafari(): boolean;
  107746. }
  107747. /**
  107748. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107749. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107750. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107751. * @param name The name of the class, case should be preserved
  107752. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107753. */
  107754. export function className(name: string, module?: string): (target: Object) => void;
  107755. /**
  107756. * An implementation of a loop for asynchronous functions.
  107757. */
  107758. export class AsyncLoop {
  107759. /**
  107760. * Defines the number of iterations for the loop
  107761. */
  107762. iterations: number;
  107763. /**
  107764. * Defines the current index of the loop.
  107765. */
  107766. index: number;
  107767. private _done;
  107768. private _fn;
  107769. private _successCallback;
  107770. /**
  107771. * Constructor.
  107772. * @param iterations the number of iterations.
  107773. * @param func the function to run each iteration
  107774. * @param successCallback the callback that will be called upon succesful execution
  107775. * @param offset starting offset.
  107776. */
  107777. constructor(
  107778. /**
  107779. * Defines the number of iterations for the loop
  107780. */
  107781. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107782. /**
  107783. * Execute the next iteration. Must be called after the last iteration was finished.
  107784. */
  107785. executeNext(): void;
  107786. /**
  107787. * Break the loop and run the success callback.
  107788. */
  107789. breakLoop(): void;
  107790. /**
  107791. * Create and run an async loop.
  107792. * @param iterations the number of iterations.
  107793. * @param fn the function to run each iteration
  107794. * @param successCallback the callback that will be called upon succesful execution
  107795. * @param offset starting offset.
  107796. * @returns the created async loop object
  107797. */
  107798. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107799. /**
  107800. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107801. * @param iterations total number of iterations
  107802. * @param syncedIterations number of synchronous iterations in each async iteration.
  107803. * @param fn the function to call each iteration.
  107804. * @param callback a success call back that will be called when iterating stops.
  107805. * @param breakFunction a break condition (optional)
  107806. * @param timeout timeout settings for the setTimeout function. default - 0.
  107807. * @returns the created async loop object
  107808. */
  107809. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107810. }
  107811. }
  107812. declare module BABYLON {
  107813. /**
  107814. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107815. * The underlying implementation relies on an associative array to ensure the best performances.
  107816. * The value can be anything including 'null' but except 'undefined'
  107817. */
  107818. export class StringDictionary<T> {
  107819. /**
  107820. * This will clear this dictionary and copy the content from the 'source' one.
  107821. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107822. * @param source the dictionary to take the content from and copy to this dictionary
  107823. */
  107824. copyFrom(source: StringDictionary<T>): void;
  107825. /**
  107826. * Get a value based from its key
  107827. * @param key the given key to get the matching value from
  107828. * @return the value if found, otherwise undefined is returned
  107829. */
  107830. get(key: string): T | undefined;
  107831. /**
  107832. * Get a value from its key or add it if it doesn't exist.
  107833. * This method will ensure you that a given key/data will be present in the dictionary.
  107834. * @param key the given key to get the matching value from
  107835. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107836. * The factory will only be invoked if there's no data for the given key.
  107837. * @return the value corresponding to the key.
  107838. */
  107839. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107840. /**
  107841. * Get a value from its key if present in the dictionary otherwise add it
  107842. * @param key the key to get the value from
  107843. * @param val if there's no such key/value pair in the dictionary add it with this value
  107844. * @return the value corresponding to the key
  107845. */
  107846. getOrAdd(key: string, val: T): T;
  107847. /**
  107848. * Check if there's a given key in the dictionary
  107849. * @param key the key to check for
  107850. * @return true if the key is present, false otherwise
  107851. */
  107852. contains(key: string): boolean;
  107853. /**
  107854. * Add a new key and its corresponding value
  107855. * @param key the key to add
  107856. * @param value the value corresponding to the key
  107857. * @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
  107858. */
  107859. add(key: string, value: T): boolean;
  107860. /**
  107861. * Update a specific value associated to a key
  107862. * @param key defines the key to use
  107863. * @param value defines the value to store
  107864. * @returns true if the value was updated (or false if the key was not found)
  107865. */
  107866. set(key: string, value: T): boolean;
  107867. /**
  107868. * Get the element of the given key and remove it from the dictionary
  107869. * @param key defines the key to search
  107870. * @returns the value associated with the key or null if not found
  107871. */
  107872. getAndRemove(key: string): Nullable<T>;
  107873. /**
  107874. * Remove a key/value from the dictionary.
  107875. * @param key the key to remove
  107876. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107877. */
  107878. remove(key: string): boolean;
  107879. /**
  107880. * Clear the whole content of the dictionary
  107881. */
  107882. clear(): void;
  107883. /**
  107884. * Gets the current count
  107885. */
  107886. get count(): number;
  107887. /**
  107888. * Execute a callback on each key/val of the dictionary.
  107889. * Note that you can remove any element in this dictionary in the callback implementation
  107890. * @param callback the callback to execute on a given key/value pair
  107891. */
  107892. forEach(callback: (key: string, val: T) => void): void;
  107893. /**
  107894. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107895. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107896. * Note that you can remove any element in this dictionary in the callback implementation
  107897. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107898. * @returns the first item
  107899. */
  107900. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107901. private _count;
  107902. private _data;
  107903. }
  107904. }
  107905. declare module BABYLON {
  107906. /** @hidden */
  107907. export interface ICollisionCoordinator {
  107908. createCollider(): Collider;
  107909. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107910. init(scene: Scene): void;
  107911. }
  107912. /** @hidden */
  107913. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107914. private _scene;
  107915. private _scaledPosition;
  107916. private _scaledVelocity;
  107917. private _finalPosition;
  107918. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107919. createCollider(): Collider;
  107920. init(scene: Scene): void;
  107921. private _collideWithWorld;
  107922. }
  107923. }
  107924. declare module BABYLON {
  107925. /**
  107926. * Class used to manage all inputs for the scene.
  107927. */
  107928. export class InputManager {
  107929. /** The distance in pixel that you have to move to prevent some events */
  107930. static DragMovementThreshold: number;
  107931. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107932. static LongPressDelay: number;
  107933. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107934. static DoubleClickDelay: number;
  107935. /** If you need to check double click without raising a single click at first click, enable this flag */
  107936. static ExclusiveDoubleClickMode: boolean;
  107937. private _wheelEventName;
  107938. private _onPointerMove;
  107939. private _onPointerDown;
  107940. private _onPointerUp;
  107941. private _initClickEvent;
  107942. private _initActionManager;
  107943. private _delayedSimpleClick;
  107944. private _delayedSimpleClickTimeout;
  107945. private _previousDelayedSimpleClickTimeout;
  107946. private _meshPickProceed;
  107947. private _previousButtonPressed;
  107948. private _currentPickResult;
  107949. private _previousPickResult;
  107950. private _totalPointersPressed;
  107951. private _doubleClickOccured;
  107952. private _pointerOverMesh;
  107953. private _pickedDownMesh;
  107954. private _pickedUpMesh;
  107955. private _pointerX;
  107956. private _pointerY;
  107957. private _unTranslatedPointerX;
  107958. private _unTranslatedPointerY;
  107959. private _startingPointerPosition;
  107960. private _previousStartingPointerPosition;
  107961. private _startingPointerTime;
  107962. private _previousStartingPointerTime;
  107963. private _pointerCaptures;
  107964. private _onKeyDown;
  107965. private _onKeyUp;
  107966. private _onCanvasFocusObserver;
  107967. private _onCanvasBlurObserver;
  107968. private _scene;
  107969. /**
  107970. * Creates a new InputManager
  107971. * @param scene defines the hosting scene
  107972. */
  107973. constructor(scene: Scene);
  107974. /**
  107975. * Gets the mesh that is currently under the pointer
  107976. */
  107977. get meshUnderPointer(): Nullable<AbstractMesh>;
  107978. /**
  107979. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107980. */
  107981. get unTranslatedPointer(): Vector2;
  107982. /**
  107983. * Gets or sets the current on-screen X position of the pointer
  107984. */
  107985. get pointerX(): number;
  107986. set pointerX(value: number);
  107987. /**
  107988. * Gets or sets the current on-screen Y position of the pointer
  107989. */
  107990. get pointerY(): number;
  107991. set pointerY(value: number);
  107992. private _updatePointerPosition;
  107993. private _processPointerMove;
  107994. private _setRayOnPointerInfo;
  107995. private _checkPrePointerObservable;
  107996. /**
  107997. * Use this method to simulate a pointer move on a mesh
  107998. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107999. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108000. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108001. */
  108002. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108003. /**
  108004. * Use this method to simulate a pointer down on a mesh
  108005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108008. */
  108009. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108010. private _processPointerDown;
  108011. /** @hidden */
  108012. _isPointerSwiping(): boolean;
  108013. /**
  108014. * Use this method to simulate a pointer up on a mesh
  108015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108018. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108019. */
  108020. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108021. private _processPointerUp;
  108022. /**
  108023. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108024. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108025. * @returns true if the pointer was captured
  108026. */
  108027. isPointerCaptured(pointerId?: number): boolean;
  108028. /**
  108029. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108030. * @param attachUp defines if you want to attach events to pointerup
  108031. * @param attachDown defines if you want to attach events to pointerdown
  108032. * @param attachMove defines if you want to attach events to pointermove
  108033. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108034. */
  108035. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108036. /**
  108037. * Detaches all event handlers
  108038. */
  108039. detachControl(): void;
  108040. /**
  108041. * Force the value of meshUnderPointer
  108042. * @param mesh defines the mesh to use
  108043. */
  108044. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108045. /**
  108046. * Gets the mesh under the pointer
  108047. * @returns a Mesh or null if no mesh is under the pointer
  108048. */
  108049. getPointerOverMesh(): Nullable<AbstractMesh>;
  108050. }
  108051. }
  108052. declare module BABYLON {
  108053. /**
  108054. * Helper class used to generate session unique ID
  108055. */
  108056. export class UniqueIdGenerator {
  108057. private static _UniqueIdCounter;
  108058. /**
  108059. * Gets an unique (relatively to the current scene) Id
  108060. */
  108061. static get UniqueId(): number;
  108062. }
  108063. }
  108064. declare module BABYLON {
  108065. /**
  108066. * This class defines the direct association between an animation and a target
  108067. */
  108068. export class TargetedAnimation {
  108069. /**
  108070. * Animation to perform
  108071. */
  108072. animation: Animation;
  108073. /**
  108074. * Target to animate
  108075. */
  108076. target: any;
  108077. /**
  108078. * Serialize the object
  108079. * @returns the JSON object representing the current entity
  108080. */
  108081. serialize(): any;
  108082. }
  108083. /**
  108084. * Use this class to create coordinated animations on multiple targets
  108085. */
  108086. export class AnimationGroup implements IDisposable {
  108087. /** The name of the animation group */
  108088. name: string;
  108089. private _scene;
  108090. private _targetedAnimations;
  108091. private _animatables;
  108092. private _from;
  108093. private _to;
  108094. private _isStarted;
  108095. private _isPaused;
  108096. private _speedRatio;
  108097. private _loopAnimation;
  108098. /**
  108099. * Gets or sets the unique id of the node
  108100. */
  108101. uniqueId: number;
  108102. /**
  108103. * This observable will notify when one animation have ended
  108104. */
  108105. onAnimationEndObservable: Observable<TargetedAnimation>;
  108106. /**
  108107. * Observer raised when one animation loops
  108108. */
  108109. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108110. /**
  108111. * Observer raised when all animations have looped
  108112. */
  108113. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108114. /**
  108115. * This observable will notify when all animations have ended.
  108116. */
  108117. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108118. /**
  108119. * This observable will notify when all animations have paused.
  108120. */
  108121. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108122. /**
  108123. * This observable will notify when all animations are playing.
  108124. */
  108125. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108126. /**
  108127. * Gets the first frame
  108128. */
  108129. get from(): number;
  108130. /**
  108131. * Gets the last frame
  108132. */
  108133. get to(): number;
  108134. /**
  108135. * Define if the animations are started
  108136. */
  108137. get isStarted(): boolean;
  108138. /**
  108139. * Gets a value indicating that the current group is playing
  108140. */
  108141. get isPlaying(): boolean;
  108142. /**
  108143. * Gets or sets the speed ratio to use for all animations
  108144. */
  108145. get speedRatio(): number;
  108146. /**
  108147. * Gets or sets the speed ratio to use for all animations
  108148. */
  108149. set speedRatio(value: number);
  108150. /**
  108151. * Gets or sets if all animations should loop or not
  108152. */
  108153. get loopAnimation(): boolean;
  108154. set loopAnimation(value: boolean);
  108155. /**
  108156. * Gets the targeted animations for this animation group
  108157. */
  108158. get targetedAnimations(): Array<TargetedAnimation>;
  108159. /**
  108160. * returning the list of animatables controlled by this animation group.
  108161. */
  108162. get animatables(): Array<Animatable>;
  108163. /**
  108164. * Instantiates a new Animation Group.
  108165. * This helps managing several animations at once.
  108166. * @see http://doc.babylonjs.com/how_to/group
  108167. * @param name Defines the name of the group
  108168. * @param scene Defines the scene the group belongs to
  108169. */
  108170. constructor(
  108171. /** The name of the animation group */
  108172. name: string, scene?: Nullable<Scene>);
  108173. /**
  108174. * Add an animation (with its target) in the group
  108175. * @param animation defines the animation we want to add
  108176. * @param target defines the target of the animation
  108177. * @returns the TargetedAnimation object
  108178. */
  108179. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108180. /**
  108181. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108182. * It can add constant keys at begin or end
  108183. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108184. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108185. * @returns the animation group
  108186. */
  108187. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108188. private _animationLoopCount;
  108189. private _animationLoopFlags;
  108190. private _processLoop;
  108191. /**
  108192. * Start all animations on given targets
  108193. * @param loop defines if animations must loop
  108194. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108195. * @param from defines the from key (optional)
  108196. * @param to defines the to key (optional)
  108197. * @returns the current animation group
  108198. */
  108199. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108200. /**
  108201. * Pause all animations
  108202. * @returns the animation group
  108203. */
  108204. pause(): AnimationGroup;
  108205. /**
  108206. * Play all animations to initial state
  108207. * This function will start() the animations if they were not started or will restart() them if they were paused
  108208. * @param loop defines if animations must loop
  108209. * @returns the animation group
  108210. */
  108211. play(loop?: boolean): AnimationGroup;
  108212. /**
  108213. * Reset all animations to initial state
  108214. * @returns the animation group
  108215. */
  108216. reset(): AnimationGroup;
  108217. /**
  108218. * Restart animations from key 0
  108219. * @returns the animation group
  108220. */
  108221. restart(): AnimationGroup;
  108222. /**
  108223. * Stop all animations
  108224. * @returns the animation group
  108225. */
  108226. stop(): AnimationGroup;
  108227. /**
  108228. * Set animation weight for all animatables
  108229. * @param weight defines the weight to use
  108230. * @return the animationGroup
  108231. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108232. */
  108233. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108234. /**
  108235. * Synchronize and normalize all animatables with a source animatable
  108236. * @param root defines the root animatable to synchronize with
  108237. * @return the animationGroup
  108238. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108239. */
  108240. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108241. /**
  108242. * Goes to a specific frame in this animation group
  108243. * @param frame the frame number to go to
  108244. * @return the animationGroup
  108245. */
  108246. goToFrame(frame: number): AnimationGroup;
  108247. /**
  108248. * Dispose all associated resources
  108249. */
  108250. dispose(): void;
  108251. private _checkAnimationGroupEnded;
  108252. /**
  108253. * Clone the current animation group and returns a copy
  108254. * @param newName defines the name of the new group
  108255. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108256. * @returns the new aniamtion group
  108257. */
  108258. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108259. /**
  108260. * Serializes the animationGroup to an object
  108261. * @returns Serialized object
  108262. */
  108263. serialize(): any;
  108264. /**
  108265. * Returns a new AnimationGroup object parsed from the source provided.
  108266. * @param parsedAnimationGroup defines the source
  108267. * @param scene defines the scene that will receive the animationGroup
  108268. * @returns a new AnimationGroup
  108269. */
  108270. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108271. /**
  108272. * Returns the string "AnimationGroup"
  108273. * @returns "AnimationGroup"
  108274. */
  108275. getClassName(): string;
  108276. /**
  108277. * Creates a detailled string about the object
  108278. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108279. * @returns a string representing the object
  108280. */
  108281. toString(fullDetails?: boolean): string;
  108282. }
  108283. }
  108284. declare module BABYLON {
  108285. /**
  108286. * Define an interface for all classes that will hold resources
  108287. */
  108288. export interface IDisposable {
  108289. /**
  108290. * Releases all held resources
  108291. */
  108292. dispose(): void;
  108293. }
  108294. /** Interface defining initialization parameters for Scene class */
  108295. export interface SceneOptions {
  108296. /**
  108297. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108298. * It will improve performance when the number of geometries becomes important.
  108299. */
  108300. useGeometryUniqueIdsMap?: boolean;
  108301. /**
  108302. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108303. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108304. */
  108305. useMaterialMeshMap?: boolean;
  108306. /**
  108307. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108308. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108309. */
  108310. useClonedMeshMap?: boolean;
  108311. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108312. virtual?: boolean;
  108313. }
  108314. /**
  108315. * Represents a scene to be rendered by the engine.
  108316. * @see http://doc.babylonjs.com/features/scene
  108317. */
  108318. export class Scene extends AbstractScene implements IAnimatable {
  108319. /** The fog is deactivated */
  108320. static readonly FOGMODE_NONE: number;
  108321. /** The fog density is following an exponential function */
  108322. static readonly FOGMODE_EXP: number;
  108323. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108324. static readonly FOGMODE_EXP2: number;
  108325. /** The fog density is following a linear function. */
  108326. static readonly FOGMODE_LINEAR: number;
  108327. /**
  108328. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108330. */
  108331. static MinDeltaTime: number;
  108332. /**
  108333. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108335. */
  108336. static MaxDeltaTime: number;
  108337. /**
  108338. * Factory used to create the default material.
  108339. * @param name The name of the material to create
  108340. * @param scene The scene to create the material for
  108341. * @returns The default material
  108342. */
  108343. static DefaultMaterialFactory(scene: Scene): Material;
  108344. /**
  108345. * Factory used to create the a collision coordinator.
  108346. * @returns The collision coordinator
  108347. */
  108348. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108349. /** @hidden */
  108350. _inputManager: InputManager;
  108351. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108352. cameraToUseForPointers: Nullable<Camera>;
  108353. /** @hidden */
  108354. readonly _isScene: boolean;
  108355. /** @hidden */
  108356. _blockEntityCollection: boolean;
  108357. /**
  108358. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108359. */
  108360. autoClear: boolean;
  108361. /**
  108362. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108363. */
  108364. autoClearDepthAndStencil: boolean;
  108365. /**
  108366. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108367. */
  108368. clearColor: Color4;
  108369. /**
  108370. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108371. */
  108372. ambientColor: Color3;
  108373. /**
  108374. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108375. * It should only be one of the following (if not the default embedded one):
  108376. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108377. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108378. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108379. * The material properties need to be setup according to the type of texture in use.
  108380. */
  108381. environmentBRDFTexture: BaseTexture;
  108382. /** @hidden */
  108383. protected _environmentTexture: Nullable<BaseTexture>;
  108384. /**
  108385. * Texture used in all pbr material as the reflection texture.
  108386. * As in the majority of the scene they are the same (exception for multi room and so on),
  108387. * this is easier to reference from here than from all the materials.
  108388. */
  108389. get environmentTexture(): Nullable<BaseTexture>;
  108390. /**
  108391. * Texture used in all pbr material as the reflection texture.
  108392. * As in the majority of the scene they are the same (exception for multi room and so on),
  108393. * this is easier to set here than in all the materials.
  108394. */
  108395. set environmentTexture(value: Nullable<BaseTexture>);
  108396. /** @hidden */
  108397. protected _environmentIntensity: number;
  108398. /**
  108399. * Intensity of the environment in all pbr material.
  108400. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108401. * As in the majority of the scene they are the same (exception for multi room and so on),
  108402. * this is easier to reference from here than from all the materials.
  108403. */
  108404. get environmentIntensity(): number;
  108405. /**
  108406. * Intensity of the environment in all pbr material.
  108407. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108408. * As in the majority of the scene they are the same (exception for multi room and so on),
  108409. * this is easier to set here than in all the materials.
  108410. */
  108411. set environmentIntensity(value: number);
  108412. /** @hidden */
  108413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108414. /**
  108415. * Default image processing configuration used either in the rendering
  108416. * Forward main pass or through the imageProcessingPostProcess if present.
  108417. * As in the majority of the scene they are the same (exception for multi camera),
  108418. * this is easier to reference from here than from all the materials and post process.
  108419. *
  108420. * No setter as we it is a shared configuration, you can set the values instead.
  108421. */
  108422. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108423. private _forceWireframe;
  108424. /**
  108425. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108426. */
  108427. set forceWireframe(value: boolean);
  108428. get forceWireframe(): boolean;
  108429. private _skipFrustumClipping;
  108430. /**
  108431. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108432. */
  108433. set skipFrustumClipping(value: boolean);
  108434. get skipFrustumClipping(): boolean;
  108435. private _forcePointsCloud;
  108436. /**
  108437. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108438. */
  108439. set forcePointsCloud(value: boolean);
  108440. get forcePointsCloud(): boolean;
  108441. /**
  108442. * Gets or sets the active clipplane 1
  108443. */
  108444. clipPlane: Nullable<Plane>;
  108445. /**
  108446. * Gets or sets the active clipplane 2
  108447. */
  108448. clipPlane2: Nullable<Plane>;
  108449. /**
  108450. * Gets or sets the active clipplane 3
  108451. */
  108452. clipPlane3: Nullable<Plane>;
  108453. /**
  108454. * Gets or sets the active clipplane 4
  108455. */
  108456. clipPlane4: Nullable<Plane>;
  108457. /**
  108458. * Gets or sets the active clipplane 5
  108459. */
  108460. clipPlane5: Nullable<Plane>;
  108461. /**
  108462. * Gets or sets the active clipplane 6
  108463. */
  108464. clipPlane6: Nullable<Plane>;
  108465. /**
  108466. * Gets or sets a boolean indicating if animations are enabled
  108467. */
  108468. animationsEnabled: boolean;
  108469. private _animationPropertiesOverride;
  108470. /**
  108471. * Gets or sets the animation properties override
  108472. */
  108473. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108474. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108475. /**
  108476. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108477. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108478. */
  108479. useConstantAnimationDeltaTime: boolean;
  108480. /**
  108481. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108482. * Please note that it requires to run a ray cast through the scene on every frame
  108483. */
  108484. constantlyUpdateMeshUnderPointer: boolean;
  108485. /**
  108486. * Defines the HTML cursor to use when hovering over interactive elements
  108487. */
  108488. hoverCursor: string;
  108489. /**
  108490. * Defines the HTML default cursor to use (empty by default)
  108491. */
  108492. defaultCursor: string;
  108493. /**
  108494. * Defines whether cursors are handled by the scene.
  108495. */
  108496. doNotHandleCursors: boolean;
  108497. /**
  108498. * This is used to call preventDefault() on pointer down
  108499. * in order to block unwanted artifacts like system double clicks
  108500. */
  108501. preventDefaultOnPointerDown: boolean;
  108502. /**
  108503. * This is used to call preventDefault() on pointer up
  108504. * in order to block unwanted artifacts like system double clicks
  108505. */
  108506. preventDefaultOnPointerUp: boolean;
  108507. /**
  108508. * Gets or sets user defined metadata
  108509. */
  108510. metadata: any;
  108511. /**
  108512. * For internal use only. Please do not use.
  108513. */
  108514. reservedDataStore: any;
  108515. /**
  108516. * Gets the name of the plugin used to load this scene (null by default)
  108517. */
  108518. loadingPluginName: string;
  108519. /**
  108520. * Use this array to add regular expressions used to disable offline support for specific urls
  108521. */
  108522. disableOfflineSupportExceptionRules: RegExp[];
  108523. /**
  108524. * An event triggered when the scene is disposed.
  108525. */
  108526. onDisposeObservable: Observable<Scene>;
  108527. private _onDisposeObserver;
  108528. /** Sets a function to be executed when this scene is disposed. */
  108529. set onDispose(callback: () => void);
  108530. /**
  108531. * An event triggered before rendering the scene (right after animations and physics)
  108532. */
  108533. onBeforeRenderObservable: Observable<Scene>;
  108534. private _onBeforeRenderObserver;
  108535. /** Sets a function to be executed before rendering this scene */
  108536. set beforeRender(callback: Nullable<() => void>);
  108537. /**
  108538. * An event triggered after rendering the scene
  108539. */
  108540. onAfterRenderObservable: Observable<Scene>;
  108541. /**
  108542. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108543. */
  108544. onAfterRenderCameraObservable: Observable<Camera>;
  108545. private _onAfterRenderObserver;
  108546. /** Sets a function to be executed after rendering this scene */
  108547. set afterRender(callback: Nullable<() => void>);
  108548. /**
  108549. * An event triggered before animating the scene
  108550. */
  108551. onBeforeAnimationsObservable: Observable<Scene>;
  108552. /**
  108553. * An event triggered after animations processing
  108554. */
  108555. onAfterAnimationsObservable: Observable<Scene>;
  108556. /**
  108557. * An event triggered before draw calls are ready to be sent
  108558. */
  108559. onBeforeDrawPhaseObservable: Observable<Scene>;
  108560. /**
  108561. * An event triggered after draw calls have been sent
  108562. */
  108563. onAfterDrawPhaseObservable: Observable<Scene>;
  108564. /**
  108565. * An event triggered when the scene is ready
  108566. */
  108567. onReadyObservable: Observable<Scene>;
  108568. /**
  108569. * An event triggered before rendering a camera
  108570. */
  108571. onBeforeCameraRenderObservable: Observable<Camera>;
  108572. private _onBeforeCameraRenderObserver;
  108573. /** Sets a function to be executed before rendering a camera*/
  108574. set beforeCameraRender(callback: () => void);
  108575. /**
  108576. * An event triggered after rendering a camera
  108577. */
  108578. onAfterCameraRenderObservable: Observable<Camera>;
  108579. private _onAfterCameraRenderObserver;
  108580. /** Sets a function to be executed after rendering a camera*/
  108581. set afterCameraRender(callback: () => void);
  108582. /**
  108583. * An event triggered when active meshes evaluation is about to start
  108584. */
  108585. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108586. /**
  108587. * An event triggered when active meshes evaluation is done
  108588. */
  108589. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108590. /**
  108591. * An event triggered when particles rendering is about to start
  108592. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108593. */
  108594. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108595. /**
  108596. * An event triggered when particles rendering is done
  108597. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108598. */
  108599. onAfterParticlesRenderingObservable: Observable<Scene>;
  108600. /**
  108601. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108602. */
  108603. onDataLoadedObservable: Observable<Scene>;
  108604. /**
  108605. * An event triggered when a camera is created
  108606. */
  108607. onNewCameraAddedObservable: Observable<Camera>;
  108608. /**
  108609. * An event triggered when a camera is removed
  108610. */
  108611. onCameraRemovedObservable: Observable<Camera>;
  108612. /**
  108613. * An event triggered when a light is created
  108614. */
  108615. onNewLightAddedObservable: Observable<Light>;
  108616. /**
  108617. * An event triggered when a light is removed
  108618. */
  108619. onLightRemovedObservable: Observable<Light>;
  108620. /**
  108621. * An event triggered when a geometry is created
  108622. */
  108623. onNewGeometryAddedObservable: Observable<Geometry>;
  108624. /**
  108625. * An event triggered when a geometry is removed
  108626. */
  108627. onGeometryRemovedObservable: Observable<Geometry>;
  108628. /**
  108629. * An event triggered when a transform node is created
  108630. */
  108631. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108632. /**
  108633. * An event triggered when a transform node is removed
  108634. */
  108635. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108636. /**
  108637. * An event triggered when a mesh is created
  108638. */
  108639. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108640. /**
  108641. * An event triggered when a mesh is removed
  108642. */
  108643. onMeshRemovedObservable: Observable<AbstractMesh>;
  108644. /**
  108645. * An event triggered when a skeleton is created
  108646. */
  108647. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108648. /**
  108649. * An event triggered when a skeleton is removed
  108650. */
  108651. onSkeletonRemovedObservable: Observable<Skeleton>;
  108652. /**
  108653. * An event triggered when a material is created
  108654. */
  108655. onNewMaterialAddedObservable: Observable<Material>;
  108656. /**
  108657. * An event triggered when a material is removed
  108658. */
  108659. onMaterialRemovedObservable: Observable<Material>;
  108660. /**
  108661. * An event triggered when a texture is created
  108662. */
  108663. onNewTextureAddedObservable: Observable<BaseTexture>;
  108664. /**
  108665. * An event triggered when a texture is removed
  108666. */
  108667. onTextureRemovedObservable: Observable<BaseTexture>;
  108668. /**
  108669. * An event triggered when render targets are about to be rendered
  108670. * Can happen multiple times per frame.
  108671. */
  108672. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108673. /**
  108674. * An event triggered when render targets were rendered.
  108675. * Can happen multiple times per frame.
  108676. */
  108677. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108678. /**
  108679. * An event triggered before calculating deterministic simulation step
  108680. */
  108681. onBeforeStepObservable: Observable<Scene>;
  108682. /**
  108683. * An event triggered after calculating deterministic simulation step
  108684. */
  108685. onAfterStepObservable: Observable<Scene>;
  108686. /**
  108687. * An event triggered when the activeCamera property is updated
  108688. */
  108689. onActiveCameraChanged: Observable<Scene>;
  108690. /**
  108691. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108692. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108693. * 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)
  108694. */
  108695. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108696. /**
  108697. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108698. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108699. * 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)
  108700. */
  108701. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108702. /**
  108703. * This Observable will when a mesh has been imported into the scene.
  108704. */
  108705. onMeshImportedObservable: Observable<AbstractMesh>;
  108706. /**
  108707. * This Observable will when an animation file has been imported into the scene.
  108708. */
  108709. onAnimationFileImportedObservable: Observable<Scene>;
  108710. /**
  108711. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108712. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108713. */
  108714. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108715. /** @hidden */
  108716. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108717. /**
  108718. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108719. */
  108720. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108721. /**
  108722. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108723. */
  108724. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108725. /**
  108726. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108727. */
  108728. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108729. /** Callback called when a pointer move is detected */
  108730. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108731. /** Callback called when a pointer down is detected */
  108732. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108733. /** Callback called when a pointer up is detected */
  108734. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108735. /** Callback called when a pointer pick is detected */
  108736. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108737. /**
  108738. * 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).
  108739. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108740. */
  108741. onPrePointerObservable: Observable<PointerInfoPre>;
  108742. /**
  108743. * Observable event triggered each time an input event is received from the rendering canvas
  108744. */
  108745. onPointerObservable: Observable<PointerInfo>;
  108746. /**
  108747. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108748. */
  108749. get unTranslatedPointer(): Vector2;
  108750. /**
  108751. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108752. */
  108753. static get DragMovementThreshold(): number;
  108754. static set DragMovementThreshold(value: number);
  108755. /**
  108756. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108757. */
  108758. static get LongPressDelay(): number;
  108759. static set LongPressDelay(value: number);
  108760. /**
  108761. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108762. */
  108763. static get DoubleClickDelay(): number;
  108764. static set DoubleClickDelay(value: number);
  108765. /** If you need to check double click without raising a single click at first click, enable this flag */
  108766. static get ExclusiveDoubleClickMode(): boolean;
  108767. static set ExclusiveDoubleClickMode(value: boolean);
  108768. /** @hidden */
  108769. _mirroredCameraPosition: Nullable<Vector3>;
  108770. /**
  108771. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108772. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108773. */
  108774. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108775. /**
  108776. * Observable event triggered each time an keyboard event is received from the hosting window
  108777. */
  108778. onKeyboardObservable: Observable<KeyboardInfo>;
  108779. private _useRightHandedSystem;
  108780. /**
  108781. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108782. */
  108783. set useRightHandedSystem(value: boolean);
  108784. get useRightHandedSystem(): boolean;
  108785. private _timeAccumulator;
  108786. private _currentStepId;
  108787. private _currentInternalStep;
  108788. /**
  108789. * Sets the step Id used by deterministic lock step
  108790. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108791. * @param newStepId defines the step Id
  108792. */
  108793. setStepId(newStepId: number): void;
  108794. /**
  108795. * Gets the step Id used by deterministic lock step
  108796. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108797. * @returns the step Id
  108798. */
  108799. getStepId(): number;
  108800. /**
  108801. * Gets the internal step used by deterministic lock step
  108802. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108803. * @returns the internal step
  108804. */
  108805. getInternalStep(): number;
  108806. private _fogEnabled;
  108807. /**
  108808. * Gets or sets a boolean indicating if fog is enabled on this scene
  108809. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108810. * (Default is true)
  108811. */
  108812. set fogEnabled(value: boolean);
  108813. get fogEnabled(): boolean;
  108814. private _fogMode;
  108815. /**
  108816. * Gets or sets the fog mode to use
  108817. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108818. * | mode | value |
  108819. * | --- | --- |
  108820. * | FOGMODE_NONE | 0 |
  108821. * | FOGMODE_EXP | 1 |
  108822. * | FOGMODE_EXP2 | 2 |
  108823. * | FOGMODE_LINEAR | 3 |
  108824. */
  108825. set fogMode(value: number);
  108826. get fogMode(): number;
  108827. /**
  108828. * Gets or sets the fog color to use
  108829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108830. * (Default is Color3(0.2, 0.2, 0.3))
  108831. */
  108832. fogColor: Color3;
  108833. /**
  108834. * Gets or sets the fog density to use
  108835. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108836. * (Default is 0.1)
  108837. */
  108838. fogDensity: number;
  108839. /**
  108840. * Gets or sets the fog start distance to use
  108841. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108842. * (Default is 0)
  108843. */
  108844. fogStart: number;
  108845. /**
  108846. * Gets or sets the fog end distance to use
  108847. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108848. * (Default is 1000)
  108849. */
  108850. fogEnd: number;
  108851. private _shadowsEnabled;
  108852. /**
  108853. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108854. */
  108855. set shadowsEnabled(value: boolean);
  108856. get shadowsEnabled(): boolean;
  108857. private _lightsEnabled;
  108858. /**
  108859. * Gets or sets a boolean indicating if lights are enabled on this scene
  108860. */
  108861. set lightsEnabled(value: boolean);
  108862. get lightsEnabled(): boolean;
  108863. /** All of the active cameras added to this scene. */
  108864. activeCameras: Camera[];
  108865. /** @hidden */
  108866. _activeCamera: Nullable<Camera>;
  108867. /** Gets or sets the current active camera */
  108868. get activeCamera(): Nullable<Camera>;
  108869. set activeCamera(value: Nullable<Camera>);
  108870. private _defaultMaterial;
  108871. /** The default material used on meshes when no material is affected */
  108872. get defaultMaterial(): Material;
  108873. /** The default material used on meshes when no material is affected */
  108874. set defaultMaterial(value: Material);
  108875. private _texturesEnabled;
  108876. /**
  108877. * Gets or sets a boolean indicating if textures are enabled on this scene
  108878. */
  108879. set texturesEnabled(value: boolean);
  108880. get texturesEnabled(): boolean;
  108881. /**
  108882. * Gets or sets a boolean indicating if particles are enabled on this scene
  108883. */
  108884. particlesEnabled: boolean;
  108885. /**
  108886. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108887. */
  108888. spritesEnabled: boolean;
  108889. private _skeletonsEnabled;
  108890. /**
  108891. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108892. */
  108893. set skeletonsEnabled(value: boolean);
  108894. get skeletonsEnabled(): boolean;
  108895. /**
  108896. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108897. */
  108898. lensFlaresEnabled: boolean;
  108899. /**
  108900. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108902. */
  108903. collisionsEnabled: boolean;
  108904. private _collisionCoordinator;
  108905. /** @hidden */
  108906. get collisionCoordinator(): ICollisionCoordinator;
  108907. /**
  108908. * Defines the gravity applied to this scene (used only for collisions)
  108909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108910. */
  108911. gravity: Vector3;
  108912. /**
  108913. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108914. */
  108915. postProcessesEnabled: boolean;
  108916. /**
  108917. * The list of postprocesses added to the scene
  108918. */
  108919. postProcesses: PostProcess[];
  108920. /**
  108921. * Gets the current postprocess manager
  108922. */
  108923. postProcessManager: PostProcessManager;
  108924. /**
  108925. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108926. */
  108927. renderTargetsEnabled: boolean;
  108928. /**
  108929. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108930. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108931. */
  108932. dumpNextRenderTargets: boolean;
  108933. /**
  108934. * The list of user defined render targets added to the scene
  108935. */
  108936. customRenderTargets: RenderTargetTexture[];
  108937. /**
  108938. * Defines if texture loading must be delayed
  108939. * If true, textures will only be loaded when they need to be rendered
  108940. */
  108941. useDelayedTextureLoading: boolean;
  108942. /**
  108943. * Gets the list of meshes imported to the scene through SceneLoader
  108944. */
  108945. importedMeshesFiles: String[];
  108946. /**
  108947. * Gets or sets a boolean indicating if probes are enabled on this scene
  108948. */
  108949. probesEnabled: boolean;
  108950. /**
  108951. * Gets or sets the current offline provider to use to store scene data
  108952. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108953. */
  108954. offlineProvider: IOfflineProvider;
  108955. /**
  108956. * Gets or sets the action manager associated with the scene
  108957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108958. */
  108959. actionManager: AbstractActionManager;
  108960. private _meshesForIntersections;
  108961. /**
  108962. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108963. */
  108964. proceduralTexturesEnabled: boolean;
  108965. private _engine;
  108966. private _totalVertices;
  108967. /** @hidden */
  108968. _activeIndices: PerfCounter;
  108969. /** @hidden */
  108970. _activeParticles: PerfCounter;
  108971. /** @hidden */
  108972. _activeBones: PerfCounter;
  108973. private _animationRatio;
  108974. /** @hidden */
  108975. _animationTimeLast: number;
  108976. /** @hidden */
  108977. _animationTime: number;
  108978. /**
  108979. * Gets or sets a general scale for animation speed
  108980. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108981. */
  108982. animationTimeScale: number;
  108983. /** @hidden */
  108984. _cachedMaterial: Nullable<Material>;
  108985. /** @hidden */
  108986. _cachedEffect: Nullable<Effect>;
  108987. /** @hidden */
  108988. _cachedVisibility: Nullable<number>;
  108989. private _renderId;
  108990. private _frameId;
  108991. private _executeWhenReadyTimeoutId;
  108992. private _intermediateRendering;
  108993. private _viewUpdateFlag;
  108994. private _projectionUpdateFlag;
  108995. /** @hidden */
  108996. _toBeDisposed: Nullable<IDisposable>[];
  108997. private _activeRequests;
  108998. /** @hidden */
  108999. _pendingData: any[];
  109000. private _isDisposed;
  109001. /**
  109002. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109003. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109004. */
  109005. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109006. private _activeMeshes;
  109007. private _processedMaterials;
  109008. private _renderTargets;
  109009. /** @hidden */
  109010. _activeParticleSystems: SmartArray<IParticleSystem>;
  109011. private _activeSkeletons;
  109012. private _softwareSkinnedMeshes;
  109013. private _renderingManager;
  109014. /** @hidden */
  109015. _activeAnimatables: Animatable[];
  109016. private _transformMatrix;
  109017. private _sceneUbo;
  109018. /** @hidden */
  109019. _viewMatrix: Matrix;
  109020. private _projectionMatrix;
  109021. /** @hidden */
  109022. _forcedViewPosition: Nullable<Vector3>;
  109023. /** @hidden */
  109024. _frustumPlanes: Plane[];
  109025. /**
  109026. * Gets the list of frustum planes (built from the active camera)
  109027. */
  109028. get frustumPlanes(): Plane[];
  109029. /**
  109030. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109031. * This is useful if there are more lights that the maximum simulteanous authorized
  109032. */
  109033. requireLightSorting: boolean;
  109034. /** @hidden */
  109035. readonly useMaterialMeshMap: boolean;
  109036. /** @hidden */
  109037. readonly useClonedMeshMap: boolean;
  109038. private _externalData;
  109039. private _uid;
  109040. /**
  109041. * @hidden
  109042. * Backing store of defined scene components.
  109043. */
  109044. _components: ISceneComponent[];
  109045. /**
  109046. * @hidden
  109047. * Backing store of defined scene components.
  109048. */
  109049. _serializableComponents: ISceneSerializableComponent[];
  109050. /**
  109051. * List of components to register on the next registration step.
  109052. */
  109053. private _transientComponents;
  109054. /**
  109055. * Registers the transient components if needed.
  109056. */
  109057. private _registerTransientComponents;
  109058. /**
  109059. * @hidden
  109060. * Add a component to the scene.
  109061. * Note that the ccomponent could be registered on th next frame if this is called after
  109062. * the register component stage.
  109063. * @param component Defines the component to add to the scene
  109064. */
  109065. _addComponent(component: ISceneComponent): void;
  109066. /**
  109067. * @hidden
  109068. * Gets a component from the scene.
  109069. * @param name defines the name of the component to retrieve
  109070. * @returns the component or null if not present
  109071. */
  109072. _getComponent(name: string): Nullable<ISceneComponent>;
  109073. /**
  109074. * @hidden
  109075. * Defines the actions happening before camera updates.
  109076. */
  109077. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109078. /**
  109079. * @hidden
  109080. * Defines the actions happening before clear the canvas.
  109081. */
  109082. _beforeClearStage: Stage<SimpleStageAction>;
  109083. /**
  109084. * @hidden
  109085. * Defines the actions when collecting render targets for the frame.
  109086. */
  109087. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109088. /**
  109089. * @hidden
  109090. * Defines the actions happening for one camera in the frame.
  109091. */
  109092. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109093. /**
  109094. * @hidden
  109095. * Defines the actions happening during the per mesh ready checks.
  109096. */
  109097. _isReadyForMeshStage: Stage<MeshStageAction>;
  109098. /**
  109099. * @hidden
  109100. * Defines the actions happening before evaluate active mesh checks.
  109101. */
  109102. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109103. /**
  109104. * @hidden
  109105. * Defines the actions happening during the evaluate sub mesh checks.
  109106. */
  109107. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109108. /**
  109109. * @hidden
  109110. * Defines the actions happening during the active mesh stage.
  109111. */
  109112. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109113. /**
  109114. * @hidden
  109115. * Defines the actions happening during the per camera render target step.
  109116. */
  109117. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109118. /**
  109119. * @hidden
  109120. * Defines the actions happening just before the active camera is drawing.
  109121. */
  109122. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109123. /**
  109124. * @hidden
  109125. * Defines the actions happening just before a render target is drawing.
  109126. */
  109127. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109128. /**
  109129. * @hidden
  109130. * Defines the actions happening just before a rendering group is drawing.
  109131. */
  109132. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109133. /**
  109134. * @hidden
  109135. * Defines the actions happening just before a mesh is drawing.
  109136. */
  109137. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109138. /**
  109139. * @hidden
  109140. * Defines the actions happening just after a mesh has been drawn.
  109141. */
  109142. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109143. /**
  109144. * @hidden
  109145. * Defines the actions happening just after a rendering group has been drawn.
  109146. */
  109147. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109148. /**
  109149. * @hidden
  109150. * Defines the actions happening just after the active camera has been drawn.
  109151. */
  109152. _afterCameraDrawStage: Stage<CameraStageAction>;
  109153. /**
  109154. * @hidden
  109155. * Defines the actions happening just after a render target has been drawn.
  109156. */
  109157. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109158. /**
  109159. * @hidden
  109160. * Defines the actions happening just after rendering all cameras and computing intersections.
  109161. */
  109162. _afterRenderStage: Stage<SimpleStageAction>;
  109163. /**
  109164. * @hidden
  109165. * Defines the actions happening when a pointer move event happens.
  109166. */
  109167. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109168. /**
  109169. * @hidden
  109170. * Defines the actions happening when a pointer down event happens.
  109171. */
  109172. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109173. /**
  109174. * @hidden
  109175. * Defines the actions happening when a pointer up event happens.
  109176. */
  109177. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109178. /**
  109179. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109180. */
  109181. private geometriesByUniqueId;
  109182. /**
  109183. * Creates a new Scene
  109184. * @param engine defines the engine to use to render this scene
  109185. * @param options defines the scene options
  109186. */
  109187. constructor(engine: Engine, options?: SceneOptions);
  109188. /**
  109189. * Gets a string idenfifying the name of the class
  109190. * @returns "Scene" string
  109191. */
  109192. getClassName(): string;
  109193. private _defaultMeshCandidates;
  109194. /**
  109195. * @hidden
  109196. */
  109197. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109198. private _defaultSubMeshCandidates;
  109199. /**
  109200. * @hidden
  109201. */
  109202. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109203. /**
  109204. * Sets the default candidate providers for the scene.
  109205. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109206. * and getCollidingSubMeshCandidates to their default function
  109207. */
  109208. setDefaultCandidateProviders(): void;
  109209. /**
  109210. * Gets the mesh that is currently under the pointer
  109211. */
  109212. get meshUnderPointer(): Nullable<AbstractMesh>;
  109213. /**
  109214. * Gets or sets the current on-screen X position of the pointer
  109215. */
  109216. get pointerX(): number;
  109217. set pointerX(value: number);
  109218. /**
  109219. * Gets or sets the current on-screen Y position of the pointer
  109220. */
  109221. get pointerY(): number;
  109222. set pointerY(value: number);
  109223. /**
  109224. * Gets the cached material (ie. the latest rendered one)
  109225. * @returns the cached material
  109226. */
  109227. getCachedMaterial(): Nullable<Material>;
  109228. /**
  109229. * Gets the cached effect (ie. the latest rendered one)
  109230. * @returns the cached effect
  109231. */
  109232. getCachedEffect(): Nullable<Effect>;
  109233. /**
  109234. * Gets the cached visibility state (ie. the latest rendered one)
  109235. * @returns the cached visibility state
  109236. */
  109237. getCachedVisibility(): Nullable<number>;
  109238. /**
  109239. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109240. * @param material defines the current material
  109241. * @param effect defines the current effect
  109242. * @param visibility defines the current visibility state
  109243. * @returns true if one parameter is not cached
  109244. */
  109245. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109246. /**
  109247. * Gets the engine associated with the scene
  109248. * @returns an Engine
  109249. */
  109250. getEngine(): Engine;
  109251. /**
  109252. * Gets the total number of vertices rendered per frame
  109253. * @returns the total number of vertices rendered per frame
  109254. */
  109255. getTotalVertices(): number;
  109256. /**
  109257. * Gets the performance counter for total vertices
  109258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109259. */
  109260. get totalVerticesPerfCounter(): PerfCounter;
  109261. /**
  109262. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109263. * @returns the total number of active indices rendered per frame
  109264. */
  109265. getActiveIndices(): number;
  109266. /**
  109267. * Gets the performance counter for active indices
  109268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109269. */
  109270. get totalActiveIndicesPerfCounter(): PerfCounter;
  109271. /**
  109272. * Gets the total number of active particles rendered per frame
  109273. * @returns the total number of active particles rendered per frame
  109274. */
  109275. getActiveParticles(): number;
  109276. /**
  109277. * Gets the performance counter for active particles
  109278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109279. */
  109280. get activeParticlesPerfCounter(): PerfCounter;
  109281. /**
  109282. * Gets the total number of active bones rendered per frame
  109283. * @returns the total number of active bones rendered per frame
  109284. */
  109285. getActiveBones(): number;
  109286. /**
  109287. * Gets the performance counter for active bones
  109288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109289. */
  109290. get activeBonesPerfCounter(): PerfCounter;
  109291. /**
  109292. * Gets the array of active meshes
  109293. * @returns an array of AbstractMesh
  109294. */
  109295. getActiveMeshes(): SmartArray<AbstractMesh>;
  109296. /**
  109297. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109298. * @returns a number
  109299. */
  109300. getAnimationRatio(): number;
  109301. /**
  109302. * Gets an unique Id for the current render phase
  109303. * @returns a number
  109304. */
  109305. getRenderId(): number;
  109306. /**
  109307. * Gets an unique Id for the current frame
  109308. * @returns a number
  109309. */
  109310. getFrameId(): number;
  109311. /** Call this function if you want to manually increment the render Id*/
  109312. incrementRenderId(): void;
  109313. private _createUbo;
  109314. /**
  109315. * Use this method to simulate a pointer move on a mesh
  109316. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109317. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109318. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109319. * @returns the current scene
  109320. */
  109321. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109322. /**
  109323. * Use this method to simulate a pointer down on a mesh
  109324. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109325. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109326. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109327. * @returns the current scene
  109328. */
  109329. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109330. /**
  109331. * Use this method to simulate a pointer up on a mesh
  109332. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109333. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109334. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109335. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109336. * @returns the current scene
  109337. */
  109338. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109339. /**
  109340. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109341. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109342. * @returns true if the pointer was captured
  109343. */
  109344. isPointerCaptured(pointerId?: number): boolean;
  109345. /**
  109346. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109347. * @param attachUp defines if you want to attach events to pointerup
  109348. * @param attachDown defines if you want to attach events to pointerdown
  109349. * @param attachMove defines if you want to attach events to pointermove
  109350. */
  109351. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109352. /** Detaches all event handlers*/
  109353. detachControl(): void;
  109354. /**
  109355. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109356. * Delay loaded resources are not taking in account
  109357. * @return true if all required resources are ready
  109358. */
  109359. isReady(): boolean;
  109360. /** Resets all cached information relative to material (including effect and visibility) */
  109361. resetCachedMaterial(): void;
  109362. /**
  109363. * Registers a function to be called before every frame render
  109364. * @param func defines the function to register
  109365. */
  109366. registerBeforeRender(func: () => void): void;
  109367. /**
  109368. * Unregisters a function called before every frame render
  109369. * @param func defines the function to unregister
  109370. */
  109371. unregisterBeforeRender(func: () => void): void;
  109372. /**
  109373. * Registers a function to be called after every frame render
  109374. * @param func defines the function to register
  109375. */
  109376. registerAfterRender(func: () => void): void;
  109377. /**
  109378. * Unregisters a function called after every frame render
  109379. * @param func defines the function to unregister
  109380. */
  109381. unregisterAfterRender(func: () => void): void;
  109382. private _executeOnceBeforeRender;
  109383. /**
  109384. * The provided function will run before render once and will be disposed afterwards.
  109385. * A timeout delay can be provided so that the function will be executed in N ms.
  109386. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109387. * @param func The function to be executed.
  109388. * @param timeout optional delay in ms
  109389. */
  109390. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109391. /** @hidden */
  109392. _addPendingData(data: any): void;
  109393. /** @hidden */
  109394. _removePendingData(data: any): void;
  109395. /**
  109396. * Returns the number of items waiting to be loaded
  109397. * @returns the number of items waiting to be loaded
  109398. */
  109399. getWaitingItemsCount(): number;
  109400. /**
  109401. * Returns a boolean indicating if the scene is still loading data
  109402. */
  109403. get isLoading(): boolean;
  109404. /**
  109405. * Registers a function to be executed when the scene is ready
  109406. * @param {Function} func - the function to be executed
  109407. */
  109408. executeWhenReady(func: () => void): void;
  109409. /**
  109410. * Returns a promise that resolves when the scene is ready
  109411. * @returns A promise that resolves when the scene is ready
  109412. */
  109413. whenReadyAsync(): Promise<void>;
  109414. /** @hidden */
  109415. _checkIsReady(): void;
  109416. /**
  109417. * Gets all animatable attached to the scene
  109418. */
  109419. get animatables(): Animatable[];
  109420. /**
  109421. * Resets the last animation time frame.
  109422. * Useful to override when animations start running when loading a scene for the first time.
  109423. */
  109424. resetLastAnimationTimeFrame(): void;
  109425. /**
  109426. * Gets the current view matrix
  109427. * @returns a Matrix
  109428. */
  109429. getViewMatrix(): Matrix;
  109430. /**
  109431. * Gets the current projection matrix
  109432. * @returns a Matrix
  109433. */
  109434. getProjectionMatrix(): Matrix;
  109435. /**
  109436. * Gets the current transform matrix
  109437. * @returns a Matrix made of View * Projection
  109438. */
  109439. getTransformMatrix(): Matrix;
  109440. /**
  109441. * Sets the current transform matrix
  109442. * @param viewL defines the View matrix to use
  109443. * @param projectionL defines the Projection matrix to use
  109444. * @param viewR defines the right View matrix to use (if provided)
  109445. * @param projectionR defines the right Projection matrix to use (if provided)
  109446. */
  109447. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109448. /**
  109449. * Gets the uniform buffer used to store scene data
  109450. * @returns a UniformBuffer
  109451. */
  109452. getSceneUniformBuffer(): UniformBuffer;
  109453. /**
  109454. * Gets an unique (relatively to the current scene) Id
  109455. * @returns an unique number for the scene
  109456. */
  109457. getUniqueId(): number;
  109458. /**
  109459. * Add a mesh to the list of scene's meshes
  109460. * @param newMesh defines the mesh to add
  109461. * @param recursive if all child meshes should also be added to the scene
  109462. */
  109463. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109464. /**
  109465. * Remove a mesh for the list of scene's meshes
  109466. * @param toRemove defines the mesh to remove
  109467. * @param recursive if all child meshes should also be removed from the scene
  109468. * @returns the index where the mesh was in the mesh list
  109469. */
  109470. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109471. /**
  109472. * Add a transform node to the list of scene's transform nodes
  109473. * @param newTransformNode defines the transform node to add
  109474. */
  109475. addTransformNode(newTransformNode: TransformNode): void;
  109476. /**
  109477. * Remove a transform node for the list of scene's transform nodes
  109478. * @param toRemove defines the transform node to remove
  109479. * @returns the index where the transform node was in the transform node list
  109480. */
  109481. removeTransformNode(toRemove: TransformNode): number;
  109482. /**
  109483. * Remove a skeleton for the list of scene's skeletons
  109484. * @param toRemove defines the skeleton to remove
  109485. * @returns the index where the skeleton was in the skeleton list
  109486. */
  109487. removeSkeleton(toRemove: Skeleton): number;
  109488. /**
  109489. * Remove a morph target for the list of scene's morph targets
  109490. * @param toRemove defines the morph target to remove
  109491. * @returns the index where the morph target was in the morph target list
  109492. */
  109493. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109494. /**
  109495. * Remove a light for the list of scene's lights
  109496. * @param toRemove defines the light to remove
  109497. * @returns the index where the light was in the light list
  109498. */
  109499. removeLight(toRemove: Light): number;
  109500. /**
  109501. * Remove a camera for the list of scene's cameras
  109502. * @param toRemove defines the camera to remove
  109503. * @returns the index where the camera was in the camera list
  109504. */
  109505. removeCamera(toRemove: Camera): number;
  109506. /**
  109507. * Remove a particle system for the list of scene's particle systems
  109508. * @param toRemove defines the particle system to remove
  109509. * @returns the index where the particle system was in the particle system list
  109510. */
  109511. removeParticleSystem(toRemove: IParticleSystem): number;
  109512. /**
  109513. * Remove a animation for the list of scene's animations
  109514. * @param toRemove defines the animation to remove
  109515. * @returns the index where the animation was in the animation list
  109516. */
  109517. removeAnimation(toRemove: Animation): number;
  109518. /**
  109519. * Will stop the animation of the given target
  109520. * @param target - the target
  109521. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109522. * @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)
  109523. */
  109524. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109525. /**
  109526. * Removes the given animation group from this scene.
  109527. * @param toRemove The animation group to remove
  109528. * @returns The index of the removed animation group
  109529. */
  109530. removeAnimationGroup(toRemove: AnimationGroup): number;
  109531. /**
  109532. * Removes the given multi-material from this scene.
  109533. * @param toRemove The multi-material to remove
  109534. * @returns The index of the removed multi-material
  109535. */
  109536. removeMultiMaterial(toRemove: MultiMaterial): number;
  109537. /**
  109538. * Removes the given material from this scene.
  109539. * @param toRemove The material to remove
  109540. * @returns The index of the removed material
  109541. */
  109542. removeMaterial(toRemove: Material): number;
  109543. /**
  109544. * Removes the given action manager from this scene.
  109545. * @param toRemove The action manager to remove
  109546. * @returns The index of the removed action manager
  109547. */
  109548. removeActionManager(toRemove: AbstractActionManager): number;
  109549. /**
  109550. * Removes the given texture from this scene.
  109551. * @param toRemove The texture to remove
  109552. * @returns The index of the removed texture
  109553. */
  109554. removeTexture(toRemove: BaseTexture): number;
  109555. /**
  109556. * Adds the given light to this scene
  109557. * @param newLight The light to add
  109558. */
  109559. addLight(newLight: Light): void;
  109560. /**
  109561. * Sorts the list list based on light priorities
  109562. */
  109563. sortLightsByPriority(): void;
  109564. /**
  109565. * Adds the given camera to this scene
  109566. * @param newCamera The camera to add
  109567. */
  109568. addCamera(newCamera: Camera): void;
  109569. /**
  109570. * Adds the given skeleton to this scene
  109571. * @param newSkeleton The skeleton to add
  109572. */
  109573. addSkeleton(newSkeleton: Skeleton): void;
  109574. /**
  109575. * Adds the given particle system to this scene
  109576. * @param newParticleSystem The particle system to add
  109577. */
  109578. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109579. /**
  109580. * Adds the given animation to this scene
  109581. * @param newAnimation The animation to add
  109582. */
  109583. addAnimation(newAnimation: Animation): void;
  109584. /**
  109585. * Adds the given animation group to this scene.
  109586. * @param newAnimationGroup The animation group to add
  109587. */
  109588. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109589. /**
  109590. * Adds the given multi-material to this scene
  109591. * @param newMultiMaterial The multi-material to add
  109592. */
  109593. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109594. /**
  109595. * Adds the given material to this scene
  109596. * @param newMaterial The material to add
  109597. */
  109598. addMaterial(newMaterial: Material): void;
  109599. /**
  109600. * Adds the given morph target to this scene
  109601. * @param newMorphTargetManager The morph target to add
  109602. */
  109603. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109604. /**
  109605. * Adds the given geometry to this scene
  109606. * @param newGeometry The geometry to add
  109607. */
  109608. addGeometry(newGeometry: Geometry): void;
  109609. /**
  109610. * Adds the given action manager to this scene
  109611. * @param newActionManager The action manager to add
  109612. */
  109613. addActionManager(newActionManager: AbstractActionManager): void;
  109614. /**
  109615. * Adds the given texture to this scene.
  109616. * @param newTexture The texture to add
  109617. */
  109618. addTexture(newTexture: BaseTexture): void;
  109619. /**
  109620. * Switch active camera
  109621. * @param newCamera defines the new active camera
  109622. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109623. */
  109624. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109625. /**
  109626. * sets the active camera of the scene using its ID
  109627. * @param id defines the camera's ID
  109628. * @return the new active camera or null if none found.
  109629. */
  109630. setActiveCameraByID(id: string): Nullable<Camera>;
  109631. /**
  109632. * sets the active camera of the scene using its name
  109633. * @param name defines the camera's name
  109634. * @returns the new active camera or null if none found.
  109635. */
  109636. setActiveCameraByName(name: string): Nullable<Camera>;
  109637. /**
  109638. * get an animation group using its name
  109639. * @param name defines the material's name
  109640. * @return the animation group or null if none found.
  109641. */
  109642. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109643. /**
  109644. * Get a material using its unique id
  109645. * @param uniqueId defines the material's unique id
  109646. * @return the material or null if none found.
  109647. */
  109648. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109649. /**
  109650. * get a material using its id
  109651. * @param id defines the material's ID
  109652. * @return the material or null if none found.
  109653. */
  109654. getMaterialByID(id: string): Nullable<Material>;
  109655. /**
  109656. * Gets a the last added material using a given id
  109657. * @param id defines the material's ID
  109658. * @return the last material with the given id or null if none found.
  109659. */
  109660. getLastMaterialByID(id: string): Nullable<Material>;
  109661. /**
  109662. * Gets a material using its name
  109663. * @param name defines the material's name
  109664. * @return the material or null if none found.
  109665. */
  109666. getMaterialByName(name: string): Nullable<Material>;
  109667. /**
  109668. * Get a texture using its unique id
  109669. * @param uniqueId defines the texture's unique id
  109670. * @return the texture or null if none found.
  109671. */
  109672. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109673. /**
  109674. * Gets a camera using its id
  109675. * @param id defines the id to look for
  109676. * @returns the camera or null if not found
  109677. */
  109678. getCameraByID(id: string): Nullable<Camera>;
  109679. /**
  109680. * Gets a camera using its unique id
  109681. * @param uniqueId defines the unique id to look for
  109682. * @returns the camera or null if not found
  109683. */
  109684. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109685. /**
  109686. * Gets a camera using its name
  109687. * @param name defines the camera's name
  109688. * @return the camera or null if none found.
  109689. */
  109690. getCameraByName(name: string): Nullable<Camera>;
  109691. /**
  109692. * Gets a bone using its id
  109693. * @param id defines the bone's id
  109694. * @return the bone or null if not found
  109695. */
  109696. getBoneByID(id: string): Nullable<Bone>;
  109697. /**
  109698. * Gets a bone using its id
  109699. * @param name defines the bone's name
  109700. * @return the bone or null if not found
  109701. */
  109702. getBoneByName(name: string): Nullable<Bone>;
  109703. /**
  109704. * Gets a light node using its name
  109705. * @param name defines the the light's name
  109706. * @return the light or null if none found.
  109707. */
  109708. getLightByName(name: string): Nullable<Light>;
  109709. /**
  109710. * Gets a light node using its id
  109711. * @param id defines the light's id
  109712. * @return the light or null if none found.
  109713. */
  109714. getLightByID(id: string): Nullable<Light>;
  109715. /**
  109716. * Gets a light node using its scene-generated unique ID
  109717. * @param uniqueId defines the light's unique id
  109718. * @return the light or null if none found.
  109719. */
  109720. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109721. /**
  109722. * Gets a particle system by id
  109723. * @param id defines the particle system id
  109724. * @return the corresponding system or null if none found
  109725. */
  109726. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109727. /**
  109728. * Gets a geometry using its ID
  109729. * @param id defines the geometry's id
  109730. * @return the geometry or null if none found.
  109731. */
  109732. getGeometryByID(id: string): Nullable<Geometry>;
  109733. private _getGeometryByUniqueID;
  109734. /**
  109735. * Add a new geometry to this scene
  109736. * @param geometry defines the geometry to be added to the scene.
  109737. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109738. * @return a boolean defining if the geometry was added or not
  109739. */
  109740. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109741. /**
  109742. * Removes an existing geometry
  109743. * @param geometry defines the geometry to be removed from the scene
  109744. * @return a boolean defining if the geometry was removed or not
  109745. */
  109746. removeGeometry(geometry: Geometry): boolean;
  109747. /**
  109748. * Gets the list of geometries attached to the scene
  109749. * @returns an array of Geometry
  109750. */
  109751. getGeometries(): Geometry[];
  109752. /**
  109753. * Gets the first added mesh found of a given ID
  109754. * @param id defines the id to search for
  109755. * @return the mesh found or null if not found at all
  109756. */
  109757. getMeshByID(id: string): Nullable<AbstractMesh>;
  109758. /**
  109759. * Gets a list of meshes using their id
  109760. * @param id defines the id to search for
  109761. * @returns a list of meshes
  109762. */
  109763. getMeshesByID(id: string): Array<AbstractMesh>;
  109764. /**
  109765. * Gets the first added transform node found of a given ID
  109766. * @param id defines the id to search for
  109767. * @return the found transform node or null if not found at all.
  109768. */
  109769. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109770. /**
  109771. * Gets a transform node with its auto-generated unique id
  109772. * @param uniqueId efines the unique id to search for
  109773. * @return the found transform node or null if not found at all.
  109774. */
  109775. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109776. /**
  109777. * Gets a list of transform nodes using their id
  109778. * @param id defines the id to search for
  109779. * @returns a list of transform nodes
  109780. */
  109781. getTransformNodesByID(id: string): Array<TransformNode>;
  109782. /**
  109783. * Gets a mesh with its auto-generated unique id
  109784. * @param uniqueId defines the unique id to search for
  109785. * @return the found mesh or null if not found at all.
  109786. */
  109787. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109788. /**
  109789. * Gets a the last added mesh using a given id
  109790. * @param id defines the id to search for
  109791. * @return the found mesh or null if not found at all.
  109792. */
  109793. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109794. /**
  109795. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109796. * @param id defines the id to search for
  109797. * @return the found node or null if not found at all
  109798. */
  109799. getLastEntryByID(id: string): Nullable<Node>;
  109800. /**
  109801. * Gets a node (Mesh, Camera, Light) using a given id
  109802. * @param id defines the id to search for
  109803. * @return the found node or null if not found at all
  109804. */
  109805. getNodeByID(id: string): Nullable<Node>;
  109806. /**
  109807. * Gets a node (Mesh, Camera, Light) using a given name
  109808. * @param name defines the name to search for
  109809. * @return the found node or null if not found at all.
  109810. */
  109811. getNodeByName(name: string): Nullable<Node>;
  109812. /**
  109813. * Gets a mesh using a given name
  109814. * @param name defines the name to search for
  109815. * @return the found mesh or null if not found at all.
  109816. */
  109817. getMeshByName(name: string): Nullable<AbstractMesh>;
  109818. /**
  109819. * Gets a transform node using a given name
  109820. * @param name defines the name to search for
  109821. * @return the found transform node or null if not found at all.
  109822. */
  109823. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109824. /**
  109825. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109826. * @param id defines the id to search for
  109827. * @return the found skeleton or null if not found at all.
  109828. */
  109829. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109830. /**
  109831. * Gets a skeleton using a given auto generated unique id
  109832. * @param uniqueId defines the unique id to search for
  109833. * @return the found skeleton or null if not found at all.
  109834. */
  109835. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109836. /**
  109837. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109838. * @param id defines the id to search for
  109839. * @return the found skeleton or null if not found at all.
  109840. */
  109841. getSkeletonById(id: string): Nullable<Skeleton>;
  109842. /**
  109843. * Gets a skeleton using a given name
  109844. * @param name defines the name to search for
  109845. * @return the found skeleton or null if not found at all.
  109846. */
  109847. getSkeletonByName(name: string): Nullable<Skeleton>;
  109848. /**
  109849. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109850. * @param id defines the id to search for
  109851. * @return the found morph target manager or null if not found at all.
  109852. */
  109853. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109854. /**
  109855. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109856. * @param id defines the id to search for
  109857. * @return the found morph target or null if not found at all.
  109858. */
  109859. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109860. /**
  109861. * Gets a boolean indicating if the given mesh is active
  109862. * @param mesh defines the mesh to look for
  109863. * @returns true if the mesh is in the active list
  109864. */
  109865. isActiveMesh(mesh: AbstractMesh): boolean;
  109866. /**
  109867. * Return a unique id as a string which can serve as an identifier for the scene
  109868. */
  109869. get uid(): string;
  109870. /**
  109871. * Add an externaly attached data from its key.
  109872. * This method call will fail and return false, if such key already exists.
  109873. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109874. * @param key the unique key that identifies the data
  109875. * @param data the data object to associate to the key for this Engine instance
  109876. * @return true if no such key were already present and the data was added successfully, false otherwise
  109877. */
  109878. addExternalData<T>(key: string, data: T): boolean;
  109879. /**
  109880. * Get an externaly attached data from its key
  109881. * @param key the unique key that identifies the data
  109882. * @return the associated data, if present (can be null), or undefined if not present
  109883. */
  109884. getExternalData<T>(key: string): Nullable<T>;
  109885. /**
  109886. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109887. * @param key the unique key that identifies the data
  109888. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109889. * @return the associated data, can be null if the factory returned null.
  109890. */
  109891. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109892. /**
  109893. * Remove an externaly attached data from the Engine instance
  109894. * @param key the unique key that identifies the data
  109895. * @return true if the data was successfully removed, false if it doesn't exist
  109896. */
  109897. removeExternalData(key: string): boolean;
  109898. private _evaluateSubMesh;
  109899. /**
  109900. * Clear the processed materials smart array preventing retention point in material dispose.
  109901. */
  109902. freeProcessedMaterials(): void;
  109903. private _preventFreeActiveMeshesAndRenderingGroups;
  109904. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109905. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109906. * when disposing several meshes in a row or a hierarchy of meshes.
  109907. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109908. */
  109909. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109910. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109911. /**
  109912. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109913. */
  109914. freeActiveMeshes(): void;
  109915. /**
  109916. * Clear the info related to rendering groups preventing retention points during dispose.
  109917. */
  109918. freeRenderingGroups(): void;
  109919. /** @hidden */
  109920. _isInIntermediateRendering(): boolean;
  109921. /**
  109922. * Lambda returning the list of potentially active meshes.
  109923. */
  109924. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109925. /**
  109926. * Lambda returning the list of potentially active sub meshes.
  109927. */
  109928. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109929. /**
  109930. * Lambda returning the list of potentially intersecting sub meshes.
  109931. */
  109932. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109933. /**
  109934. * Lambda returning the list of potentially colliding sub meshes.
  109935. */
  109936. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109937. private _activeMeshesFrozen;
  109938. private _skipEvaluateActiveMeshesCompletely;
  109939. /**
  109940. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109941. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109942. * @returns the current scene
  109943. */
  109944. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109945. /**
  109946. * Use this function to restart evaluating active meshes on every frame
  109947. * @returns the current scene
  109948. */
  109949. unfreezeActiveMeshes(): Scene;
  109950. private _evaluateActiveMeshes;
  109951. private _activeMesh;
  109952. /**
  109953. * Update the transform matrix to update from the current active camera
  109954. * @param force defines a boolean used to force the update even if cache is up to date
  109955. */
  109956. updateTransformMatrix(force?: boolean): void;
  109957. private _bindFrameBuffer;
  109958. /** @hidden */
  109959. _allowPostProcessClearColor: boolean;
  109960. /** @hidden */
  109961. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109962. private _processSubCameras;
  109963. private _checkIntersections;
  109964. /** @hidden */
  109965. _advancePhysicsEngineStep(step: number): void;
  109966. /**
  109967. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109968. */
  109969. getDeterministicFrameTime: () => number;
  109970. /** @hidden */
  109971. _animate(): void;
  109972. /** Execute all animations (for a frame) */
  109973. animate(): void;
  109974. /**
  109975. * Render the scene
  109976. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109977. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109978. */
  109979. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109980. /**
  109981. * Freeze all materials
  109982. * A frozen material will not be updatable but should be faster to render
  109983. */
  109984. freezeMaterials(): void;
  109985. /**
  109986. * Unfreeze all materials
  109987. * A frozen material will not be updatable but should be faster to render
  109988. */
  109989. unfreezeMaterials(): void;
  109990. /**
  109991. * Releases all held ressources
  109992. */
  109993. dispose(): void;
  109994. /**
  109995. * Gets if the scene is already disposed
  109996. */
  109997. get isDisposed(): boolean;
  109998. /**
  109999. * Call this function to reduce memory footprint of the scene.
  110000. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110001. */
  110002. clearCachedVertexData(): void;
  110003. /**
  110004. * This function will remove the local cached buffer data from texture.
  110005. * It will save memory but will prevent the texture from being rebuilt
  110006. */
  110007. cleanCachedTextureBuffer(): void;
  110008. /**
  110009. * Get the world extend vectors with an optional filter
  110010. *
  110011. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110012. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110013. */
  110014. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110015. min: Vector3;
  110016. max: Vector3;
  110017. };
  110018. /**
  110019. * Creates a ray that can be used to pick in the scene
  110020. * @param x defines the x coordinate of the origin (on-screen)
  110021. * @param y defines the y coordinate of the origin (on-screen)
  110022. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110023. * @param camera defines the camera to use for the picking
  110024. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110025. * @returns a Ray
  110026. */
  110027. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110028. /**
  110029. * Creates a ray that can be used to pick in the scene
  110030. * @param x defines the x coordinate of the origin (on-screen)
  110031. * @param y defines the y coordinate of the origin (on-screen)
  110032. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110033. * @param result defines the ray where to store the picking ray
  110034. * @param camera defines the camera to use for the picking
  110035. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110036. * @returns the current scene
  110037. */
  110038. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110039. /**
  110040. * Creates a ray that can be used to pick in the scene
  110041. * @param x defines the x coordinate of the origin (on-screen)
  110042. * @param y defines the y coordinate of the origin (on-screen)
  110043. * @param camera defines the camera to use for the picking
  110044. * @returns a Ray
  110045. */
  110046. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110047. /**
  110048. * Creates a ray that can be used to pick in the scene
  110049. * @param x defines the x coordinate of the origin (on-screen)
  110050. * @param y defines the y coordinate of the origin (on-screen)
  110051. * @param result defines the ray where to store the picking ray
  110052. * @param camera defines the camera to use for the picking
  110053. * @returns the current scene
  110054. */
  110055. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110056. /** Launch a ray to try to pick a mesh in the scene
  110057. * @param x position on screen
  110058. * @param y position on screen
  110059. * @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
  110060. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110061. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110062. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110063. * @returns a PickingInfo
  110064. */
  110065. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110066. /** Use the given ray to pick a mesh in the scene
  110067. * @param ray The ray to use to pick meshes
  110068. * @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
  110069. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110070. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110071. * @returns a PickingInfo
  110072. */
  110073. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110074. /**
  110075. * Launch a ray to try to pick a mesh in the scene
  110076. * @param x X position on screen
  110077. * @param y Y position on screen
  110078. * @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
  110079. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110081. * @returns an array of PickingInfo
  110082. */
  110083. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110084. /**
  110085. * Launch a ray to try to pick a mesh in the scene
  110086. * @param ray Ray to use
  110087. * @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
  110088. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110089. * @returns an array of PickingInfo
  110090. */
  110091. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110092. /**
  110093. * Force the value of meshUnderPointer
  110094. * @param mesh defines the mesh to use
  110095. */
  110096. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110097. /**
  110098. * Gets the mesh under the pointer
  110099. * @returns a Mesh or null if no mesh is under the pointer
  110100. */
  110101. getPointerOverMesh(): Nullable<AbstractMesh>;
  110102. /** @hidden */
  110103. _rebuildGeometries(): void;
  110104. /** @hidden */
  110105. _rebuildTextures(): void;
  110106. private _getByTags;
  110107. /**
  110108. * Get a list of meshes by tags
  110109. * @param tagsQuery defines the tags query to use
  110110. * @param forEach defines a predicate used to filter results
  110111. * @returns an array of Mesh
  110112. */
  110113. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110114. /**
  110115. * Get a list of cameras by tags
  110116. * @param tagsQuery defines the tags query to use
  110117. * @param forEach defines a predicate used to filter results
  110118. * @returns an array of Camera
  110119. */
  110120. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110121. /**
  110122. * Get a list of lights by tags
  110123. * @param tagsQuery defines the tags query to use
  110124. * @param forEach defines a predicate used to filter results
  110125. * @returns an array of Light
  110126. */
  110127. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110128. /**
  110129. * Get a list of materials by tags
  110130. * @param tagsQuery defines the tags query to use
  110131. * @param forEach defines a predicate used to filter results
  110132. * @returns an array of Material
  110133. */
  110134. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110135. /**
  110136. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110137. * This allowed control for front to back rendering or reversly depending of the special needs.
  110138. *
  110139. * @param renderingGroupId The rendering group id corresponding to its index
  110140. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110141. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110142. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110143. */
  110144. 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;
  110145. /**
  110146. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110147. *
  110148. * @param renderingGroupId The rendering group id corresponding to its index
  110149. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110150. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110151. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110152. */
  110153. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110154. /**
  110155. * Gets the current auto clear configuration for one rendering group of the rendering
  110156. * manager.
  110157. * @param index the rendering group index to get the information for
  110158. * @returns The auto clear setup for the requested rendering group
  110159. */
  110160. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110161. private _blockMaterialDirtyMechanism;
  110162. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110163. get blockMaterialDirtyMechanism(): boolean;
  110164. set blockMaterialDirtyMechanism(value: boolean);
  110165. /**
  110166. * Will flag all materials as dirty to trigger new shader compilation
  110167. * @param flag defines the flag used to specify which material part must be marked as dirty
  110168. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110169. */
  110170. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110171. /** @hidden */
  110172. _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;
  110173. /** @hidden */
  110174. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110175. /** @hidden */
  110176. _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;
  110177. /** @hidden */
  110178. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110179. /** @hidden */
  110180. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110181. /** @hidden */
  110182. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110183. }
  110184. }
  110185. declare module BABYLON {
  110186. /**
  110187. * Set of assets to keep when moving a scene into an asset container.
  110188. */
  110189. export class KeepAssets extends AbstractScene {
  110190. }
  110191. /**
  110192. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110193. */
  110194. export class InstantiatedEntries {
  110195. /**
  110196. * List of new root nodes (eg. nodes with no parent)
  110197. */
  110198. rootNodes: TransformNode[];
  110199. /**
  110200. * List of new skeletons
  110201. */
  110202. skeletons: Skeleton[];
  110203. /**
  110204. * List of new animation groups
  110205. */
  110206. animationGroups: AnimationGroup[];
  110207. }
  110208. /**
  110209. * Container with a set of assets that can be added or removed from a scene.
  110210. */
  110211. export class AssetContainer extends AbstractScene {
  110212. private _wasAddedToScene;
  110213. /**
  110214. * The scene the AssetContainer belongs to.
  110215. */
  110216. scene: Scene;
  110217. /**
  110218. * Instantiates an AssetContainer.
  110219. * @param scene The scene the AssetContainer belongs to.
  110220. */
  110221. constructor(scene: Scene);
  110222. /**
  110223. * Instantiate or clone all meshes and add the new ones to the scene.
  110224. * Skeletons and animation groups will all be cloned
  110225. * @param nameFunction defines an optional function used to get new names for clones
  110226. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110227. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110228. */
  110229. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110230. /**
  110231. * Adds all the assets from the container to the scene.
  110232. */
  110233. addAllToScene(): void;
  110234. /**
  110235. * Removes all the assets in the container from the scene
  110236. */
  110237. removeAllFromScene(): void;
  110238. /**
  110239. * Disposes all the assets in the container
  110240. */
  110241. dispose(): void;
  110242. private _moveAssets;
  110243. /**
  110244. * Removes all the assets contained in the scene and adds them to the container.
  110245. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110246. */
  110247. moveAllFromScene(keepAssets?: KeepAssets): void;
  110248. /**
  110249. * 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.
  110250. * @returns the root mesh
  110251. */
  110252. createRootMesh(): Mesh;
  110253. /**
  110254. * Merge animations from this asset container into a scene
  110255. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110256. * @param animatables set of animatables to retarget to a node from the scene
  110257. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110258. */
  110259. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110260. }
  110261. }
  110262. declare module BABYLON {
  110263. /**
  110264. * Defines how the parser contract is defined.
  110265. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110266. */
  110267. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110268. /**
  110269. * Defines how the individual parser contract is defined.
  110270. * These parser can parse an individual asset
  110271. */
  110272. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110273. /**
  110274. * Base class of the scene acting as a container for the different elements composing a scene.
  110275. * This class is dynamically extended by the different components of the scene increasing
  110276. * flexibility and reducing coupling
  110277. */
  110278. export abstract class AbstractScene {
  110279. /**
  110280. * Stores the list of available parsers in the application.
  110281. */
  110282. private static _BabylonFileParsers;
  110283. /**
  110284. * Stores the list of available individual parsers in the application.
  110285. */
  110286. private static _IndividualBabylonFileParsers;
  110287. /**
  110288. * Adds a parser in the list of available ones
  110289. * @param name Defines the name of the parser
  110290. * @param parser Defines the parser to add
  110291. */
  110292. static AddParser(name: string, parser: BabylonFileParser): void;
  110293. /**
  110294. * Gets a general parser from the list of avaialble ones
  110295. * @param name Defines the name of the parser
  110296. * @returns the requested parser or null
  110297. */
  110298. static GetParser(name: string): Nullable<BabylonFileParser>;
  110299. /**
  110300. * Adds n individual parser in the list of available ones
  110301. * @param name Defines the name of the parser
  110302. * @param parser Defines the parser to add
  110303. */
  110304. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110305. /**
  110306. * Gets an individual parser from the list of avaialble ones
  110307. * @param name Defines the name of the parser
  110308. * @returns the requested parser or null
  110309. */
  110310. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110311. /**
  110312. * Parser json data and populate both a scene and its associated container object
  110313. * @param jsonData Defines the data to parse
  110314. * @param scene Defines the scene to parse the data for
  110315. * @param container Defines the container attached to the parsing sequence
  110316. * @param rootUrl Defines the root url of the data
  110317. */
  110318. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110319. /**
  110320. * Gets the list of root nodes (ie. nodes with no parent)
  110321. */
  110322. rootNodes: Node[];
  110323. /** All of the cameras added to this scene
  110324. * @see http://doc.babylonjs.com/babylon101/cameras
  110325. */
  110326. cameras: Camera[];
  110327. /**
  110328. * All of the lights added to this scene
  110329. * @see http://doc.babylonjs.com/babylon101/lights
  110330. */
  110331. lights: Light[];
  110332. /**
  110333. * All of the (abstract) meshes added to this scene
  110334. */
  110335. meshes: AbstractMesh[];
  110336. /**
  110337. * The list of skeletons added to the scene
  110338. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110339. */
  110340. skeletons: Skeleton[];
  110341. /**
  110342. * All of the particle systems added to this scene
  110343. * @see http://doc.babylonjs.com/babylon101/particles
  110344. */
  110345. particleSystems: IParticleSystem[];
  110346. /**
  110347. * Gets a list of Animations associated with the scene
  110348. */
  110349. animations: Animation[];
  110350. /**
  110351. * All of the animation groups added to this scene
  110352. * @see http://doc.babylonjs.com/how_to/group
  110353. */
  110354. animationGroups: AnimationGroup[];
  110355. /**
  110356. * All of the multi-materials added to this scene
  110357. * @see http://doc.babylonjs.com/how_to/multi_materials
  110358. */
  110359. multiMaterials: MultiMaterial[];
  110360. /**
  110361. * All of the materials added to this scene
  110362. * In the context of a Scene, it is not supposed to be modified manually.
  110363. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110364. * Note also that the order of the Material within the array is not significant and might change.
  110365. * @see http://doc.babylonjs.com/babylon101/materials
  110366. */
  110367. materials: Material[];
  110368. /**
  110369. * The list of morph target managers added to the scene
  110370. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110371. */
  110372. morphTargetManagers: MorphTargetManager[];
  110373. /**
  110374. * The list of geometries used in the scene.
  110375. */
  110376. geometries: Geometry[];
  110377. /**
  110378. * All of the tranform nodes added to this scene
  110379. * In the context of a Scene, it is not supposed to be modified manually.
  110380. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110381. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110382. * @see http://doc.babylonjs.com/how_to/transformnode
  110383. */
  110384. transformNodes: TransformNode[];
  110385. /**
  110386. * ActionManagers available on the scene.
  110387. */
  110388. actionManagers: AbstractActionManager[];
  110389. /**
  110390. * Textures to keep.
  110391. */
  110392. textures: BaseTexture[];
  110393. /**
  110394. * Environment texture for the scene
  110395. */
  110396. environmentTexture: Nullable<BaseTexture>;
  110397. /**
  110398. * @returns all meshes, lights, cameras, transformNodes and bones
  110399. */
  110400. getNodes(): Array<Node>;
  110401. }
  110402. }
  110403. declare module BABYLON {
  110404. /**
  110405. * Interface used to define options for Sound class
  110406. */
  110407. export interface ISoundOptions {
  110408. /**
  110409. * Does the sound autoplay once loaded.
  110410. */
  110411. autoplay?: boolean;
  110412. /**
  110413. * Does the sound loop after it finishes playing once.
  110414. */
  110415. loop?: boolean;
  110416. /**
  110417. * Sound's volume
  110418. */
  110419. volume?: number;
  110420. /**
  110421. * Is it a spatial sound?
  110422. */
  110423. spatialSound?: boolean;
  110424. /**
  110425. * Maximum distance to hear that sound
  110426. */
  110427. maxDistance?: number;
  110428. /**
  110429. * Uses user defined attenuation function
  110430. */
  110431. useCustomAttenuation?: boolean;
  110432. /**
  110433. * Define the roll off factor of spatial sounds.
  110434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110435. */
  110436. rolloffFactor?: number;
  110437. /**
  110438. * Define the reference distance the sound should be heard perfectly.
  110439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110440. */
  110441. refDistance?: number;
  110442. /**
  110443. * Define the distance attenuation model the sound will follow.
  110444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110445. */
  110446. distanceModel?: string;
  110447. /**
  110448. * Defines the playback speed (1 by default)
  110449. */
  110450. playbackRate?: number;
  110451. /**
  110452. * Defines if the sound is from a streaming source
  110453. */
  110454. streaming?: boolean;
  110455. /**
  110456. * Defines an optional length (in seconds) inside the sound file
  110457. */
  110458. length?: number;
  110459. /**
  110460. * Defines an optional offset (in seconds) inside the sound file
  110461. */
  110462. offset?: number;
  110463. /**
  110464. * If true, URLs will not be required to state the audio file codec to use.
  110465. */
  110466. skipCodecCheck?: boolean;
  110467. }
  110468. /**
  110469. * Defines a sound that can be played in the application.
  110470. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110472. */
  110473. export class Sound {
  110474. /**
  110475. * The name of the sound in the scene.
  110476. */
  110477. name: string;
  110478. /**
  110479. * Does the sound autoplay once loaded.
  110480. */
  110481. autoplay: boolean;
  110482. /**
  110483. * Does the sound loop after it finishes playing once.
  110484. */
  110485. loop: boolean;
  110486. /**
  110487. * Does the sound use a custom attenuation curve to simulate the falloff
  110488. * happening when the source gets further away from the camera.
  110489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110490. */
  110491. useCustomAttenuation: boolean;
  110492. /**
  110493. * The sound track id this sound belongs to.
  110494. */
  110495. soundTrackId: number;
  110496. /**
  110497. * Is this sound currently played.
  110498. */
  110499. isPlaying: boolean;
  110500. /**
  110501. * Is this sound currently paused.
  110502. */
  110503. isPaused: boolean;
  110504. /**
  110505. * Does this sound enables spatial sound.
  110506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110507. */
  110508. spatialSound: boolean;
  110509. /**
  110510. * Define the reference distance the sound should be heard perfectly.
  110511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110512. */
  110513. refDistance: number;
  110514. /**
  110515. * Define the roll off factor of spatial sounds.
  110516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110517. */
  110518. rolloffFactor: number;
  110519. /**
  110520. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110522. */
  110523. maxDistance: number;
  110524. /**
  110525. * Define the distance attenuation model the sound will follow.
  110526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110527. */
  110528. distanceModel: string;
  110529. /**
  110530. * @hidden
  110531. * Back Compat
  110532. **/
  110533. onended: () => any;
  110534. /**
  110535. * Observable event when the current playing sound finishes.
  110536. */
  110537. onEndedObservable: Observable<Sound>;
  110538. private _panningModel;
  110539. private _playbackRate;
  110540. private _streaming;
  110541. private _startTime;
  110542. private _startOffset;
  110543. private _position;
  110544. /** @hidden */
  110545. _positionInEmitterSpace: boolean;
  110546. private _localDirection;
  110547. private _volume;
  110548. private _isReadyToPlay;
  110549. private _isDirectional;
  110550. private _readyToPlayCallback;
  110551. private _audioBuffer;
  110552. private _soundSource;
  110553. private _streamingSource;
  110554. private _soundPanner;
  110555. private _soundGain;
  110556. private _inputAudioNode;
  110557. private _outputAudioNode;
  110558. private _coneInnerAngle;
  110559. private _coneOuterAngle;
  110560. private _coneOuterGain;
  110561. private _scene;
  110562. private _connectedTransformNode;
  110563. private _customAttenuationFunction;
  110564. private _registerFunc;
  110565. private _isOutputConnected;
  110566. private _htmlAudioElement;
  110567. private _urlType;
  110568. private _length?;
  110569. private _offset?;
  110570. /** @hidden */
  110571. static _SceneComponentInitialization: (scene: Scene) => void;
  110572. /**
  110573. * Create a sound and attach it to a scene
  110574. * @param name Name of your sound
  110575. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110576. * @param scene defines the scene the sound belongs to
  110577. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110578. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110579. */
  110580. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110581. /**
  110582. * Release the sound and its associated resources
  110583. */
  110584. dispose(): void;
  110585. /**
  110586. * Gets if the sounds is ready to be played or not.
  110587. * @returns true if ready, otherwise false
  110588. */
  110589. isReady(): boolean;
  110590. private _soundLoaded;
  110591. /**
  110592. * Sets the data of the sound from an audiobuffer
  110593. * @param audioBuffer The audioBuffer containing the data
  110594. */
  110595. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110596. /**
  110597. * Updates the current sounds options such as maxdistance, loop...
  110598. * @param options A JSON object containing values named as the object properties
  110599. */
  110600. updateOptions(options: ISoundOptions): void;
  110601. private _createSpatialParameters;
  110602. private _updateSpatialParameters;
  110603. /**
  110604. * Switch the panning model to HRTF:
  110605. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110607. */
  110608. switchPanningModelToHRTF(): void;
  110609. /**
  110610. * Switch the panning model to Equal Power:
  110611. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110613. */
  110614. switchPanningModelToEqualPower(): void;
  110615. private _switchPanningModel;
  110616. /**
  110617. * Connect this sound to a sound track audio node like gain...
  110618. * @param soundTrackAudioNode the sound track audio node to connect to
  110619. */
  110620. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110621. /**
  110622. * Transform this sound into a directional source
  110623. * @param coneInnerAngle Size of the inner cone in degree
  110624. * @param coneOuterAngle Size of the outer cone in degree
  110625. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110626. */
  110627. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110628. /**
  110629. * Gets or sets the inner angle for the directional cone.
  110630. */
  110631. get directionalConeInnerAngle(): number;
  110632. /**
  110633. * Gets or sets the inner angle for the directional cone.
  110634. */
  110635. set directionalConeInnerAngle(value: number);
  110636. /**
  110637. * Gets or sets the outer angle for the directional cone.
  110638. */
  110639. get directionalConeOuterAngle(): number;
  110640. /**
  110641. * Gets or sets the outer angle for the directional cone.
  110642. */
  110643. set directionalConeOuterAngle(value: number);
  110644. /**
  110645. * Sets the position of the emitter if spatial sound is enabled
  110646. * @param newPosition Defines the new posisiton
  110647. */
  110648. setPosition(newPosition: Vector3): void;
  110649. /**
  110650. * Sets the local direction of the emitter if spatial sound is enabled
  110651. * @param newLocalDirection Defines the new local direction
  110652. */
  110653. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110654. private _updateDirection;
  110655. /** @hidden */
  110656. updateDistanceFromListener(): void;
  110657. /**
  110658. * Sets a new custom attenuation function for the sound.
  110659. * @param callback Defines the function used for the attenuation
  110660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110661. */
  110662. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110663. /**
  110664. * Play the sound
  110665. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110666. * @param offset (optional) Start the sound at a specific time in seconds
  110667. * @param length (optional) Sound duration (in seconds)
  110668. */
  110669. play(time?: number, offset?: number, length?: number): void;
  110670. private _onended;
  110671. /**
  110672. * Stop the sound
  110673. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110674. */
  110675. stop(time?: number): void;
  110676. /**
  110677. * Put the sound in pause
  110678. */
  110679. pause(): void;
  110680. /**
  110681. * Sets a dedicated volume for this sounds
  110682. * @param newVolume Define the new volume of the sound
  110683. * @param time Define time for gradual change to new volume
  110684. */
  110685. setVolume(newVolume: number, time?: number): void;
  110686. /**
  110687. * Set the sound play back rate
  110688. * @param newPlaybackRate Define the playback rate the sound should be played at
  110689. */
  110690. setPlaybackRate(newPlaybackRate: number): void;
  110691. /**
  110692. * Gets the volume of the sound.
  110693. * @returns the volume of the sound
  110694. */
  110695. getVolume(): number;
  110696. /**
  110697. * Attach the sound to a dedicated mesh
  110698. * @param transformNode The transform node to connect the sound with
  110699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110700. */
  110701. attachToMesh(transformNode: TransformNode): void;
  110702. /**
  110703. * Detach the sound from the previously attached mesh
  110704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110705. */
  110706. detachFromMesh(): void;
  110707. private _onRegisterAfterWorldMatrixUpdate;
  110708. /**
  110709. * Clone the current sound in the scene.
  110710. * @returns the new sound clone
  110711. */
  110712. clone(): Nullable<Sound>;
  110713. /**
  110714. * Gets the current underlying audio buffer containing the data
  110715. * @returns the audio buffer
  110716. */
  110717. getAudioBuffer(): Nullable<AudioBuffer>;
  110718. /**
  110719. * Serializes the Sound in a JSON representation
  110720. * @returns the JSON representation of the sound
  110721. */
  110722. serialize(): any;
  110723. /**
  110724. * Parse a JSON representation of a sound to innstantiate in a given scene
  110725. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110726. * @param scene Define the scene the new parsed sound should be created in
  110727. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110728. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110729. * @returns the newly parsed sound
  110730. */
  110731. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110732. }
  110733. }
  110734. declare module BABYLON {
  110735. /**
  110736. * This defines an action helpful to play a defined sound on a triggered action.
  110737. */
  110738. export class PlaySoundAction extends Action {
  110739. private _sound;
  110740. /**
  110741. * Instantiate the action
  110742. * @param triggerOptions defines the trigger options
  110743. * @param sound defines the sound to play
  110744. * @param condition defines the trigger related conditions
  110745. */
  110746. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110747. /** @hidden */
  110748. _prepare(): void;
  110749. /**
  110750. * Execute the action and play the sound.
  110751. */
  110752. execute(): void;
  110753. /**
  110754. * Serializes the actions and its related information.
  110755. * @param parent defines the object to serialize in
  110756. * @returns the serialized object
  110757. */
  110758. serialize(parent: any): any;
  110759. }
  110760. /**
  110761. * This defines an action helpful to stop a defined sound on a triggered action.
  110762. */
  110763. export class StopSoundAction extends Action {
  110764. private _sound;
  110765. /**
  110766. * Instantiate the action
  110767. * @param triggerOptions defines the trigger options
  110768. * @param sound defines the sound to stop
  110769. * @param condition defines the trigger related conditions
  110770. */
  110771. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110772. /** @hidden */
  110773. _prepare(): void;
  110774. /**
  110775. * Execute the action and stop the sound.
  110776. */
  110777. execute(): void;
  110778. /**
  110779. * Serializes the actions and its related information.
  110780. * @param parent defines the object to serialize in
  110781. * @returns the serialized object
  110782. */
  110783. serialize(parent: any): any;
  110784. }
  110785. }
  110786. declare module BABYLON {
  110787. /**
  110788. * This defines an action responsible to change the value of a property
  110789. * by interpolating between its current value and the newly set one once triggered.
  110790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110791. */
  110792. export class InterpolateValueAction extends Action {
  110793. /**
  110794. * Defines the path of the property where the value should be interpolated
  110795. */
  110796. propertyPath: string;
  110797. /**
  110798. * Defines the target value at the end of the interpolation.
  110799. */
  110800. value: any;
  110801. /**
  110802. * Defines the time it will take for the property to interpolate to the value.
  110803. */
  110804. duration: number;
  110805. /**
  110806. * Defines if the other scene animations should be stopped when the action has been triggered
  110807. */
  110808. stopOtherAnimations?: boolean;
  110809. /**
  110810. * Defines a callback raised once the interpolation animation has been done.
  110811. */
  110812. onInterpolationDone?: () => void;
  110813. /**
  110814. * Observable triggered once the interpolation animation has been done.
  110815. */
  110816. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110817. private _target;
  110818. private _effectiveTarget;
  110819. private _property;
  110820. /**
  110821. * Instantiate the action
  110822. * @param triggerOptions defines the trigger options
  110823. * @param target defines the object containing the value to interpolate
  110824. * @param propertyPath defines the path to the property in the target object
  110825. * @param value defines the target value at the end of the interpolation
  110826. * @param duration deines the time it will take for the property to interpolate to the value.
  110827. * @param condition defines the trigger related conditions
  110828. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110829. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110830. */
  110831. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110832. /** @hidden */
  110833. _prepare(): void;
  110834. /**
  110835. * Execute the action starts the value interpolation.
  110836. */
  110837. execute(): void;
  110838. /**
  110839. * Serializes the actions and its related information.
  110840. * @param parent defines the object to serialize in
  110841. * @returns the serialized object
  110842. */
  110843. serialize(parent: any): any;
  110844. }
  110845. }
  110846. declare module BABYLON {
  110847. /**
  110848. * Options allowed during the creation of a sound track.
  110849. */
  110850. export interface ISoundTrackOptions {
  110851. /**
  110852. * The volume the sound track should take during creation
  110853. */
  110854. volume?: number;
  110855. /**
  110856. * Define if the sound track is the main sound track of the scene
  110857. */
  110858. mainTrack?: boolean;
  110859. }
  110860. /**
  110861. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110862. * It will be also used in a future release to apply effects on a specific track.
  110863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110864. */
  110865. export class SoundTrack {
  110866. /**
  110867. * The unique identifier of the sound track in the scene.
  110868. */
  110869. id: number;
  110870. /**
  110871. * The list of sounds included in the sound track.
  110872. */
  110873. soundCollection: Array<Sound>;
  110874. private _outputAudioNode;
  110875. private _scene;
  110876. private _connectedAnalyser;
  110877. private _options;
  110878. private _isInitialized;
  110879. /**
  110880. * Creates a new sound track.
  110881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110882. * @param scene Define the scene the sound track belongs to
  110883. * @param options
  110884. */
  110885. constructor(scene: Scene, options?: ISoundTrackOptions);
  110886. private _initializeSoundTrackAudioGraph;
  110887. /**
  110888. * Release the sound track and its associated resources
  110889. */
  110890. dispose(): void;
  110891. /**
  110892. * Adds a sound to this sound track
  110893. * @param sound define the cound to add
  110894. * @ignoreNaming
  110895. */
  110896. AddSound(sound: Sound): void;
  110897. /**
  110898. * Removes a sound to this sound track
  110899. * @param sound define the cound to remove
  110900. * @ignoreNaming
  110901. */
  110902. RemoveSound(sound: Sound): void;
  110903. /**
  110904. * Set a global volume for the full sound track.
  110905. * @param newVolume Define the new volume of the sound track
  110906. */
  110907. setVolume(newVolume: number): void;
  110908. /**
  110909. * Switch the panning model to HRTF:
  110910. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110912. */
  110913. switchPanningModelToHRTF(): void;
  110914. /**
  110915. * Switch the panning model to Equal Power:
  110916. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110918. */
  110919. switchPanningModelToEqualPower(): void;
  110920. /**
  110921. * Connect the sound track to an audio analyser allowing some amazing
  110922. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110924. * @param analyser The analyser to connect to the engine
  110925. */
  110926. connectToAnalyser(analyser: Analyser): void;
  110927. }
  110928. }
  110929. declare module BABYLON {
  110930. interface AbstractScene {
  110931. /**
  110932. * The list of sounds used in the scene.
  110933. */
  110934. sounds: Nullable<Array<Sound>>;
  110935. }
  110936. interface Scene {
  110937. /**
  110938. * @hidden
  110939. * Backing field
  110940. */
  110941. _mainSoundTrack: SoundTrack;
  110942. /**
  110943. * The main sound track played by the scene.
  110944. * It cotains your primary collection of sounds.
  110945. */
  110946. mainSoundTrack: SoundTrack;
  110947. /**
  110948. * The list of sound tracks added to the scene
  110949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110950. */
  110951. soundTracks: Nullable<Array<SoundTrack>>;
  110952. /**
  110953. * Gets a sound using a given name
  110954. * @param name defines the name to search for
  110955. * @return the found sound or null if not found at all.
  110956. */
  110957. getSoundByName(name: string): Nullable<Sound>;
  110958. /**
  110959. * Gets or sets if audio support is enabled
  110960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110961. */
  110962. audioEnabled: boolean;
  110963. /**
  110964. * Gets or sets if audio will be output to headphones
  110965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110966. */
  110967. headphone: boolean;
  110968. /**
  110969. * Gets or sets custom audio listener position provider
  110970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110971. */
  110972. audioListenerPositionProvider: Nullable<() => Vector3>;
  110973. /**
  110974. * Gets or sets a refresh rate when using 3D audio positioning
  110975. */
  110976. audioPositioningRefreshRate: number;
  110977. }
  110978. /**
  110979. * Defines the sound scene component responsible to manage any sounds
  110980. * in a given scene.
  110981. */
  110982. export class AudioSceneComponent implements ISceneSerializableComponent {
  110983. /**
  110984. * The component name helpfull to identify the component in the list of scene components.
  110985. */
  110986. readonly name: string;
  110987. /**
  110988. * The scene the component belongs to.
  110989. */
  110990. scene: Scene;
  110991. private _audioEnabled;
  110992. /**
  110993. * Gets whether audio is enabled or not.
  110994. * Please use related enable/disable method to switch state.
  110995. */
  110996. get audioEnabled(): boolean;
  110997. private _headphone;
  110998. /**
  110999. * Gets whether audio is outputing to headphone or not.
  111000. * Please use the according Switch methods to change output.
  111001. */
  111002. get headphone(): boolean;
  111003. /**
  111004. * Gets or sets a refresh rate when using 3D audio positioning
  111005. */
  111006. audioPositioningRefreshRate: number;
  111007. private _audioListenerPositionProvider;
  111008. /**
  111009. * Gets the current audio listener position provider
  111010. */
  111011. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111012. /**
  111013. * Sets a custom listener position for all sounds in the scene
  111014. * By default, this is the position of the first active camera
  111015. */
  111016. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111017. /**
  111018. * Creates a new instance of the component for the given scene
  111019. * @param scene Defines the scene to register the component in
  111020. */
  111021. constructor(scene: Scene);
  111022. /**
  111023. * Registers the component in a given scene
  111024. */
  111025. register(): void;
  111026. /**
  111027. * Rebuilds the elements related to this component in case of
  111028. * context lost for instance.
  111029. */
  111030. rebuild(): void;
  111031. /**
  111032. * Serializes the component data to the specified json object
  111033. * @param serializationObject The object to serialize to
  111034. */
  111035. serialize(serializationObject: any): void;
  111036. /**
  111037. * Adds all the elements from the container to the scene
  111038. * @param container the container holding the elements
  111039. */
  111040. addFromContainer(container: AbstractScene): void;
  111041. /**
  111042. * Removes all the elements in the container from the scene
  111043. * @param container contains the elements to remove
  111044. * @param dispose if the removed element should be disposed (default: false)
  111045. */
  111046. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111047. /**
  111048. * Disposes the component and the associated ressources.
  111049. */
  111050. dispose(): void;
  111051. /**
  111052. * Disables audio in the associated scene.
  111053. */
  111054. disableAudio(): void;
  111055. /**
  111056. * Enables audio in the associated scene.
  111057. */
  111058. enableAudio(): void;
  111059. /**
  111060. * Switch audio to headphone output.
  111061. */
  111062. switchAudioModeForHeadphones(): void;
  111063. /**
  111064. * Switch audio to normal speakers.
  111065. */
  111066. switchAudioModeForNormalSpeakers(): void;
  111067. private _cachedCameraDirection;
  111068. private _cachedCameraPosition;
  111069. private _lastCheck;
  111070. private _afterRender;
  111071. }
  111072. }
  111073. declare module BABYLON {
  111074. /**
  111075. * Wraps one or more Sound objects and selects one with random weight for playback.
  111076. */
  111077. export class WeightedSound {
  111078. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111079. loop: boolean;
  111080. private _coneInnerAngle;
  111081. private _coneOuterAngle;
  111082. private _volume;
  111083. /** A Sound is currently playing. */
  111084. isPlaying: boolean;
  111085. /** A Sound is currently paused. */
  111086. isPaused: boolean;
  111087. private _sounds;
  111088. private _weights;
  111089. private _currentIndex?;
  111090. /**
  111091. * Creates a new WeightedSound from the list of sounds given.
  111092. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111093. * @param sounds Array of Sounds that will be selected from.
  111094. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111095. */
  111096. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111097. /**
  111098. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111099. */
  111100. get directionalConeInnerAngle(): number;
  111101. /**
  111102. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111103. */
  111104. set directionalConeInnerAngle(value: number);
  111105. /**
  111106. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111107. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111108. */
  111109. get directionalConeOuterAngle(): number;
  111110. /**
  111111. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111112. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111113. */
  111114. set directionalConeOuterAngle(value: number);
  111115. /**
  111116. * Playback volume.
  111117. */
  111118. get volume(): number;
  111119. /**
  111120. * Playback volume.
  111121. */
  111122. set volume(value: number);
  111123. private _onended;
  111124. /**
  111125. * Suspend playback
  111126. */
  111127. pause(): void;
  111128. /**
  111129. * Stop playback
  111130. */
  111131. stop(): void;
  111132. /**
  111133. * Start playback.
  111134. * @param startOffset Position the clip head at a specific time in seconds.
  111135. */
  111136. play(startOffset?: number): void;
  111137. }
  111138. }
  111139. declare module BABYLON {
  111140. /**
  111141. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111143. */
  111144. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111145. /**
  111146. * Gets the name of the behavior.
  111147. */
  111148. get name(): string;
  111149. /**
  111150. * The easing function used by animations
  111151. */
  111152. static EasingFunction: BackEase;
  111153. /**
  111154. * The easing mode used by animations
  111155. */
  111156. static EasingMode: number;
  111157. /**
  111158. * The duration of the animation, in milliseconds
  111159. */
  111160. transitionDuration: number;
  111161. /**
  111162. * Length of the distance animated by the transition when lower radius is reached
  111163. */
  111164. lowerRadiusTransitionRange: number;
  111165. /**
  111166. * Length of the distance animated by the transition when upper radius is reached
  111167. */
  111168. upperRadiusTransitionRange: number;
  111169. private _autoTransitionRange;
  111170. /**
  111171. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111172. */
  111173. get autoTransitionRange(): boolean;
  111174. /**
  111175. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111176. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111177. */
  111178. set autoTransitionRange(value: boolean);
  111179. private _attachedCamera;
  111180. private _onAfterCheckInputsObserver;
  111181. private _onMeshTargetChangedObserver;
  111182. /**
  111183. * Initializes the behavior.
  111184. */
  111185. init(): void;
  111186. /**
  111187. * Attaches the behavior to its arc rotate camera.
  111188. * @param camera Defines the camera to attach the behavior to
  111189. */
  111190. attach(camera: ArcRotateCamera): void;
  111191. /**
  111192. * Detaches the behavior from its current arc rotate camera.
  111193. */
  111194. detach(): void;
  111195. private _radiusIsAnimating;
  111196. private _radiusBounceTransition;
  111197. private _animatables;
  111198. private _cachedWheelPrecision;
  111199. /**
  111200. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111201. * @param radiusLimit The limit to check against.
  111202. * @return Bool to indicate if at limit.
  111203. */
  111204. private _isRadiusAtLimit;
  111205. /**
  111206. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111207. * @param radiusDelta The delta by which to animate to. Can be negative.
  111208. */
  111209. private _applyBoundRadiusAnimation;
  111210. /**
  111211. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111212. */
  111213. protected _clearAnimationLocks(): void;
  111214. /**
  111215. * Stops and removes all animations that have been applied to the camera
  111216. */
  111217. stopAllAnimations(): void;
  111218. }
  111219. }
  111220. declare module BABYLON {
  111221. /**
  111222. * 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.
  111223. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111224. */
  111225. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111226. /**
  111227. * Gets the name of the behavior.
  111228. */
  111229. get name(): string;
  111230. private _mode;
  111231. private _radiusScale;
  111232. private _positionScale;
  111233. private _defaultElevation;
  111234. private _elevationReturnTime;
  111235. private _elevationReturnWaitTime;
  111236. private _zoomStopsAnimation;
  111237. private _framingTime;
  111238. /**
  111239. * The easing function used by animations
  111240. */
  111241. static EasingFunction: ExponentialEase;
  111242. /**
  111243. * The easing mode used by animations
  111244. */
  111245. static EasingMode: number;
  111246. /**
  111247. * Sets the current mode used by the behavior
  111248. */
  111249. set mode(mode: number);
  111250. /**
  111251. * Gets current mode used by the behavior.
  111252. */
  111253. get mode(): number;
  111254. /**
  111255. * Sets the scale applied to the radius (1 by default)
  111256. */
  111257. set radiusScale(radius: number);
  111258. /**
  111259. * Gets the scale applied to the radius
  111260. */
  111261. get radiusScale(): number;
  111262. /**
  111263. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111264. */
  111265. set positionScale(scale: number);
  111266. /**
  111267. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111268. */
  111269. get positionScale(): number;
  111270. /**
  111271. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111272. * behaviour is triggered, in radians.
  111273. */
  111274. set defaultElevation(elevation: number);
  111275. /**
  111276. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111277. * behaviour is triggered, in radians.
  111278. */
  111279. get defaultElevation(): number;
  111280. /**
  111281. * Sets the time (in milliseconds) taken to return to the default beta position.
  111282. * Negative value indicates camera should not return to default.
  111283. */
  111284. set elevationReturnTime(speed: number);
  111285. /**
  111286. * Gets the time (in milliseconds) taken to return to the default beta position.
  111287. * Negative value indicates camera should not return to default.
  111288. */
  111289. get elevationReturnTime(): number;
  111290. /**
  111291. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111292. */
  111293. set elevationReturnWaitTime(time: number);
  111294. /**
  111295. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111296. */
  111297. get elevationReturnWaitTime(): number;
  111298. /**
  111299. * Sets the flag that indicates if user zooming should stop animation.
  111300. */
  111301. set zoomStopsAnimation(flag: boolean);
  111302. /**
  111303. * Gets the flag that indicates if user zooming should stop animation.
  111304. */
  111305. get zoomStopsAnimation(): boolean;
  111306. /**
  111307. * Sets the transition time when framing the mesh, in milliseconds
  111308. */
  111309. set framingTime(time: number);
  111310. /**
  111311. * Gets the transition time when framing the mesh, in milliseconds
  111312. */
  111313. get framingTime(): number;
  111314. /**
  111315. * Define if the behavior should automatically change the configured
  111316. * camera limits and sensibilities.
  111317. */
  111318. autoCorrectCameraLimitsAndSensibility: boolean;
  111319. private _onPrePointerObservableObserver;
  111320. private _onAfterCheckInputsObserver;
  111321. private _onMeshTargetChangedObserver;
  111322. private _attachedCamera;
  111323. private _isPointerDown;
  111324. private _lastInteractionTime;
  111325. /**
  111326. * Initializes the behavior.
  111327. */
  111328. init(): void;
  111329. /**
  111330. * Attaches the behavior to its arc rotate camera.
  111331. * @param camera Defines the camera to attach the behavior to
  111332. */
  111333. attach(camera: ArcRotateCamera): void;
  111334. /**
  111335. * Detaches the behavior from its current arc rotate camera.
  111336. */
  111337. detach(): void;
  111338. private _animatables;
  111339. private _betaIsAnimating;
  111340. private _betaTransition;
  111341. private _radiusTransition;
  111342. private _vectorTransition;
  111343. /**
  111344. * Targets the given mesh and updates zoom level accordingly.
  111345. * @param mesh The mesh to target.
  111346. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111347. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111348. */
  111349. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111350. /**
  111351. * Targets the given mesh with its children and updates zoom level accordingly.
  111352. * @param mesh The mesh to target.
  111353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111355. */
  111356. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111357. /**
  111358. * Targets the given meshes with their children and updates zoom level accordingly.
  111359. * @param meshes The mesh to target.
  111360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111362. */
  111363. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111364. /**
  111365. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111366. * @param minimumWorld Determines the smaller position of the bounding box extend
  111367. * @param maximumWorld Determines the bigger position of the bounding box extend
  111368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111370. */
  111371. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111372. /**
  111373. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111374. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111375. * frustum width.
  111376. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111377. * to fully enclose the mesh in the viewing frustum.
  111378. */
  111379. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111380. /**
  111381. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111382. * is automatically returned to its default position (expected to be above ground plane).
  111383. */
  111384. private _maintainCameraAboveGround;
  111385. /**
  111386. * Returns the frustum slope based on the canvas ratio and camera FOV
  111387. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111388. */
  111389. private _getFrustumSlope;
  111390. /**
  111391. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111392. */
  111393. private _clearAnimationLocks;
  111394. /**
  111395. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111396. */
  111397. private _applyUserInteraction;
  111398. /**
  111399. * Stops and removes all animations that have been applied to the camera
  111400. */
  111401. stopAllAnimations(): void;
  111402. /**
  111403. * Gets a value indicating if the user is moving the camera
  111404. */
  111405. get isUserIsMoving(): boolean;
  111406. /**
  111407. * The camera can move all the way towards the mesh.
  111408. */
  111409. static IgnoreBoundsSizeMode: number;
  111410. /**
  111411. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111412. */
  111413. static FitFrustumSidesMode: number;
  111414. }
  111415. }
  111416. declare module BABYLON {
  111417. /**
  111418. * Base class for Camera Pointer Inputs.
  111419. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111420. * for example usage.
  111421. */
  111422. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111423. /**
  111424. * Defines the camera the input is attached to.
  111425. */
  111426. abstract camera: Camera;
  111427. /**
  111428. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111429. */
  111430. protected _altKey: boolean;
  111431. protected _ctrlKey: boolean;
  111432. protected _metaKey: boolean;
  111433. protected _shiftKey: boolean;
  111434. /**
  111435. * Which mouse buttons were pressed at time of last mouse event.
  111436. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111437. */
  111438. protected _buttonsPressed: number;
  111439. /**
  111440. * Defines the buttons associated with the input to handle camera move.
  111441. */
  111442. buttons: number[];
  111443. /**
  111444. * Attach the input controls to a specific dom element to get the input from.
  111445. * @param element Defines the element the controls should be listened from
  111446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111447. */
  111448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111449. /**
  111450. * Detach the current controls from the specified dom element.
  111451. * @param element Defines the element to stop listening the inputs from
  111452. */
  111453. detachControl(element: Nullable<HTMLElement>): void;
  111454. /**
  111455. * Gets the class name of the current input.
  111456. * @returns the class name
  111457. */
  111458. getClassName(): string;
  111459. /**
  111460. * Get the friendly name associated with the input class.
  111461. * @returns the input friendly name
  111462. */
  111463. getSimpleName(): string;
  111464. /**
  111465. * Called on pointer POINTERDOUBLETAP event.
  111466. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111467. */
  111468. protected onDoubleTap(type: string): void;
  111469. /**
  111470. * Called on pointer POINTERMOVE event if only a single touch is active.
  111471. * Override this method to provide functionality.
  111472. */
  111473. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111474. /**
  111475. * Called on pointer POINTERMOVE event if multiple touches are active.
  111476. * Override this method to provide functionality.
  111477. */
  111478. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111479. /**
  111480. * Called on JS contextmenu event.
  111481. * Override this method to provide functionality.
  111482. */
  111483. protected onContextMenu(evt: PointerEvent): void;
  111484. /**
  111485. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111486. * press.
  111487. * Override this method to provide functionality.
  111488. */
  111489. protected onButtonDown(evt: PointerEvent): void;
  111490. /**
  111491. * Called each time a new POINTERUP event occurs. Ie, for each button
  111492. * release.
  111493. * Override this method to provide functionality.
  111494. */
  111495. protected onButtonUp(evt: PointerEvent): void;
  111496. /**
  111497. * Called when window becomes inactive.
  111498. * Override this method to provide functionality.
  111499. */
  111500. protected onLostFocus(): void;
  111501. private _pointerInput;
  111502. private _observer;
  111503. private _onLostFocus;
  111504. private pointA;
  111505. private pointB;
  111506. }
  111507. }
  111508. declare module BABYLON {
  111509. /**
  111510. * Manage the pointers inputs to control an arc rotate camera.
  111511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111512. */
  111513. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111514. /**
  111515. * Defines the camera the input is attached to.
  111516. */
  111517. camera: ArcRotateCamera;
  111518. /**
  111519. * Gets the class name of the current input.
  111520. * @returns the class name
  111521. */
  111522. getClassName(): string;
  111523. /**
  111524. * Defines the buttons associated with the input to handle camera move.
  111525. */
  111526. buttons: number[];
  111527. /**
  111528. * Defines the pointer angular sensibility along the X axis or how fast is
  111529. * the camera rotating.
  111530. */
  111531. angularSensibilityX: number;
  111532. /**
  111533. * Defines the pointer angular sensibility along the Y axis or how fast is
  111534. * the camera rotating.
  111535. */
  111536. angularSensibilityY: number;
  111537. /**
  111538. * Defines the pointer pinch precision or how fast is the camera zooming.
  111539. */
  111540. pinchPrecision: number;
  111541. /**
  111542. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111543. * from 0.
  111544. * It defines the percentage of current camera.radius to use as delta when
  111545. * pinch zoom is used.
  111546. */
  111547. pinchDeltaPercentage: number;
  111548. /**
  111549. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111550. * that any object in the plane at the camera's target point will scale
  111551. * perfectly with finger motion.
  111552. * Overrides pinchDeltaPercentage and pinchPrecision.
  111553. */
  111554. useNaturalPinchZoom: boolean;
  111555. /**
  111556. * Defines the pointer panning sensibility or how fast is the camera moving.
  111557. */
  111558. panningSensibility: number;
  111559. /**
  111560. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111561. */
  111562. multiTouchPanning: boolean;
  111563. /**
  111564. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111565. * zoom (pinch) through multitouch.
  111566. */
  111567. multiTouchPanAndZoom: boolean;
  111568. /**
  111569. * Revers pinch action direction.
  111570. */
  111571. pinchInwards: boolean;
  111572. private _isPanClick;
  111573. private _twoFingerActivityCount;
  111574. private _isPinching;
  111575. /**
  111576. * Called on pointer POINTERMOVE event if only a single touch is active.
  111577. */
  111578. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111579. /**
  111580. * Called on pointer POINTERDOUBLETAP event.
  111581. */
  111582. protected onDoubleTap(type: string): void;
  111583. /**
  111584. * Called on pointer POINTERMOVE event if multiple touches are active.
  111585. */
  111586. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111587. /**
  111588. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111589. * press.
  111590. */
  111591. protected onButtonDown(evt: PointerEvent): void;
  111592. /**
  111593. * Called each time a new POINTERUP event occurs. Ie, for each button
  111594. * release.
  111595. */
  111596. protected onButtonUp(evt: PointerEvent): void;
  111597. /**
  111598. * Called when window becomes inactive.
  111599. */
  111600. protected onLostFocus(): void;
  111601. }
  111602. }
  111603. declare module BABYLON {
  111604. /**
  111605. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111607. */
  111608. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111609. /**
  111610. * Defines the camera the input is attached to.
  111611. */
  111612. camera: ArcRotateCamera;
  111613. /**
  111614. * Defines the list of key codes associated with the up action (increase alpha)
  111615. */
  111616. keysUp: number[];
  111617. /**
  111618. * Defines the list of key codes associated with the down action (decrease alpha)
  111619. */
  111620. keysDown: number[];
  111621. /**
  111622. * Defines the list of key codes associated with the left action (increase beta)
  111623. */
  111624. keysLeft: number[];
  111625. /**
  111626. * Defines the list of key codes associated with the right action (decrease beta)
  111627. */
  111628. keysRight: number[];
  111629. /**
  111630. * Defines the list of key codes associated with the reset action.
  111631. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111632. */
  111633. keysReset: number[];
  111634. /**
  111635. * Defines the panning sensibility of the inputs.
  111636. * (How fast is the camera panning)
  111637. */
  111638. panningSensibility: number;
  111639. /**
  111640. * Defines the zooming sensibility of the inputs.
  111641. * (How fast is the camera zooming)
  111642. */
  111643. zoomingSensibility: number;
  111644. /**
  111645. * Defines whether maintaining the alt key down switch the movement mode from
  111646. * orientation to zoom.
  111647. */
  111648. useAltToZoom: boolean;
  111649. /**
  111650. * Rotation speed of the camera
  111651. */
  111652. angularSpeed: number;
  111653. private _keys;
  111654. private _ctrlPressed;
  111655. private _altPressed;
  111656. private _onCanvasBlurObserver;
  111657. private _onKeyboardObserver;
  111658. private _engine;
  111659. private _scene;
  111660. /**
  111661. * Attach the input controls to a specific dom element to get the input from.
  111662. * @param element Defines the element the controls should be listened from
  111663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111664. */
  111665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111666. /**
  111667. * Detach the current controls from the specified dom element.
  111668. * @param element Defines the element to stop listening the inputs from
  111669. */
  111670. detachControl(element: Nullable<HTMLElement>): void;
  111671. /**
  111672. * Update the current camera state depending on the inputs that have been used this frame.
  111673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111674. */
  111675. checkInputs(): void;
  111676. /**
  111677. * Gets the class name of the current intput.
  111678. * @returns the class name
  111679. */
  111680. getClassName(): string;
  111681. /**
  111682. * Get the friendly name associated with the input class.
  111683. * @returns the input friendly name
  111684. */
  111685. getSimpleName(): string;
  111686. }
  111687. }
  111688. declare module BABYLON {
  111689. /**
  111690. * Manage the mouse wheel inputs to control an arc rotate camera.
  111691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111692. */
  111693. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111694. /**
  111695. * Defines the camera the input is attached to.
  111696. */
  111697. camera: ArcRotateCamera;
  111698. /**
  111699. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111700. */
  111701. wheelPrecision: number;
  111702. /**
  111703. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111704. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111705. */
  111706. wheelDeltaPercentage: number;
  111707. private _wheel;
  111708. private _observer;
  111709. private computeDeltaFromMouseWheelLegacyEvent;
  111710. /**
  111711. * Attach the input controls to a specific dom element to get the input from.
  111712. * @param element Defines the element the controls should be listened from
  111713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111714. */
  111715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111716. /**
  111717. * Detach the current controls from the specified dom element.
  111718. * @param element Defines the element to stop listening the inputs from
  111719. */
  111720. detachControl(element: Nullable<HTMLElement>): void;
  111721. /**
  111722. * Gets the class name of the current intput.
  111723. * @returns the class name
  111724. */
  111725. getClassName(): string;
  111726. /**
  111727. * Get the friendly name associated with the input class.
  111728. * @returns the input friendly name
  111729. */
  111730. getSimpleName(): string;
  111731. }
  111732. }
  111733. declare module BABYLON {
  111734. /**
  111735. * Default Inputs manager for the ArcRotateCamera.
  111736. * It groups all the default supported inputs for ease of use.
  111737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111738. */
  111739. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111740. /**
  111741. * Instantiates a new ArcRotateCameraInputsManager.
  111742. * @param camera Defines the camera the inputs belong to
  111743. */
  111744. constructor(camera: ArcRotateCamera);
  111745. /**
  111746. * Add mouse wheel input support to the input manager.
  111747. * @returns the current input manager
  111748. */
  111749. addMouseWheel(): ArcRotateCameraInputsManager;
  111750. /**
  111751. * Add pointers input support to the input manager.
  111752. * @returns the current input manager
  111753. */
  111754. addPointers(): ArcRotateCameraInputsManager;
  111755. /**
  111756. * Add keyboard input support to the input manager.
  111757. * @returns the current input manager
  111758. */
  111759. addKeyboard(): ArcRotateCameraInputsManager;
  111760. }
  111761. }
  111762. declare module BABYLON {
  111763. /**
  111764. * This represents an orbital type of camera.
  111765. *
  111766. * 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.
  111767. * 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.
  111768. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111769. */
  111770. export class ArcRotateCamera extends TargetCamera {
  111771. /**
  111772. * Defines the rotation angle of the camera along the longitudinal axis.
  111773. */
  111774. alpha: number;
  111775. /**
  111776. * Defines the rotation angle of the camera along the latitudinal axis.
  111777. */
  111778. beta: number;
  111779. /**
  111780. * Defines the radius of the camera from it s target point.
  111781. */
  111782. radius: number;
  111783. protected _target: Vector3;
  111784. protected _targetHost: Nullable<AbstractMesh>;
  111785. /**
  111786. * Defines the target point of the camera.
  111787. * The camera looks towards it form the radius distance.
  111788. */
  111789. get target(): Vector3;
  111790. set target(value: Vector3);
  111791. /**
  111792. * Define the current local position of the camera in the scene
  111793. */
  111794. get position(): Vector3;
  111795. set position(newPosition: Vector3);
  111796. protected _upVector: Vector3;
  111797. protected _upToYMatrix: Matrix;
  111798. protected _YToUpMatrix: Matrix;
  111799. /**
  111800. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111801. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111802. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111803. */
  111804. set upVector(vec: Vector3);
  111805. get upVector(): Vector3;
  111806. /**
  111807. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111808. */
  111809. setMatUp(): void;
  111810. /**
  111811. * Current inertia value on the longitudinal axis.
  111812. * The bigger this number the longer it will take for the camera to stop.
  111813. */
  111814. inertialAlphaOffset: number;
  111815. /**
  111816. * Current inertia value on the latitudinal axis.
  111817. * The bigger this number the longer it will take for the camera to stop.
  111818. */
  111819. inertialBetaOffset: number;
  111820. /**
  111821. * Current inertia value on the radius axis.
  111822. * The bigger this number the longer it will take for the camera to stop.
  111823. */
  111824. inertialRadiusOffset: number;
  111825. /**
  111826. * Minimum allowed angle on the longitudinal axis.
  111827. * This can help limiting how the Camera is able to move in the scene.
  111828. */
  111829. lowerAlphaLimit: Nullable<number>;
  111830. /**
  111831. * Maximum allowed angle on the longitudinal axis.
  111832. * This can help limiting how the Camera is able to move in the scene.
  111833. */
  111834. upperAlphaLimit: Nullable<number>;
  111835. /**
  111836. * Minimum allowed angle on the latitudinal axis.
  111837. * This can help limiting how the Camera is able to move in the scene.
  111838. */
  111839. lowerBetaLimit: number;
  111840. /**
  111841. * Maximum allowed angle on the latitudinal axis.
  111842. * This can help limiting how the Camera is able to move in the scene.
  111843. */
  111844. upperBetaLimit: number;
  111845. /**
  111846. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111847. * This can help limiting how the Camera is able to move in the scene.
  111848. */
  111849. lowerRadiusLimit: Nullable<number>;
  111850. /**
  111851. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111852. * This can help limiting how the Camera is able to move in the scene.
  111853. */
  111854. upperRadiusLimit: Nullable<number>;
  111855. /**
  111856. * Defines the current inertia value used during panning of the camera along the X axis.
  111857. */
  111858. inertialPanningX: number;
  111859. /**
  111860. * Defines the current inertia value used during panning of the camera along the Y axis.
  111861. */
  111862. inertialPanningY: number;
  111863. /**
  111864. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111865. * Basically if your fingers moves away from more than this distance you will be considered
  111866. * in pinch mode.
  111867. */
  111868. pinchToPanMaxDistance: number;
  111869. /**
  111870. * Defines the maximum distance the camera can pan.
  111871. * This could help keeping the cammera always in your scene.
  111872. */
  111873. panningDistanceLimit: Nullable<number>;
  111874. /**
  111875. * Defines the target of the camera before paning.
  111876. */
  111877. panningOriginTarget: Vector3;
  111878. /**
  111879. * Defines the value of the inertia used during panning.
  111880. * 0 would mean stop inertia and one would mean no decelleration at all.
  111881. */
  111882. panningInertia: number;
  111883. /**
  111884. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111885. */
  111886. get angularSensibilityX(): number;
  111887. set angularSensibilityX(value: number);
  111888. /**
  111889. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111890. */
  111891. get angularSensibilityY(): number;
  111892. set angularSensibilityY(value: number);
  111893. /**
  111894. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111895. */
  111896. get pinchPrecision(): number;
  111897. set pinchPrecision(value: number);
  111898. /**
  111899. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111900. * It will be used instead of pinchDeltaPrecision if different from 0.
  111901. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111902. */
  111903. get pinchDeltaPercentage(): number;
  111904. set pinchDeltaPercentage(value: number);
  111905. /**
  111906. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111907. * and pinch delta percentage.
  111908. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111909. * that any object in the plane at the camera's target point will scale
  111910. * perfectly with finger motion.
  111911. */
  111912. get useNaturalPinchZoom(): boolean;
  111913. set useNaturalPinchZoom(value: boolean);
  111914. /**
  111915. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111916. */
  111917. get panningSensibility(): number;
  111918. set panningSensibility(value: number);
  111919. /**
  111920. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111921. */
  111922. get keysUp(): number[];
  111923. set keysUp(value: number[]);
  111924. /**
  111925. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111926. */
  111927. get keysDown(): number[];
  111928. set keysDown(value: number[]);
  111929. /**
  111930. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111931. */
  111932. get keysLeft(): number[];
  111933. set keysLeft(value: number[]);
  111934. /**
  111935. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111936. */
  111937. get keysRight(): number[];
  111938. set keysRight(value: number[]);
  111939. /**
  111940. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111941. */
  111942. get wheelPrecision(): number;
  111943. set wheelPrecision(value: number);
  111944. /**
  111945. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111946. * It will be used instead of pinchDeltaPrecision if different from 0.
  111947. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111948. */
  111949. get wheelDeltaPercentage(): number;
  111950. set wheelDeltaPercentage(value: number);
  111951. /**
  111952. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111953. */
  111954. zoomOnFactor: number;
  111955. /**
  111956. * Defines a screen offset for the camera position.
  111957. */
  111958. targetScreenOffset: Vector2;
  111959. /**
  111960. * Allows the camera to be completely reversed.
  111961. * If false the camera can not arrive upside down.
  111962. */
  111963. allowUpsideDown: boolean;
  111964. /**
  111965. * Define if double tap/click is used to restore the previously saved state of the camera.
  111966. */
  111967. useInputToRestoreState: boolean;
  111968. /** @hidden */
  111969. _viewMatrix: Matrix;
  111970. /** @hidden */
  111971. _useCtrlForPanning: boolean;
  111972. /** @hidden */
  111973. _panningMouseButton: number;
  111974. /**
  111975. * Defines the input associated to the camera.
  111976. */
  111977. inputs: ArcRotateCameraInputsManager;
  111978. /** @hidden */
  111979. _reset: () => void;
  111980. /**
  111981. * Defines the allowed panning axis.
  111982. */
  111983. panningAxis: Vector3;
  111984. protected _localDirection: Vector3;
  111985. protected _transformedDirection: Vector3;
  111986. private _bouncingBehavior;
  111987. /**
  111988. * Gets the bouncing behavior of the camera if it has been enabled.
  111989. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111990. */
  111991. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111992. /**
  111993. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111995. */
  111996. get useBouncingBehavior(): boolean;
  111997. set useBouncingBehavior(value: boolean);
  111998. private _framingBehavior;
  111999. /**
  112000. * Gets the framing behavior of the camera if it has been enabled.
  112001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112002. */
  112003. get framingBehavior(): Nullable<FramingBehavior>;
  112004. /**
  112005. * Defines if the framing behavior of the camera is enabled on the camera.
  112006. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112007. */
  112008. get useFramingBehavior(): boolean;
  112009. set useFramingBehavior(value: boolean);
  112010. private _autoRotationBehavior;
  112011. /**
  112012. * Gets the auto rotation behavior of the camera if it has been enabled.
  112013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112014. */
  112015. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112016. /**
  112017. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112019. */
  112020. get useAutoRotationBehavior(): boolean;
  112021. set useAutoRotationBehavior(value: boolean);
  112022. /**
  112023. * Observable triggered when the mesh target has been changed on the camera.
  112024. */
  112025. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112026. /**
  112027. * Event raised when the camera is colliding with a mesh.
  112028. */
  112029. onCollide: (collidedMesh: AbstractMesh) => void;
  112030. /**
  112031. * Defines whether the camera should check collision with the objects oh the scene.
  112032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112033. */
  112034. checkCollisions: boolean;
  112035. /**
  112036. * Defines the collision radius of the camera.
  112037. * This simulates a sphere around the camera.
  112038. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112039. */
  112040. collisionRadius: Vector3;
  112041. protected _collider: Collider;
  112042. protected _previousPosition: Vector3;
  112043. protected _collisionVelocity: Vector3;
  112044. protected _newPosition: Vector3;
  112045. protected _previousAlpha: number;
  112046. protected _previousBeta: number;
  112047. protected _previousRadius: number;
  112048. protected _collisionTriggered: boolean;
  112049. protected _targetBoundingCenter: Nullable<Vector3>;
  112050. private _computationVector;
  112051. /**
  112052. * Instantiates a new ArcRotateCamera in a given scene
  112053. * @param name Defines the name of the camera
  112054. * @param alpha Defines the camera rotation along the logitudinal axis
  112055. * @param beta Defines the camera rotation along the latitudinal axis
  112056. * @param radius Defines the camera distance from its target
  112057. * @param target Defines the camera target
  112058. * @param scene Defines the scene the camera belongs to
  112059. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112060. */
  112061. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112062. /** @hidden */
  112063. _initCache(): void;
  112064. /** @hidden */
  112065. _updateCache(ignoreParentClass?: boolean): void;
  112066. protected _getTargetPosition(): Vector3;
  112067. private _storedAlpha;
  112068. private _storedBeta;
  112069. private _storedRadius;
  112070. private _storedTarget;
  112071. private _storedTargetScreenOffset;
  112072. /**
  112073. * Stores the current state of the camera (alpha, beta, radius and target)
  112074. * @returns the camera itself
  112075. */
  112076. storeState(): Camera;
  112077. /**
  112078. * @hidden
  112079. * Restored camera state. You must call storeState() first
  112080. */
  112081. _restoreStateValues(): boolean;
  112082. /** @hidden */
  112083. _isSynchronizedViewMatrix(): boolean;
  112084. /**
  112085. * Attached controls to the current camera.
  112086. * @param element Defines the element the controls should be listened from
  112087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112088. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112089. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112090. */
  112091. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112092. /**
  112093. * Detach the current controls from the camera.
  112094. * The camera will stop reacting to inputs.
  112095. * @param element Defines the element to stop listening the inputs from
  112096. */
  112097. detachControl(element: HTMLElement): void;
  112098. /** @hidden */
  112099. _checkInputs(): void;
  112100. protected _checkLimits(): void;
  112101. /**
  112102. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112103. */
  112104. rebuildAnglesAndRadius(): void;
  112105. /**
  112106. * Use a position to define the current camera related information like alpha, beta and radius
  112107. * @param position Defines the position to set the camera at
  112108. */
  112109. setPosition(position: Vector3): void;
  112110. /**
  112111. * Defines the target the camera should look at.
  112112. * This will automatically adapt alpha beta and radius to fit within the new target.
  112113. * @param target Defines the new target as a Vector or a mesh
  112114. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112115. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112116. */
  112117. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112118. /** @hidden */
  112119. _getViewMatrix(): Matrix;
  112120. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112121. /**
  112122. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112123. * @param meshes Defines the mesh to zoom on
  112124. * @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)
  112125. */
  112126. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112127. /**
  112128. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112129. * The target will be changed but the radius
  112130. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112131. * @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)
  112132. */
  112133. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112134. min: Vector3;
  112135. max: Vector3;
  112136. distance: number;
  112137. }, doNotUpdateMaxZ?: boolean): void;
  112138. /**
  112139. * @override
  112140. * Override Camera.createRigCamera
  112141. */
  112142. createRigCamera(name: string, cameraIndex: number): Camera;
  112143. /**
  112144. * @hidden
  112145. * @override
  112146. * Override Camera._updateRigCameras
  112147. */
  112148. _updateRigCameras(): void;
  112149. /**
  112150. * Destroy the camera and release the current resources hold by it.
  112151. */
  112152. dispose(): void;
  112153. /**
  112154. * Gets the current object class name.
  112155. * @return the class name
  112156. */
  112157. getClassName(): string;
  112158. }
  112159. }
  112160. declare module BABYLON {
  112161. /**
  112162. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112164. */
  112165. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112166. /**
  112167. * Gets the name of the behavior.
  112168. */
  112169. get name(): string;
  112170. private _zoomStopsAnimation;
  112171. private _idleRotationSpeed;
  112172. private _idleRotationWaitTime;
  112173. private _idleRotationSpinupTime;
  112174. /**
  112175. * Sets the flag that indicates if user zooming should stop animation.
  112176. */
  112177. set zoomStopsAnimation(flag: boolean);
  112178. /**
  112179. * Gets the flag that indicates if user zooming should stop animation.
  112180. */
  112181. get zoomStopsAnimation(): boolean;
  112182. /**
  112183. * Sets the default speed at which the camera rotates around the model.
  112184. */
  112185. set idleRotationSpeed(speed: number);
  112186. /**
  112187. * Gets the default speed at which the camera rotates around the model.
  112188. */
  112189. get idleRotationSpeed(): number;
  112190. /**
  112191. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112192. */
  112193. set idleRotationWaitTime(time: number);
  112194. /**
  112195. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112196. */
  112197. get idleRotationWaitTime(): number;
  112198. /**
  112199. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112200. */
  112201. set idleRotationSpinupTime(time: number);
  112202. /**
  112203. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112204. */
  112205. get idleRotationSpinupTime(): number;
  112206. /**
  112207. * Gets a value indicating if the camera is currently rotating because of this behavior
  112208. */
  112209. get rotationInProgress(): boolean;
  112210. private _onPrePointerObservableObserver;
  112211. private _onAfterCheckInputsObserver;
  112212. private _attachedCamera;
  112213. private _isPointerDown;
  112214. private _lastFrameTime;
  112215. private _lastInteractionTime;
  112216. private _cameraRotationSpeed;
  112217. /**
  112218. * Initializes the behavior.
  112219. */
  112220. init(): void;
  112221. /**
  112222. * Attaches the behavior to its arc rotate camera.
  112223. * @param camera Defines the camera to attach the behavior to
  112224. */
  112225. attach(camera: ArcRotateCamera): void;
  112226. /**
  112227. * Detaches the behavior from its current arc rotate camera.
  112228. */
  112229. detach(): void;
  112230. /**
  112231. * Returns true if user is scrolling.
  112232. * @return true if user is scrolling.
  112233. */
  112234. private _userIsZooming;
  112235. private _lastFrameRadius;
  112236. private _shouldAnimationStopForInteraction;
  112237. /**
  112238. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112239. */
  112240. private _applyUserInteraction;
  112241. private _userIsMoving;
  112242. }
  112243. }
  112244. declare module BABYLON {
  112245. /**
  112246. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112247. */
  112248. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112249. private ui;
  112250. /**
  112251. * The name of the behavior
  112252. */
  112253. name: string;
  112254. /**
  112255. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112256. */
  112257. distanceAwayFromFace: number;
  112258. /**
  112259. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112260. */
  112261. distanceAwayFromBottomOfFace: number;
  112262. private _faceVectors;
  112263. private _target;
  112264. private _scene;
  112265. private _onRenderObserver;
  112266. private _tmpMatrix;
  112267. private _tmpVector;
  112268. /**
  112269. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112270. * @param ui The transform node that should be attched to the mesh
  112271. */
  112272. constructor(ui: TransformNode);
  112273. /**
  112274. * Initializes the behavior
  112275. */
  112276. init(): void;
  112277. private _closestFace;
  112278. private _zeroVector;
  112279. private _lookAtTmpMatrix;
  112280. private _lookAtToRef;
  112281. /**
  112282. * Attaches the AttachToBoxBehavior to the passed in mesh
  112283. * @param target The mesh that the specified node will be attached to
  112284. */
  112285. attach(target: Mesh): void;
  112286. /**
  112287. * Detaches the behavior from the mesh
  112288. */
  112289. detach(): void;
  112290. }
  112291. }
  112292. declare module BABYLON {
  112293. /**
  112294. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112295. */
  112296. export class FadeInOutBehavior implements Behavior<Mesh> {
  112297. /**
  112298. * Time in milliseconds to delay before fading in (Default: 0)
  112299. */
  112300. delay: number;
  112301. /**
  112302. * Time in milliseconds for the mesh to fade in (Default: 300)
  112303. */
  112304. fadeInTime: number;
  112305. private _millisecondsPerFrame;
  112306. private _hovered;
  112307. private _hoverValue;
  112308. private _ownerNode;
  112309. /**
  112310. * Instatiates the FadeInOutBehavior
  112311. */
  112312. constructor();
  112313. /**
  112314. * The name of the behavior
  112315. */
  112316. get name(): string;
  112317. /**
  112318. * Initializes the behavior
  112319. */
  112320. init(): void;
  112321. /**
  112322. * Attaches the fade behavior on the passed in mesh
  112323. * @param ownerNode The mesh that will be faded in/out once attached
  112324. */
  112325. attach(ownerNode: Mesh): void;
  112326. /**
  112327. * Detaches the behavior from the mesh
  112328. */
  112329. detach(): void;
  112330. /**
  112331. * Triggers the mesh to begin fading in or out
  112332. * @param value if the object should fade in or out (true to fade in)
  112333. */
  112334. fadeIn(value: boolean): void;
  112335. private _update;
  112336. private _setAllVisibility;
  112337. }
  112338. }
  112339. declare module BABYLON {
  112340. /**
  112341. * Class containing a set of static utilities functions for managing Pivots
  112342. * @hidden
  112343. */
  112344. export class PivotTools {
  112345. private static _PivotCached;
  112346. private static _OldPivotPoint;
  112347. private static _PivotTranslation;
  112348. private static _PivotTmpVector;
  112349. /** @hidden */
  112350. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112351. /** @hidden */
  112352. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112353. }
  112354. }
  112355. declare module BABYLON {
  112356. /**
  112357. * Class containing static functions to help procedurally build meshes
  112358. */
  112359. export class PlaneBuilder {
  112360. /**
  112361. * Creates a plane mesh
  112362. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112363. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112364. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112368. * @param name defines the name of the mesh
  112369. * @param options defines the options used to create the mesh
  112370. * @param scene defines the hosting scene
  112371. * @returns the plane mesh
  112372. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112373. */
  112374. static CreatePlane(name: string, options: {
  112375. size?: number;
  112376. width?: number;
  112377. height?: number;
  112378. sideOrientation?: number;
  112379. frontUVs?: Vector4;
  112380. backUVs?: Vector4;
  112381. updatable?: boolean;
  112382. sourcePlane?: Plane;
  112383. }, scene?: Nullable<Scene>): Mesh;
  112384. }
  112385. }
  112386. declare module BABYLON {
  112387. /**
  112388. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112389. */
  112390. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112391. private static _AnyMouseID;
  112392. /**
  112393. * Abstract mesh the behavior is set on
  112394. */
  112395. attachedNode: AbstractMesh;
  112396. private _dragPlane;
  112397. private _scene;
  112398. private _pointerObserver;
  112399. private _beforeRenderObserver;
  112400. private static _planeScene;
  112401. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112402. /**
  112403. * 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)
  112404. */
  112405. maxDragAngle: number;
  112406. /**
  112407. * @hidden
  112408. */
  112409. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112410. /**
  112411. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112412. */
  112413. currentDraggingPointerID: number;
  112414. /**
  112415. * The last position where the pointer hit the drag plane in world space
  112416. */
  112417. lastDragPosition: Vector3;
  112418. /**
  112419. * If the behavior is currently in a dragging state
  112420. */
  112421. dragging: boolean;
  112422. /**
  112423. * 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)
  112424. */
  112425. dragDeltaRatio: number;
  112426. /**
  112427. * If the drag plane orientation should be updated during the dragging (Default: true)
  112428. */
  112429. updateDragPlane: boolean;
  112430. private _debugMode;
  112431. private _moving;
  112432. /**
  112433. * Fires each time the attached mesh is dragged with the pointer
  112434. * * delta between last drag position and current drag position in world space
  112435. * * dragDistance along the drag axis
  112436. * * dragPlaneNormal normal of the current drag plane used during the drag
  112437. * * dragPlanePoint in world space where the drag intersects the drag plane
  112438. */
  112439. onDragObservable: Observable<{
  112440. delta: Vector3;
  112441. dragPlanePoint: Vector3;
  112442. dragPlaneNormal: Vector3;
  112443. dragDistance: number;
  112444. pointerId: number;
  112445. }>;
  112446. /**
  112447. * Fires each time a drag begins (eg. mouse down on mesh)
  112448. */
  112449. onDragStartObservable: Observable<{
  112450. dragPlanePoint: Vector3;
  112451. pointerId: number;
  112452. }>;
  112453. /**
  112454. * Fires each time a drag ends (eg. mouse release after drag)
  112455. */
  112456. onDragEndObservable: Observable<{
  112457. dragPlanePoint: Vector3;
  112458. pointerId: number;
  112459. }>;
  112460. /**
  112461. * If the attached mesh should be moved when dragged
  112462. */
  112463. moveAttached: boolean;
  112464. /**
  112465. * If the drag behavior will react to drag events (Default: true)
  112466. */
  112467. enabled: boolean;
  112468. /**
  112469. * If pointer events should start and release the drag (Default: true)
  112470. */
  112471. startAndReleaseDragOnPointerEvents: boolean;
  112472. /**
  112473. * If camera controls should be detached during the drag
  112474. */
  112475. detachCameraControls: boolean;
  112476. /**
  112477. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112478. */
  112479. useObjectOrientationForDragging: boolean;
  112480. private _options;
  112481. /**
  112482. * Gets the options used by the behavior
  112483. */
  112484. get options(): {
  112485. dragAxis?: Vector3;
  112486. dragPlaneNormal?: Vector3;
  112487. };
  112488. /**
  112489. * Sets the options used by the behavior
  112490. */
  112491. set options(options: {
  112492. dragAxis?: Vector3;
  112493. dragPlaneNormal?: Vector3;
  112494. });
  112495. /**
  112496. * Creates a pointer drag behavior that can be attached to a mesh
  112497. * @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)
  112498. */
  112499. constructor(options?: {
  112500. dragAxis?: Vector3;
  112501. dragPlaneNormal?: Vector3;
  112502. });
  112503. /**
  112504. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112505. */
  112506. validateDrag: (targetPosition: Vector3) => boolean;
  112507. /**
  112508. * The name of the behavior
  112509. */
  112510. get name(): string;
  112511. /**
  112512. * Initializes the behavior
  112513. */
  112514. init(): void;
  112515. private _tmpVector;
  112516. private _alternatePickedPoint;
  112517. private _worldDragAxis;
  112518. private _targetPosition;
  112519. private _attachedElement;
  112520. /**
  112521. * Attaches the drag behavior the passed in mesh
  112522. * @param ownerNode The mesh that will be dragged around once attached
  112523. * @param predicate Predicate to use for pick filtering
  112524. */
  112525. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112526. /**
  112527. * Force relase the drag action by code.
  112528. */
  112529. releaseDrag(): void;
  112530. private _startDragRay;
  112531. private _lastPointerRay;
  112532. /**
  112533. * Simulates the start of a pointer drag event on the behavior
  112534. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112535. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112536. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112537. */
  112538. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112539. private _startDrag;
  112540. private _dragDelta;
  112541. private _moveDrag;
  112542. private _pickWithRayOnDragPlane;
  112543. private _pointA;
  112544. private _pointB;
  112545. private _pointC;
  112546. private _lineA;
  112547. private _lineB;
  112548. private _localAxis;
  112549. private _lookAt;
  112550. private _updateDragPlanePosition;
  112551. /**
  112552. * Detaches the behavior from the mesh
  112553. */
  112554. detach(): void;
  112555. }
  112556. }
  112557. declare module BABYLON {
  112558. /**
  112559. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112560. */
  112561. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112562. private _dragBehaviorA;
  112563. private _dragBehaviorB;
  112564. private _startDistance;
  112565. private _initialScale;
  112566. private _targetScale;
  112567. private _ownerNode;
  112568. private _sceneRenderObserver;
  112569. /**
  112570. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112571. */
  112572. constructor();
  112573. /**
  112574. * The name of the behavior
  112575. */
  112576. get name(): string;
  112577. /**
  112578. * Initializes the behavior
  112579. */
  112580. init(): void;
  112581. private _getCurrentDistance;
  112582. /**
  112583. * Attaches the scale behavior the passed in mesh
  112584. * @param ownerNode The mesh that will be scaled around once attached
  112585. */
  112586. attach(ownerNode: Mesh): void;
  112587. /**
  112588. * Detaches the behavior from the mesh
  112589. */
  112590. detach(): void;
  112591. }
  112592. }
  112593. declare module BABYLON {
  112594. /**
  112595. * 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
  112596. */
  112597. export class SixDofDragBehavior implements Behavior<Mesh> {
  112598. private static _virtualScene;
  112599. private _ownerNode;
  112600. private _sceneRenderObserver;
  112601. private _scene;
  112602. private _targetPosition;
  112603. private _virtualOriginMesh;
  112604. private _virtualDragMesh;
  112605. private _pointerObserver;
  112606. private _moving;
  112607. private _startingOrientation;
  112608. /**
  112609. * 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)
  112610. */
  112611. private zDragFactor;
  112612. /**
  112613. * If the object should rotate to face the drag origin
  112614. */
  112615. rotateDraggedObject: boolean;
  112616. /**
  112617. * If the behavior is currently in a dragging state
  112618. */
  112619. dragging: boolean;
  112620. /**
  112621. * 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)
  112622. */
  112623. dragDeltaRatio: number;
  112624. /**
  112625. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112626. */
  112627. currentDraggingPointerID: number;
  112628. /**
  112629. * If camera controls should be detached during the drag
  112630. */
  112631. detachCameraControls: boolean;
  112632. /**
  112633. * Fires each time a drag starts
  112634. */
  112635. onDragStartObservable: Observable<{}>;
  112636. /**
  112637. * Fires each time a drag ends (eg. mouse release after drag)
  112638. */
  112639. onDragEndObservable: Observable<{}>;
  112640. /**
  112641. * 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
  112642. */
  112643. constructor();
  112644. /**
  112645. * The name of the behavior
  112646. */
  112647. get name(): string;
  112648. /**
  112649. * Initializes the behavior
  112650. */
  112651. init(): void;
  112652. /**
  112653. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112654. */
  112655. private get _pointerCamera();
  112656. /**
  112657. * Attaches the scale behavior the passed in mesh
  112658. * @param ownerNode The mesh that will be scaled around once attached
  112659. */
  112660. attach(ownerNode: Mesh): void;
  112661. /**
  112662. * Detaches the behavior from the mesh
  112663. */
  112664. detach(): void;
  112665. }
  112666. }
  112667. declare module BABYLON {
  112668. /**
  112669. * Class used to apply inverse kinematics to bones
  112670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112671. */
  112672. export class BoneIKController {
  112673. private static _tmpVecs;
  112674. private static _tmpQuat;
  112675. private static _tmpMats;
  112676. /**
  112677. * Gets or sets the target mesh
  112678. */
  112679. targetMesh: AbstractMesh;
  112680. /** Gets or sets the mesh used as pole */
  112681. poleTargetMesh: AbstractMesh;
  112682. /**
  112683. * Gets or sets the bone used as pole
  112684. */
  112685. poleTargetBone: Nullable<Bone>;
  112686. /**
  112687. * Gets or sets the target position
  112688. */
  112689. targetPosition: Vector3;
  112690. /**
  112691. * Gets or sets the pole target position
  112692. */
  112693. poleTargetPosition: Vector3;
  112694. /**
  112695. * Gets or sets the pole target local offset
  112696. */
  112697. poleTargetLocalOffset: Vector3;
  112698. /**
  112699. * Gets or sets the pole angle
  112700. */
  112701. poleAngle: number;
  112702. /**
  112703. * Gets or sets the mesh associated with the controller
  112704. */
  112705. mesh: AbstractMesh;
  112706. /**
  112707. * 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)
  112708. */
  112709. slerpAmount: number;
  112710. private _bone1Quat;
  112711. private _bone1Mat;
  112712. private _bone2Ang;
  112713. private _bone1;
  112714. private _bone2;
  112715. private _bone1Length;
  112716. private _bone2Length;
  112717. private _maxAngle;
  112718. private _maxReach;
  112719. private _rightHandedSystem;
  112720. private _bendAxis;
  112721. private _slerping;
  112722. private _adjustRoll;
  112723. /**
  112724. * Gets or sets maximum allowed angle
  112725. */
  112726. get maxAngle(): number;
  112727. set maxAngle(value: number);
  112728. /**
  112729. * Creates a new BoneIKController
  112730. * @param mesh defines the mesh to control
  112731. * @param bone defines the bone to control
  112732. * @param options defines options to set up the controller
  112733. */
  112734. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112735. targetMesh?: AbstractMesh;
  112736. poleTargetMesh?: AbstractMesh;
  112737. poleTargetBone?: Bone;
  112738. poleTargetLocalOffset?: Vector3;
  112739. poleAngle?: number;
  112740. bendAxis?: Vector3;
  112741. maxAngle?: number;
  112742. slerpAmount?: number;
  112743. });
  112744. private _setMaxAngle;
  112745. /**
  112746. * Force the controller to update the bones
  112747. */
  112748. update(): void;
  112749. }
  112750. }
  112751. declare module BABYLON {
  112752. /**
  112753. * Class used to make a bone look toward a point in space
  112754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112755. */
  112756. export class BoneLookController {
  112757. private static _tmpVecs;
  112758. private static _tmpQuat;
  112759. private static _tmpMats;
  112760. /**
  112761. * The target Vector3 that the bone will look at
  112762. */
  112763. target: Vector3;
  112764. /**
  112765. * The mesh that the bone is attached to
  112766. */
  112767. mesh: AbstractMesh;
  112768. /**
  112769. * The bone that will be looking to the target
  112770. */
  112771. bone: Bone;
  112772. /**
  112773. * The up axis of the coordinate system that is used when the bone is rotated
  112774. */
  112775. upAxis: Vector3;
  112776. /**
  112777. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112778. */
  112779. upAxisSpace: Space;
  112780. /**
  112781. * Used to make an adjustment to the yaw of the bone
  112782. */
  112783. adjustYaw: number;
  112784. /**
  112785. * Used to make an adjustment to the pitch of the bone
  112786. */
  112787. adjustPitch: number;
  112788. /**
  112789. * Used to make an adjustment to the roll of the bone
  112790. */
  112791. adjustRoll: number;
  112792. /**
  112793. * 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)
  112794. */
  112795. slerpAmount: number;
  112796. private _minYaw;
  112797. private _maxYaw;
  112798. private _minPitch;
  112799. private _maxPitch;
  112800. private _minYawSin;
  112801. private _minYawCos;
  112802. private _maxYawSin;
  112803. private _maxYawCos;
  112804. private _midYawConstraint;
  112805. private _minPitchTan;
  112806. private _maxPitchTan;
  112807. private _boneQuat;
  112808. private _slerping;
  112809. private _transformYawPitch;
  112810. private _transformYawPitchInv;
  112811. private _firstFrameSkipped;
  112812. private _yawRange;
  112813. private _fowardAxis;
  112814. /**
  112815. * Gets or sets the minimum yaw angle that the bone can look to
  112816. */
  112817. get minYaw(): number;
  112818. set minYaw(value: number);
  112819. /**
  112820. * Gets or sets the maximum yaw angle that the bone can look to
  112821. */
  112822. get maxYaw(): number;
  112823. set maxYaw(value: number);
  112824. /**
  112825. * Gets or sets the minimum pitch angle that the bone can look to
  112826. */
  112827. get minPitch(): number;
  112828. set minPitch(value: number);
  112829. /**
  112830. * Gets or sets the maximum pitch angle that the bone can look to
  112831. */
  112832. get maxPitch(): number;
  112833. set maxPitch(value: number);
  112834. /**
  112835. * Create a BoneLookController
  112836. * @param mesh the mesh that the bone belongs to
  112837. * @param bone the bone that will be looking to the target
  112838. * @param target the target Vector3 to look at
  112839. * @param options optional settings:
  112840. * * maxYaw: the maximum angle the bone will yaw to
  112841. * * minYaw: the minimum angle the bone will yaw to
  112842. * * maxPitch: the maximum angle the bone will pitch to
  112843. * * minPitch: the minimum angle the bone will yaw to
  112844. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112845. * * upAxis: the up axis of the coordinate system
  112846. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112847. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112848. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112849. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112850. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112851. * * adjustRoll: used to make an adjustment to the roll of the bone
  112852. **/
  112853. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112854. maxYaw?: number;
  112855. minYaw?: number;
  112856. maxPitch?: number;
  112857. minPitch?: number;
  112858. slerpAmount?: number;
  112859. upAxis?: Vector3;
  112860. upAxisSpace?: Space;
  112861. yawAxis?: Vector3;
  112862. pitchAxis?: Vector3;
  112863. adjustYaw?: number;
  112864. adjustPitch?: number;
  112865. adjustRoll?: number;
  112866. });
  112867. /**
  112868. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112869. */
  112870. update(): void;
  112871. private _getAngleDiff;
  112872. private _getAngleBetween;
  112873. private _isAngleBetween;
  112874. }
  112875. }
  112876. declare module BABYLON {
  112877. /**
  112878. * Manage the gamepad inputs to control an arc rotate camera.
  112879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112880. */
  112881. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112882. /**
  112883. * Defines the camera the input is attached to.
  112884. */
  112885. camera: ArcRotateCamera;
  112886. /**
  112887. * Defines the gamepad the input is gathering event from.
  112888. */
  112889. gamepad: Nullable<Gamepad>;
  112890. /**
  112891. * Defines the gamepad rotation sensiblity.
  112892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112893. */
  112894. gamepadRotationSensibility: number;
  112895. /**
  112896. * Defines the gamepad move sensiblity.
  112897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112898. */
  112899. gamepadMoveSensibility: number;
  112900. private _yAxisScale;
  112901. /**
  112902. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112903. */
  112904. get invertYAxis(): boolean;
  112905. set invertYAxis(value: boolean);
  112906. private _onGamepadConnectedObserver;
  112907. private _onGamepadDisconnectedObserver;
  112908. /**
  112909. * Attach the input controls to a specific dom element to get the input from.
  112910. * @param element Defines the element the controls should be listened from
  112911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112912. */
  112913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112914. /**
  112915. * Detach the current controls from the specified dom element.
  112916. * @param element Defines the element to stop listening the inputs from
  112917. */
  112918. detachControl(element: Nullable<HTMLElement>): void;
  112919. /**
  112920. * Update the current camera state depending on the inputs that have been used this frame.
  112921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112922. */
  112923. checkInputs(): void;
  112924. /**
  112925. * Gets the class name of the current intput.
  112926. * @returns the class name
  112927. */
  112928. getClassName(): string;
  112929. /**
  112930. * Get the friendly name associated with the input class.
  112931. * @returns the input friendly name
  112932. */
  112933. getSimpleName(): string;
  112934. }
  112935. }
  112936. declare module BABYLON {
  112937. interface ArcRotateCameraInputsManager {
  112938. /**
  112939. * Add orientation input support to the input manager.
  112940. * @returns the current input manager
  112941. */
  112942. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112943. }
  112944. /**
  112945. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112947. */
  112948. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112949. /**
  112950. * Defines the camera the input is attached to.
  112951. */
  112952. camera: ArcRotateCamera;
  112953. /**
  112954. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112955. */
  112956. alphaCorrection: number;
  112957. /**
  112958. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112959. */
  112960. gammaCorrection: number;
  112961. private _alpha;
  112962. private _gamma;
  112963. private _dirty;
  112964. private _deviceOrientationHandler;
  112965. /**
  112966. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112967. */
  112968. constructor();
  112969. /**
  112970. * Attach the input controls to a specific dom element to get the input from.
  112971. * @param element Defines the element the controls should be listened from
  112972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112973. */
  112974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112975. /** @hidden */
  112976. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112977. /**
  112978. * Update the current camera state depending on the inputs that have been used this frame.
  112979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112980. */
  112981. checkInputs(): void;
  112982. /**
  112983. * Detach the current controls from the specified dom element.
  112984. * @param element Defines the element to stop listening the inputs from
  112985. */
  112986. detachControl(element: Nullable<HTMLElement>): void;
  112987. /**
  112988. * Gets the class name of the current intput.
  112989. * @returns the class name
  112990. */
  112991. getClassName(): string;
  112992. /**
  112993. * Get the friendly name associated with the input class.
  112994. * @returns the input friendly name
  112995. */
  112996. getSimpleName(): string;
  112997. }
  112998. }
  112999. declare module BABYLON {
  113000. /**
  113001. * Listen to mouse events to control the camera.
  113002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113003. */
  113004. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113005. /**
  113006. * Defines the camera the input is attached to.
  113007. */
  113008. camera: FlyCamera;
  113009. /**
  113010. * Defines if touch is enabled. (Default is true.)
  113011. */
  113012. touchEnabled: boolean;
  113013. /**
  113014. * Defines the buttons associated with the input to handle camera rotation.
  113015. */
  113016. buttons: number[];
  113017. /**
  113018. * Assign buttons for Yaw control.
  113019. */
  113020. buttonsYaw: number[];
  113021. /**
  113022. * Assign buttons for Pitch control.
  113023. */
  113024. buttonsPitch: number[];
  113025. /**
  113026. * Assign buttons for Roll control.
  113027. */
  113028. buttonsRoll: number[];
  113029. /**
  113030. * Detect if any button is being pressed while mouse is moved.
  113031. * -1 = Mouse locked.
  113032. * 0 = Left button.
  113033. * 1 = Middle Button.
  113034. * 2 = Right Button.
  113035. */
  113036. activeButton: number;
  113037. /**
  113038. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113039. * Higher values reduce its sensitivity.
  113040. */
  113041. angularSensibility: number;
  113042. private _mousemoveCallback;
  113043. private _observer;
  113044. private _rollObserver;
  113045. private previousPosition;
  113046. private noPreventDefault;
  113047. private element;
  113048. /**
  113049. * Listen to mouse events to control the camera.
  113050. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113052. */
  113053. constructor(touchEnabled?: boolean);
  113054. /**
  113055. * Attach the mouse control to the HTML DOM element.
  113056. * @param element Defines the element that listens to the input events.
  113057. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113058. */
  113059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113060. /**
  113061. * Detach the current controls from the specified dom element.
  113062. * @param element Defines the element to stop listening the inputs from
  113063. */
  113064. detachControl(element: Nullable<HTMLElement>): void;
  113065. /**
  113066. * Gets the class name of the current input.
  113067. * @returns the class name.
  113068. */
  113069. getClassName(): string;
  113070. /**
  113071. * Get the friendly name associated with the input class.
  113072. * @returns the input's friendly name.
  113073. */
  113074. getSimpleName(): string;
  113075. private _pointerInput;
  113076. private _onMouseMove;
  113077. /**
  113078. * Rotate camera by mouse offset.
  113079. */
  113080. private rotateCamera;
  113081. }
  113082. }
  113083. declare module BABYLON {
  113084. /**
  113085. * Default Inputs manager for the FlyCamera.
  113086. * It groups all the default supported inputs for ease of use.
  113087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113088. */
  113089. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113090. /**
  113091. * Instantiates a new FlyCameraInputsManager.
  113092. * @param camera Defines the camera the inputs belong to.
  113093. */
  113094. constructor(camera: FlyCamera);
  113095. /**
  113096. * Add keyboard input support to the input manager.
  113097. * @returns the new FlyCameraKeyboardMoveInput().
  113098. */
  113099. addKeyboard(): FlyCameraInputsManager;
  113100. /**
  113101. * Add mouse input support to the input manager.
  113102. * @param touchEnabled Enable touch screen support.
  113103. * @returns the new FlyCameraMouseInput().
  113104. */
  113105. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113106. }
  113107. }
  113108. declare module BABYLON {
  113109. /**
  113110. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113111. * such as in a 3D Space Shooter or a Flight Simulator.
  113112. */
  113113. export class FlyCamera extends TargetCamera {
  113114. /**
  113115. * Define the collision ellipsoid of the camera.
  113116. * This is helpful for simulating a camera body, like a player's body.
  113117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113118. */
  113119. ellipsoid: Vector3;
  113120. /**
  113121. * Define an offset for the position of the ellipsoid around the camera.
  113122. * This can be helpful if the camera is attached away from the player's body center,
  113123. * such as at its head.
  113124. */
  113125. ellipsoidOffset: Vector3;
  113126. /**
  113127. * Enable or disable collisions of the camera with the rest of the scene objects.
  113128. */
  113129. checkCollisions: boolean;
  113130. /**
  113131. * Enable or disable gravity on the camera.
  113132. */
  113133. applyGravity: boolean;
  113134. /**
  113135. * Define the current direction the camera is moving to.
  113136. */
  113137. cameraDirection: Vector3;
  113138. /**
  113139. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113140. * This overrides and empties cameraRotation.
  113141. */
  113142. rotationQuaternion: Quaternion;
  113143. /**
  113144. * Track Roll to maintain the wanted Rolling when looking around.
  113145. */
  113146. _trackRoll: number;
  113147. /**
  113148. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113149. */
  113150. rollCorrect: number;
  113151. /**
  113152. * Mimic a banked turn, Rolling the camera when Yawing.
  113153. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113154. */
  113155. bankedTurn: boolean;
  113156. /**
  113157. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113158. */
  113159. bankedTurnLimit: number;
  113160. /**
  113161. * Value of 0 disables the banked Roll.
  113162. * Value of 1 is equal to the Yaw angle in radians.
  113163. */
  113164. bankedTurnMultiplier: number;
  113165. /**
  113166. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113167. */
  113168. inputs: FlyCameraInputsManager;
  113169. /**
  113170. * Gets the input sensibility for mouse input.
  113171. * Higher values reduce sensitivity.
  113172. */
  113173. get angularSensibility(): number;
  113174. /**
  113175. * Sets the input sensibility for a mouse input.
  113176. * Higher values reduce sensitivity.
  113177. */
  113178. set angularSensibility(value: number);
  113179. /**
  113180. * Get the keys for camera movement forward.
  113181. */
  113182. get keysForward(): number[];
  113183. /**
  113184. * Set the keys for camera movement forward.
  113185. */
  113186. set keysForward(value: number[]);
  113187. /**
  113188. * Get the keys for camera movement backward.
  113189. */
  113190. get keysBackward(): number[];
  113191. set keysBackward(value: number[]);
  113192. /**
  113193. * Get the keys for camera movement up.
  113194. */
  113195. get keysUp(): number[];
  113196. /**
  113197. * Set the keys for camera movement up.
  113198. */
  113199. set keysUp(value: number[]);
  113200. /**
  113201. * Get the keys for camera movement down.
  113202. */
  113203. get keysDown(): number[];
  113204. /**
  113205. * Set the keys for camera movement down.
  113206. */
  113207. set keysDown(value: number[]);
  113208. /**
  113209. * Get the keys for camera movement left.
  113210. */
  113211. get keysLeft(): number[];
  113212. /**
  113213. * Set the keys for camera movement left.
  113214. */
  113215. set keysLeft(value: number[]);
  113216. /**
  113217. * Set the keys for camera movement right.
  113218. */
  113219. get keysRight(): number[];
  113220. /**
  113221. * Set the keys for camera movement right.
  113222. */
  113223. set keysRight(value: number[]);
  113224. /**
  113225. * Event raised when the camera collides with a mesh in the scene.
  113226. */
  113227. onCollide: (collidedMesh: AbstractMesh) => void;
  113228. private _collider;
  113229. private _needMoveForGravity;
  113230. private _oldPosition;
  113231. private _diffPosition;
  113232. private _newPosition;
  113233. /** @hidden */
  113234. _localDirection: Vector3;
  113235. /** @hidden */
  113236. _transformedDirection: Vector3;
  113237. /**
  113238. * Instantiates a FlyCamera.
  113239. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113240. * such as in a 3D Space Shooter or a Flight Simulator.
  113241. * @param name Define the name of the camera in the scene.
  113242. * @param position Define the starting position of the camera in the scene.
  113243. * @param scene Define the scene the camera belongs to.
  113244. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113245. */
  113246. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113247. /**
  113248. * Attach a control to the HTML DOM element.
  113249. * @param element Defines the element that listens to the input events.
  113250. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113251. */
  113252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113253. /**
  113254. * Detach a control from the HTML DOM element.
  113255. * The camera will stop reacting to that input.
  113256. * @param element Defines the element that listens to the input events.
  113257. */
  113258. detachControl(element: HTMLElement): void;
  113259. private _collisionMask;
  113260. /**
  113261. * Get the mask that the camera ignores in collision events.
  113262. */
  113263. get collisionMask(): number;
  113264. /**
  113265. * Set the mask that the camera ignores in collision events.
  113266. */
  113267. set collisionMask(mask: number);
  113268. /** @hidden */
  113269. _collideWithWorld(displacement: Vector3): void;
  113270. /** @hidden */
  113271. private _onCollisionPositionChange;
  113272. /** @hidden */
  113273. _checkInputs(): void;
  113274. /** @hidden */
  113275. _decideIfNeedsToMove(): boolean;
  113276. /** @hidden */
  113277. _updatePosition(): void;
  113278. /**
  113279. * Restore the Roll to its target value at the rate specified.
  113280. * @param rate - Higher means slower restoring.
  113281. * @hidden
  113282. */
  113283. restoreRoll(rate: number): void;
  113284. /**
  113285. * Destroy the camera and release the current resources held by it.
  113286. */
  113287. dispose(): void;
  113288. /**
  113289. * Get the current object class name.
  113290. * @returns the class name.
  113291. */
  113292. getClassName(): string;
  113293. }
  113294. }
  113295. declare module BABYLON {
  113296. /**
  113297. * Listen to keyboard events to control the camera.
  113298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113299. */
  113300. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113301. /**
  113302. * Defines the camera the input is attached to.
  113303. */
  113304. camera: FlyCamera;
  113305. /**
  113306. * The list of keyboard keys used to control the forward move of the camera.
  113307. */
  113308. keysForward: number[];
  113309. /**
  113310. * The list of keyboard keys used to control the backward move of the camera.
  113311. */
  113312. keysBackward: number[];
  113313. /**
  113314. * The list of keyboard keys used to control the forward move of the camera.
  113315. */
  113316. keysUp: number[];
  113317. /**
  113318. * The list of keyboard keys used to control the backward move of the camera.
  113319. */
  113320. keysDown: number[];
  113321. /**
  113322. * The list of keyboard keys used to control the right strafe move of the camera.
  113323. */
  113324. keysRight: number[];
  113325. /**
  113326. * The list of keyboard keys used to control the left strafe move of the camera.
  113327. */
  113328. keysLeft: number[];
  113329. private _keys;
  113330. private _onCanvasBlurObserver;
  113331. private _onKeyboardObserver;
  113332. private _engine;
  113333. private _scene;
  113334. /**
  113335. * Attach the input controls to a specific dom element to get the input from.
  113336. * @param element Defines the element the controls should be listened from
  113337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113338. */
  113339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113340. /**
  113341. * Detach the current controls from the specified dom element.
  113342. * @param element Defines the element to stop listening the inputs from
  113343. */
  113344. detachControl(element: Nullable<HTMLElement>): void;
  113345. /**
  113346. * Gets the class name of the current intput.
  113347. * @returns the class name
  113348. */
  113349. getClassName(): string;
  113350. /** @hidden */
  113351. _onLostFocus(e: FocusEvent): void;
  113352. /**
  113353. * Get the friendly name associated with the input class.
  113354. * @returns the input friendly name
  113355. */
  113356. getSimpleName(): string;
  113357. /**
  113358. * Update the current camera state depending on the inputs that have been used this frame.
  113359. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113360. */
  113361. checkInputs(): void;
  113362. }
  113363. }
  113364. declare module BABYLON {
  113365. /**
  113366. * Manage the mouse wheel inputs to control a follow camera.
  113367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113368. */
  113369. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113370. /**
  113371. * Defines the camera the input is attached to.
  113372. */
  113373. camera: FollowCamera;
  113374. /**
  113375. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113376. */
  113377. axisControlRadius: boolean;
  113378. /**
  113379. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113380. */
  113381. axisControlHeight: boolean;
  113382. /**
  113383. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113384. */
  113385. axisControlRotation: boolean;
  113386. /**
  113387. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113388. * relation to mouseWheel events.
  113389. */
  113390. wheelPrecision: number;
  113391. /**
  113392. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113393. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113394. */
  113395. wheelDeltaPercentage: number;
  113396. private _wheel;
  113397. private _observer;
  113398. /**
  113399. * Attach the input controls to a specific dom element to get the input from.
  113400. * @param element Defines the element the controls should be listened from
  113401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113402. */
  113403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113404. /**
  113405. * Detach the current controls from the specified dom element.
  113406. * @param element Defines the element to stop listening the inputs from
  113407. */
  113408. detachControl(element: Nullable<HTMLElement>): void;
  113409. /**
  113410. * Gets the class name of the current intput.
  113411. * @returns the class name
  113412. */
  113413. getClassName(): string;
  113414. /**
  113415. * Get the friendly name associated with the input class.
  113416. * @returns the input friendly name
  113417. */
  113418. getSimpleName(): string;
  113419. }
  113420. }
  113421. declare module BABYLON {
  113422. /**
  113423. * Manage the pointers inputs to control an follow camera.
  113424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113425. */
  113426. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113427. /**
  113428. * Defines the camera the input is attached to.
  113429. */
  113430. camera: FollowCamera;
  113431. /**
  113432. * Gets the class name of the current input.
  113433. * @returns the class name
  113434. */
  113435. getClassName(): string;
  113436. /**
  113437. * Defines the pointer angular sensibility along the X axis or how fast is
  113438. * the camera rotating.
  113439. * A negative number will reverse the axis direction.
  113440. */
  113441. angularSensibilityX: number;
  113442. /**
  113443. * Defines the pointer angular sensibility along the Y axis or how fast is
  113444. * the camera rotating.
  113445. * A negative number will reverse the axis direction.
  113446. */
  113447. angularSensibilityY: number;
  113448. /**
  113449. * Defines the pointer pinch precision or how fast is the camera zooming.
  113450. * A negative number will reverse the axis direction.
  113451. */
  113452. pinchPrecision: number;
  113453. /**
  113454. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113455. * from 0.
  113456. * It defines the percentage of current camera.radius to use as delta when
  113457. * pinch zoom is used.
  113458. */
  113459. pinchDeltaPercentage: number;
  113460. /**
  113461. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113462. */
  113463. axisXControlRadius: boolean;
  113464. /**
  113465. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113466. */
  113467. axisXControlHeight: boolean;
  113468. /**
  113469. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113470. */
  113471. axisXControlRotation: boolean;
  113472. /**
  113473. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113474. */
  113475. axisYControlRadius: boolean;
  113476. /**
  113477. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113478. */
  113479. axisYControlHeight: boolean;
  113480. /**
  113481. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113482. */
  113483. axisYControlRotation: boolean;
  113484. /**
  113485. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113486. */
  113487. axisPinchControlRadius: boolean;
  113488. /**
  113489. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113490. */
  113491. axisPinchControlHeight: boolean;
  113492. /**
  113493. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113494. */
  113495. axisPinchControlRotation: boolean;
  113496. /**
  113497. * Log error messages if basic misconfiguration has occurred.
  113498. */
  113499. warningEnable: boolean;
  113500. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113501. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113502. private _warningCounter;
  113503. private _warning;
  113504. }
  113505. }
  113506. declare module BABYLON {
  113507. /**
  113508. * Default Inputs manager for the FollowCamera.
  113509. * It groups all the default supported inputs for ease of use.
  113510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113511. */
  113512. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113513. /**
  113514. * Instantiates a new FollowCameraInputsManager.
  113515. * @param camera Defines the camera the inputs belong to
  113516. */
  113517. constructor(camera: FollowCamera);
  113518. /**
  113519. * Add keyboard input support to the input manager.
  113520. * @returns the current input manager
  113521. */
  113522. addKeyboard(): FollowCameraInputsManager;
  113523. /**
  113524. * Add mouse wheel input support to the input manager.
  113525. * @returns the current input manager
  113526. */
  113527. addMouseWheel(): FollowCameraInputsManager;
  113528. /**
  113529. * Add pointers input support to the input manager.
  113530. * @returns the current input manager
  113531. */
  113532. addPointers(): FollowCameraInputsManager;
  113533. /**
  113534. * Add orientation input support to the input manager.
  113535. * @returns the current input manager
  113536. */
  113537. addVRDeviceOrientation(): FollowCameraInputsManager;
  113538. }
  113539. }
  113540. declare module BABYLON {
  113541. /**
  113542. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113543. * an arc rotate version arcFollowCamera are available.
  113544. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113545. */
  113546. export class FollowCamera extends TargetCamera {
  113547. /**
  113548. * Distance the follow camera should follow an object at
  113549. */
  113550. radius: number;
  113551. /**
  113552. * Minimum allowed distance of the camera to the axis of rotation
  113553. * (The camera can not get closer).
  113554. * This can help limiting how the Camera is able to move in the scene.
  113555. */
  113556. lowerRadiusLimit: Nullable<number>;
  113557. /**
  113558. * Maximum allowed distance of the camera to the axis of rotation
  113559. * (The camera can not get further).
  113560. * This can help limiting how the Camera is able to move in the scene.
  113561. */
  113562. upperRadiusLimit: Nullable<number>;
  113563. /**
  113564. * Define a rotation offset between the camera and the object it follows
  113565. */
  113566. rotationOffset: number;
  113567. /**
  113568. * Minimum allowed angle to camera position relative to target object.
  113569. * This can help limiting how the Camera is able to move in the scene.
  113570. */
  113571. lowerRotationOffsetLimit: Nullable<number>;
  113572. /**
  113573. * Maximum allowed angle to camera position relative to target object.
  113574. * This can help limiting how the Camera is able to move in the scene.
  113575. */
  113576. upperRotationOffsetLimit: Nullable<number>;
  113577. /**
  113578. * Define a height offset between the camera and the object it follows.
  113579. * It can help following an object from the top (like a car chaing a plane)
  113580. */
  113581. heightOffset: number;
  113582. /**
  113583. * Minimum allowed height of camera position relative to target object.
  113584. * This can help limiting how the Camera is able to move in the scene.
  113585. */
  113586. lowerHeightOffsetLimit: Nullable<number>;
  113587. /**
  113588. * Maximum allowed height of camera position relative to target object.
  113589. * This can help limiting how the Camera is able to move in the scene.
  113590. */
  113591. upperHeightOffsetLimit: Nullable<number>;
  113592. /**
  113593. * Define how fast the camera can accelerate to follow it s target.
  113594. */
  113595. cameraAcceleration: number;
  113596. /**
  113597. * Define the speed limit of the camera following an object.
  113598. */
  113599. maxCameraSpeed: number;
  113600. /**
  113601. * Define the target of the camera.
  113602. */
  113603. lockedTarget: Nullable<AbstractMesh>;
  113604. /**
  113605. * Defines the input associated with the camera.
  113606. */
  113607. inputs: FollowCameraInputsManager;
  113608. /**
  113609. * Instantiates the follow camera.
  113610. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113611. * @param name Define the name of the camera in the scene
  113612. * @param position Define the position of the camera
  113613. * @param scene Define the scene the camera belong to
  113614. * @param lockedTarget Define the target of the camera
  113615. */
  113616. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113617. private _follow;
  113618. /**
  113619. * Attached controls to the current camera.
  113620. * @param element Defines the element the controls should be listened from
  113621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113622. */
  113623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113624. /**
  113625. * Detach the current controls from the camera.
  113626. * The camera will stop reacting to inputs.
  113627. * @param element Defines the element to stop listening the inputs from
  113628. */
  113629. detachControl(element: HTMLElement): void;
  113630. /** @hidden */
  113631. _checkInputs(): void;
  113632. private _checkLimits;
  113633. /**
  113634. * Gets the camera class name.
  113635. * @returns the class name
  113636. */
  113637. getClassName(): string;
  113638. }
  113639. /**
  113640. * Arc Rotate version of the follow camera.
  113641. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113642. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113643. */
  113644. export class ArcFollowCamera extends TargetCamera {
  113645. /** The longitudinal angle of the camera */
  113646. alpha: number;
  113647. /** The latitudinal angle of the camera */
  113648. beta: number;
  113649. /** The radius of the camera from its target */
  113650. radius: number;
  113651. /** Define the camera target (the messh it should follow) */
  113652. target: Nullable<AbstractMesh>;
  113653. private _cartesianCoordinates;
  113654. /**
  113655. * Instantiates a new ArcFollowCamera
  113656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113657. * @param name Define the name of the camera
  113658. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113659. * @param beta Define the rotation angle of the camera around the elevation axis
  113660. * @param radius Define the radius of the camera from its target point
  113661. * @param target Define the target of the camera
  113662. * @param scene Define the scene the camera belongs to
  113663. */
  113664. constructor(name: string,
  113665. /** The longitudinal angle of the camera */
  113666. alpha: number,
  113667. /** The latitudinal angle of the camera */
  113668. beta: number,
  113669. /** The radius of the camera from its target */
  113670. radius: number,
  113671. /** Define the camera target (the messh it should follow) */
  113672. target: Nullable<AbstractMesh>, scene: Scene);
  113673. private _follow;
  113674. /** @hidden */
  113675. _checkInputs(): void;
  113676. /**
  113677. * Returns the class name of the object.
  113678. * It is mostly used internally for serialization purposes.
  113679. */
  113680. getClassName(): string;
  113681. }
  113682. }
  113683. declare module BABYLON {
  113684. /**
  113685. * Manage the keyboard inputs to control the movement of a follow camera.
  113686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113687. */
  113688. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113689. /**
  113690. * Defines the camera the input is attached to.
  113691. */
  113692. camera: FollowCamera;
  113693. /**
  113694. * Defines the list of key codes associated with the up action (increase heightOffset)
  113695. */
  113696. keysHeightOffsetIncr: number[];
  113697. /**
  113698. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113699. */
  113700. keysHeightOffsetDecr: number[];
  113701. /**
  113702. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113703. */
  113704. keysHeightOffsetModifierAlt: boolean;
  113705. /**
  113706. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113707. */
  113708. keysHeightOffsetModifierCtrl: boolean;
  113709. /**
  113710. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113711. */
  113712. keysHeightOffsetModifierShift: boolean;
  113713. /**
  113714. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113715. */
  113716. keysRotationOffsetIncr: number[];
  113717. /**
  113718. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113719. */
  113720. keysRotationOffsetDecr: number[];
  113721. /**
  113722. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113723. */
  113724. keysRotationOffsetModifierAlt: boolean;
  113725. /**
  113726. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113727. */
  113728. keysRotationOffsetModifierCtrl: boolean;
  113729. /**
  113730. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113731. */
  113732. keysRotationOffsetModifierShift: boolean;
  113733. /**
  113734. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113735. */
  113736. keysRadiusIncr: number[];
  113737. /**
  113738. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113739. */
  113740. keysRadiusDecr: number[];
  113741. /**
  113742. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113743. */
  113744. keysRadiusModifierAlt: boolean;
  113745. /**
  113746. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113747. */
  113748. keysRadiusModifierCtrl: boolean;
  113749. /**
  113750. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113751. */
  113752. keysRadiusModifierShift: boolean;
  113753. /**
  113754. * Defines the rate of change of heightOffset.
  113755. */
  113756. heightSensibility: number;
  113757. /**
  113758. * Defines the rate of change of rotationOffset.
  113759. */
  113760. rotationSensibility: number;
  113761. /**
  113762. * Defines the rate of change of radius.
  113763. */
  113764. radiusSensibility: number;
  113765. private _keys;
  113766. private _ctrlPressed;
  113767. private _altPressed;
  113768. private _shiftPressed;
  113769. private _onCanvasBlurObserver;
  113770. private _onKeyboardObserver;
  113771. private _engine;
  113772. private _scene;
  113773. /**
  113774. * Attach the input controls to a specific dom element to get the input from.
  113775. * @param element Defines the element the controls should be listened from
  113776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113777. */
  113778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113779. /**
  113780. * Detach the current controls from the specified dom element.
  113781. * @param element Defines the element to stop listening the inputs from
  113782. */
  113783. detachControl(element: Nullable<HTMLElement>): void;
  113784. /**
  113785. * Update the current camera state depending on the inputs that have been used this frame.
  113786. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113787. */
  113788. checkInputs(): void;
  113789. /**
  113790. * Gets the class name of the current input.
  113791. * @returns the class name
  113792. */
  113793. getClassName(): string;
  113794. /**
  113795. * Get the friendly name associated with the input class.
  113796. * @returns the input friendly name
  113797. */
  113798. getSimpleName(): string;
  113799. /**
  113800. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113801. * allow modification of the heightOffset value.
  113802. */
  113803. private _modifierHeightOffset;
  113804. /**
  113805. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113806. * allow modification of the rotationOffset value.
  113807. */
  113808. private _modifierRotationOffset;
  113809. /**
  113810. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113811. * allow modification of the radius value.
  113812. */
  113813. private _modifierRadius;
  113814. }
  113815. }
  113816. declare module BABYLON {
  113817. interface FreeCameraInputsManager {
  113818. /**
  113819. * @hidden
  113820. */
  113821. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113822. /**
  113823. * Add orientation input support to the input manager.
  113824. * @returns the current input manager
  113825. */
  113826. addDeviceOrientation(): FreeCameraInputsManager;
  113827. }
  113828. /**
  113829. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113830. * Screen rotation is taken into account.
  113831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113832. */
  113833. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113834. private _camera;
  113835. private _screenOrientationAngle;
  113836. private _constantTranform;
  113837. private _screenQuaternion;
  113838. private _alpha;
  113839. private _beta;
  113840. private _gamma;
  113841. /**
  113842. * Can be used to detect if a device orientation sensor is available on a device
  113843. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113844. * @returns a promise that will resolve on orientation change
  113845. */
  113846. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113847. /**
  113848. * @hidden
  113849. */
  113850. _onDeviceOrientationChangedObservable: Observable<void>;
  113851. /**
  113852. * Instantiates a new input
  113853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113854. */
  113855. constructor();
  113856. /**
  113857. * Define the camera controlled by the input.
  113858. */
  113859. get camera(): FreeCamera;
  113860. set camera(camera: FreeCamera);
  113861. /**
  113862. * Attach the input controls to a specific dom element to get the input from.
  113863. * @param element Defines the element the controls should be listened from
  113864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113865. */
  113866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113867. private _orientationChanged;
  113868. private _deviceOrientation;
  113869. /**
  113870. * Detach the current controls from the specified dom element.
  113871. * @param element Defines the element to stop listening the inputs from
  113872. */
  113873. detachControl(element: Nullable<HTMLElement>): void;
  113874. /**
  113875. * Update the current camera state depending on the inputs that have been used this frame.
  113876. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113877. */
  113878. checkInputs(): void;
  113879. /**
  113880. * Gets the class name of the current intput.
  113881. * @returns the class name
  113882. */
  113883. getClassName(): string;
  113884. /**
  113885. * Get the friendly name associated with the input class.
  113886. * @returns the input friendly name
  113887. */
  113888. getSimpleName(): string;
  113889. }
  113890. }
  113891. declare module BABYLON {
  113892. /**
  113893. * Manage the gamepad inputs to control a free camera.
  113894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113895. */
  113896. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113897. /**
  113898. * Define the camera the input is attached to.
  113899. */
  113900. camera: FreeCamera;
  113901. /**
  113902. * Define the Gamepad controlling the input
  113903. */
  113904. gamepad: Nullable<Gamepad>;
  113905. /**
  113906. * Defines the gamepad rotation sensiblity.
  113907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113908. */
  113909. gamepadAngularSensibility: number;
  113910. /**
  113911. * Defines the gamepad move sensiblity.
  113912. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113913. */
  113914. gamepadMoveSensibility: number;
  113915. private _yAxisScale;
  113916. /**
  113917. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113918. */
  113919. get invertYAxis(): boolean;
  113920. set invertYAxis(value: boolean);
  113921. private _onGamepadConnectedObserver;
  113922. private _onGamepadDisconnectedObserver;
  113923. private _cameraTransform;
  113924. private _deltaTransform;
  113925. private _vector3;
  113926. private _vector2;
  113927. /**
  113928. * Attach the input controls to a specific dom element to get the input from.
  113929. * @param element Defines the element the controls should be listened from
  113930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113931. */
  113932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113933. /**
  113934. * Detach the current controls from the specified dom element.
  113935. * @param element Defines the element to stop listening the inputs from
  113936. */
  113937. detachControl(element: Nullable<HTMLElement>): void;
  113938. /**
  113939. * Update the current camera state depending on the inputs that have been used this frame.
  113940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113941. */
  113942. checkInputs(): void;
  113943. /**
  113944. * Gets the class name of the current intput.
  113945. * @returns the class name
  113946. */
  113947. getClassName(): string;
  113948. /**
  113949. * Get the friendly name associated with the input class.
  113950. * @returns the input friendly name
  113951. */
  113952. getSimpleName(): string;
  113953. }
  113954. }
  113955. declare module BABYLON {
  113956. /**
  113957. * Defines the potential axis of a Joystick
  113958. */
  113959. export enum JoystickAxis {
  113960. /** X axis */
  113961. X = 0,
  113962. /** Y axis */
  113963. Y = 1,
  113964. /** Z axis */
  113965. Z = 2
  113966. }
  113967. /**
  113968. * Class used to define virtual joystick (used in touch mode)
  113969. */
  113970. export class VirtualJoystick {
  113971. /**
  113972. * Gets or sets a boolean indicating that left and right values must be inverted
  113973. */
  113974. reverseLeftRight: boolean;
  113975. /**
  113976. * Gets or sets a boolean indicating that up and down values must be inverted
  113977. */
  113978. reverseUpDown: boolean;
  113979. /**
  113980. * Gets the offset value for the position (ie. the change of the position value)
  113981. */
  113982. deltaPosition: Vector3;
  113983. /**
  113984. * Gets a boolean indicating if the virtual joystick was pressed
  113985. */
  113986. pressed: boolean;
  113987. /**
  113988. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113989. */
  113990. static Canvas: Nullable<HTMLCanvasElement>;
  113991. private static _globalJoystickIndex;
  113992. private static vjCanvasContext;
  113993. private static vjCanvasWidth;
  113994. private static vjCanvasHeight;
  113995. private static halfWidth;
  113996. private _action;
  113997. private _axisTargetedByLeftAndRight;
  113998. private _axisTargetedByUpAndDown;
  113999. private _joystickSensibility;
  114000. private _inversedSensibility;
  114001. private _joystickPointerID;
  114002. private _joystickColor;
  114003. private _joystickPointerPos;
  114004. private _joystickPreviousPointerPos;
  114005. private _joystickPointerStartPos;
  114006. private _deltaJoystickVector;
  114007. private _leftJoystick;
  114008. private _touches;
  114009. private _onPointerDownHandlerRef;
  114010. private _onPointerMoveHandlerRef;
  114011. private _onPointerUpHandlerRef;
  114012. private _onResize;
  114013. /**
  114014. * Creates a new virtual joystick
  114015. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114016. */
  114017. constructor(leftJoystick?: boolean);
  114018. /**
  114019. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114020. * @param newJoystickSensibility defines the new sensibility
  114021. */
  114022. setJoystickSensibility(newJoystickSensibility: number): void;
  114023. private _onPointerDown;
  114024. private _onPointerMove;
  114025. private _onPointerUp;
  114026. /**
  114027. * Change the color of the virtual joystick
  114028. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114029. */
  114030. setJoystickColor(newColor: string): void;
  114031. /**
  114032. * Defines a callback to call when the joystick is touched
  114033. * @param action defines the callback
  114034. */
  114035. setActionOnTouch(action: () => any): void;
  114036. /**
  114037. * Defines which axis you'd like to control for left & right
  114038. * @param axis defines the axis to use
  114039. */
  114040. setAxisForLeftRight(axis: JoystickAxis): void;
  114041. /**
  114042. * Defines which axis you'd like to control for up & down
  114043. * @param axis defines the axis to use
  114044. */
  114045. setAxisForUpDown(axis: JoystickAxis): void;
  114046. private _drawVirtualJoystick;
  114047. /**
  114048. * Release internal HTML canvas
  114049. */
  114050. releaseCanvas(): void;
  114051. }
  114052. }
  114053. declare module BABYLON {
  114054. interface FreeCameraInputsManager {
  114055. /**
  114056. * Add virtual joystick input support to the input manager.
  114057. * @returns the current input manager
  114058. */
  114059. addVirtualJoystick(): FreeCameraInputsManager;
  114060. }
  114061. /**
  114062. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114064. */
  114065. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114066. /**
  114067. * Defines the camera the input is attached to.
  114068. */
  114069. camera: FreeCamera;
  114070. private _leftjoystick;
  114071. private _rightjoystick;
  114072. /**
  114073. * Gets the left stick of the virtual joystick.
  114074. * @returns The virtual Joystick
  114075. */
  114076. getLeftJoystick(): VirtualJoystick;
  114077. /**
  114078. * Gets the right stick of the virtual joystick.
  114079. * @returns The virtual Joystick
  114080. */
  114081. getRightJoystick(): VirtualJoystick;
  114082. /**
  114083. * Update the current camera state depending on the inputs that have been used this frame.
  114084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114085. */
  114086. checkInputs(): void;
  114087. /**
  114088. * Attach the input controls to a specific dom element to get the input from.
  114089. * @param element Defines the element the controls should be listened from
  114090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114091. */
  114092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114093. /**
  114094. * Detach the current controls from the specified dom element.
  114095. * @param element Defines the element to stop listening the inputs from
  114096. */
  114097. detachControl(element: Nullable<HTMLElement>): void;
  114098. /**
  114099. * Gets the class name of the current intput.
  114100. * @returns the class name
  114101. */
  114102. getClassName(): string;
  114103. /**
  114104. * Get the friendly name associated with the input class.
  114105. * @returns the input friendly name
  114106. */
  114107. getSimpleName(): string;
  114108. }
  114109. }
  114110. declare module BABYLON {
  114111. /**
  114112. * This represents a FPS type of camera controlled by touch.
  114113. * This is like a universal camera minus the Gamepad controls.
  114114. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114115. */
  114116. export class TouchCamera extends FreeCamera {
  114117. /**
  114118. * Defines the touch sensibility for rotation.
  114119. * The higher the faster.
  114120. */
  114121. get touchAngularSensibility(): number;
  114122. set touchAngularSensibility(value: number);
  114123. /**
  114124. * Defines the touch sensibility for move.
  114125. * The higher the faster.
  114126. */
  114127. get touchMoveSensibility(): number;
  114128. set touchMoveSensibility(value: number);
  114129. /**
  114130. * Instantiates a new touch camera.
  114131. * This represents a FPS type of camera controlled by touch.
  114132. * This is like a universal camera minus the Gamepad controls.
  114133. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114134. * @param name Define the name of the camera in the scene
  114135. * @param position Define the start position of the camera in the scene
  114136. * @param scene Define the scene the camera belongs to
  114137. */
  114138. constructor(name: string, position: Vector3, scene: Scene);
  114139. /**
  114140. * Gets the current object class name.
  114141. * @return the class name
  114142. */
  114143. getClassName(): string;
  114144. /** @hidden */
  114145. _setupInputs(): void;
  114146. }
  114147. }
  114148. declare module BABYLON {
  114149. /**
  114150. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114151. * being tilted forward or back and left or right.
  114152. */
  114153. export class DeviceOrientationCamera extends FreeCamera {
  114154. private _initialQuaternion;
  114155. private _quaternionCache;
  114156. private _tmpDragQuaternion;
  114157. private _disablePointerInputWhenUsingDeviceOrientation;
  114158. /**
  114159. * Creates a new device orientation camera
  114160. * @param name The name of the camera
  114161. * @param position The start position camera
  114162. * @param scene The scene the camera belongs to
  114163. */
  114164. constructor(name: string, position: Vector3, scene: Scene);
  114165. /**
  114166. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114167. */
  114168. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114169. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114170. private _dragFactor;
  114171. /**
  114172. * Enabled turning on the y axis when the orientation sensor is active
  114173. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114174. */
  114175. enableHorizontalDragging(dragFactor?: number): void;
  114176. /**
  114177. * Gets the current instance class name ("DeviceOrientationCamera").
  114178. * This helps avoiding instanceof at run time.
  114179. * @returns the class name
  114180. */
  114181. getClassName(): string;
  114182. /**
  114183. * @hidden
  114184. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114185. */
  114186. _checkInputs(): void;
  114187. /**
  114188. * Reset the camera to its default orientation on the specified axis only.
  114189. * @param axis The axis to reset
  114190. */
  114191. resetToCurrentRotation(axis?: Axis): void;
  114192. }
  114193. }
  114194. declare module BABYLON {
  114195. /**
  114196. * Defines supported buttons for XBox360 compatible gamepads
  114197. */
  114198. export enum Xbox360Button {
  114199. /** A */
  114200. A = 0,
  114201. /** B */
  114202. B = 1,
  114203. /** X */
  114204. X = 2,
  114205. /** Y */
  114206. Y = 3,
  114207. /** Left button */
  114208. LB = 4,
  114209. /** Right button */
  114210. RB = 5,
  114211. /** Back */
  114212. Back = 8,
  114213. /** Start */
  114214. Start = 9,
  114215. /** Left stick */
  114216. LeftStick = 10,
  114217. /** Right stick */
  114218. RightStick = 11
  114219. }
  114220. /** Defines values for XBox360 DPad */
  114221. export enum Xbox360Dpad {
  114222. /** Up */
  114223. Up = 12,
  114224. /** Down */
  114225. Down = 13,
  114226. /** Left */
  114227. Left = 14,
  114228. /** Right */
  114229. Right = 15
  114230. }
  114231. /**
  114232. * Defines a XBox360 gamepad
  114233. */
  114234. export class Xbox360Pad extends Gamepad {
  114235. private _leftTrigger;
  114236. private _rightTrigger;
  114237. private _onlefttriggerchanged;
  114238. private _onrighttriggerchanged;
  114239. private _onbuttondown;
  114240. private _onbuttonup;
  114241. private _ondpaddown;
  114242. private _ondpadup;
  114243. /** Observable raised when a button is pressed */
  114244. onButtonDownObservable: Observable<Xbox360Button>;
  114245. /** Observable raised when a button is released */
  114246. onButtonUpObservable: Observable<Xbox360Button>;
  114247. /** Observable raised when a pad is pressed */
  114248. onPadDownObservable: Observable<Xbox360Dpad>;
  114249. /** Observable raised when a pad is released */
  114250. onPadUpObservable: Observable<Xbox360Dpad>;
  114251. private _buttonA;
  114252. private _buttonB;
  114253. private _buttonX;
  114254. private _buttonY;
  114255. private _buttonBack;
  114256. private _buttonStart;
  114257. private _buttonLB;
  114258. private _buttonRB;
  114259. private _buttonLeftStick;
  114260. private _buttonRightStick;
  114261. private _dPadUp;
  114262. private _dPadDown;
  114263. private _dPadLeft;
  114264. private _dPadRight;
  114265. private _isXboxOnePad;
  114266. /**
  114267. * Creates a new XBox360 gamepad object
  114268. * @param id defines the id of this gamepad
  114269. * @param index defines its index
  114270. * @param gamepad defines the internal HTML gamepad object
  114271. * @param xboxOne defines if it is a XBox One gamepad
  114272. */
  114273. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114274. /**
  114275. * Defines the callback to call when left trigger is pressed
  114276. * @param callback defines the callback to use
  114277. */
  114278. onlefttriggerchanged(callback: (value: number) => void): void;
  114279. /**
  114280. * Defines the callback to call when right trigger is pressed
  114281. * @param callback defines the callback to use
  114282. */
  114283. onrighttriggerchanged(callback: (value: number) => void): void;
  114284. /**
  114285. * Gets the left trigger value
  114286. */
  114287. get leftTrigger(): number;
  114288. /**
  114289. * Sets the left trigger value
  114290. */
  114291. set leftTrigger(newValue: number);
  114292. /**
  114293. * Gets the right trigger value
  114294. */
  114295. get rightTrigger(): number;
  114296. /**
  114297. * Sets the right trigger value
  114298. */
  114299. set rightTrigger(newValue: number);
  114300. /**
  114301. * Defines the callback to call when a button is pressed
  114302. * @param callback defines the callback to use
  114303. */
  114304. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114305. /**
  114306. * Defines the callback to call when a button is released
  114307. * @param callback defines the callback to use
  114308. */
  114309. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114310. /**
  114311. * Defines the callback to call when a pad is pressed
  114312. * @param callback defines the callback to use
  114313. */
  114314. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114315. /**
  114316. * Defines the callback to call when a pad is released
  114317. * @param callback defines the callback to use
  114318. */
  114319. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114320. private _setButtonValue;
  114321. private _setDPadValue;
  114322. /**
  114323. * Gets the value of the `A` button
  114324. */
  114325. get buttonA(): number;
  114326. /**
  114327. * Sets the value of the `A` button
  114328. */
  114329. set buttonA(value: number);
  114330. /**
  114331. * Gets the value of the `B` button
  114332. */
  114333. get buttonB(): number;
  114334. /**
  114335. * Sets the value of the `B` button
  114336. */
  114337. set buttonB(value: number);
  114338. /**
  114339. * Gets the value of the `X` button
  114340. */
  114341. get buttonX(): number;
  114342. /**
  114343. * Sets the value of the `X` button
  114344. */
  114345. set buttonX(value: number);
  114346. /**
  114347. * Gets the value of the `Y` button
  114348. */
  114349. get buttonY(): number;
  114350. /**
  114351. * Sets the value of the `Y` button
  114352. */
  114353. set buttonY(value: number);
  114354. /**
  114355. * Gets the value of the `Start` button
  114356. */
  114357. get buttonStart(): number;
  114358. /**
  114359. * Sets the value of the `Start` button
  114360. */
  114361. set buttonStart(value: number);
  114362. /**
  114363. * Gets the value of the `Back` button
  114364. */
  114365. get buttonBack(): number;
  114366. /**
  114367. * Sets the value of the `Back` button
  114368. */
  114369. set buttonBack(value: number);
  114370. /**
  114371. * Gets the value of the `Left` button
  114372. */
  114373. get buttonLB(): number;
  114374. /**
  114375. * Sets the value of the `Left` button
  114376. */
  114377. set buttonLB(value: number);
  114378. /**
  114379. * Gets the value of the `Right` button
  114380. */
  114381. get buttonRB(): number;
  114382. /**
  114383. * Sets the value of the `Right` button
  114384. */
  114385. set buttonRB(value: number);
  114386. /**
  114387. * Gets the value of the Left joystick
  114388. */
  114389. get buttonLeftStick(): number;
  114390. /**
  114391. * Sets the value of the Left joystick
  114392. */
  114393. set buttonLeftStick(value: number);
  114394. /**
  114395. * Gets the value of the Right joystick
  114396. */
  114397. get buttonRightStick(): number;
  114398. /**
  114399. * Sets the value of the Right joystick
  114400. */
  114401. set buttonRightStick(value: number);
  114402. /**
  114403. * Gets the value of D-pad up
  114404. */
  114405. get dPadUp(): number;
  114406. /**
  114407. * Sets the value of D-pad up
  114408. */
  114409. set dPadUp(value: number);
  114410. /**
  114411. * Gets the value of D-pad down
  114412. */
  114413. get dPadDown(): number;
  114414. /**
  114415. * Sets the value of D-pad down
  114416. */
  114417. set dPadDown(value: number);
  114418. /**
  114419. * Gets the value of D-pad left
  114420. */
  114421. get dPadLeft(): number;
  114422. /**
  114423. * Sets the value of D-pad left
  114424. */
  114425. set dPadLeft(value: number);
  114426. /**
  114427. * Gets the value of D-pad right
  114428. */
  114429. get dPadRight(): number;
  114430. /**
  114431. * Sets the value of D-pad right
  114432. */
  114433. set dPadRight(value: number);
  114434. /**
  114435. * Force the gamepad to synchronize with device values
  114436. */
  114437. update(): void;
  114438. /**
  114439. * Disposes the gamepad
  114440. */
  114441. dispose(): void;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /**
  114446. * Defines supported buttons for DualShock compatible gamepads
  114447. */
  114448. export enum DualShockButton {
  114449. /** Cross */
  114450. Cross = 0,
  114451. /** Circle */
  114452. Circle = 1,
  114453. /** Square */
  114454. Square = 2,
  114455. /** Triangle */
  114456. Triangle = 3,
  114457. /** L1 */
  114458. L1 = 4,
  114459. /** R1 */
  114460. R1 = 5,
  114461. /** Share */
  114462. Share = 8,
  114463. /** Options */
  114464. Options = 9,
  114465. /** Left stick */
  114466. LeftStick = 10,
  114467. /** Right stick */
  114468. RightStick = 11
  114469. }
  114470. /** Defines values for DualShock DPad */
  114471. export enum DualShockDpad {
  114472. /** Up */
  114473. Up = 12,
  114474. /** Down */
  114475. Down = 13,
  114476. /** Left */
  114477. Left = 14,
  114478. /** Right */
  114479. Right = 15
  114480. }
  114481. /**
  114482. * Defines a DualShock gamepad
  114483. */
  114484. export class DualShockPad extends Gamepad {
  114485. private _leftTrigger;
  114486. private _rightTrigger;
  114487. private _onlefttriggerchanged;
  114488. private _onrighttriggerchanged;
  114489. private _onbuttondown;
  114490. private _onbuttonup;
  114491. private _ondpaddown;
  114492. private _ondpadup;
  114493. /** Observable raised when a button is pressed */
  114494. onButtonDownObservable: Observable<DualShockButton>;
  114495. /** Observable raised when a button is released */
  114496. onButtonUpObservable: Observable<DualShockButton>;
  114497. /** Observable raised when a pad is pressed */
  114498. onPadDownObservable: Observable<DualShockDpad>;
  114499. /** Observable raised when a pad is released */
  114500. onPadUpObservable: Observable<DualShockDpad>;
  114501. private _buttonCross;
  114502. private _buttonCircle;
  114503. private _buttonSquare;
  114504. private _buttonTriangle;
  114505. private _buttonShare;
  114506. private _buttonOptions;
  114507. private _buttonL1;
  114508. private _buttonR1;
  114509. private _buttonLeftStick;
  114510. private _buttonRightStick;
  114511. private _dPadUp;
  114512. private _dPadDown;
  114513. private _dPadLeft;
  114514. private _dPadRight;
  114515. /**
  114516. * Creates a new DualShock gamepad object
  114517. * @param id defines the id of this gamepad
  114518. * @param index defines its index
  114519. * @param gamepad defines the internal HTML gamepad object
  114520. */
  114521. constructor(id: string, index: number, gamepad: any);
  114522. /**
  114523. * Defines the callback to call when left trigger is pressed
  114524. * @param callback defines the callback to use
  114525. */
  114526. onlefttriggerchanged(callback: (value: number) => void): void;
  114527. /**
  114528. * Defines the callback to call when right trigger is pressed
  114529. * @param callback defines the callback to use
  114530. */
  114531. onrighttriggerchanged(callback: (value: number) => void): void;
  114532. /**
  114533. * Gets the left trigger value
  114534. */
  114535. get leftTrigger(): number;
  114536. /**
  114537. * Sets the left trigger value
  114538. */
  114539. set leftTrigger(newValue: number);
  114540. /**
  114541. * Gets the right trigger value
  114542. */
  114543. get rightTrigger(): number;
  114544. /**
  114545. * Sets the right trigger value
  114546. */
  114547. set rightTrigger(newValue: number);
  114548. /**
  114549. * Defines the callback to call when a button is pressed
  114550. * @param callback defines the callback to use
  114551. */
  114552. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114553. /**
  114554. * Defines the callback to call when a button is released
  114555. * @param callback defines the callback to use
  114556. */
  114557. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114558. /**
  114559. * Defines the callback to call when a pad is pressed
  114560. * @param callback defines the callback to use
  114561. */
  114562. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114563. /**
  114564. * Defines the callback to call when a pad is released
  114565. * @param callback defines the callback to use
  114566. */
  114567. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114568. private _setButtonValue;
  114569. private _setDPadValue;
  114570. /**
  114571. * Gets the value of the `Cross` button
  114572. */
  114573. get buttonCross(): number;
  114574. /**
  114575. * Sets the value of the `Cross` button
  114576. */
  114577. set buttonCross(value: number);
  114578. /**
  114579. * Gets the value of the `Circle` button
  114580. */
  114581. get buttonCircle(): number;
  114582. /**
  114583. * Sets the value of the `Circle` button
  114584. */
  114585. set buttonCircle(value: number);
  114586. /**
  114587. * Gets the value of the `Square` button
  114588. */
  114589. get buttonSquare(): number;
  114590. /**
  114591. * Sets the value of the `Square` button
  114592. */
  114593. set buttonSquare(value: number);
  114594. /**
  114595. * Gets the value of the `Triangle` button
  114596. */
  114597. get buttonTriangle(): number;
  114598. /**
  114599. * Sets the value of the `Triangle` button
  114600. */
  114601. set buttonTriangle(value: number);
  114602. /**
  114603. * Gets the value of the `Options` button
  114604. */
  114605. get buttonOptions(): number;
  114606. /**
  114607. * Sets the value of the `Options` button
  114608. */
  114609. set buttonOptions(value: number);
  114610. /**
  114611. * Gets the value of the `Share` button
  114612. */
  114613. get buttonShare(): number;
  114614. /**
  114615. * Sets the value of the `Share` button
  114616. */
  114617. set buttonShare(value: number);
  114618. /**
  114619. * Gets the value of the `L1` button
  114620. */
  114621. get buttonL1(): number;
  114622. /**
  114623. * Sets the value of the `L1` button
  114624. */
  114625. set buttonL1(value: number);
  114626. /**
  114627. * Gets the value of the `R1` button
  114628. */
  114629. get buttonR1(): number;
  114630. /**
  114631. * Sets the value of the `R1` button
  114632. */
  114633. set buttonR1(value: number);
  114634. /**
  114635. * Gets the value of the Left joystick
  114636. */
  114637. get buttonLeftStick(): number;
  114638. /**
  114639. * Sets the value of the Left joystick
  114640. */
  114641. set buttonLeftStick(value: number);
  114642. /**
  114643. * Gets the value of the Right joystick
  114644. */
  114645. get buttonRightStick(): number;
  114646. /**
  114647. * Sets the value of the Right joystick
  114648. */
  114649. set buttonRightStick(value: number);
  114650. /**
  114651. * Gets the value of D-pad up
  114652. */
  114653. get dPadUp(): number;
  114654. /**
  114655. * Sets the value of D-pad up
  114656. */
  114657. set dPadUp(value: number);
  114658. /**
  114659. * Gets the value of D-pad down
  114660. */
  114661. get dPadDown(): number;
  114662. /**
  114663. * Sets the value of D-pad down
  114664. */
  114665. set dPadDown(value: number);
  114666. /**
  114667. * Gets the value of D-pad left
  114668. */
  114669. get dPadLeft(): number;
  114670. /**
  114671. * Sets the value of D-pad left
  114672. */
  114673. set dPadLeft(value: number);
  114674. /**
  114675. * Gets the value of D-pad right
  114676. */
  114677. get dPadRight(): number;
  114678. /**
  114679. * Sets the value of D-pad right
  114680. */
  114681. set dPadRight(value: number);
  114682. /**
  114683. * Force the gamepad to synchronize with device values
  114684. */
  114685. update(): void;
  114686. /**
  114687. * Disposes the gamepad
  114688. */
  114689. dispose(): void;
  114690. }
  114691. }
  114692. declare module BABYLON {
  114693. /**
  114694. * Manager for handling gamepads
  114695. */
  114696. export class GamepadManager {
  114697. private _scene?;
  114698. private _babylonGamepads;
  114699. private _oneGamepadConnected;
  114700. /** @hidden */
  114701. _isMonitoring: boolean;
  114702. private _gamepadEventSupported;
  114703. private _gamepadSupport?;
  114704. /**
  114705. * observable to be triggered when the gamepad controller has been connected
  114706. */
  114707. onGamepadConnectedObservable: Observable<Gamepad>;
  114708. /**
  114709. * observable to be triggered when the gamepad controller has been disconnected
  114710. */
  114711. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114712. private _onGamepadConnectedEvent;
  114713. private _onGamepadDisconnectedEvent;
  114714. /**
  114715. * Initializes the gamepad manager
  114716. * @param _scene BabylonJS scene
  114717. */
  114718. constructor(_scene?: Scene | undefined);
  114719. /**
  114720. * The gamepads in the game pad manager
  114721. */
  114722. get gamepads(): Gamepad[];
  114723. /**
  114724. * Get the gamepad controllers based on type
  114725. * @param type The type of gamepad controller
  114726. * @returns Nullable gamepad
  114727. */
  114728. getGamepadByType(type?: number): Nullable<Gamepad>;
  114729. /**
  114730. * Disposes the gamepad manager
  114731. */
  114732. dispose(): void;
  114733. private _addNewGamepad;
  114734. private _startMonitoringGamepads;
  114735. private _stopMonitoringGamepads;
  114736. /** @hidden */
  114737. _checkGamepadsStatus(): void;
  114738. private _updateGamepadObjects;
  114739. }
  114740. }
  114741. declare module BABYLON {
  114742. interface Scene {
  114743. /** @hidden */
  114744. _gamepadManager: Nullable<GamepadManager>;
  114745. /**
  114746. * Gets the gamepad manager associated with the scene
  114747. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114748. */
  114749. gamepadManager: GamepadManager;
  114750. }
  114751. /**
  114752. * Interface representing a free camera inputs manager
  114753. */
  114754. interface FreeCameraInputsManager {
  114755. /**
  114756. * Adds gamepad input support to the FreeCameraInputsManager.
  114757. * @returns the FreeCameraInputsManager
  114758. */
  114759. addGamepad(): FreeCameraInputsManager;
  114760. }
  114761. /**
  114762. * Interface representing an arc rotate camera inputs manager
  114763. */
  114764. interface ArcRotateCameraInputsManager {
  114765. /**
  114766. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114767. * @returns the camera inputs manager
  114768. */
  114769. addGamepad(): ArcRotateCameraInputsManager;
  114770. }
  114771. /**
  114772. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114773. */
  114774. export class GamepadSystemSceneComponent implements ISceneComponent {
  114775. /**
  114776. * The component name helpfull to identify the component in the list of scene components.
  114777. */
  114778. readonly name: string;
  114779. /**
  114780. * The scene the component belongs to.
  114781. */
  114782. scene: Scene;
  114783. /**
  114784. * Creates a new instance of the component for the given scene
  114785. * @param scene Defines the scene to register the component in
  114786. */
  114787. constructor(scene: Scene);
  114788. /**
  114789. * Registers the component in a given scene
  114790. */
  114791. register(): void;
  114792. /**
  114793. * Rebuilds the elements related to this component in case of
  114794. * context lost for instance.
  114795. */
  114796. rebuild(): void;
  114797. /**
  114798. * Disposes the component and the associated ressources
  114799. */
  114800. dispose(): void;
  114801. private _beforeCameraUpdate;
  114802. }
  114803. }
  114804. declare module BABYLON {
  114805. /**
  114806. * 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,
  114807. * which still works and will still be found in many Playgrounds.
  114808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114809. */
  114810. export class UniversalCamera extends TouchCamera {
  114811. /**
  114812. * Defines the gamepad rotation sensiblity.
  114813. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114814. */
  114815. get gamepadAngularSensibility(): number;
  114816. set gamepadAngularSensibility(value: number);
  114817. /**
  114818. * Defines the gamepad move sensiblity.
  114819. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114820. */
  114821. get gamepadMoveSensibility(): number;
  114822. set gamepadMoveSensibility(value: number);
  114823. /**
  114824. * 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,
  114825. * which still works and will still be found in many Playgrounds.
  114826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114827. * @param name Define the name of the camera in the scene
  114828. * @param position Define the start position of the camera in the scene
  114829. * @param scene Define the scene the camera belongs to
  114830. */
  114831. constructor(name: string, position: Vector3, scene: Scene);
  114832. /**
  114833. * Gets the current object class name.
  114834. * @return the class name
  114835. */
  114836. getClassName(): string;
  114837. }
  114838. }
  114839. declare module BABYLON {
  114840. /**
  114841. * This represents a FPS type of camera. This is only here for back compat purpose.
  114842. * Please use the UniversalCamera instead as both are identical.
  114843. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114844. */
  114845. export class GamepadCamera extends UniversalCamera {
  114846. /**
  114847. * Instantiates a new Gamepad Camera
  114848. * This represents a FPS type of camera. This is only here for back compat purpose.
  114849. * Please use the UniversalCamera instead as both are identical.
  114850. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114851. * @param name Define the name of the camera in the scene
  114852. * @param position Define the start position of the camera in the scene
  114853. * @param scene Define the scene the camera belongs to
  114854. */
  114855. constructor(name: string, position: Vector3, scene: Scene);
  114856. /**
  114857. * Gets the current object class name.
  114858. * @return the class name
  114859. */
  114860. getClassName(): string;
  114861. }
  114862. }
  114863. declare module BABYLON {
  114864. /** @hidden */
  114865. export var passPixelShader: {
  114866. name: string;
  114867. shader: string;
  114868. };
  114869. }
  114870. declare module BABYLON {
  114871. /** @hidden */
  114872. export var passCubePixelShader: {
  114873. name: string;
  114874. shader: string;
  114875. };
  114876. }
  114877. declare module BABYLON {
  114878. /**
  114879. * PassPostProcess which produces an output the same as it's input
  114880. */
  114881. export class PassPostProcess extends PostProcess {
  114882. /**
  114883. * Creates the PassPostProcess
  114884. * @param name The name of the effect.
  114885. * @param options The required width/height ratio to downsize to before computing the render pass.
  114886. * @param camera The camera to apply the render pass to.
  114887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114888. * @param engine The engine which the post process will be applied. (default: current engine)
  114889. * @param reusable If the post process can be reused on the same frame. (default: false)
  114890. * @param textureType The type of texture to be used when performing the post processing.
  114891. * @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)
  114892. */
  114893. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114894. }
  114895. /**
  114896. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114897. */
  114898. export class PassCubePostProcess extends PostProcess {
  114899. private _face;
  114900. /**
  114901. * Gets or sets the cube face to display.
  114902. * * 0 is +X
  114903. * * 1 is -X
  114904. * * 2 is +Y
  114905. * * 3 is -Y
  114906. * * 4 is +Z
  114907. * * 5 is -Z
  114908. */
  114909. get face(): number;
  114910. set face(value: number);
  114911. /**
  114912. * Creates the PassCubePostProcess
  114913. * @param name The name of the effect.
  114914. * @param options The required width/height ratio to downsize to before computing the render pass.
  114915. * @param camera The camera to apply the render pass to.
  114916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114917. * @param engine The engine which the post process will be applied. (default: current engine)
  114918. * @param reusable If the post process can be reused on the same frame. (default: false)
  114919. * @param textureType The type of texture to be used when performing the post processing.
  114920. * @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)
  114921. */
  114922. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114923. }
  114924. }
  114925. declare module BABYLON {
  114926. /** @hidden */
  114927. export var anaglyphPixelShader: {
  114928. name: string;
  114929. shader: string;
  114930. };
  114931. }
  114932. declare module BABYLON {
  114933. /**
  114934. * Postprocess used to generate anaglyphic rendering
  114935. */
  114936. export class AnaglyphPostProcess extends PostProcess {
  114937. private _passedProcess;
  114938. /**
  114939. * Creates a new AnaglyphPostProcess
  114940. * @param name defines postprocess name
  114941. * @param options defines creation options or target ratio scale
  114942. * @param rigCameras defines cameras using this postprocess
  114943. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114944. * @param engine defines hosting engine
  114945. * @param reusable defines if the postprocess will be reused multiple times per frame
  114946. */
  114947. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114948. }
  114949. }
  114950. declare module BABYLON {
  114951. /**
  114952. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114953. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114954. */
  114955. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114956. /**
  114957. * Creates a new AnaglyphArcRotateCamera
  114958. * @param name defines camera name
  114959. * @param alpha defines alpha angle (in radians)
  114960. * @param beta defines beta angle (in radians)
  114961. * @param radius defines radius
  114962. * @param target defines camera target
  114963. * @param interaxialDistance defines distance between each color axis
  114964. * @param scene defines the hosting scene
  114965. */
  114966. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114967. /**
  114968. * Gets camera class name
  114969. * @returns AnaglyphArcRotateCamera
  114970. */
  114971. getClassName(): string;
  114972. }
  114973. }
  114974. declare module BABYLON {
  114975. /**
  114976. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114977. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114978. */
  114979. export class AnaglyphFreeCamera extends FreeCamera {
  114980. /**
  114981. * Creates a new AnaglyphFreeCamera
  114982. * @param name defines camera name
  114983. * @param position defines initial position
  114984. * @param interaxialDistance defines distance between each color axis
  114985. * @param scene defines the hosting scene
  114986. */
  114987. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114988. /**
  114989. * Gets camera class name
  114990. * @returns AnaglyphFreeCamera
  114991. */
  114992. getClassName(): string;
  114993. }
  114994. }
  114995. declare module BABYLON {
  114996. /**
  114997. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114998. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114999. */
  115000. export class AnaglyphGamepadCamera extends GamepadCamera {
  115001. /**
  115002. * Creates a new AnaglyphGamepadCamera
  115003. * @param name defines camera name
  115004. * @param position defines initial position
  115005. * @param interaxialDistance defines distance between each color axis
  115006. * @param scene defines the hosting scene
  115007. */
  115008. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115009. /**
  115010. * Gets camera class name
  115011. * @returns AnaglyphGamepadCamera
  115012. */
  115013. getClassName(): string;
  115014. }
  115015. }
  115016. declare module BABYLON {
  115017. /**
  115018. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115019. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115020. */
  115021. export class AnaglyphUniversalCamera extends UniversalCamera {
  115022. /**
  115023. * Creates a new AnaglyphUniversalCamera
  115024. * @param name defines camera name
  115025. * @param position defines initial position
  115026. * @param interaxialDistance defines distance between each color axis
  115027. * @param scene defines the hosting scene
  115028. */
  115029. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115030. /**
  115031. * Gets camera class name
  115032. * @returns AnaglyphUniversalCamera
  115033. */
  115034. getClassName(): string;
  115035. }
  115036. }
  115037. declare module BABYLON {
  115038. /** @hidden */
  115039. export var stereoscopicInterlacePixelShader: {
  115040. name: string;
  115041. shader: string;
  115042. };
  115043. }
  115044. declare module BABYLON {
  115045. /**
  115046. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115047. */
  115048. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115049. private _stepSize;
  115050. private _passedProcess;
  115051. /**
  115052. * Initializes a StereoscopicInterlacePostProcessI
  115053. * @param name The name of the effect.
  115054. * @param rigCameras The rig cameras to be appled to the post process
  115055. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115056. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115058. * @param engine The engine which the post process will be applied. (default: current engine)
  115059. * @param reusable If the post process can be reused on the same frame. (default: false)
  115060. */
  115061. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115062. }
  115063. /**
  115064. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115065. */
  115066. export class StereoscopicInterlacePostProcess extends PostProcess {
  115067. private _stepSize;
  115068. private _passedProcess;
  115069. /**
  115070. * Initializes a StereoscopicInterlacePostProcess
  115071. * @param name The name of the effect.
  115072. * @param rigCameras The rig cameras to be appled to the post process
  115073. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115075. * @param engine The engine which the post process will be applied. (default: current engine)
  115076. * @param reusable If the post process can be reused on the same frame. (default: false)
  115077. */
  115078. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115079. }
  115080. }
  115081. declare module BABYLON {
  115082. /**
  115083. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115084. * @see http://doc.babylonjs.com/features/cameras
  115085. */
  115086. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115087. /**
  115088. * Creates a new StereoscopicArcRotateCamera
  115089. * @param name defines camera name
  115090. * @param alpha defines alpha angle (in radians)
  115091. * @param beta defines beta angle (in radians)
  115092. * @param radius defines radius
  115093. * @param target defines camera target
  115094. * @param interaxialDistance defines distance between each color axis
  115095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115096. * @param scene defines the hosting scene
  115097. */
  115098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115099. /**
  115100. * Gets camera class name
  115101. * @returns StereoscopicArcRotateCamera
  115102. */
  115103. getClassName(): string;
  115104. }
  115105. }
  115106. declare module BABYLON {
  115107. /**
  115108. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115109. * @see http://doc.babylonjs.com/features/cameras
  115110. */
  115111. export class StereoscopicFreeCamera extends FreeCamera {
  115112. /**
  115113. * Creates a new StereoscopicFreeCamera
  115114. * @param name defines camera name
  115115. * @param position defines initial position
  115116. * @param interaxialDistance defines distance between each color axis
  115117. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115118. * @param scene defines the hosting scene
  115119. */
  115120. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115121. /**
  115122. * Gets camera class name
  115123. * @returns StereoscopicFreeCamera
  115124. */
  115125. getClassName(): string;
  115126. }
  115127. }
  115128. declare module BABYLON {
  115129. /**
  115130. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115131. * @see http://doc.babylonjs.com/features/cameras
  115132. */
  115133. export class StereoscopicGamepadCamera extends GamepadCamera {
  115134. /**
  115135. * Creates a new StereoscopicGamepadCamera
  115136. * @param name defines camera name
  115137. * @param position defines initial position
  115138. * @param interaxialDistance defines distance between each color axis
  115139. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115140. * @param scene defines the hosting scene
  115141. */
  115142. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115143. /**
  115144. * Gets camera class name
  115145. * @returns StereoscopicGamepadCamera
  115146. */
  115147. getClassName(): string;
  115148. }
  115149. }
  115150. declare module BABYLON {
  115151. /**
  115152. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115153. * @see http://doc.babylonjs.com/features/cameras
  115154. */
  115155. export class StereoscopicUniversalCamera extends UniversalCamera {
  115156. /**
  115157. * Creates a new StereoscopicUniversalCamera
  115158. * @param name defines camera name
  115159. * @param position defines initial position
  115160. * @param interaxialDistance defines distance between each color axis
  115161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115162. * @param scene defines the hosting scene
  115163. */
  115164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115165. /**
  115166. * Gets camera class name
  115167. * @returns StereoscopicUniversalCamera
  115168. */
  115169. getClassName(): string;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /**
  115174. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115175. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115176. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115177. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115178. */
  115179. export class VirtualJoysticksCamera extends FreeCamera {
  115180. /**
  115181. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115182. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115183. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115184. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115185. * @param name Define the name of the camera in the scene
  115186. * @param position Define the start position of the camera in the scene
  115187. * @param scene Define the scene the camera belongs to
  115188. */
  115189. constructor(name: string, position: Vector3, scene: Scene);
  115190. /**
  115191. * Gets the current object class name.
  115192. * @return the class name
  115193. */
  115194. getClassName(): string;
  115195. }
  115196. }
  115197. declare module BABYLON {
  115198. /**
  115199. * This represents all the required metrics to create a VR camera.
  115200. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115201. */
  115202. export class VRCameraMetrics {
  115203. /**
  115204. * Define the horizontal resolution off the screen.
  115205. */
  115206. hResolution: number;
  115207. /**
  115208. * Define the vertical resolution off the screen.
  115209. */
  115210. vResolution: number;
  115211. /**
  115212. * Define the horizontal screen size.
  115213. */
  115214. hScreenSize: number;
  115215. /**
  115216. * Define the vertical screen size.
  115217. */
  115218. vScreenSize: number;
  115219. /**
  115220. * Define the vertical screen center position.
  115221. */
  115222. vScreenCenter: number;
  115223. /**
  115224. * Define the distance of the eyes to the screen.
  115225. */
  115226. eyeToScreenDistance: number;
  115227. /**
  115228. * Define the distance between both lenses
  115229. */
  115230. lensSeparationDistance: number;
  115231. /**
  115232. * Define the distance between both viewer's eyes.
  115233. */
  115234. interpupillaryDistance: number;
  115235. /**
  115236. * Define the distortion factor of the VR postprocess.
  115237. * Please, touch with care.
  115238. */
  115239. distortionK: number[];
  115240. /**
  115241. * Define the chromatic aberration correction factors for the VR post process.
  115242. */
  115243. chromaAbCorrection: number[];
  115244. /**
  115245. * Define the scale factor of the post process.
  115246. * The smaller the better but the slower.
  115247. */
  115248. postProcessScaleFactor: number;
  115249. /**
  115250. * Define an offset for the lens center.
  115251. */
  115252. lensCenterOffset: number;
  115253. /**
  115254. * Define if the current vr camera should compensate the distortion of the lense or not.
  115255. */
  115256. compensateDistortion: boolean;
  115257. /**
  115258. * Defines if multiview should be enabled when rendering (Default: false)
  115259. */
  115260. multiviewEnabled: boolean;
  115261. /**
  115262. * Gets the rendering aspect ratio based on the provided resolutions.
  115263. */
  115264. get aspectRatio(): number;
  115265. /**
  115266. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115267. */
  115268. get aspectRatioFov(): number;
  115269. /**
  115270. * @hidden
  115271. */
  115272. get leftHMatrix(): Matrix;
  115273. /**
  115274. * @hidden
  115275. */
  115276. get rightHMatrix(): Matrix;
  115277. /**
  115278. * @hidden
  115279. */
  115280. get leftPreViewMatrix(): Matrix;
  115281. /**
  115282. * @hidden
  115283. */
  115284. get rightPreViewMatrix(): Matrix;
  115285. /**
  115286. * Get the default VRMetrics based on the most generic setup.
  115287. * @returns the default vr metrics
  115288. */
  115289. static GetDefault(): VRCameraMetrics;
  115290. }
  115291. }
  115292. declare module BABYLON {
  115293. /** @hidden */
  115294. export var vrDistortionCorrectionPixelShader: {
  115295. name: string;
  115296. shader: string;
  115297. };
  115298. }
  115299. declare module BABYLON {
  115300. /**
  115301. * VRDistortionCorrectionPostProcess used for mobile VR
  115302. */
  115303. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115304. private _isRightEye;
  115305. private _distortionFactors;
  115306. private _postProcessScaleFactor;
  115307. private _lensCenterOffset;
  115308. private _scaleIn;
  115309. private _scaleFactor;
  115310. private _lensCenter;
  115311. /**
  115312. * Initializes the VRDistortionCorrectionPostProcess
  115313. * @param name The name of the effect.
  115314. * @param camera The camera to apply the render pass to.
  115315. * @param isRightEye If this is for the right eye distortion
  115316. * @param vrMetrics All the required metrics for the VR camera
  115317. */
  115318. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115319. }
  115320. }
  115321. declare module BABYLON {
  115322. /**
  115323. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115324. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115325. */
  115326. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115327. /**
  115328. * Creates a new VRDeviceOrientationArcRotateCamera
  115329. * @param name defines camera name
  115330. * @param alpha defines the camera rotation along the logitudinal axis
  115331. * @param beta defines the camera rotation along the latitudinal axis
  115332. * @param radius defines the camera distance from its target
  115333. * @param target defines the camera target
  115334. * @param scene defines the scene the camera belongs to
  115335. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115336. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115337. */
  115338. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115339. /**
  115340. * Gets camera class name
  115341. * @returns VRDeviceOrientationArcRotateCamera
  115342. */
  115343. getClassName(): string;
  115344. }
  115345. }
  115346. declare module BABYLON {
  115347. /**
  115348. * Camera used to simulate VR rendering (based on FreeCamera)
  115349. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115350. */
  115351. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115352. /**
  115353. * Creates a new VRDeviceOrientationFreeCamera
  115354. * @param name defines camera name
  115355. * @param position defines the start position of the camera
  115356. * @param scene defines the scene the camera belongs to
  115357. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115358. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115359. */
  115360. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115361. /**
  115362. * Gets camera class name
  115363. * @returns VRDeviceOrientationFreeCamera
  115364. */
  115365. getClassName(): string;
  115366. }
  115367. }
  115368. declare module BABYLON {
  115369. /**
  115370. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115371. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115372. */
  115373. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115374. /**
  115375. * Creates a new VRDeviceOrientationGamepadCamera
  115376. * @param name defines camera name
  115377. * @param position defines the start position of the camera
  115378. * @param scene defines the scene the camera belongs to
  115379. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115380. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115381. */
  115382. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115383. /**
  115384. * Gets camera class name
  115385. * @returns VRDeviceOrientationGamepadCamera
  115386. */
  115387. getClassName(): string;
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /** @hidden */
  115392. export var imageProcessingPixelShader: {
  115393. name: string;
  115394. shader: string;
  115395. };
  115396. }
  115397. declare module BABYLON {
  115398. /**
  115399. * ImageProcessingPostProcess
  115400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115401. */
  115402. export class ImageProcessingPostProcess extends PostProcess {
  115403. /**
  115404. * Default configuration related to image processing available in the PBR Material.
  115405. */
  115406. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115407. /**
  115408. * Gets the image processing configuration used either in this material.
  115409. */
  115410. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115411. /**
  115412. * Sets the Default image processing configuration used either in the this material.
  115413. *
  115414. * If sets to null, the scene one is in use.
  115415. */
  115416. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115417. /**
  115418. * Keep track of the image processing observer to allow dispose and replace.
  115419. */
  115420. private _imageProcessingObserver;
  115421. /**
  115422. * Attaches a new image processing configuration to the PBR Material.
  115423. * @param configuration
  115424. */
  115425. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115426. /**
  115427. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115428. */
  115429. get colorCurves(): Nullable<ColorCurves>;
  115430. /**
  115431. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115432. */
  115433. set colorCurves(value: Nullable<ColorCurves>);
  115434. /**
  115435. * Gets wether the color curves effect is enabled.
  115436. */
  115437. get colorCurvesEnabled(): boolean;
  115438. /**
  115439. * Sets wether the color curves effect is enabled.
  115440. */
  115441. set colorCurvesEnabled(value: boolean);
  115442. /**
  115443. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115444. */
  115445. get colorGradingTexture(): Nullable<BaseTexture>;
  115446. /**
  115447. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115448. */
  115449. set colorGradingTexture(value: Nullable<BaseTexture>);
  115450. /**
  115451. * Gets wether the color grading effect is enabled.
  115452. */
  115453. get colorGradingEnabled(): boolean;
  115454. /**
  115455. * Gets wether the color grading effect is enabled.
  115456. */
  115457. set colorGradingEnabled(value: boolean);
  115458. /**
  115459. * Gets exposure used in the effect.
  115460. */
  115461. get exposure(): number;
  115462. /**
  115463. * Sets exposure used in the effect.
  115464. */
  115465. set exposure(value: number);
  115466. /**
  115467. * Gets wether tonemapping is enabled or not.
  115468. */
  115469. get toneMappingEnabled(): boolean;
  115470. /**
  115471. * Sets wether tonemapping is enabled or not
  115472. */
  115473. set toneMappingEnabled(value: boolean);
  115474. /**
  115475. * Gets the type of tone mapping effect.
  115476. */
  115477. get toneMappingType(): number;
  115478. /**
  115479. * Sets the type of tone mapping effect.
  115480. */
  115481. set toneMappingType(value: number);
  115482. /**
  115483. * Gets contrast used in the effect.
  115484. */
  115485. get contrast(): number;
  115486. /**
  115487. * Sets contrast used in the effect.
  115488. */
  115489. set contrast(value: number);
  115490. /**
  115491. * Gets Vignette stretch size.
  115492. */
  115493. get vignetteStretch(): number;
  115494. /**
  115495. * Sets Vignette stretch size.
  115496. */
  115497. set vignetteStretch(value: number);
  115498. /**
  115499. * Gets Vignette centre X Offset.
  115500. */
  115501. get vignetteCentreX(): number;
  115502. /**
  115503. * Sets Vignette centre X Offset.
  115504. */
  115505. set vignetteCentreX(value: number);
  115506. /**
  115507. * Gets Vignette centre Y Offset.
  115508. */
  115509. get vignetteCentreY(): number;
  115510. /**
  115511. * Sets Vignette centre Y Offset.
  115512. */
  115513. set vignetteCentreY(value: number);
  115514. /**
  115515. * Gets Vignette weight or intensity of the vignette effect.
  115516. */
  115517. get vignetteWeight(): number;
  115518. /**
  115519. * Sets Vignette weight or intensity of the vignette effect.
  115520. */
  115521. set vignetteWeight(value: number);
  115522. /**
  115523. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115524. * if vignetteEnabled is set to true.
  115525. */
  115526. get vignetteColor(): Color4;
  115527. /**
  115528. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115529. * if vignetteEnabled is set to true.
  115530. */
  115531. set vignetteColor(value: Color4);
  115532. /**
  115533. * Gets Camera field of view used by the Vignette effect.
  115534. */
  115535. get vignetteCameraFov(): number;
  115536. /**
  115537. * Sets Camera field of view used by the Vignette effect.
  115538. */
  115539. set vignetteCameraFov(value: number);
  115540. /**
  115541. * Gets the vignette blend mode allowing different kind of effect.
  115542. */
  115543. get vignetteBlendMode(): number;
  115544. /**
  115545. * Sets the vignette blend mode allowing different kind of effect.
  115546. */
  115547. set vignetteBlendMode(value: number);
  115548. /**
  115549. * Gets wether the vignette effect is enabled.
  115550. */
  115551. get vignetteEnabled(): boolean;
  115552. /**
  115553. * Sets wether the vignette effect is enabled.
  115554. */
  115555. set vignetteEnabled(value: boolean);
  115556. private _fromLinearSpace;
  115557. /**
  115558. * Gets wether the input of the processing is in Gamma or Linear Space.
  115559. */
  115560. get fromLinearSpace(): boolean;
  115561. /**
  115562. * Sets wether the input of the processing is in Gamma or Linear Space.
  115563. */
  115564. set fromLinearSpace(value: boolean);
  115565. /**
  115566. * Defines cache preventing GC.
  115567. */
  115568. private _defines;
  115569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115570. /**
  115571. * "ImageProcessingPostProcess"
  115572. * @returns "ImageProcessingPostProcess"
  115573. */
  115574. getClassName(): string;
  115575. protected _updateParameters(): void;
  115576. dispose(camera?: Camera): void;
  115577. }
  115578. }
  115579. declare module BABYLON {
  115580. /**
  115581. * Class containing static functions to help procedurally build meshes
  115582. */
  115583. export class GroundBuilder {
  115584. /**
  115585. * Creates a ground mesh
  115586. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115587. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115589. * @param name defines the name of the mesh
  115590. * @param options defines the options used to create the mesh
  115591. * @param scene defines the hosting scene
  115592. * @returns the ground mesh
  115593. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115594. */
  115595. static CreateGround(name: string, options: {
  115596. width?: number;
  115597. height?: number;
  115598. subdivisions?: number;
  115599. subdivisionsX?: number;
  115600. subdivisionsY?: number;
  115601. updatable?: boolean;
  115602. }, scene: any): Mesh;
  115603. /**
  115604. * Creates a tiled ground mesh
  115605. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115606. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115607. * * 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
  115608. * * 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
  115609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115610. * @param name defines the name of the mesh
  115611. * @param options defines the options used to create the mesh
  115612. * @param scene defines the hosting scene
  115613. * @returns the tiled ground mesh
  115614. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115615. */
  115616. static CreateTiledGround(name: string, options: {
  115617. xmin: number;
  115618. zmin: number;
  115619. xmax: number;
  115620. zmax: number;
  115621. subdivisions?: {
  115622. w: number;
  115623. h: number;
  115624. };
  115625. precision?: {
  115626. w: number;
  115627. h: number;
  115628. };
  115629. updatable?: boolean;
  115630. }, scene?: Nullable<Scene>): Mesh;
  115631. /**
  115632. * Creates a ground mesh from a height map
  115633. * * The parameter `url` sets the URL of the height map image resource.
  115634. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115635. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115636. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115637. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115638. * * 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.
  115639. * * 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).
  115640. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115642. * @param name defines the name of the mesh
  115643. * @param url defines the url to the height map
  115644. * @param options defines the options used to create the mesh
  115645. * @param scene defines the hosting scene
  115646. * @returns the ground mesh
  115647. * @see https://doc.babylonjs.com/babylon101/height_map
  115648. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115649. */
  115650. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115651. width?: number;
  115652. height?: number;
  115653. subdivisions?: number;
  115654. minHeight?: number;
  115655. maxHeight?: number;
  115656. colorFilter?: Color3;
  115657. alphaFilter?: number;
  115658. updatable?: boolean;
  115659. onReady?: (mesh: GroundMesh) => void;
  115660. }, scene?: Nullable<Scene>): GroundMesh;
  115661. }
  115662. }
  115663. declare module BABYLON {
  115664. /**
  115665. * Class containing static functions to help procedurally build meshes
  115666. */
  115667. export class TorusBuilder {
  115668. /**
  115669. * Creates a torus mesh
  115670. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115671. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115672. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115676. * @param name defines the name of the mesh
  115677. * @param options defines the options used to create the mesh
  115678. * @param scene defines the hosting scene
  115679. * @returns the torus mesh
  115680. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115681. */
  115682. static CreateTorus(name: string, options: {
  115683. diameter?: number;
  115684. thickness?: number;
  115685. tessellation?: number;
  115686. updatable?: boolean;
  115687. sideOrientation?: number;
  115688. frontUVs?: Vector4;
  115689. backUVs?: Vector4;
  115690. }, scene: any): Mesh;
  115691. }
  115692. }
  115693. declare module BABYLON {
  115694. /**
  115695. * Class containing static functions to help procedurally build meshes
  115696. */
  115697. export class CylinderBuilder {
  115698. /**
  115699. * Creates a cylinder or a cone mesh
  115700. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115701. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115702. * * 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.
  115703. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115704. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115705. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115706. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115707. * * 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).
  115708. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115709. * * 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).
  115710. * * 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
  115711. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115712. * * 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
  115713. * * 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.
  115714. * * If `enclose` is false, a ring surface is one element.
  115715. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115716. * * 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
  115717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115720. * @param name defines the name of the mesh
  115721. * @param options defines the options used to create the mesh
  115722. * @param scene defines the hosting scene
  115723. * @returns the cylinder mesh
  115724. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115725. */
  115726. static CreateCylinder(name: string, options: {
  115727. height?: number;
  115728. diameterTop?: number;
  115729. diameterBottom?: number;
  115730. diameter?: number;
  115731. tessellation?: number;
  115732. subdivisions?: number;
  115733. arc?: number;
  115734. faceColors?: Color4[];
  115735. faceUV?: Vector4[];
  115736. updatable?: boolean;
  115737. hasRings?: boolean;
  115738. enclose?: boolean;
  115739. cap?: number;
  115740. sideOrientation?: number;
  115741. frontUVs?: Vector4;
  115742. backUVs?: Vector4;
  115743. }, scene: any): Mesh;
  115744. }
  115745. }
  115746. declare module BABYLON {
  115747. /**
  115748. * States of the webXR experience
  115749. */
  115750. export enum WebXRState {
  115751. /**
  115752. * Transitioning to being in XR mode
  115753. */
  115754. ENTERING_XR = 0,
  115755. /**
  115756. * Transitioning to non XR mode
  115757. */
  115758. EXITING_XR = 1,
  115759. /**
  115760. * In XR mode and presenting
  115761. */
  115762. IN_XR = 2,
  115763. /**
  115764. * Not entered XR mode
  115765. */
  115766. NOT_IN_XR = 3
  115767. }
  115768. /**
  115769. * Abstraction of the XR render target
  115770. */
  115771. export interface WebXRRenderTarget extends IDisposable {
  115772. /**
  115773. * xrpresent context of the canvas which can be used to display/mirror xr content
  115774. */
  115775. canvasContext: WebGLRenderingContext;
  115776. /**
  115777. * xr layer for the canvas
  115778. */
  115779. xrLayer: Nullable<XRWebGLLayer>;
  115780. /**
  115781. * Initializes the xr layer for the session
  115782. * @param xrSession xr session
  115783. * @returns a promise that will resolve once the XR Layer has been created
  115784. */
  115785. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115786. }
  115787. }
  115788. declare module BABYLON {
  115789. /**
  115790. * COnfiguration object for WebXR output canvas
  115791. */
  115792. export class WebXRManagedOutputCanvasOptions {
  115793. /**
  115794. * An optional canvas in case you wish to create it yourself and provide it here.
  115795. * If not provided, a new canvas will be created
  115796. */
  115797. canvasElement?: HTMLCanvasElement;
  115798. /**
  115799. * Options for this XR Layer output
  115800. */
  115801. canvasOptions?: XRWebGLLayerOptions;
  115802. /**
  115803. * CSS styling for a newly created canvas (if not provided)
  115804. */
  115805. newCanvasCssStyle?: string;
  115806. /**
  115807. * Get the default values of the configuration object
  115808. * @returns default values of this configuration object
  115809. */
  115810. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115811. }
  115812. /**
  115813. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115814. */
  115815. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115816. private _options;
  115817. private _canvas;
  115818. private _engine;
  115819. /**
  115820. * Rendering context of the canvas which can be used to display/mirror xr content
  115821. */
  115822. canvasContext: WebGLRenderingContext;
  115823. /**
  115824. * xr layer for the canvas
  115825. */
  115826. xrLayer: Nullable<XRWebGLLayer>;
  115827. /**
  115828. * Initializes the canvas to be added/removed upon entering/exiting xr
  115829. * @param _xrSessionManager The XR Session manager
  115830. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115831. */
  115832. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115833. /**
  115834. * Disposes of the object
  115835. */
  115836. dispose(): void;
  115837. /**
  115838. * Initializes the xr layer for the session
  115839. * @param xrSession xr session
  115840. * @returns a promise that will resolve once the XR Layer has been created
  115841. */
  115842. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115843. private _addCanvas;
  115844. private _removeCanvas;
  115845. private _setManagedOutputCanvas;
  115846. }
  115847. }
  115848. declare module BABYLON {
  115849. /**
  115850. * Manages an XRSession to work with Babylon's engine
  115851. * @see https://doc.babylonjs.com/how_to/webxr
  115852. */
  115853. export class WebXRSessionManager implements IDisposable {
  115854. /** The scene which the session should be created for */
  115855. scene: Scene;
  115856. private _referenceSpace;
  115857. private _rttProvider;
  115858. private _sessionEnded;
  115859. private _xrNavigator;
  115860. private baseLayer;
  115861. /**
  115862. * The base reference space from which the session started. good if you want to reset your
  115863. * reference space
  115864. */
  115865. baseReferenceSpace: XRReferenceSpace;
  115866. /**
  115867. * Current XR frame
  115868. */
  115869. currentFrame: Nullable<XRFrame>;
  115870. /** WebXR timestamp updated every frame */
  115871. currentTimestamp: number;
  115872. /**
  115873. * Used just in case of a failure to initialize an immersive session.
  115874. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115875. */
  115876. defaultHeightCompensation: number;
  115877. /**
  115878. * Fires every time a new xrFrame arrives which can be used to update the camera
  115879. */
  115880. onXRFrameObservable: Observable<XRFrame>;
  115881. /**
  115882. * Fires when the reference space changed
  115883. */
  115884. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115885. /**
  115886. * Fires when the xr session is ended either by the device or manually done
  115887. */
  115888. onXRSessionEnded: Observable<any>;
  115889. /**
  115890. * Fires when the xr session is ended either by the device or manually done
  115891. */
  115892. onXRSessionInit: Observable<XRSession>;
  115893. /**
  115894. * Underlying xr session
  115895. */
  115896. session: XRSession;
  115897. /**
  115898. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115899. * or get the offset the player is currently at.
  115900. */
  115901. viewerReferenceSpace: XRReferenceSpace;
  115902. /**
  115903. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115904. * @param scene The scene which the session should be created for
  115905. */
  115906. constructor(
  115907. /** The scene which the session should be created for */
  115908. scene: Scene);
  115909. /**
  115910. * The current reference space used in this session. This reference space can constantly change!
  115911. * It is mainly used to offset the camera's position.
  115912. */
  115913. get referenceSpace(): XRReferenceSpace;
  115914. /**
  115915. * Set a new reference space and triggers the observable
  115916. */
  115917. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115918. /**
  115919. * Disposes of the session manager
  115920. */
  115921. dispose(): void;
  115922. /**
  115923. * Stops the xrSession and restores the render loop
  115924. * @returns Promise which resolves after it exits XR
  115925. */
  115926. exitXRAsync(): Promise<void>;
  115927. /**
  115928. * Gets the correct render target texture to be rendered this frame for this eye
  115929. * @param eye the eye for which to get the render target
  115930. * @returns the render target for the specified eye
  115931. */
  115932. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115933. /**
  115934. * Creates a WebXRRenderTarget object for the XR session
  115935. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115936. * @param options optional options to provide when creating a new render target
  115937. * @returns a WebXR render target to which the session can render
  115938. */
  115939. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115940. /**
  115941. * Initializes the manager
  115942. * After initialization enterXR can be called to start an XR session
  115943. * @returns Promise which resolves after it is initialized
  115944. */
  115945. initializeAsync(): Promise<void>;
  115946. /**
  115947. * Initializes an xr session
  115948. * @param xrSessionMode mode to initialize
  115949. * @param xrSessionInit defines optional and required values to pass to the session builder
  115950. * @returns a promise which will resolve once the session has been initialized
  115951. */
  115952. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115953. /**
  115954. * Checks if a session would be supported for the creation options specified
  115955. * @param sessionMode session mode to check if supported eg. immersive-vr
  115956. * @returns A Promise that resolves to true if supported and false if not
  115957. */
  115958. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115959. /**
  115960. * Resets the reference space to the one started the session
  115961. */
  115962. resetReferenceSpace(): void;
  115963. /**
  115964. * Starts rendering to the xr layer
  115965. */
  115966. runXRRenderLoop(): void;
  115967. /**
  115968. * Sets the reference space on the xr session
  115969. * @param referenceSpaceType space to set
  115970. * @returns a promise that will resolve once the reference space has been set
  115971. */
  115972. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115973. /**
  115974. * Updates the render state of the session
  115975. * @param state state to set
  115976. * @returns a promise that resolves once the render state has been updated
  115977. */
  115978. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115979. /**
  115980. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115981. * @param sessionMode defines the session to test
  115982. * @returns a promise with boolean as final value
  115983. */
  115984. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115985. private _createRenderTargetTexture;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /**
  115990. * WebXR Camera which holds the views for the xrSession
  115991. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115992. */
  115993. export class WebXRCamera extends FreeCamera {
  115994. private _xrSessionManager;
  115995. private _firstFrame;
  115996. private _referenceQuaternion;
  115997. private _referencedPosition;
  115998. private _xrInvPositionCache;
  115999. private _xrInvQuaternionCache;
  116000. /**
  116001. * Should position compensation execute on first frame.
  116002. * This is used when copying the position from a native (non XR) camera
  116003. */
  116004. compensateOnFirstFrame: boolean;
  116005. /**
  116006. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116007. * @param name the name of the camera
  116008. * @param scene the scene to add the camera to
  116009. * @param _xrSessionManager a constructed xr session manager
  116010. */
  116011. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116012. /**
  116013. * Return the user's height, unrelated to the current ground.
  116014. * This will be the y position of this camera, when ground level is 0.
  116015. */
  116016. get realWorldHeight(): number;
  116017. /** @hidden */
  116018. _updateForDualEyeDebugging(): void;
  116019. /**
  116020. * Sets this camera's transformation based on a non-vr camera
  116021. * @param otherCamera the non-vr camera to copy the transformation from
  116022. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116023. */
  116024. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116025. /**
  116026. * Gets the current instance class name ("WebXRCamera").
  116027. * @returns the class name
  116028. */
  116029. getClassName(): string;
  116030. private _updateFromXRSession;
  116031. private _updateNumberOfRigCameras;
  116032. private _updateReferenceSpace;
  116033. private _updateReferenceSpaceOffset;
  116034. }
  116035. }
  116036. declare module BABYLON {
  116037. /**
  116038. * Defining the interface required for a (webxr) feature
  116039. */
  116040. export interface IWebXRFeature extends IDisposable {
  116041. /**
  116042. * Is this feature attached
  116043. */
  116044. attached: boolean;
  116045. /**
  116046. * Should auto-attach be disabled?
  116047. */
  116048. disableAutoAttach: boolean;
  116049. /**
  116050. * Attach the feature to the session
  116051. * Will usually be called by the features manager
  116052. *
  116053. * @param force should attachment be forced (even when already attached)
  116054. * @returns true if successful.
  116055. */
  116056. attach(force?: boolean): boolean;
  116057. /**
  116058. * Detach the feature from the session
  116059. * Will usually be called by the features manager
  116060. *
  116061. * @returns true if successful.
  116062. */
  116063. detach(): boolean;
  116064. }
  116065. /**
  116066. * A list of the currently available features without referencing them
  116067. */
  116068. export class WebXRFeatureName {
  116069. /**
  116070. * The name of the anchor system feature
  116071. */
  116072. static ANCHOR_SYSTEM: string;
  116073. /**
  116074. * The name of the background remover feature
  116075. */
  116076. static BACKGROUND_REMOVER: string;
  116077. /**
  116078. * The name of the hit test feature
  116079. */
  116080. static HIT_TEST: string;
  116081. /**
  116082. * physics impostors for xr controllers feature
  116083. */
  116084. static PHYSICS_CONTROLLERS: string;
  116085. /**
  116086. * The name of the plane detection feature
  116087. */
  116088. static PLANE_DETECTION: string;
  116089. /**
  116090. * The name of the pointer selection feature
  116091. */
  116092. static POINTER_SELECTION: string;
  116093. /**
  116094. * The name of the teleportation feature
  116095. */
  116096. static TELEPORTATION: string;
  116097. }
  116098. /**
  116099. * Defining the constructor of a feature. Used to register the modules.
  116100. */
  116101. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116102. /**
  116103. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116104. * It is mainly used in AR sessions.
  116105. *
  116106. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116107. */
  116108. export class WebXRFeaturesManager implements IDisposable {
  116109. private _xrSessionManager;
  116110. private static readonly _AvailableFeatures;
  116111. private _features;
  116112. /**
  116113. * constructs a new features manages.
  116114. *
  116115. * @param _xrSessionManager an instance of WebXRSessionManager
  116116. */
  116117. constructor(_xrSessionManager: WebXRSessionManager);
  116118. /**
  116119. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116120. * Mainly used internally.
  116121. *
  116122. * @param featureName the name of the feature to register
  116123. * @param constructorFunction the function used to construct the module
  116124. * @param version the (babylon) version of the module
  116125. * @param stable is that a stable version of this module
  116126. */
  116127. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116128. /**
  116129. * Returns a constructor of a specific feature.
  116130. *
  116131. * @param featureName the name of the feature to construct
  116132. * @param version the version of the feature to load
  116133. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116134. * @param options optional options provided to the module.
  116135. * @returns a function that, when called, will return a new instance of this feature
  116136. */
  116137. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116138. /**
  116139. * Can be used to return the list of features currently registered
  116140. *
  116141. * @returns an Array of available features
  116142. */
  116143. static GetAvailableFeatures(): string[];
  116144. /**
  116145. * Gets the versions available for a specific feature
  116146. * @param featureName the name of the feature
  116147. * @returns an array with the available versions
  116148. */
  116149. static GetAvailableVersions(featureName: string): string[];
  116150. /**
  116151. * Return the latest unstable version of this feature
  116152. * @param featureName the name of the feature to search
  116153. * @returns the version number. if not found will return -1
  116154. */
  116155. static GetLatestVersionOfFeature(featureName: string): number;
  116156. /**
  116157. * Return the latest stable version of this feature
  116158. * @param featureName the name of the feature to search
  116159. * @returns the version number. if not found will return -1
  116160. */
  116161. static GetStableVersionOfFeature(featureName: string): number;
  116162. /**
  116163. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116164. * Can be used during a session to start a feature
  116165. * @param featureName the name of feature to attach
  116166. */
  116167. attachFeature(featureName: string): void;
  116168. /**
  116169. * Can be used inside a session or when the session ends to detach a specific feature
  116170. * @param featureName the name of the feature to detach
  116171. */
  116172. detachFeature(featureName: string): void;
  116173. /**
  116174. * Used to disable an already-enabled feature
  116175. * The feature will be disposed and will be recreated once enabled.
  116176. * @param featureName the feature to disable
  116177. * @returns true if disable was successful
  116178. */
  116179. disableFeature(featureName: string | {
  116180. Name: string;
  116181. }): boolean;
  116182. /**
  116183. * dispose this features manager
  116184. */
  116185. dispose(): void;
  116186. /**
  116187. * 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.
  116188. * 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.
  116189. *
  116190. * @param featureName the name of the feature to load or the class of the feature
  116191. * @param version optional version to load. if not provided the latest version will be enabled
  116192. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116193. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116194. * @returns a new constructed feature or throws an error if feature not found.
  116195. */
  116196. enableFeature(featureName: string | {
  116197. Name: string;
  116198. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116199. /**
  116200. * get the implementation of an enabled feature.
  116201. * @param featureName the name of the feature to load
  116202. * @returns the feature class, if found
  116203. */
  116204. getEnabledFeature(featureName: string): IWebXRFeature;
  116205. /**
  116206. * Get the list of enabled features
  116207. * @returns an array of enabled features
  116208. */
  116209. getEnabledFeatures(): string[];
  116210. }
  116211. }
  116212. declare module BABYLON {
  116213. /**
  116214. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116215. * @see https://doc.babylonjs.com/how_to/webxr
  116216. */
  116217. export class WebXRExperienceHelper implements IDisposable {
  116218. private scene;
  116219. private _nonVRCamera;
  116220. private _originalSceneAutoClear;
  116221. private _supported;
  116222. /**
  116223. * Camera used to render xr content
  116224. */
  116225. camera: WebXRCamera;
  116226. /** A features manager for this xr session */
  116227. featuresManager: WebXRFeaturesManager;
  116228. /**
  116229. * Observers registered here will be triggered after the camera's initial transformation is set
  116230. * This can be used to set a different ground level or an extra rotation.
  116231. *
  116232. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116233. * to the position set after this observable is done executing.
  116234. */
  116235. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116236. /**
  116237. * Fires when the state of the experience helper has changed
  116238. */
  116239. onStateChangedObservable: Observable<WebXRState>;
  116240. /** Session manager used to keep track of xr session */
  116241. sessionManager: WebXRSessionManager;
  116242. /**
  116243. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116244. */
  116245. state: WebXRState;
  116246. /**
  116247. * Creates a WebXRExperienceHelper
  116248. * @param scene The scene the helper should be created in
  116249. */
  116250. private constructor();
  116251. /**
  116252. * Creates the experience helper
  116253. * @param scene the scene to attach the experience helper to
  116254. * @returns a promise for the experience helper
  116255. */
  116256. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116257. /**
  116258. * Disposes of the experience helper
  116259. */
  116260. dispose(): void;
  116261. /**
  116262. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116263. * @param sessionMode options for the XR session
  116264. * @param referenceSpaceType frame of reference of the XR session
  116265. * @param renderTarget the output canvas that will be used to enter XR mode
  116266. * @returns promise that resolves after xr mode has entered
  116267. */
  116268. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116269. /**
  116270. * Exits XR mode and returns the scene to its original state
  116271. * @returns promise that resolves after xr mode has exited
  116272. */
  116273. exitXRAsync(): Promise<void>;
  116274. private _nonXRToXRCamera;
  116275. private _setState;
  116276. }
  116277. }
  116278. declare module BABYLON {
  116279. /**
  116280. * X-Y values for axes in WebXR
  116281. */
  116282. export interface IWebXRMotionControllerAxesValue {
  116283. /**
  116284. * The value of the x axis
  116285. */
  116286. x: number;
  116287. /**
  116288. * The value of the y-axis
  116289. */
  116290. y: number;
  116291. }
  116292. /**
  116293. * changed / previous values for the values of this component
  116294. */
  116295. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116296. /**
  116297. * current (this frame) value
  116298. */
  116299. current: T;
  116300. /**
  116301. * previous (last change) value
  116302. */
  116303. previous: T;
  116304. }
  116305. /**
  116306. * Represents changes in the component between current frame and last values recorded
  116307. */
  116308. export interface IWebXRMotionControllerComponentChanges {
  116309. /**
  116310. * will be populated with previous and current values if axes changed
  116311. */
  116312. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116313. /**
  116314. * will be populated with previous and current values if pressed changed
  116315. */
  116316. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116317. /**
  116318. * will be populated with previous and current values if touched changed
  116319. */
  116320. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116321. /**
  116322. * will be populated with previous and current values if value changed
  116323. */
  116324. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116325. }
  116326. /**
  116327. * This class represents a single component (for example button or thumbstick) of a motion controller
  116328. */
  116329. export class WebXRControllerComponent implements IDisposable {
  116330. /**
  116331. * the id of this component
  116332. */
  116333. id: string;
  116334. /**
  116335. * the type of the component
  116336. */
  116337. type: MotionControllerComponentType;
  116338. private _buttonIndex;
  116339. private _axesIndices;
  116340. private _axes;
  116341. private _changes;
  116342. private _currentValue;
  116343. private _hasChanges;
  116344. private _pressed;
  116345. private _touched;
  116346. /**
  116347. * button component type
  116348. */
  116349. static BUTTON_TYPE: MotionControllerComponentType;
  116350. /**
  116351. * squeeze component type
  116352. */
  116353. static SQUEEZE_TYPE: MotionControllerComponentType;
  116354. /**
  116355. * Thumbstick component type
  116356. */
  116357. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116358. /**
  116359. * Touchpad component type
  116360. */
  116361. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116362. /**
  116363. * trigger component type
  116364. */
  116365. static TRIGGER_TYPE: MotionControllerComponentType;
  116366. /**
  116367. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116368. * the axes data changes
  116369. */
  116370. onAxisValueChangedObservable: Observable<{
  116371. x: number;
  116372. y: number;
  116373. }>;
  116374. /**
  116375. * Observers registered here will be triggered when the state of a button changes
  116376. * State change is either pressed / touched / value
  116377. */
  116378. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116379. /**
  116380. * Creates a new component for a motion controller.
  116381. * It is created by the motion controller itself
  116382. *
  116383. * @param id the id of this component
  116384. * @param type the type of the component
  116385. * @param _buttonIndex index in the buttons array of the gamepad
  116386. * @param _axesIndices indices of the values in the axes array of the gamepad
  116387. */
  116388. constructor(
  116389. /**
  116390. * the id of this component
  116391. */
  116392. id: string,
  116393. /**
  116394. * the type of the component
  116395. */
  116396. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116397. /**
  116398. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116399. */
  116400. get axes(): IWebXRMotionControllerAxesValue;
  116401. /**
  116402. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116403. */
  116404. get changes(): IWebXRMotionControllerComponentChanges;
  116405. /**
  116406. * Return whether or not the component changed the last frame
  116407. */
  116408. get hasChanges(): boolean;
  116409. /**
  116410. * is the button currently pressed
  116411. */
  116412. get pressed(): boolean;
  116413. /**
  116414. * is the button currently touched
  116415. */
  116416. get touched(): boolean;
  116417. /**
  116418. * Get the current value of this component
  116419. */
  116420. get value(): number;
  116421. /**
  116422. * Dispose this component
  116423. */
  116424. dispose(): void;
  116425. /**
  116426. * Are there axes correlating to this component
  116427. * @return true is axes data is available
  116428. */
  116429. isAxes(): boolean;
  116430. /**
  116431. * Is this component a button (hence - pressable)
  116432. * @returns true if can be pressed
  116433. */
  116434. isButton(): boolean;
  116435. /**
  116436. * update this component using the gamepad object it is in. Called on every frame
  116437. * @param nativeController the native gamepad controller object
  116438. */
  116439. update(nativeController: IMinimalMotionControllerObject): void;
  116440. }
  116441. }
  116442. declare module BABYLON {
  116443. /**
  116444. * Class used to represent data loading progression
  116445. */
  116446. export class SceneLoaderProgressEvent {
  116447. /** defines if data length to load can be evaluated */
  116448. readonly lengthComputable: boolean;
  116449. /** defines the loaded data length */
  116450. readonly loaded: number;
  116451. /** defines the data length to load */
  116452. readonly total: number;
  116453. /**
  116454. * Create a new progress event
  116455. * @param lengthComputable defines if data length to load can be evaluated
  116456. * @param loaded defines the loaded data length
  116457. * @param total defines the data length to load
  116458. */
  116459. constructor(
  116460. /** defines if data length to load can be evaluated */
  116461. lengthComputable: boolean,
  116462. /** defines the loaded data length */
  116463. loaded: number,
  116464. /** defines the data length to load */
  116465. total: number);
  116466. /**
  116467. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116468. * @param event defines the source event
  116469. * @returns a new SceneLoaderProgressEvent
  116470. */
  116471. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116472. }
  116473. /**
  116474. * Interface used by SceneLoader plugins to define supported file extensions
  116475. */
  116476. export interface ISceneLoaderPluginExtensions {
  116477. /**
  116478. * Defines the list of supported extensions
  116479. */
  116480. [extension: string]: {
  116481. isBinary: boolean;
  116482. };
  116483. }
  116484. /**
  116485. * Interface used by SceneLoader plugin factory
  116486. */
  116487. export interface ISceneLoaderPluginFactory {
  116488. /**
  116489. * Defines the name of the factory
  116490. */
  116491. name: string;
  116492. /**
  116493. * Function called to create a new plugin
  116494. * @return the new plugin
  116495. */
  116496. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116497. /**
  116498. * The callback that returns true if the data can be directly loaded.
  116499. * @param data string containing the file data
  116500. * @returns if the data can be loaded directly
  116501. */
  116502. canDirectLoad?(data: string): boolean;
  116503. }
  116504. /**
  116505. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116506. */
  116507. export interface ISceneLoaderPluginBase {
  116508. /**
  116509. * The friendly name of this plugin.
  116510. */
  116511. name: string;
  116512. /**
  116513. * The file extensions supported by this plugin.
  116514. */
  116515. extensions: string | ISceneLoaderPluginExtensions;
  116516. /**
  116517. * The callback called when loading from a url.
  116518. * @param scene scene loading this url
  116519. * @param url url to load
  116520. * @param onSuccess callback called when the file successfully loads
  116521. * @param onProgress callback called while file is loading (if the server supports this mode)
  116522. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116523. * @param onError callback called when the file fails to load
  116524. * @returns a file request object
  116525. */
  116526. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116527. /**
  116528. * The callback called when loading from a file object.
  116529. * @param scene scene loading this file
  116530. * @param file defines the file to load
  116531. * @param onSuccess defines the callback to call when data is loaded
  116532. * @param onProgress defines the callback to call during loading process
  116533. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116534. * @param onError defines the callback to call when an error occurs
  116535. * @returns a file request object
  116536. */
  116537. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116538. /**
  116539. * The callback that returns true if the data can be directly loaded.
  116540. * @param data string containing the file data
  116541. * @returns if the data can be loaded directly
  116542. */
  116543. canDirectLoad?(data: string): boolean;
  116544. /**
  116545. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116546. * @param scene scene loading this data
  116547. * @param data string containing the data
  116548. * @returns data to pass to the plugin
  116549. */
  116550. directLoad?(scene: Scene, data: string): any;
  116551. /**
  116552. * The callback that allows custom handling of the root url based on the response url.
  116553. * @param rootUrl the original root url
  116554. * @param responseURL the response url if available
  116555. * @returns the new root url
  116556. */
  116557. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116558. }
  116559. /**
  116560. * Interface used to define a SceneLoader plugin
  116561. */
  116562. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116563. /**
  116564. * Import meshes into a scene.
  116565. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116566. * @param scene The scene to import into
  116567. * @param data The data to import
  116568. * @param rootUrl The root url for scene and resources
  116569. * @param meshes The meshes array to import into
  116570. * @param particleSystems The particle systems array to import into
  116571. * @param skeletons The skeletons array to import into
  116572. * @param onError The callback when import fails
  116573. * @returns True if successful or false otherwise
  116574. */
  116575. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116576. /**
  116577. * Load into a scene.
  116578. * @param scene The scene to load into
  116579. * @param data The data to import
  116580. * @param rootUrl The root url for scene and resources
  116581. * @param onError The callback when import fails
  116582. * @returns True if successful or false otherwise
  116583. */
  116584. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116585. /**
  116586. * Load into an asset container.
  116587. * @param scene The scene to load into
  116588. * @param data The data to import
  116589. * @param rootUrl The root url for scene and resources
  116590. * @param onError The callback when import fails
  116591. * @returns The loaded asset container
  116592. */
  116593. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116594. }
  116595. /**
  116596. * Interface used to define an async SceneLoader plugin
  116597. */
  116598. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116599. /**
  116600. * Import meshes into a scene.
  116601. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116602. * @param scene The scene to import into
  116603. * @param data The data to import
  116604. * @param rootUrl The root url for scene and resources
  116605. * @param onProgress The callback when the load progresses
  116606. * @param fileName Defines the name of the file to load
  116607. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116608. */
  116609. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116610. meshes: AbstractMesh[];
  116611. particleSystems: IParticleSystem[];
  116612. skeletons: Skeleton[];
  116613. animationGroups: AnimationGroup[];
  116614. }>;
  116615. /**
  116616. * Load into a scene.
  116617. * @param scene The scene to load into
  116618. * @param data The data to import
  116619. * @param rootUrl The root url for scene and resources
  116620. * @param onProgress The callback when the load progresses
  116621. * @param fileName Defines the name of the file to load
  116622. * @returns Nothing
  116623. */
  116624. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116625. /**
  116626. * Load into an asset container.
  116627. * @param scene The scene to load into
  116628. * @param data The data to import
  116629. * @param rootUrl The root url for scene and resources
  116630. * @param onProgress The callback when the load progresses
  116631. * @param fileName Defines the name of the file to load
  116632. * @returns The loaded asset container
  116633. */
  116634. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116635. }
  116636. /**
  116637. * Mode that determines how to handle old animation groups before loading new ones.
  116638. */
  116639. export enum SceneLoaderAnimationGroupLoadingMode {
  116640. /**
  116641. * Reset all old animations to initial state then dispose them.
  116642. */
  116643. Clean = 0,
  116644. /**
  116645. * Stop all old animations.
  116646. */
  116647. Stop = 1,
  116648. /**
  116649. * Restart old animations from first frame.
  116650. */
  116651. Sync = 2,
  116652. /**
  116653. * Old animations remains untouched.
  116654. */
  116655. NoSync = 3
  116656. }
  116657. /**
  116658. * Class used to load scene from various file formats using registered plugins
  116659. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116660. */
  116661. export class SceneLoader {
  116662. /**
  116663. * No logging while loading
  116664. */
  116665. static readonly NO_LOGGING: number;
  116666. /**
  116667. * Minimal logging while loading
  116668. */
  116669. static readonly MINIMAL_LOGGING: number;
  116670. /**
  116671. * Summary logging while loading
  116672. */
  116673. static readonly SUMMARY_LOGGING: number;
  116674. /**
  116675. * Detailled logging while loading
  116676. */
  116677. static readonly DETAILED_LOGGING: number;
  116678. /**
  116679. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116680. */
  116681. static get ForceFullSceneLoadingForIncremental(): boolean;
  116682. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116683. /**
  116684. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116685. */
  116686. static get ShowLoadingScreen(): boolean;
  116687. static set ShowLoadingScreen(value: boolean);
  116688. /**
  116689. * Defines the current logging level (while loading the scene)
  116690. * @ignorenaming
  116691. */
  116692. static get loggingLevel(): number;
  116693. static set loggingLevel(value: number);
  116694. /**
  116695. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116696. */
  116697. static get CleanBoneMatrixWeights(): boolean;
  116698. static set CleanBoneMatrixWeights(value: boolean);
  116699. /**
  116700. * Event raised when a plugin is used to load a scene
  116701. */
  116702. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116703. private static _registeredPlugins;
  116704. private static _getDefaultPlugin;
  116705. private static _getPluginForExtension;
  116706. private static _getPluginForDirectLoad;
  116707. private static _getPluginForFilename;
  116708. private static _getDirectLoad;
  116709. private static _loadData;
  116710. private static _getFileInfo;
  116711. /**
  116712. * Gets a plugin that can load the given extension
  116713. * @param extension defines the extension to load
  116714. * @returns a plugin or null if none works
  116715. */
  116716. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116717. /**
  116718. * Gets a boolean indicating that the given extension can be loaded
  116719. * @param extension defines the extension to load
  116720. * @returns true if the extension is supported
  116721. */
  116722. static IsPluginForExtensionAvailable(extension: string): boolean;
  116723. /**
  116724. * Adds a new plugin to the list of registered plugins
  116725. * @param plugin defines the plugin to add
  116726. */
  116727. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116728. /**
  116729. * Import meshes into a scene
  116730. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116731. * @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)
  116732. * @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)
  116733. * @param scene the instance of BABYLON.Scene to append to
  116734. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116735. * @param onProgress a callback with a progress event for each file being loaded
  116736. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116737. * @param pluginExtension the extension used to determine the plugin
  116738. * @returns The loaded plugin
  116739. */
  116740. 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>;
  116741. /**
  116742. * Import meshes into a scene
  116743. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116744. * @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)
  116745. * @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)
  116746. * @param scene the instance of BABYLON.Scene to append to
  116747. * @param onProgress a callback with a progress event for each file being loaded
  116748. * @param pluginExtension the extension used to determine the plugin
  116749. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116750. */
  116751. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116752. meshes: AbstractMesh[];
  116753. particleSystems: IParticleSystem[];
  116754. skeletons: Skeleton[];
  116755. animationGroups: AnimationGroup[];
  116756. }>;
  116757. /**
  116758. * Load a scene
  116759. * @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)
  116760. * @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)
  116761. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116762. * @param onSuccess a callback with the scene when import succeeds
  116763. * @param onProgress a callback with a progress event for each file being loaded
  116764. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116765. * @param pluginExtension the extension used to determine the plugin
  116766. * @returns The loaded plugin
  116767. */
  116768. 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>;
  116769. /**
  116770. * Load a scene
  116771. * @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)
  116772. * @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)
  116773. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116774. * @param onProgress a callback with a progress event for each file being loaded
  116775. * @param pluginExtension the extension used to determine the plugin
  116776. * @returns The loaded scene
  116777. */
  116778. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116779. /**
  116780. * Append a scene
  116781. * @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)
  116782. * @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)
  116783. * @param scene is the instance of BABYLON.Scene to append to
  116784. * @param onSuccess a callback with the scene when import succeeds
  116785. * @param onProgress a callback with a progress event for each file being loaded
  116786. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116787. * @param pluginExtension the extension used to determine the plugin
  116788. * @returns The loaded plugin
  116789. */
  116790. 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>;
  116791. /**
  116792. * Append a scene
  116793. * @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)
  116794. * @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)
  116795. * @param scene is the instance of BABYLON.Scene to append to
  116796. * @param onProgress a callback with a progress event for each file being loaded
  116797. * @param pluginExtension the extension used to determine the plugin
  116798. * @returns The given scene
  116799. */
  116800. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116801. /**
  116802. * Load a scene into an asset container
  116803. * @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)
  116804. * @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)
  116805. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116806. * @param onSuccess a callback with the scene when import succeeds
  116807. * @param onProgress a callback with a progress event for each file being loaded
  116808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116809. * @param pluginExtension the extension used to determine the plugin
  116810. * @returns The loaded plugin
  116811. */
  116812. 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>;
  116813. /**
  116814. * Load a scene into an asset container
  116815. * @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)
  116816. * @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)
  116817. * @param scene is the instance of Scene to append to
  116818. * @param onProgress a callback with a progress event for each file being loaded
  116819. * @param pluginExtension the extension used to determine the plugin
  116820. * @returns The loaded asset container
  116821. */
  116822. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116823. /**
  116824. * Import animations from a file into a scene
  116825. * @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)
  116826. * @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)
  116827. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116828. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116829. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116830. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116831. * @param onSuccess a callback with the scene when import succeeds
  116832. * @param onProgress a callback with a progress event for each file being loaded
  116833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116834. */
  116835. 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;
  116836. /**
  116837. * Import animations from a file into a scene
  116838. * @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)
  116839. * @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)
  116840. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116841. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116842. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116843. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116844. * @param onSuccess a callback with the scene when import succeeds
  116845. * @param onProgress a callback with a progress event for each file being loaded
  116846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116847. * @returns the updated scene with imported animations
  116848. */
  116849. 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>;
  116850. }
  116851. }
  116852. declare module BABYLON {
  116853. /**
  116854. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116855. */
  116856. export type MotionControllerHandness = "none" | "left" | "right";
  116857. /**
  116858. * The type of components available in motion controllers.
  116859. * This is not the name of the component.
  116860. */
  116861. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116862. /**
  116863. * The state of a controller component
  116864. */
  116865. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116866. /**
  116867. * The schema of motion controller layout.
  116868. * No object will be initialized using this interface
  116869. * This is used just to define the profile.
  116870. */
  116871. export interface IMotionControllerLayout {
  116872. /**
  116873. * Path to load the assets. Usually relative to the base path
  116874. */
  116875. assetPath: string;
  116876. /**
  116877. * Available components (unsorted)
  116878. */
  116879. components: {
  116880. /**
  116881. * A map of component Ids
  116882. */
  116883. [componentId: string]: {
  116884. /**
  116885. * The type of input the component outputs
  116886. */
  116887. type: MotionControllerComponentType;
  116888. /**
  116889. * The indices of this component in the gamepad object
  116890. */
  116891. gamepadIndices: {
  116892. /**
  116893. * Index of button
  116894. */
  116895. button?: number;
  116896. /**
  116897. * If available, index of x-axis
  116898. */
  116899. xAxis?: number;
  116900. /**
  116901. * If available, index of y-axis
  116902. */
  116903. yAxis?: number;
  116904. };
  116905. /**
  116906. * The mesh's root node name
  116907. */
  116908. rootNodeName: string;
  116909. /**
  116910. * Animation definitions for this model
  116911. */
  116912. visualResponses: {
  116913. [stateKey: string]: {
  116914. /**
  116915. * What property will be animated
  116916. */
  116917. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116918. /**
  116919. * What states influence this visual response
  116920. */
  116921. states: MotionControllerComponentStateType[];
  116922. /**
  116923. * Type of animation - movement or visibility
  116924. */
  116925. valueNodeProperty: "transform" | "visibility";
  116926. /**
  116927. * Base node name to move. Its position will be calculated according to the min and max nodes
  116928. */
  116929. valueNodeName?: string;
  116930. /**
  116931. * Minimum movement node
  116932. */
  116933. minNodeName?: string;
  116934. /**
  116935. * Max movement node
  116936. */
  116937. maxNodeName?: string;
  116938. };
  116939. };
  116940. /**
  116941. * If touch enabled, what is the name of node to display user feedback
  116942. */
  116943. touchPointNodeName?: string;
  116944. };
  116945. };
  116946. /**
  116947. * Is it xr standard mapping or not
  116948. */
  116949. gamepadMapping: "" | "xr-standard";
  116950. /**
  116951. * Base root node of this entire model
  116952. */
  116953. rootNodeName: string;
  116954. /**
  116955. * Defines the main button component id
  116956. */
  116957. selectComponentId: string;
  116958. }
  116959. /**
  116960. * A definition for the layout map in the input profile
  116961. */
  116962. export interface IMotionControllerLayoutMap {
  116963. /**
  116964. * Layouts with handness type as a key
  116965. */
  116966. [handness: string]: IMotionControllerLayout;
  116967. }
  116968. /**
  116969. * The XR Input profile schema
  116970. * Profiles can be found here:
  116971. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116972. */
  116973. export interface IMotionControllerProfile {
  116974. /**
  116975. * fallback profiles for this profileId
  116976. */
  116977. fallbackProfileIds: string[];
  116978. /**
  116979. * The layout map, with handness as key
  116980. */
  116981. layouts: IMotionControllerLayoutMap;
  116982. /**
  116983. * The id of this profile
  116984. * correlates to the profile(s) in the xrInput.profiles array
  116985. */
  116986. profileId: string;
  116987. }
  116988. /**
  116989. * A helper-interface for the 3 meshes needed for controller button animation
  116990. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116991. */
  116992. export interface IMotionControllerButtonMeshMap {
  116993. /**
  116994. * the mesh that defines the pressed value mesh position.
  116995. * This is used to find the max-position of this button
  116996. */
  116997. pressedMesh: AbstractMesh;
  116998. /**
  116999. * the mesh that defines the unpressed value mesh position.
  117000. * This is used to find the min (or initial) position of this button
  117001. */
  117002. unpressedMesh: AbstractMesh;
  117003. /**
  117004. * The mesh that will be changed when value changes
  117005. */
  117006. valueMesh: AbstractMesh;
  117007. }
  117008. /**
  117009. * A helper-interface for the 3 meshes needed for controller axis animation.
  117010. * This will be expanded when touchpad animations are fully supported
  117011. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117012. */
  117013. export interface IMotionControllerMeshMap {
  117014. /**
  117015. * the mesh that defines the maximum value mesh position.
  117016. */
  117017. maxMesh?: AbstractMesh;
  117018. /**
  117019. * the mesh that defines the minimum value mesh position.
  117020. */
  117021. minMesh?: AbstractMesh;
  117022. /**
  117023. * The mesh that will be changed when axis value changes
  117024. */
  117025. valueMesh: AbstractMesh;
  117026. }
  117027. /**
  117028. * The elements needed for change-detection of the gamepad objects in motion controllers
  117029. */
  117030. export interface IMinimalMotionControllerObject {
  117031. /**
  117032. * Available axes of this controller
  117033. */
  117034. axes: number[];
  117035. /**
  117036. * An array of available buttons
  117037. */
  117038. buttons: Array<{
  117039. /**
  117040. * Value of the button/trigger
  117041. */
  117042. value: number;
  117043. /**
  117044. * If the button/trigger is currently touched
  117045. */
  117046. touched: boolean;
  117047. /**
  117048. * If the button/trigger is currently pressed
  117049. */
  117050. pressed: boolean;
  117051. }>;
  117052. }
  117053. /**
  117054. * An Abstract Motion controller
  117055. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117056. * Each component has an observable to check for changes in value and state
  117057. */
  117058. export abstract class WebXRAbstractMotionController implements IDisposable {
  117059. protected scene: Scene;
  117060. protected layout: IMotionControllerLayout;
  117061. /**
  117062. * The gamepad object correlating to this controller
  117063. */
  117064. gamepadObject: IMinimalMotionControllerObject;
  117065. /**
  117066. * handness (left/right/none) of this controller
  117067. */
  117068. handness: MotionControllerHandness;
  117069. private _initComponent;
  117070. private _modelReady;
  117071. /**
  117072. * A map of components (WebXRControllerComponent) in this motion controller
  117073. * Components have a ComponentType and can also have both button and axis definitions
  117074. */
  117075. readonly components: {
  117076. [id: string]: WebXRControllerComponent;
  117077. };
  117078. /**
  117079. * Disable the model's animation. Can be set at any time.
  117080. */
  117081. disableAnimation: boolean;
  117082. /**
  117083. * Observers registered here will be triggered when the model of this controller is done loading
  117084. */
  117085. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117086. /**
  117087. * The profile id of this motion controller
  117088. */
  117089. abstract profileId: string;
  117090. /**
  117091. * The root mesh of the model. It is null if the model was not yet initialized
  117092. */
  117093. rootMesh: Nullable<AbstractMesh>;
  117094. /**
  117095. * constructs a new abstract motion controller
  117096. * @param scene the scene to which the model of the controller will be added
  117097. * @param layout The profile layout to load
  117098. * @param gamepadObject The gamepad object correlating to this controller
  117099. * @param handness handness (left/right/none) of this controller
  117100. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117101. */
  117102. constructor(scene: Scene, layout: IMotionControllerLayout,
  117103. /**
  117104. * The gamepad object correlating to this controller
  117105. */
  117106. gamepadObject: IMinimalMotionControllerObject,
  117107. /**
  117108. * handness (left/right/none) of this controller
  117109. */
  117110. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117111. /**
  117112. * Dispose this controller, the model mesh and all its components
  117113. */
  117114. dispose(): void;
  117115. /**
  117116. * Returns all components of specific type
  117117. * @param type the type to search for
  117118. * @return an array of components with this type
  117119. */
  117120. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117121. /**
  117122. * get a component based an its component id as defined in layout.components
  117123. * @param id the id of the component
  117124. * @returns the component correlates to the id or undefined if not found
  117125. */
  117126. getComponent(id: string): WebXRControllerComponent;
  117127. /**
  117128. * Get the list of components available in this motion controller
  117129. * @returns an array of strings correlating to available components
  117130. */
  117131. getComponentIds(): string[];
  117132. /**
  117133. * Get the first component of specific type
  117134. * @param type type of component to find
  117135. * @return a controller component or null if not found
  117136. */
  117137. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117138. /**
  117139. * Get the main (Select) component of this controller as defined in the layout
  117140. * @returns the main component of this controller
  117141. */
  117142. getMainComponent(): WebXRControllerComponent;
  117143. /**
  117144. * Loads the model correlating to this controller
  117145. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117146. * @returns A promise fulfilled with the result of the model loading
  117147. */
  117148. loadModel(): Promise<boolean>;
  117149. /**
  117150. * Update this model using the current XRFrame
  117151. * @param xrFrame the current xr frame to use and update the model
  117152. */
  117153. updateFromXRFrame(xrFrame: XRFrame): void;
  117154. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117155. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117156. /**
  117157. * Moves the axis on the controller mesh based on its current state
  117158. * @param axis the index of the axis
  117159. * @param axisValue the value of the axis which determines the meshes new position
  117160. * @hidden
  117161. */
  117162. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117163. /**
  117164. * Update the model itself with the current frame data
  117165. * @param xrFrame the frame to use for updating the model mesh
  117166. */
  117167. protected updateModel(xrFrame: XRFrame): void;
  117168. /**
  117169. * Get the filename and path for this controller's model
  117170. * @returns a map of filename and path
  117171. */
  117172. protected abstract _getFilenameAndPath(): {
  117173. filename: string;
  117174. path: string;
  117175. };
  117176. /**
  117177. * This function is called before the mesh is loaded. It checks for loading constraints.
  117178. * For example, this function can check if the GLB loader is available
  117179. * If this function returns false, the generic controller will be loaded instead
  117180. * @returns Is the client ready to load the mesh
  117181. */
  117182. protected abstract _getModelLoadingConstraints(): boolean;
  117183. /**
  117184. * This function will be called after the model was successfully loaded and can be used
  117185. * for mesh transformations before it is available for the user
  117186. * @param meshes the loaded meshes
  117187. */
  117188. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117189. /**
  117190. * Set the root mesh for this controller. Important for the WebXR controller class
  117191. * @param meshes the loaded meshes
  117192. */
  117193. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117194. /**
  117195. * A function executed each frame that updates the mesh (if needed)
  117196. * @param xrFrame the current xrFrame
  117197. */
  117198. protected abstract _updateModel(xrFrame: XRFrame): void;
  117199. private _getGenericFilenameAndPath;
  117200. private _getGenericParentMesh;
  117201. }
  117202. }
  117203. declare module BABYLON {
  117204. /**
  117205. * A generic trigger-only motion controller for WebXR
  117206. */
  117207. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117208. /**
  117209. * Static version of the profile id of this controller
  117210. */
  117211. static ProfileId: string;
  117212. profileId: string;
  117213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117214. protected _getFilenameAndPath(): {
  117215. filename: string;
  117216. path: string;
  117217. };
  117218. protected _getModelLoadingConstraints(): boolean;
  117219. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117221. protected _updateModel(): void;
  117222. }
  117223. }
  117224. declare module BABYLON {
  117225. /**
  117226. * Class containing static functions to help procedurally build meshes
  117227. */
  117228. export class SphereBuilder {
  117229. /**
  117230. * Creates a sphere mesh
  117231. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117232. * * 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`)
  117233. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117234. * * 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
  117235. * * 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)
  117236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117239. * @param name defines the name of the mesh
  117240. * @param options defines the options used to create the mesh
  117241. * @param scene defines the hosting scene
  117242. * @returns the sphere mesh
  117243. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117244. */
  117245. static CreateSphere(name: string, options: {
  117246. segments?: number;
  117247. diameter?: number;
  117248. diameterX?: number;
  117249. diameterY?: number;
  117250. diameterZ?: number;
  117251. arc?: number;
  117252. slice?: number;
  117253. sideOrientation?: number;
  117254. frontUVs?: Vector4;
  117255. backUVs?: Vector4;
  117256. updatable?: boolean;
  117257. }, scene?: Nullable<Scene>): Mesh;
  117258. }
  117259. }
  117260. declare module BABYLON {
  117261. /**
  117262. * A profiled motion controller has its profile loaded from an online repository.
  117263. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117264. */
  117265. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117266. private _repositoryUrl;
  117267. private _buttonMeshMapping;
  117268. private _touchDots;
  117269. /**
  117270. * The profile ID of this controller. Will be populated when the controller initializes.
  117271. */
  117272. profileId: string;
  117273. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117274. dispose(): void;
  117275. protected _getFilenameAndPath(): {
  117276. filename: string;
  117277. path: string;
  117278. };
  117279. protected _getModelLoadingConstraints(): boolean;
  117280. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117281. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117282. protected _updateModel(_xrFrame: XRFrame): void;
  117283. }
  117284. }
  117285. declare module BABYLON {
  117286. /**
  117287. * A construction function type to create a new controller based on an xrInput object
  117288. */
  117289. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117290. /**
  117291. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117292. *
  117293. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117294. * it should be replaced with auto-loaded controllers.
  117295. *
  117296. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117297. */
  117298. export class WebXRMotionControllerManager {
  117299. private static _AvailableControllers;
  117300. private static _Fallbacks;
  117301. private static _ProfileLoadingPromises;
  117302. private static _ProfilesList;
  117303. /**
  117304. * The base URL of the online controller repository. Can be changed at any time.
  117305. */
  117306. static BaseRepositoryUrl: string;
  117307. /**
  117308. * Which repository gets priority - local or online
  117309. */
  117310. static PrioritizeOnlineRepository: boolean;
  117311. /**
  117312. * Use the online repository, or use only locally-defined controllers
  117313. */
  117314. static UseOnlineRepository: boolean;
  117315. /**
  117316. * Clear the cache used for profile loading and reload when requested again
  117317. */
  117318. static ClearProfilesCache(): void;
  117319. /**
  117320. * Register the default fallbacks.
  117321. * This function is called automatically when this file is imported.
  117322. */
  117323. static DefaultFallbacks(): void;
  117324. /**
  117325. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117326. * @param profileId the profile to which a fallback needs to be found
  117327. * @return an array with corresponding fallback profiles
  117328. */
  117329. static FindFallbackWithProfileId(profileId: string): string[];
  117330. /**
  117331. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117332. * The order of search:
  117333. *
  117334. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117335. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117336. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117337. * 4) return the generic trigger controller if none were found
  117338. *
  117339. * @param xrInput the xrInput to which a new controller is initialized
  117340. * @param scene the scene to which the model will be added
  117341. * @param forceProfile force a certain profile for this controller
  117342. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117343. */
  117344. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117345. /**
  117346. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117347. *
  117348. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117349. *
  117350. * @param type the profile type to register
  117351. * @param constructFunction the function to be called when loading this profile
  117352. */
  117353. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117354. /**
  117355. * Register a fallback to a specific profile.
  117356. * @param profileId the profileId that will receive the fallbacks
  117357. * @param fallbacks A list of fallback profiles
  117358. */
  117359. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117360. /**
  117361. * Will update the list of profiles available in the repository
  117362. * @return a promise that resolves to a map of profiles available online
  117363. */
  117364. static UpdateProfilesList(): Promise<{
  117365. [profile: string]: string;
  117366. }>;
  117367. private static _LoadProfileFromRepository;
  117368. private static _LoadProfilesFromAvailableControllers;
  117369. }
  117370. }
  117371. declare module BABYLON {
  117372. /**
  117373. * Configuration options for the WebXR controller creation
  117374. */
  117375. export interface IWebXRControllerOptions {
  117376. /**
  117377. * Should the controller mesh be animated when a user interacts with it
  117378. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117379. */
  117380. disableMotionControllerAnimation?: boolean;
  117381. /**
  117382. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117383. */
  117384. doNotLoadControllerMesh?: boolean;
  117385. /**
  117386. * Force a specific controller type for this controller.
  117387. * This can be used when creating your own profile or when testing different controllers
  117388. */
  117389. forceControllerProfile?: string;
  117390. }
  117391. /**
  117392. * Represents an XR controller
  117393. */
  117394. export class WebXRInputSource {
  117395. private _scene;
  117396. /** The underlying input source for the controller */
  117397. inputSource: XRInputSource;
  117398. private _options;
  117399. private _tmpQuaternion;
  117400. private _tmpVector;
  117401. private _uniqueId;
  117402. /**
  117403. * 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
  117404. */
  117405. grip?: AbstractMesh;
  117406. /**
  117407. * If available, this is the gamepad object related to this controller.
  117408. * Using this object it is possible to get click events and trackpad changes of the
  117409. * webxr controller that is currently being used.
  117410. */
  117411. motionController?: WebXRAbstractMotionController;
  117412. /**
  117413. * Event that fires when the controller is removed/disposed.
  117414. * The object provided as event data is this controller, after associated assets were disposed.
  117415. * uniqueId is still available.
  117416. */
  117417. onDisposeObservable: Observable<WebXRInputSource>;
  117418. /**
  117419. * Will be triggered when the mesh associated with the motion controller is done loading.
  117420. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117421. * A shortened version of controller -> motion controller -> on mesh loaded.
  117422. */
  117423. onMeshLoadedObservable: Observable<AbstractMesh>;
  117424. /**
  117425. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117426. */
  117427. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117428. /**
  117429. * Pointer which can be used to select objects or attach a visible laser to
  117430. */
  117431. pointer: AbstractMesh;
  117432. /**
  117433. * Creates the controller
  117434. * @see https://doc.babylonjs.com/how_to/webxr
  117435. * @param _scene the scene which the controller should be associated to
  117436. * @param inputSource the underlying input source for the controller
  117437. * @param _options options for this controller creation
  117438. */
  117439. constructor(_scene: Scene,
  117440. /** The underlying input source for the controller */
  117441. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117442. /**
  117443. * Get this controllers unique id
  117444. */
  117445. get uniqueId(): string;
  117446. /**
  117447. * Disposes of the object
  117448. */
  117449. dispose(): void;
  117450. /**
  117451. * Gets a world space ray coming from the pointer or grip
  117452. * @param result the resulting ray
  117453. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117454. */
  117455. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117456. /**
  117457. * Updates the controller pose based on the given XRFrame
  117458. * @param xrFrame xr frame to update the pose with
  117459. * @param referenceSpace reference space to use
  117460. */
  117461. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117462. }
  117463. }
  117464. declare module BABYLON {
  117465. /**
  117466. * The schema for initialization options of the XR Input class
  117467. */
  117468. export interface IWebXRInputOptions {
  117469. /**
  117470. * If set to true no model will be automatically loaded
  117471. */
  117472. doNotLoadControllerMeshes?: boolean;
  117473. /**
  117474. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117475. * If not found, the xr input profile data will be used.
  117476. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117477. */
  117478. forceInputProfile?: string;
  117479. /**
  117480. * Do not send a request to the controller repository to load the profile.
  117481. *
  117482. * Instead, use the controllers available in babylon itself.
  117483. */
  117484. disableOnlineControllerRepository?: boolean;
  117485. /**
  117486. * A custom URL for the controllers repository
  117487. */
  117488. customControllersRepositoryURL?: string;
  117489. /**
  117490. * Should the controller model's components not move according to the user input
  117491. */
  117492. disableControllerAnimation?: boolean;
  117493. }
  117494. /**
  117495. * XR input used to track XR inputs such as controllers/rays
  117496. */
  117497. export class WebXRInput implements IDisposable {
  117498. /**
  117499. * the xr session manager for this session
  117500. */
  117501. xrSessionManager: WebXRSessionManager;
  117502. /**
  117503. * the WebXR camera for this session. Mainly used for teleportation
  117504. */
  117505. xrCamera: WebXRCamera;
  117506. private readonly options;
  117507. /**
  117508. * XR controllers being tracked
  117509. */
  117510. controllers: Array<WebXRInputSource>;
  117511. private _frameObserver;
  117512. private _sessionEndedObserver;
  117513. private _sessionInitObserver;
  117514. /**
  117515. * Event when a controller has been connected/added
  117516. */
  117517. onControllerAddedObservable: Observable<WebXRInputSource>;
  117518. /**
  117519. * Event when a controller has been removed/disconnected
  117520. */
  117521. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117522. /**
  117523. * Initializes the WebXRInput
  117524. * @param xrSessionManager the xr session manager for this session
  117525. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117526. * @param options = initialization options for this xr input
  117527. */
  117528. constructor(
  117529. /**
  117530. * the xr session manager for this session
  117531. */
  117532. xrSessionManager: WebXRSessionManager,
  117533. /**
  117534. * the WebXR camera for this session. Mainly used for teleportation
  117535. */
  117536. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117537. private _onInputSourcesChange;
  117538. private _addAndRemoveControllers;
  117539. /**
  117540. * Disposes of the object
  117541. */
  117542. dispose(): void;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * This is the base class for all WebXR features.
  117548. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117549. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117550. */
  117551. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117552. protected _xrSessionManager: WebXRSessionManager;
  117553. private _attached;
  117554. private _removeOnDetach;
  117555. /**
  117556. * Should auto-attach be disabled?
  117557. */
  117558. disableAutoAttach: boolean;
  117559. /**
  117560. * Construct a new (abstract) WebXR feature
  117561. * @param _xrSessionManager the xr session manager for this feature
  117562. */
  117563. constructor(_xrSessionManager: WebXRSessionManager);
  117564. /**
  117565. * Is this feature attached
  117566. */
  117567. get attached(): boolean;
  117568. /**
  117569. * attach this feature
  117570. *
  117571. * @param force should attachment be forced (even when already attached)
  117572. * @returns true if successful, false is failed or already attached
  117573. */
  117574. attach(force?: boolean): boolean;
  117575. /**
  117576. * detach this feature.
  117577. *
  117578. * @returns true if successful, false if failed or already detached
  117579. */
  117580. detach(): boolean;
  117581. /**
  117582. * Dispose this feature and all of the resources attached
  117583. */
  117584. dispose(): void;
  117585. /**
  117586. * This is used to register callbacks that will automatically be removed when detach is called.
  117587. * @param observable the observable to which the observer will be attached
  117588. * @param callback the callback to register
  117589. */
  117590. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117591. /**
  117592. * Code in this function will be executed on each xrFrame received from the browser.
  117593. * This function will not execute after the feature is detached.
  117594. * @param _xrFrame the current frame
  117595. */
  117596. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117597. }
  117598. }
  117599. declare module BABYLON {
  117600. /**
  117601. * Renders a layer on top of an existing scene
  117602. */
  117603. export class UtilityLayerRenderer implements IDisposable {
  117604. /** the original scene that will be rendered on top of */
  117605. originalScene: Scene;
  117606. private _pointerCaptures;
  117607. private _lastPointerEvents;
  117608. private static _DefaultUtilityLayer;
  117609. private static _DefaultKeepDepthUtilityLayer;
  117610. private _sharedGizmoLight;
  117611. private _renderCamera;
  117612. /**
  117613. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117614. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117615. * @returns the camera that is used when rendering the utility layer
  117616. */
  117617. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117618. /**
  117619. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117620. * @param cam the camera that should be used when rendering the utility layer
  117621. */
  117622. setRenderCamera(cam: Nullable<Camera>): void;
  117623. /**
  117624. * @hidden
  117625. * Light which used by gizmos to get light shading
  117626. */
  117627. _getSharedGizmoLight(): HemisphericLight;
  117628. /**
  117629. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117630. */
  117631. pickUtilitySceneFirst: boolean;
  117632. /**
  117633. * 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)
  117634. */
  117635. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117636. /**
  117637. * 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)
  117638. */
  117639. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117640. /**
  117641. * The scene that is rendered on top of the original scene
  117642. */
  117643. utilityLayerScene: Scene;
  117644. /**
  117645. * If the utility layer should automatically be rendered on top of existing scene
  117646. */
  117647. shouldRender: boolean;
  117648. /**
  117649. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117650. */
  117651. onlyCheckPointerDownEvents: boolean;
  117652. /**
  117653. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117654. */
  117655. processAllEvents: boolean;
  117656. /**
  117657. * Observable raised when the pointer move from the utility layer scene to the main scene
  117658. */
  117659. onPointerOutObservable: Observable<number>;
  117660. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117661. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117662. private _afterRenderObserver;
  117663. private _sceneDisposeObserver;
  117664. private _originalPointerObserver;
  117665. /**
  117666. * Instantiates a UtilityLayerRenderer
  117667. * @param originalScene the original scene that will be rendered on top of
  117668. * @param handleEvents boolean indicating if the utility layer should handle events
  117669. */
  117670. constructor(
  117671. /** the original scene that will be rendered on top of */
  117672. originalScene: Scene, handleEvents?: boolean);
  117673. private _notifyObservers;
  117674. /**
  117675. * Renders the utility layers scene on top of the original scene
  117676. */
  117677. render(): void;
  117678. /**
  117679. * Disposes of the renderer
  117680. */
  117681. dispose(): void;
  117682. private _updateCamera;
  117683. }
  117684. }
  117685. declare module BABYLON {
  117686. /**
  117687. * Options interface for the pointer selection module
  117688. */
  117689. export interface IWebXRControllerPointerSelectionOptions {
  117690. /**
  117691. * if provided, this scene will be used to render meshes.
  117692. */
  117693. customUtilityLayerScene?: Scene;
  117694. /**
  117695. * 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)
  117696. * If not disabled, the last picked point will be used to execute a pointer up event
  117697. * If disabled, pointer up event will be triggered right after the pointer down event.
  117698. * Used in screen and gaze target ray mode only
  117699. */
  117700. disablePointerUpOnTouchOut: boolean;
  117701. /**
  117702. * For gaze mode (time to select instead of press)
  117703. */
  117704. forceGazeMode: boolean;
  117705. /**
  117706. * 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
  117707. * to start a new countdown to the pointer down event.
  117708. * Defaults to 1.
  117709. */
  117710. gazeModePointerMovedFactor?: number;
  117711. /**
  117712. * Different button type to use instead of the main component
  117713. */
  117714. overrideButtonId?: string;
  117715. /**
  117716. * use this rendering group id for the meshes (optional)
  117717. */
  117718. renderingGroupId?: number;
  117719. /**
  117720. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117721. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117722. * 3000 means 3 seconds between pointing at something and selecting it
  117723. */
  117724. timeToSelect?: number;
  117725. /**
  117726. * Should meshes created here be added to a utility layer or the main scene
  117727. */
  117728. useUtilityLayer?: boolean;
  117729. /**
  117730. * the xr input to use with this pointer selection
  117731. */
  117732. xrInput: WebXRInput;
  117733. }
  117734. /**
  117735. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117736. */
  117737. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117738. private readonly _options;
  117739. private static _idCounter;
  117740. private _attachController;
  117741. private _controllers;
  117742. private _scene;
  117743. private _tmpVectorForPickCompare;
  117744. /**
  117745. * The module's name
  117746. */
  117747. static readonly Name: string;
  117748. /**
  117749. * The (Babylon) version of this module.
  117750. * This is an integer representing the implementation version.
  117751. * This number does not correspond to the WebXR specs version
  117752. */
  117753. static readonly Version: number;
  117754. /**
  117755. * Disable lighting on the laser pointer (so it will always be visible)
  117756. */
  117757. disablePointerLighting: boolean;
  117758. /**
  117759. * Disable lighting on the selection mesh (so it will always be visible)
  117760. */
  117761. disableSelectionMeshLighting: boolean;
  117762. /**
  117763. * Should the laser pointer be displayed
  117764. */
  117765. displayLaserPointer: boolean;
  117766. /**
  117767. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117768. */
  117769. displaySelectionMesh: boolean;
  117770. /**
  117771. * This color will be set to the laser pointer when selection is triggered
  117772. */
  117773. laserPointerPickedColor: Color3;
  117774. /**
  117775. * Default color of the laser pointer
  117776. */
  117777. lasterPointerDefaultColor: Color3;
  117778. /**
  117779. * default color of the selection ring
  117780. */
  117781. selectionMeshDefaultColor: Color3;
  117782. /**
  117783. * This color will be applied to the selection ring when selection is triggered
  117784. */
  117785. selectionMeshPickedColor: Color3;
  117786. /**
  117787. * constructs a new background remover module
  117788. * @param _xrSessionManager the session manager for this module
  117789. * @param _options read-only options to be used in this module
  117790. */
  117791. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117792. /**
  117793. * attach this feature
  117794. * Will usually be called by the features manager
  117795. *
  117796. * @returns true if successful.
  117797. */
  117798. attach(): boolean;
  117799. /**
  117800. * detach this feature.
  117801. * Will usually be called by the features manager
  117802. *
  117803. * @returns true if successful.
  117804. */
  117805. detach(): boolean;
  117806. /**
  117807. * Will get the mesh under a specific pointer.
  117808. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117809. * @param controllerId the controllerId to check
  117810. * @returns The mesh under pointer or null if no mesh is under the pointer
  117811. */
  117812. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117813. /**
  117814. * Get the xr controller that correlates to the pointer id in the pointer event
  117815. *
  117816. * @param id the pointer id to search for
  117817. * @returns the controller that correlates to this id or null if not found
  117818. */
  117819. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117820. protected _onXRFrame(_xrFrame: XRFrame): void;
  117821. private _attachGazeMode;
  117822. private _attachScreenRayMode;
  117823. private _attachTrackedPointerRayMode;
  117824. private _convertNormalToDirectionOfRay;
  117825. private _detachController;
  117826. private _generateNewMeshPair;
  117827. private _pickingMoved;
  117828. private _updatePointerDistance;
  117829. }
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * Button which can be used to enter a different mode of XR
  117834. */
  117835. export class WebXREnterExitUIButton {
  117836. /** button element */
  117837. element: HTMLElement;
  117838. /** XR initialization options for the button */
  117839. sessionMode: XRSessionMode;
  117840. /** Reference space type */
  117841. referenceSpaceType: XRReferenceSpaceType;
  117842. /**
  117843. * Creates a WebXREnterExitUIButton
  117844. * @param element button element
  117845. * @param sessionMode XR initialization session mode
  117846. * @param referenceSpaceType the type of reference space to be used
  117847. */
  117848. constructor(
  117849. /** button element */
  117850. element: HTMLElement,
  117851. /** XR initialization options for the button */
  117852. sessionMode: XRSessionMode,
  117853. /** Reference space type */
  117854. referenceSpaceType: XRReferenceSpaceType);
  117855. /**
  117856. * Extendable function which can be used to update the button's visuals when the state changes
  117857. * @param activeButton the current active button in the UI
  117858. */
  117859. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117860. }
  117861. /**
  117862. * Options to create the webXR UI
  117863. */
  117864. export class WebXREnterExitUIOptions {
  117865. /**
  117866. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117867. */
  117868. customButtons?: Array<WebXREnterExitUIButton>;
  117869. /**
  117870. * A reference space type to use when creating the default button.
  117871. * Default is local-floor
  117872. */
  117873. referenceSpaceType?: XRReferenceSpaceType;
  117874. /**
  117875. * Context to enter xr with
  117876. */
  117877. renderTarget?: Nullable<WebXRRenderTarget>;
  117878. /**
  117879. * A session mode to use when creating the default button.
  117880. * Default is immersive-vr
  117881. */
  117882. sessionMode?: XRSessionMode;
  117883. }
  117884. /**
  117885. * UI to allow the user to enter/exit XR mode
  117886. */
  117887. export class WebXREnterExitUI implements IDisposable {
  117888. private scene;
  117889. /** version of the options passed to this UI */
  117890. options: WebXREnterExitUIOptions;
  117891. private _activeButton;
  117892. private _buttons;
  117893. private _overlay;
  117894. /**
  117895. * Fired every time the active button is changed.
  117896. *
  117897. * When xr is entered via a button that launches xr that button will be the callback parameter
  117898. *
  117899. * When exiting xr the callback parameter will be null)
  117900. */
  117901. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117902. /**
  117903. *
  117904. * @param scene babylon scene object to use
  117905. * @param options (read-only) version of the options passed to this UI
  117906. */
  117907. private constructor();
  117908. /**
  117909. * Creates UI to allow the user to enter/exit XR mode
  117910. * @param scene the scene to add the ui to
  117911. * @param helper the xr experience helper to enter/exit xr with
  117912. * @param options options to configure the UI
  117913. * @returns the created ui
  117914. */
  117915. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117916. /**
  117917. * Disposes of the XR UI component
  117918. */
  117919. dispose(): void;
  117920. private _updateButtons;
  117921. }
  117922. }
  117923. declare module BABYLON {
  117924. /**
  117925. * Class containing static functions to help procedurally build meshes
  117926. */
  117927. export class LinesBuilder {
  117928. /**
  117929. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117930. * * 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
  117931. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117932. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117933. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117934. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117935. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117936. * * 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
  117937. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117940. * @param name defines the name of the new line system
  117941. * @param options defines the options used to create the line system
  117942. * @param scene defines the hosting scene
  117943. * @returns a new line system mesh
  117944. */
  117945. static CreateLineSystem(name: string, options: {
  117946. lines: Vector3[][];
  117947. updatable?: boolean;
  117948. instance?: Nullable<LinesMesh>;
  117949. colors?: Nullable<Color4[][]>;
  117950. useVertexAlpha?: boolean;
  117951. }, scene: Nullable<Scene>): LinesMesh;
  117952. /**
  117953. * Creates a line mesh
  117954. * 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
  117955. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117956. * * The parameter `points` is an array successive Vector3
  117957. * * 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
  117958. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117959. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117960. * * When updating an instance, remember that only point positions can change, not the number of points
  117961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117963. * @param name defines the name of the new line system
  117964. * @param options defines the options used to create the line system
  117965. * @param scene defines the hosting scene
  117966. * @returns a new line mesh
  117967. */
  117968. static CreateLines(name: string, options: {
  117969. points: Vector3[];
  117970. updatable?: boolean;
  117971. instance?: Nullable<LinesMesh>;
  117972. colors?: Color4[];
  117973. useVertexAlpha?: boolean;
  117974. }, scene?: Nullable<Scene>): LinesMesh;
  117975. /**
  117976. * Creates a dashed line mesh
  117977. * * 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
  117978. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117979. * * The parameter `points` is an array successive Vector3
  117980. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117981. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117982. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117983. * * 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
  117984. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117985. * * When updating an instance, remember that only point positions can change, not the number of points
  117986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117987. * @param name defines the name of the mesh
  117988. * @param options defines the options used to create the mesh
  117989. * @param scene defines the hosting scene
  117990. * @returns the dashed line mesh
  117991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117992. */
  117993. static CreateDashedLines(name: string, options: {
  117994. points: Vector3[];
  117995. dashSize?: number;
  117996. gapSize?: number;
  117997. dashNb?: number;
  117998. updatable?: boolean;
  117999. instance?: LinesMesh;
  118000. useVertexAlpha?: boolean;
  118001. }, scene?: Nullable<Scene>): LinesMesh;
  118002. }
  118003. }
  118004. declare module BABYLON {
  118005. /**
  118006. * The options container for the teleportation module
  118007. */
  118008. export interface IWebXRTeleportationOptions {
  118009. /**
  118010. * if provided, this scene will be used to render meshes.
  118011. */
  118012. customUtilityLayerScene?: Scene;
  118013. /**
  118014. * Values to configure the default target mesh
  118015. */
  118016. defaultTargetMeshOptions?: {
  118017. /**
  118018. * Fill color of the teleportation area
  118019. */
  118020. teleportationFillColor?: string;
  118021. /**
  118022. * Border color for the teleportation area
  118023. */
  118024. teleportationBorderColor?: string;
  118025. /**
  118026. * Disable the mesh's animation sequence
  118027. */
  118028. disableAnimation?: boolean;
  118029. /**
  118030. * Disable lighting on the material or the ring and arrow
  118031. */
  118032. disableLighting?: boolean;
  118033. /**
  118034. * Override the default material of the torus and arrow
  118035. */
  118036. torusArrowMaterial?: Material;
  118037. };
  118038. /**
  118039. * A list of meshes to use as floor meshes.
  118040. * Meshes can be added and removed after initializing the feature using the
  118041. * addFloorMesh and removeFloorMesh functions
  118042. * If empty, rotation will still work
  118043. */
  118044. floorMeshes?: AbstractMesh[];
  118045. /**
  118046. * use this rendering group id for the meshes (optional)
  118047. */
  118048. renderingGroupId?: number;
  118049. /**
  118050. * Should teleportation move only to snap points
  118051. */
  118052. snapPointsOnly?: boolean;
  118053. /**
  118054. * An array of points to which the teleportation will snap to.
  118055. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118056. */
  118057. snapPositions?: Vector3[];
  118058. /**
  118059. * How close should the teleportation ray be in order to snap to position.
  118060. * Default to 0.8 units (meters)
  118061. */
  118062. snapToPositionRadius?: number;
  118063. /**
  118064. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118065. * If you want to support rotation, make sure your mesh has a direction indicator.
  118066. *
  118067. * When left untouched, the default mesh will be initialized.
  118068. */
  118069. teleportationTargetMesh?: AbstractMesh;
  118070. /**
  118071. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118072. */
  118073. timeToTeleport?: number;
  118074. /**
  118075. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118076. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118077. */
  118078. useMainComponentOnly?: boolean;
  118079. /**
  118080. * Should meshes created here be added to a utility layer or the main scene
  118081. */
  118082. useUtilityLayer?: boolean;
  118083. /**
  118084. * Babylon XR Input class for controller
  118085. */
  118086. xrInput: WebXRInput;
  118087. }
  118088. /**
  118089. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118090. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118091. * the input of the attached controllers.
  118092. */
  118093. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118094. private _options;
  118095. private _controllers;
  118096. private _currentTeleportationControllerId;
  118097. private _floorMeshes;
  118098. private _quadraticBezierCurve;
  118099. private _selectionFeature;
  118100. private _snapToPositions;
  118101. private _snappedToPoint;
  118102. private _teleportationRingMaterial?;
  118103. private _tmpRay;
  118104. private _tmpVector;
  118105. /**
  118106. * The module's name
  118107. */
  118108. static readonly Name: string;
  118109. /**
  118110. * The (Babylon) version of this module.
  118111. * This is an integer representing the implementation version.
  118112. * This number does not correspond to the webxr specs version
  118113. */
  118114. static readonly Version: number;
  118115. /**
  118116. * Is movement backwards enabled
  118117. */
  118118. backwardsMovementEnabled: boolean;
  118119. /**
  118120. * Distance to travel when moving backwards
  118121. */
  118122. backwardsTeleportationDistance: number;
  118123. /**
  118124. * The distance from the user to the inspection point in the direction of the controller
  118125. * A higher number will allow the user to move further
  118126. * defaults to 5 (meters, in xr units)
  118127. */
  118128. parabolicCheckRadius: number;
  118129. /**
  118130. * Should the module support parabolic ray on top of direct ray
  118131. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118132. * Very helpful when moving between floors / different heights
  118133. */
  118134. parabolicRayEnabled: boolean;
  118135. /**
  118136. * How much rotation should be applied when rotating right and left
  118137. */
  118138. rotationAngle: number;
  118139. /**
  118140. * Is rotation enabled when moving forward?
  118141. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118142. */
  118143. rotationEnabled: boolean;
  118144. /**
  118145. * constructs a new anchor system
  118146. * @param _xrSessionManager an instance of WebXRSessionManager
  118147. * @param _options configuration object for this feature
  118148. */
  118149. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118150. /**
  118151. * Get the snapPointsOnly flag
  118152. */
  118153. get snapPointsOnly(): boolean;
  118154. /**
  118155. * Sets the snapPointsOnly flag
  118156. * @param snapToPoints should teleportation be exclusively to snap points
  118157. */
  118158. set snapPointsOnly(snapToPoints: boolean);
  118159. /**
  118160. * Add a new mesh to the floor meshes array
  118161. * @param mesh the mesh to use as floor mesh
  118162. */
  118163. addFloorMesh(mesh: AbstractMesh): void;
  118164. /**
  118165. * Add a new snap-to point to fix teleportation to this position
  118166. * @param newSnapPoint The new Snap-To point
  118167. */
  118168. addSnapPoint(newSnapPoint: Vector3): void;
  118169. attach(): boolean;
  118170. detach(): boolean;
  118171. dispose(): void;
  118172. /**
  118173. * Remove a mesh from the floor meshes array
  118174. * @param mesh the mesh to remove
  118175. */
  118176. removeFloorMesh(mesh: AbstractMesh): void;
  118177. /**
  118178. * Remove a mesh from the floor meshes array using its name
  118179. * @param name the mesh name to remove
  118180. */
  118181. removeFloorMeshByName(name: string): void;
  118182. /**
  118183. * 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
  118184. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118185. * @returns was the point found and removed or not
  118186. */
  118187. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118188. /**
  118189. * This function sets a selection feature that will be disabled when
  118190. * the forward ray is shown and will be reattached when hidden.
  118191. * This is used to remove the selection rays when moving.
  118192. * @param selectionFeature the feature to disable when forward movement is enabled
  118193. */
  118194. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118195. protected _onXRFrame(_xrFrame: XRFrame): void;
  118196. private _attachController;
  118197. private _createDefaultTargetMesh;
  118198. private _detachController;
  118199. private _findClosestSnapPointWithRadius;
  118200. private _setTargetMeshPosition;
  118201. private _setTargetMeshVisibility;
  118202. private _showParabolicPath;
  118203. private _teleportForward;
  118204. }
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * Options for the default xr helper
  118209. */
  118210. export class WebXRDefaultExperienceOptions {
  118211. /**
  118212. * Enable or disable default UI to enter XR
  118213. */
  118214. disableDefaultUI?: boolean;
  118215. /**
  118216. * Should teleportation not initialize. defaults to false.
  118217. */
  118218. disableTeleportation?: boolean;
  118219. /**
  118220. * Floor meshes that will be used for teleport
  118221. */
  118222. floorMeshes?: Array<AbstractMesh>;
  118223. /**
  118224. * If set to true, the first frame will not be used to reset position
  118225. * The first frame is mainly used when copying transformation from the old camera
  118226. * Mainly used in AR
  118227. */
  118228. ignoreNativeCameraTransformation?: boolean;
  118229. /**
  118230. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118231. */
  118232. inputOptions?: IWebXRInputOptions;
  118233. /**
  118234. * optional configuration for the output canvas
  118235. */
  118236. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118237. /**
  118238. * optional UI options. This can be used among other to change session mode and reference space type
  118239. */
  118240. uiOptions?: WebXREnterExitUIOptions;
  118241. /**
  118242. * When loading teleportation and pointer select, use stable versions instead of latest.
  118243. */
  118244. useStablePlugins?: boolean;
  118245. }
  118246. /**
  118247. * Default experience which provides a similar setup to the previous webVRExperience
  118248. */
  118249. export class WebXRDefaultExperience {
  118250. /**
  118251. * Base experience
  118252. */
  118253. baseExperience: WebXRExperienceHelper;
  118254. /**
  118255. * Enables ui for entering/exiting xr
  118256. */
  118257. enterExitUI: WebXREnterExitUI;
  118258. /**
  118259. * Input experience extension
  118260. */
  118261. input: WebXRInput;
  118262. /**
  118263. * Enables laser pointer and selection
  118264. */
  118265. pointerSelection: WebXRControllerPointerSelection;
  118266. /**
  118267. * Default target xr should render to
  118268. */
  118269. renderTarget: WebXRRenderTarget;
  118270. /**
  118271. * Enables teleportation
  118272. */
  118273. teleportation: WebXRMotionControllerTeleportation;
  118274. private constructor();
  118275. /**
  118276. * Creates the default xr experience
  118277. * @param scene scene
  118278. * @param options options for basic configuration
  118279. * @returns resulting WebXRDefaultExperience
  118280. */
  118281. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118282. /**
  118283. * DIsposes of the experience helper
  118284. */
  118285. dispose(): void;
  118286. }
  118287. }
  118288. declare module BABYLON {
  118289. /**
  118290. * Options to modify the vr teleportation behavior.
  118291. */
  118292. export interface VRTeleportationOptions {
  118293. /**
  118294. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118295. */
  118296. floorMeshName?: string;
  118297. /**
  118298. * A list of meshes to be used as the teleportation floor. (default: empty)
  118299. */
  118300. floorMeshes?: Mesh[];
  118301. /**
  118302. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118303. */
  118304. teleportationMode?: number;
  118305. /**
  118306. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118307. */
  118308. teleportationTime?: number;
  118309. /**
  118310. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118311. */
  118312. teleportationSpeed?: number;
  118313. /**
  118314. * The easing function used in the animation or null for Linear. (default CircleEase)
  118315. */
  118316. easingFunction?: EasingFunction;
  118317. }
  118318. /**
  118319. * Options to modify the vr experience helper's behavior.
  118320. */
  118321. export interface VRExperienceHelperOptions extends WebVROptions {
  118322. /**
  118323. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118324. */
  118325. createDeviceOrientationCamera?: boolean;
  118326. /**
  118327. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118328. */
  118329. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118330. /**
  118331. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118332. */
  118333. laserToggle?: boolean;
  118334. /**
  118335. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118336. */
  118337. floorMeshes?: Mesh[];
  118338. /**
  118339. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118340. */
  118341. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118342. /**
  118343. * Defines if WebXR should be used instead of WebVR (if available)
  118344. */
  118345. useXR?: boolean;
  118346. }
  118347. /**
  118348. * Event containing information after VR has been entered
  118349. */
  118350. export class OnAfterEnteringVRObservableEvent {
  118351. /**
  118352. * If entering vr was successful
  118353. */
  118354. success: boolean;
  118355. }
  118356. /**
  118357. * Helps to quickly add VR support to an existing scene.
  118358. * See http://doc.babylonjs.com/how_to/webvr_helper
  118359. */
  118360. export class VRExperienceHelper {
  118361. /** Options to modify the vr experience helper's behavior. */
  118362. webVROptions: VRExperienceHelperOptions;
  118363. private _scene;
  118364. private _position;
  118365. private _btnVR;
  118366. private _btnVRDisplayed;
  118367. private _webVRsupported;
  118368. private _webVRready;
  118369. private _webVRrequesting;
  118370. private _webVRpresenting;
  118371. private _hasEnteredVR;
  118372. private _fullscreenVRpresenting;
  118373. private _inputElement;
  118374. private _webVRCamera;
  118375. private _vrDeviceOrientationCamera;
  118376. private _deviceOrientationCamera;
  118377. private _existingCamera;
  118378. private _onKeyDown;
  118379. private _onVrDisplayPresentChange;
  118380. private _onVRDisplayChanged;
  118381. private _onVRRequestPresentStart;
  118382. private _onVRRequestPresentComplete;
  118383. /**
  118384. * 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)
  118385. */
  118386. enableGazeEvenWhenNoPointerLock: boolean;
  118387. /**
  118388. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118389. */
  118390. exitVROnDoubleTap: boolean;
  118391. /**
  118392. * Observable raised right before entering VR.
  118393. */
  118394. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118395. /**
  118396. * Observable raised when entering VR has completed.
  118397. */
  118398. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118399. /**
  118400. * Observable raised when exiting VR.
  118401. */
  118402. onExitingVRObservable: Observable<VRExperienceHelper>;
  118403. /**
  118404. * Observable raised when controller mesh is loaded.
  118405. */
  118406. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118407. /** Return this.onEnteringVRObservable
  118408. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118409. */
  118410. get onEnteringVR(): Observable<VRExperienceHelper>;
  118411. /** Return this.onExitingVRObservable
  118412. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118413. */
  118414. get onExitingVR(): Observable<VRExperienceHelper>;
  118415. /** Return this.onControllerMeshLoadedObservable
  118416. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118417. */
  118418. get onControllerMeshLoaded(): Observable<WebVRController>;
  118419. private _rayLength;
  118420. private _useCustomVRButton;
  118421. private _teleportationRequested;
  118422. private _teleportActive;
  118423. private _floorMeshName;
  118424. private _floorMeshesCollection;
  118425. private _teleportationMode;
  118426. private _teleportationTime;
  118427. private _teleportationSpeed;
  118428. private _teleportationEasing;
  118429. private _rotationAllowed;
  118430. private _teleportBackwardsVector;
  118431. private _teleportationTarget;
  118432. private _isDefaultTeleportationTarget;
  118433. private _postProcessMove;
  118434. private _teleportationFillColor;
  118435. private _teleportationBorderColor;
  118436. private _rotationAngle;
  118437. private _haloCenter;
  118438. private _cameraGazer;
  118439. private _padSensibilityUp;
  118440. private _padSensibilityDown;
  118441. private _leftController;
  118442. private _rightController;
  118443. private _gazeColor;
  118444. private _laserColor;
  118445. private _pickedLaserColor;
  118446. private _pickedGazeColor;
  118447. /**
  118448. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118449. */
  118450. onNewMeshSelected: Observable<AbstractMesh>;
  118451. /**
  118452. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118453. * This observable will provide the mesh and the controller used to select the mesh
  118454. */
  118455. onMeshSelectedWithController: Observable<{
  118456. mesh: AbstractMesh;
  118457. controller: WebVRController;
  118458. }>;
  118459. /**
  118460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118461. */
  118462. onNewMeshPicked: Observable<PickingInfo>;
  118463. private _circleEase;
  118464. /**
  118465. * Observable raised before camera teleportation
  118466. */
  118467. onBeforeCameraTeleport: Observable<Vector3>;
  118468. /**
  118469. * Observable raised after camera teleportation
  118470. */
  118471. onAfterCameraTeleport: Observable<Vector3>;
  118472. /**
  118473. * Observable raised when current selected mesh gets unselected
  118474. */
  118475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118476. private _raySelectionPredicate;
  118477. /**
  118478. * To be optionaly changed by user to define custom ray selection
  118479. */
  118480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118481. /**
  118482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118483. */
  118484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118485. /**
  118486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118487. */
  118488. teleportationEnabled: boolean;
  118489. private _defaultHeight;
  118490. private _teleportationInitialized;
  118491. private _interactionsEnabled;
  118492. private _interactionsRequested;
  118493. private _displayGaze;
  118494. private _displayLaserPointer;
  118495. /**
  118496. * The mesh used to display where the user is going to teleport.
  118497. */
  118498. get teleportationTarget(): Mesh;
  118499. /**
  118500. * Sets the mesh to be used to display where the user is going to teleport.
  118501. */
  118502. set teleportationTarget(value: Mesh);
  118503. /**
  118504. * 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
  118505. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118506. * See http://doc.babylonjs.com/resources/baking_transformations
  118507. */
  118508. get gazeTrackerMesh(): Mesh;
  118509. set gazeTrackerMesh(value: Mesh);
  118510. /**
  118511. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118512. */
  118513. updateGazeTrackerScale: boolean;
  118514. /**
  118515. * If the gaze trackers color should be updated when selecting meshes
  118516. */
  118517. updateGazeTrackerColor: boolean;
  118518. /**
  118519. * If the controller laser color should be updated when selecting meshes
  118520. */
  118521. updateControllerLaserColor: boolean;
  118522. /**
  118523. * The gaze tracking mesh corresponding to the left controller
  118524. */
  118525. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118526. /**
  118527. * The gaze tracking mesh corresponding to the right controller
  118528. */
  118529. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118530. /**
  118531. * If the ray of the gaze should be displayed.
  118532. */
  118533. get displayGaze(): boolean;
  118534. /**
  118535. * Sets if the ray of the gaze should be displayed.
  118536. */
  118537. set displayGaze(value: boolean);
  118538. /**
  118539. * If the ray of the LaserPointer should be displayed.
  118540. */
  118541. get displayLaserPointer(): boolean;
  118542. /**
  118543. * Sets if the ray of the LaserPointer should be displayed.
  118544. */
  118545. set displayLaserPointer(value: boolean);
  118546. /**
  118547. * The deviceOrientationCamera used as the camera when not in VR.
  118548. */
  118549. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118550. /**
  118551. * Based on the current WebVR support, returns the current VR camera used.
  118552. */
  118553. get currentVRCamera(): Nullable<Camera>;
  118554. /**
  118555. * The webVRCamera which is used when in VR.
  118556. */
  118557. get webVRCamera(): WebVRFreeCamera;
  118558. /**
  118559. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118560. */
  118561. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118562. /**
  118563. * The html button that is used to trigger entering into VR.
  118564. */
  118565. get vrButton(): Nullable<HTMLButtonElement>;
  118566. private get _teleportationRequestInitiated();
  118567. /**
  118568. * Defines whether or not Pointer lock should be requested when switching to
  118569. * full screen.
  118570. */
  118571. requestPointerLockOnFullScreen: boolean;
  118572. /**
  118573. * If asking to force XR, this will be populated with the default xr experience
  118574. */
  118575. xr: WebXRDefaultExperience;
  118576. /**
  118577. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118578. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118579. */
  118580. xrTestDone: boolean;
  118581. /**
  118582. * Instantiates a VRExperienceHelper.
  118583. * Helps to quickly add VR support to an existing scene.
  118584. * @param scene The scene the VRExperienceHelper belongs to.
  118585. * @param webVROptions Options to modify the vr experience helper's behavior.
  118586. */
  118587. constructor(scene: Scene,
  118588. /** Options to modify the vr experience helper's behavior. */
  118589. webVROptions?: VRExperienceHelperOptions);
  118590. private completeVRInit;
  118591. private _onDefaultMeshLoaded;
  118592. private _onResize;
  118593. private _onFullscreenChange;
  118594. /**
  118595. * Gets a value indicating if we are currently in VR mode.
  118596. */
  118597. get isInVRMode(): boolean;
  118598. private onVrDisplayPresentChange;
  118599. private onVRDisplayChanged;
  118600. private moveButtonToBottomRight;
  118601. private displayVRButton;
  118602. private updateButtonVisibility;
  118603. private _cachedAngularSensibility;
  118604. /**
  118605. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118606. * Otherwise, will use the fullscreen API.
  118607. */
  118608. enterVR(): void;
  118609. /**
  118610. * Attempt to exit VR, or fullscreen.
  118611. */
  118612. exitVR(): void;
  118613. /**
  118614. * The position of the vr experience helper.
  118615. */
  118616. get position(): Vector3;
  118617. /**
  118618. * Sets the position of the vr experience helper.
  118619. */
  118620. set position(value: Vector3);
  118621. /**
  118622. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118623. */
  118624. enableInteractions(): void;
  118625. private get _noControllerIsActive();
  118626. private beforeRender;
  118627. private _isTeleportationFloor;
  118628. /**
  118629. * Adds a floor mesh to be used for teleportation.
  118630. * @param floorMesh the mesh to be used for teleportation.
  118631. */
  118632. addFloorMesh(floorMesh: Mesh): void;
  118633. /**
  118634. * Removes a floor mesh from being used for teleportation.
  118635. * @param floorMesh the mesh to be removed.
  118636. */
  118637. removeFloorMesh(floorMesh: Mesh): void;
  118638. /**
  118639. * Enables interactions and teleportation using the VR controllers and gaze.
  118640. * @param vrTeleportationOptions options to modify teleportation behavior.
  118641. */
  118642. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118643. private _onNewGamepadConnected;
  118644. private _tryEnableInteractionOnController;
  118645. private _onNewGamepadDisconnected;
  118646. private _enableInteractionOnController;
  118647. private _checkTeleportWithRay;
  118648. private _checkRotate;
  118649. private _checkTeleportBackwards;
  118650. private _enableTeleportationOnController;
  118651. private _createTeleportationCircles;
  118652. private _displayTeleportationTarget;
  118653. private _hideTeleportationTarget;
  118654. private _rotateCamera;
  118655. private _moveTeleportationSelectorTo;
  118656. private _workingVector;
  118657. private _workingQuaternion;
  118658. private _workingMatrix;
  118659. /**
  118660. * Time Constant Teleportation Mode
  118661. */
  118662. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118663. /**
  118664. * Speed Constant Teleportation Mode
  118665. */
  118666. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118667. /**
  118668. * Teleports the users feet to the desired location
  118669. * @param location The location where the user's feet should be placed
  118670. */
  118671. teleportCamera(location: Vector3): void;
  118672. private _convertNormalToDirectionOfRay;
  118673. private _castRayAndSelectObject;
  118674. private _notifySelectedMeshUnselected;
  118675. /**
  118676. * Permanently set new colors for the laser pointer
  118677. * @param color the new laser color
  118678. * @param pickedColor the new laser color when picked mesh detected
  118679. */
  118680. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118681. /**
  118682. * Set lighting enabled / disabled on the laser pointer of both controllers
  118683. * @param enabled should the lighting be enabled on the laser pointer
  118684. */
  118685. setLaserLightingState(enabled?: boolean): void;
  118686. /**
  118687. * Permanently set new colors for the gaze pointer
  118688. * @param color the new gaze color
  118689. * @param pickedColor the new gaze color when picked mesh detected
  118690. */
  118691. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118692. /**
  118693. * Sets the color of the laser ray from the vr controllers.
  118694. * @param color new color for the ray.
  118695. */
  118696. changeLaserColor(color: Color3): void;
  118697. /**
  118698. * Sets the color of the ray from the vr headsets gaze.
  118699. * @param color new color for the ray.
  118700. */
  118701. changeGazeColor(color: Color3): void;
  118702. /**
  118703. * Exits VR and disposes of the vr experience helper
  118704. */
  118705. dispose(): void;
  118706. /**
  118707. * Gets the name of the VRExperienceHelper class
  118708. * @returns "VRExperienceHelper"
  118709. */
  118710. getClassName(): string;
  118711. }
  118712. }
  118713. declare module BABYLON {
  118714. /**
  118715. * Contains an array of blocks representing the octree
  118716. */
  118717. export interface IOctreeContainer<T> {
  118718. /**
  118719. * Blocks within the octree
  118720. */
  118721. blocks: Array<OctreeBlock<T>>;
  118722. }
  118723. /**
  118724. * Class used to store a cell in an octree
  118725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118726. */
  118727. export class OctreeBlock<T> {
  118728. /**
  118729. * Gets the content of the current block
  118730. */
  118731. entries: T[];
  118732. /**
  118733. * Gets the list of block children
  118734. */
  118735. blocks: Array<OctreeBlock<T>>;
  118736. private _depth;
  118737. private _maxDepth;
  118738. private _capacity;
  118739. private _minPoint;
  118740. private _maxPoint;
  118741. private _boundingVectors;
  118742. private _creationFunc;
  118743. /**
  118744. * Creates a new block
  118745. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118746. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118747. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118748. * @param depth defines the current depth of this block in the octree
  118749. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118750. * @param creationFunc defines a callback to call when an element is added to the block
  118751. */
  118752. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118753. /**
  118754. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118755. */
  118756. get capacity(): number;
  118757. /**
  118758. * Gets the minimum vector (in world space) of the block's bounding box
  118759. */
  118760. get minPoint(): Vector3;
  118761. /**
  118762. * Gets the maximum vector (in world space) of the block's bounding box
  118763. */
  118764. get maxPoint(): Vector3;
  118765. /**
  118766. * Add a new element to this block
  118767. * @param entry defines the element to add
  118768. */
  118769. addEntry(entry: T): void;
  118770. /**
  118771. * Remove an element from this block
  118772. * @param entry defines the element to remove
  118773. */
  118774. removeEntry(entry: T): void;
  118775. /**
  118776. * Add an array of elements to this block
  118777. * @param entries defines the array of elements to add
  118778. */
  118779. addEntries(entries: T[]): void;
  118780. /**
  118781. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118782. * @param frustumPlanes defines the frustum planes to test
  118783. * @param selection defines the array to store current content if selection is positive
  118784. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118785. */
  118786. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118787. /**
  118788. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118789. * @param sphereCenter defines the bounding sphere center
  118790. * @param sphereRadius defines the bounding sphere radius
  118791. * @param selection defines the array to store current content if selection is positive
  118792. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118793. */
  118794. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118795. /**
  118796. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118797. * @param ray defines the ray to test with
  118798. * @param selection defines the array to store current content if selection is positive
  118799. */
  118800. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118801. /**
  118802. * Subdivide the content into child blocks (this block will then be empty)
  118803. */
  118804. createInnerBlocks(): void;
  118805. /**
  118806. * @hidden
  118807. */
  118808. 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;
  118809. }
  118810. }
  118811. declare module BABYLON {
  118812. /**
  118813. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118814. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118815. */
  118816. export class Octree<T> {
  118817. /** 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.) */
  118818. maxDepth: number;
  118819. /**
  118820. * Blocks within the octree containing objects
  118821. */
  118822. blocks: Array<OctreeBlock<T>>;
  118823. /**
  118824. * Content stored in the octree
  118825. */
  118826. dynamicContent: T[];
  118827. private _maxBlockCapacity;
  118828. private _selectionContent;
  118829. private _creationFunc;
  118830. /**
  118831. * Creates a octree
  118832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118833. * @param creationFunc function to be used to instatiate the octree
  118834. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118835. * @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.)
  118836. */
  118837. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118838. /** 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.) */
  118839. maxDepth?: number);
  118840. /**
  118841. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118842. * @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);
  118843. * @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);
  118844. * @param entries meshes to be added to the octree blocks
  118845. */
  118846. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118847. /**
  118848. * Adds a mesh to the octree
  118849. * @param entry Mesh to add to the octree
  118850. */
  118851. addMesh(entry: T): void;
  118852. /**
  118853. * Remove an element from the octree
  118854. * @param entry defines the element to remove
  118855. */
  118856. removeMesh(entry: T): void;
  118857. /**
  118858. * Selects an array of meshes within the frustum
  118859. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118860. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118861. * @returns array of meshes within the frustum
  118862. */
  118863. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118864. /**
  118865. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118866. * @param sphereCenter defines the bounding sphere center
  118867. * @param sphereRadius defines the bounding sphere radius
  118868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118869. * @returns an array of objects that intersect the sphere
  118870. */
  118871. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118872. /**
  118873. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118874. * @param ray defines the ray to test with
  118875. * @returns array of intersected objects
  118876. */
  118877. intersectsRay(ray: Ray): SmartArray<T>;
  118878. /**
  118879. * Adds a mesh into the octree block if it intersects the block
  118880. */
  118881. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118882. /**
  118883. * Adds a submesh into the octree block if it intersects the block
  118884. */
  118885. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118886. }
  118887. }
  118888. declare module BABYLON {
  118889. interface Scene {
  118890. /**
  118891. * @hidden
  118892. * Backing Filed
  118893. */
  118894. _selectionOctree: Octree<AbstractMesh>;
  118895. /**
  118896. * Gets the octree used to boost mesh selection (picking)
  118897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118898. */
  118899. selectionOctree: Octree<AbstractMesh>;
  118900. /**
  118901. * Creates or updates the octree used to boost selection (picking)
  118902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118903. * @param maxCapacity defines the maximum capacity per leaf
  118904. * @param maxDepth defines the maximum depth of the octree
  118905. * @returns an octree of AbstractMesh
  118906. */
  118907. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118908. }
  118909. interface AbstractMesh {
  118910. /**
  118911. * @hidden
  118912. * Backing Field
  118913. */
  118914. _submeshesOctree: Octree<SubMesh>;
  118915. /**
  118916. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118917. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118918. * @param maxCapacity defines the maximum size of each block (64 by default)
  118919. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118920. * @returns the new octree
  118921. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118923. */
  118924. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118925. }
  118926. /**
  118927. * Defines the octree scene component responsible to manage any octrees
  118928. * in a given scene.
  118929. */
  118930. export class OctreeSceneComponent {
  118931. /**
  118932. * The component name help to identify the component in the list of scene components.
  118933. */
  118934. readonly name: string;
  118935. /**
  118936. * The scene the component belongs to.
  118937. */
  118938. scene: Scene;
  118939. /**
  118940. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118941. */
  118942. readonly checksIsEnabled: boolean;
  118943. /**
  118944. * Creates a new instance of the component for the given scene
  118945. * @param scene Defines the scene to register the component in
  118946. */
  118947. constructor(scene: Scene);
  118948. /**
  118949. * Registers the component in a given scene
  118950. */
  118951. register(): void;
  118952. /**
  118953. * Return the list of active meshes
  118954. * @returns the list of active meshes
  118955. */
  118956. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118957. /**
  118958. * Return the list of active sub meshes
  118959. * @param mesh The mesh to get the candidates sub meshes from
  118960. * @returns the list of active sub meshes
  118961. */
  118962. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118963. private _tempRay;
  118964. /**
  118965. * Return the list of sub meshes intersecting with a given local ray
  118966. * @param mesh defines the mesh to find the submesh for
  118967. * @param localRay defines the ray in local space
  118968. * @returns the list of intersecting sub meshes
  118969. */
  118970. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118971. /**
  118972. * Return the list of sub meshes colliding with a collider
  118973. * @param mesh defines the mesh to find the submesh for
  118974. * @param collider defines the collider to evaluate the collision against
  118975. * @returns the list of colliding sub meshes
  118976. */
  118977. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118978. /**
  118979. * Rebuilds the elements related to this component in case of
  118980. * context lost for instance.
  118981. */
  118982. rebuild(): void;
  118983. /**
  118984. * Disposes the component and the associated ressources.
  118985. */
  118986. dispose(): void;
  118987. }
  118988. }
  118989. declare module BABYLON {
  118990. /**
  118991. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118992. */
  118993. export class Gizmo implements IDisposable {
  118994. /** The utility layer the gizmo will be added to */
  118995. gizmoLayer: UtilityLayerRenderer;
  118996. /**
  118997. * The root mesh of the gizmo
  118998. */
  118999. _rootMesh: Mesh;
  119000. private _attachedMesh;
  119001. /**
  119002. * Ratio for the scale of the gizmo (Default: 1)
  119003. */
  119004. scaleRatio: number;
  119005. /**
  119006. * If a custom mesh has been set (Default: false)
  119007. */
  119008. protected _customMeshSet: boolean;
  119009. /**
  119010. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119011. * * When set, interactions will be enabled
  119012. */
  119013. get attachedMesh(): Nullable<AbstractMesh>;
  119014. set attachedMesh(value: Nullable<AbstractMesh>);
  119015. /**
  119016. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119017. * @param mesh The mesh to replace the default mesh of the gizmo
  119018. */
  119019. setCustomMesh(mesh: Mesh): void;
  119020. /**
  119021. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119022. */
  119023. updateGizmoRotationToMatchAttachedMesh: boolean;
  119024. /**
  119025. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119026. */
  119027. updateGizmoPositionToMatchAttachedMesh: boolean;
  119028. /**
  119029. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119030. */
  119031. updateScale: boolean;
  119032. protected _interactionsEnabled: boolean;
  119033. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119034. private _beforeRenderObserver;
  119035. private _tempVector;
  119036. /**
  119037. * Creates a gizmo
  119038. * @param gizmoLayer The utility layer the gizmo will be added to
  119039. */
  119040. constructor(
  119041. /** The utility layer the gizmo will be added to */
  119042. gizmoLayer?: UtilityLayerRenderer);
  119043. /**
  119044. * Updates the gizmo to match the attached mesh's position/rotation
  119045. */
  119046. protected _update(): void;
  119047. /**
  119048. * Disposes of the gizmo
  119049. */
  119050. dispose(): void;
  119051. }
  119052. }
  119053. declare module BABYLON {
  119054. /**
  119055. * Single plane drag gizmo
  119056. */
  119057. export class PlaneDragGizmo extends Gizmo {
  119058. /**
  119059. * Drag behavior responsible for the gizmos dragging interactions
  119060. */
  119061. dragBehavior: PointerDragBehavior;
  119062. private _pointerObserver;
  119063. /**
  119064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119065. */
  119066. snapDistance: number;
  119067. /**
  119068. * Event that fires each time the gizmo snaps to a new location.
  119069. * * snapDistance is the the change in distance
  119070. */
  119071. onSnapObservable: Observable<{
  119072. snapDistance: number;
  119073. }>;
  119074. private _plane;
  119075. private _coloredMaterial;
  119076. private _hoverMaterial;
  119077. private _isEnabled;
  119078. private _parent;
  119079. /** @hidden */
  119080. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119081. /** @hidden */
  119082. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119083. /**
  119084. * Creates a PlaneDragGizmo
  119085. * @param gizmoLayer The utility layer the gizmo will be added to
  119086. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119087. * @param color The color of the gizmo
  119088. */
  119089. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119090. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119091. /**
  119092. * If the gizmo is enabled
  119093. */
  119094. set isEnabled(value: boolean);
  119095. get isEnabled(): boolean;
  119096. /**
  119097. * Disposes of the gizmo
  119098. */
  119099. dispose(): void;
  119100. }
  119101. }
  119102. declare module BABYLON {
  119103. /**
  119104. * Gizmo that enables dragging a mesh along 3 axis
  119105. */
  119106. export class PositionGizmo extends Gizmo {
  119107. /**
  119108. * Internal gizmo used for interactions on the x axis
  119109. */
  119110. xGizmo: AxisDragGizmo;
  119111. /**
  119112. * Internal gizmo used for interactions on the y axis
  119113. */
  119114. yGizmo: AxisDragGizmo;
  119115. /**
  119116. * Internal gizmo used for interactions on the z axis
  119117. */
  119118. zGizmo: AxisDragGizmo;
  119119. /**
  119120. * Internal gizmo used for interactions on the yz plane
  119121. */
  119122. xPlaneGizmo: PlaneDragGizmo;
  119123. /**
  119124. * Internal gizmo used for interactions on the xz plane
  119125. */
  119126. yPlaneGizmo: PlaneDragGizmo;
  119127. /**
  119128. * Internal gizmo used for interactions on the xy plane
  119129. */
  119130. zPlaneGizmo: PlaneDragGizmo;
  119131. /**
  119132. * private variables
  119133. */
  119134. private _meshAttached;
  119135. private _updateGizmoRotationToMatchAttachedMesh;
  119136. private _snapDistance;
  119137. private _scaleRatio;
  119138. /** Fires an event when any of it's sub gizmos are dragged */
  119139. onDragStartObservable: Observable<unknown>;
  119140. /** Fires an event when any of it's sub gizmos are released from dragging */
  119141. onDragEndObservable: Observable<unknown>;
  119142. /**
  119143. * If set to true, planar drag is enabled
  119144. */
  119145. private _planarGizmoEnabled;
  119146. get attachedMesh(): Nullable<AbstractMesh>;
  119147. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119148. /**
  119149. * Creates a PositionGizmo
  119150. * @param gizmoLayer The utility layer the gizmo will be added to
  119151. */
  119152. constructor(gizmoLayer?: UtilityLayerRenderer);
  119153. /**
  119154. * If the planar drag gizmo is enabled
  119155. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119156. */
  119157. set planarGizmoEnabled(value: boolean);
  119158. get planarGizmoEnabled(): boolean;
  119159. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119160. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119161. /**
  119162. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119163. */
  119164. set snapDistance(value: number);
  119165. get snapDistance(): number;
  119166. /**
  119167. * Ratio for the scale of the gizmo (Default: 1)
  119168. */
  119169. set scaleRatio(value: number);
  119170. get scaleRatio(): number;
  119171. /**
  119172. * Disposes of the gizmo
  119173. */
  119174. dispose(): void;
  119175. /**
  119176. * CustomMeshes are not supported by this gizmo
  119177. * @param mesh The mesh to replace the default mesh of the gizmo
  119178. */
  119179. setCustomMesh(mesh: Mesh): void;
  119180. }
  119181. }
  119182. declare module BABYLON {
  119183. /**
  119184. * Single axis drag gizmo
  119185. */
  119186. export class AxisDragGizmo extends Gizmo {
  119187. /**
  119188. * Drag behavior responsible for the gizmos dragging interactions
  119189. */
  119190. dragBehavior: PointerDragBehavior;
  119191. private _pointerObserver;
  119192. /**
  119193. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119194. */
  119195. snapDistance: number;
  119196. /**
  119197. * Event that fires each time the gizmo snaps to a new location.
  119198. * * snapDistance is the the change in distance
  119199. */
  119200. onSnapObservable: Observable<{
  119201. snapDistance: number;
  119202. }>;
  119203. private _isEnabled;
  119204. private _parent;
  119205. private _arrow;
  119206. private _coloredMaterial;
  119207. private _hoverMaterial;
  119208. /** @hidden */
  119209. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119210. /** @hidden */
  119211. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119212. /**
  119213. * Creates an AxisDragGizmo
  119214. * @param gizmoLayer The utility layer the gizmo will be added to
  119215. * @param dragAxis The axis which the gizmo will be able to drag on
  119216. * @param color The color of the gizmo
  119217. */
  119218. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119219. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119220. /**
  119221. * If the gizmo is enabled
  119222. */
  119223. set isEnabled(value: boolean);
  119224. get isEnabled(): boolean;
  119225. /**
  119226. * Disposes of the gizmo
  119227. */
  119228. dispose(): void;
  119229. }
  119230. }
  119231. declare module BABYLON.Debug {
  119232. /**
  119233. * The Axes viewer will show 3 axes in a specific point in space
  119234. */
  119235. export class AxesViewer {
  119236. private _xAxis;
  119237. private _yAxis;
  119238. private _zAxis;
  119239. private _scaleLinesFactor;
  119240. private _instanced;
  119241. /**
  119242. * Gets the hosting scene
  119243. */
  119244. scene: Scene;
  119245. /**
  119246. * Gets or sets a number used to scale line length
  119247. */
  119248. scaleLines: number;
  119249. /** Gets the node hierarchy used to render x-axis */
  119250. get xAxis(): TransformNode;
  119251. /** Gets the node hierarchy used to render y-axis */
  119252. get yAxis(): TransformNode;
  119253. /** Gets the node hierarchy used to render z-axis */
  119254. get zAxis(): TransformNode;
  119255. /**
  119256. * Creates a new AxesViewer
  119257. * @param scene defines the hosting scene
  119258. * @param scaleLines defines a number used to scale line length (1 by default)
  119259. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119260. * @param xAxis defines the node hierarchy used to render the x-axis
  119261. * @param yAxis defines the node hierarchy used to render the y-axis
  119262. * @param zAxis defines the node hierarchy used to render the z-axis
  119263. */
  119264. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119265. /**
  119266. * Force the viewer to update
  119267. * @param position defines the position of the viewer
  119268. * @param xaxis defines the x axis of the viewer
  119269. * @param yaxis defines the y axis of the viewer
  119270. * @param zaxis defines the z axis of the viewer
  119271. */
  119272. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119273. /**
  119274. * Creates an instance of this axes viewer.
  119275. * @returns a new axes viewer with instanced meshes
  119276. */
  119277. createInstance(): AxesViewer;
  119278. /** Releases resources */
  119279. dispose(): void;
  119280. private static _SetRenderingGroupId;
  119281. }
  119282. }
  119283. declare module BABYLON.Debug {
  119284. /**
  119285. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119286. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119287. */
  119288. export class BoneAxesViewer extends AxesViewer {
  119289. /**
  119290. * Gets or sets the target mesh where to display the axes viewer
  119291. */
  119292. mesh: Nullable<Mesh>;
  119293. /**
  119294. * Gets or sets the target bone where to display the axes viewer
  119295. */
  119296. bone: Nullable<Bone>;
  119297. /** Gets current position */
  119298. pos: Vector3;
  119299. /** Gets direction of X axis */
  119300. xaxis: Vector3;
  119301. /** Gets direction of Y axis */
  119302. yaxis: Vector3;
  119303. /** Gets direction of Z axis */
  119304. zaxis: Vector3;
  119305. /**
  119306. * Creates a new BoneAxesViewer
  119307. * @param scene defines the hosting scene
  119308. * @param bone defines the target bone
  119309. * @param mesh defines the target mesh
  119310. * @param scaleLines defines a scaling factor for line length (1 by default)
  119311. */
  119312. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119313. /**
  119314. * Force the viewer to update
  119315. */
  119316. update(): void;
  119317. /** Releases resources */
  119318. dispose(): void;
  119319. }
  119320. }
  119321. declare module BABYLON {
  119322. /**
  119323. * Interface used to define scene explorer extensibility option
  119324. */
  119325. export interface IExplorerExtensibilityOption {
  119326. /**
  119327. * Define the option label
  119328. */
  119329. label: string;
  119330. /**
  119331. * Defines the action to execute on click
  119332. */
  119333. action: (entity: any) => void;
  119334. }
  119335. /**
  119336. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119337. */
  119338. export interface IExplorerExtensibilityGroup {
  119339. /**
  119340. * Defines a predicate to test if a given type mut be extended
  119341. */
  119342. predicate: (entity: any) => boolean;
  119343. /**
  119344. * Gets the list of options added to a type
  119345. */
  119346. entries: IExplorerExtensibilityOption[];
  119347. }
  119348. /**
  119349. * Interface used to define the options to use to create the Inspector
  119350. */
  119351. export interface IInspectorOptions {
  119352. /**
  119353. * Display in overlay mode (default: false)
  119354. */
  119355. overlay?: boolean;
  119356. /**
  119357. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119358. */
  119359. globalRoot?: HTMLElement;
  119360. /**
  119361. * Display the Scene explorer
  119362. */
  119363. showExplorer?: boolean;
  119364. /**
  119365. * Display the property inspector
  119366. */
  119367. showInspector?: boolean;
  119368. /**
  119369. * Display in embed mode (both panes on the right)
  119370. */
  119371. embedMode?: boolean;
  119372. /**
  119373. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119374. */
  119375. handleResize?: boolean;
  119376. /**
  119377. * Allow the panes to popup (default: true)
  119378. */
  119379. enablePopup?: boolean;
  119380. /**
  119381. * Allow the panes to be closed by users (default: true)
  119382. */
  119383. enableClose?: boolean;
  119384. /**
  119385. * Optional list of extensibility entries
  119386. */
  119387. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119388. /**
  119389. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119390. */
  119391. inspectorURL?: string;
  119392. /**
  119393. * Optional initial tab (default to DebugLayerTab.Properties)
  119394. */
  119395. initialTab?: DebugLayerTab;
  119396. }
  119397. interface Scene {
  119398. /**
  119399. * @hidden
  119400. * Backing field
  119401. */
  119402. _debugLayer: DebugLayer;
  119403. /**
  119404. * Gets the debug layer (aka Inspector) associated with the scene
  119405. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119406. */
  119407. debugLayer: DebugLayer;
  119408. }
  119409. /**
  119410. * Enum of inspector action tab
  119411. */
  119412. export enum DebugLayerTab {
  119413. /**
  119414. * Properties tag (default)
  119415. */
  119416. Properties = 0,
  119417. /**
  119418. * Debug tab
  119419. */
  119420. Debug = 1,
  119421. /**
  119422. * Statistics tab
  119423. */
  119424. Statistics = 2,
  119425. /**
  119426. * Tools tab
  119427. */
  119428. Tools = 3,
  119429. /**
  119430. * Settings tab
  119431. */
  119432. Settings = 4
  119433. }
  119434. /**
  119435. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119436. * what is happening in your scene
  119437. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119438. */
  119439. export class DebugLayer {
  119440. /**
  119441. * Define the url to get the inspector script from.
  119442. * By default it uses the babylonjs CDN.
  119443. * @ignoreNaming
  119444. */
  119445. static InspectorURL: string;
  119446. private _scene;
  119447. private BJSINSPECTOR;
  119448. private _onPropertyChangedObservable?;
  119449. /**
  119450. * Observable triggered when a property is changed through the inspector.
  119451. */
  119452. get onPropertyChangedObservable(): any;
  119453. /**
  119454. * Instantiates a new debug layer.
  119455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119456. * what is happening in your scene
  119457. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119458. * @param scene Defines the scene to inspect
  119459. */
  119460. constructor(scene: Scene);
  119461. /** Creates the inspector window. */
  119462. private _createInspector;
  119463. /**
  119464. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119465. * @param entity defines the entity to select
  119466. * @param lineContainerTitle defines the specific block to highlight
  119467. */
  119468. select(entity: any, lineContainerTitle?: string): void;
  119469. /** Get the inspector from bundle or global */
  119470. private _getGlobalInspector;
  119471. /**
  119472. * Get if the inspector is visible or not.
  119473. * @returns true if visible otherwise, false
  119474. */
  119475. isVisible(): boolean;
  119476. /**
  119477. * Hide the inspector and close its window.
  119478. */
  119479. hide(): void;
  119480. /**
  119481. * Launch the debugLayer.
  119482. * @param config Define the configuration of the inspector
  119483. * @return a promise fulfilled when the debug layer is visible
  119484. */
  119485. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119486. }
  119487. }
  119488. declare module BABYLON {
  119489. /**
  119490. * Class containing static functions to help procedurally build meshes
  119491. */
  119492. export class BoxBuilder {
  119493. /**
  119494. * Creates a box mesh
  119495. * * The parameter `size` sets the size (float) of each box side (default 1)
  119496. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119497. * * 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)
  119498. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119502. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119503. * @param name defines the name of the mesh
  119504. * @param options defines the options used to create the mesh
  119505. * @param scene defines the hosting scene
  119506. * @returns the box mesh
  119507. */
  119508. static CreateBox(name: string, options: {
  119509. size?: number;
  119510. width?: number;
  119511. height?: number;
  119512. depth?: number;
  119513. faceUV?: Vector4[];
  119514. faceColors?: Color4[];
  119515. sideOrientation?: number;
  119516. frontUVs?: Vector4;
  119517. backUVs?: Vector4;
  119518. wrap?: boolean;
  119519. topBaseAt?: number;
  119520. bottomBaseAt?: number;
  119521. updatable?: boolean;
  119522. }, scene?: Nullable<Scene>): Mesh;
  119523. }
  119524. }
  119525. declare module BABYLON.Debug {
  119526. /**
  119527. * Used to show the physics impostor around the specific mesh
  119528. */
  119529. export class PhysicsViewer {
  119530. /** @hidden */
  119531. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119532. /** @hidden */
  119533. protected _meshes: Array<Nullable<AbstractMesh>>;
  119534. /** @hidden */
  119535. protected _scene: Nullable<Scene>;
  119536. /** @hidden */
  119537. protected _numMeshes: number;
  119538. /** @hidden */
  119539. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119540. private _renderFunction;
  119541. private _utilityLayer;
  119542. private _debugBoxMesh;
  119543. private _debugSphereMesh;
  119544. private _debugCylinderMesh;
  119545. private _debugMaterial;
  119546. private _debugMeshMeshes;
  119547. /**
  119548. * Creates a new PhysicsViewer
  119549. * @param scene defines the hosting scene
  119550. */
  119551. constructor(scene: Scene);
  119552. /** @hidden */
  119553. protected _updateDebugMeshes(): void;
  119554. /**
  119555. * Renders a specified physic impostor
  119556. * @param impostor defines the impostor to render
  119557. * @param targetMesh defines the mesh represented by the impostor
  119558. * @returns the new debug mesh used to render the impostor
  119559. */
  119560. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119561. /**
  119562. * Hides a specified physic impostor
  119563. * @param impostor defines the impostor to hide
  119564. */
  119565. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119566. private _getDebugMaterial;
  119567. private _getDebugBoxMesh;
  119568. private _getDebugSphereMesh;
  119569. private _getDebugCylinderMesh;
  119570. private _getDebugMeshMesh;
  119571. private _getDebugMesh;
  119572. /** Releases all resources */
  119573. dispose(): void;
  119574. }
  119575. }
  119576. declare module BABYLON {
  119577. /**
  119578. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119579. * in order to better appreciate the issue one might have.
  119580. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119581. */
  119582. export class RayHelper {
  119583. /**
  119584. * Defines the ray we are currently tryin to visualize.
  119585. */
  119586. ray: Nullable<Ray>;
  119587. private _renderPoints;
  119588. private _renderLine;
  119589. private _renderFunction;
  119590. private _scene;
  119591. private _updateToMeshFunction;
  119592. private _attachedToMesh;
  119593. private _meshSpaceDirection;
  119594. private _meshSpaceOrigin;
  119595. /**
  119596. * Helper function to create a colored helper in a scene in one line.
  119597. * @param ray Defines the ray we are currently tryin to visualize
  119598. * @param scene Defines the scene the ray is used in
  119599. * @param color Defines the color we want to see the ray in
  119600. * @returns The newly created ray helper.
  119601. */
  119602. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119603. /**
  119604. * Instantiate a new ray helper.
  119605. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119606. * in order to better appreciate the issue one might have.
  119607. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119608. * @param ray Defines the ray we are currently tryin to visualize
  119609. */
  119610. constructor(ray: Ray);
  119611. /**
  119612. * Shows the ray we are willing to debug.
  119613. * @param scene Defines the scene the ray needs to be rendered in
  119614. * @param color Defines the color the ray needs to be rendered in
  119615. */
  119616. show(scene: Scene, color?: Color3): void;
  119617. /**
  119618. * Hides the ray we are debugging.
  119619. */
  119620. hide(): void;
  119621. private _render;
  119622. /**
  119623. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119624. * @param mesh Defines the mesh we want the helper attached to
  119625. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119626. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119627. * @param length Defines the length of the ray
  119628. */
  119629. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119630. /**
  119631. * Detach the ray helper from the mesh it has previously been attached to.
  119632. */
  119633. detachFromMesh(): void;
  119634. private _updateToMesh;
  119635. /**
  119636. * Dispose the helper and release its associated resources.
  119637. */
  119638. dispose(): void;
  119639. }
  119640. }
  119641. declare module BABYLON.Debug {
  119642. /**
  119643. * Class used to render a debug view of a given skeleton
  119644. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119645. */
  119646. export class SkeletonViewer {
  119647. /** defines the skeleton to render */
  119648. skeleton: Skeleton;
  119649. /** defines the mesh attached to the skeleton */
  119650. mesh: AbstractMesh;
  119651. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119652. autoUpdateBonesMatrices: boolean;
  119653. /** defines the rendering group id to use with the viewer */
  119654. renderingGroupId: number;
  119655. /** Gets or sets the color used to render the skeleton */
  119656. color: Color3;
  119657. private _scene;
  119658. private _debugLines;
  119659. private _debugMesh;
  119660. private _isEnabled;
  119661. private _renderFunction;
  119662. private _utilityLayer;
  119663. /**
  119664. * Returns the mesh used to render the bones
  119665. */
  119666. get debugMesh(): Nullable<LinesMesh>;
  119667. /**
  119668. * Creates a new SkeletonViewer
  119669. * @param skeleton defines the skeleton to render
  119670. * @param mesh defines the mesh attached to the skeleton
  119671. * @param scene defines the hosting scene
  119672. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119673. * @param renderingGroupId defines the rendering group id to use with the viewer
  119674. */
  119675. constructor(
  119676. /** defines the skeleton to render */
  119677. skeleton: Skeleton,
  119678. /** defines the mesh attached to the skeleton */
  119679. mesh: AbstractMesh, scene: Scene,
  119680. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119681. autoUpdateBonesMatrices?: boolean,
  119682. /** defines the rendering group id to use with the viewer */
  119683. renderingGroupId?: number);
  119684. /** Gets or sets a boolean indicating if the viewer is enabled */
  119685. set isEnabled(value: boolean);
  119686. get isEnabled(): boolean;
  119687. private _getBonePosition;
  119688. private _getLinesForBonesWithLength;
  119689. private _getLinesForBonesNoLength;
  119690. /** Update the viewer to sync with current skeleton state */
  119691. update(): void;
  119692. /** Release associated resources */
  119693. dispose(): void;
  119694. }
  119695. }
  119696. declare module BABYLON {
  119697. /**
  119698. * Options to create the null engine
  119699. */
  119700. export class NullEngineOptions {
  119701. /**
  119702. * Render width (Default: 512)
  119703. */
  119704. renderWidth: number;
  119705. /**
  119706. * Render height (Default: 256)
  119707. */
  119708. renderHeight: number;
  119709. /**
  119710. * Texture size (Default: 512)
  119711. */
  119712. textureSize: number;
  119713. /**
  119714. * If delta time between frames should be constant
  119715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119716. */
  119717. deterministicLockstep: boolean;
  119718. /**
  119719. * Maximum about of steps between frames (Default: 4)
  119720. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119721. */
  119722. lockstepMaxSteps: number;
  119723. }
  119724. /**
  119725. * The null engine class provides support for headless version of babylon.js.
  119726. * This can be used in server side scenario or for testing purposes
  119727. */
  119728. export class NullEngine extends Engine {
  119729. private _options;
  119730. /**
  119731. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119733. * @returns true if engine is in deterministic lock step mode
  119734. */
  119735. isDeterministicLockStep(): boolean;
  119736. /**
  119737. * Gets the max steps when engine is running in deterministic lock step
  119738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119739. * @returns the max steps
  119740. */
  119741. getLockstepMaxSteps(): number;
  119742. /**
  119743. * Gets the current hardware scaling level.
  119744. * By default the hardware scaling level is computed from the window device ratio.
  119745. * 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.
  119746. * @returns a number indicating the current hardware scaling level
  119747. */
  119748. getHardwareScalingLevel(): number;
  119749. constructor(options?: NullEngineOptions);
  119750. /**
  119751. * Creates a vertex buffer
  119752. * @param vertices the data for the vertex buffer
  119753. * @returns the new WebGL static buffer
  119754. */
  119755. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119756. /**
  119757. * Creates a new index buffer
  119758. * @param indices defines the content of the index buffer
  119759. * @param updatable defines if the index buffer must be updatable
  119760. * @returns a new webGL buffer
  119761. */
  119762. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119763. /**
  119764. * Clear the current render buffer or the current render target (if any is set up)
  119765. * @param color defines the color to use
  119766. * @param backBuffer defines if the back buffer must be cleared
  119767. * @param depth defines if the depth buffer must be cleared
  119768. * @param stencil defines if the stencil buffer must be cleared
  119769. */
  119770. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119771. /**
  119772. * Gets the current render width
  119773. * @param useScreen defines if screen size must be used (or the current render target if any)
  119774. * @returns a number defining the current render width
  119775. */
  119776. getRenderWidth(useScreen?: boolean): number;
  119777. /**
  119778. * Gets the current render height
  119779. * @param useScreen defines if screen size must be used (or the current render target if any)
  119780. * @returns a number defining the current render height
  119781. */
  119782. getRenderHeight(useScreen?: boolean): number;
  119783. /**
  119784. * Set the WebGL's viewport
  119785. * @param viewport defines the viewport element to be used
  119786. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119787. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119788. */
  119789. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119790. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119791. /**
  119792. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119793. * @param pipelineContext defines the pipeline context to use
  119794. * @param uniformsNames defines the list of uniform names
  119795. * @returns an array of webGL uniform locations
  119796. */
  119797. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119798. /**
  119799. * Gets the lsit of active attributes for a given webGL program
  119800. * @param pipelineContext defines the pipeline context to use
  119801. * @param attributesNames defines the list of attribute names to get
  119802. * @returns an array of indices indicating the offset of each attribute
  119803. */
  119804. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119805. /**
  119806. * Binds an effect to the webGL context
  119807. * @param effect defines the effect to bind
  119808. */
  119809. bindSamplers(effect: Effect): void;
  119810. /**
  119811. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119812. * @param effect defines the effect to activate
  119813. */
  119814. enableEffect(effect: Effect): void;
  119815. /**
  119816. * Set various states to the webGL context
  119817. * @param culling defines backface culling state
  119818. * @param zOffset defines the value to apply to zOffset (0 by default)
  119819. * @param force defines if states must be applied even if cache is up to date
  119820. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119821. */
  119822. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119823. /**
  119824. * Set the value of an uniform to an array of int32
  119825. * @param uniform defines the webGL uniform location where to store the value
  119826. * @param array defines the array of int32 to store
  119827. */
  119828. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119829. /**
  119830. * Set the value of an uniform to an array of int32 (stored as vec2)
  119831. * @param uniform defines the webGL uniform location where to store the value
  119832. * @param array defines the array of int32 to store
  119833. */
  119834. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119835. /**
  119836. * Set the value of an uniform to an array of int32 (stored as vec3)
  119837. * @param uniform defines the webGL uniform location where to store the value
  119838. * @param array defines the array of int32 to store
  119839. */
  119840. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119841. /**
  119842. * Set the value of an uniform to an array of int32 (stored as vec4)
  119843. * @param uniform defines the webGL uniform location where to store the value
  119844. * @param array defines the array of int32 to store
  119845. */
  119846. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119847. /**
  119848. * Set the value of an uniform to an array of float32
  119849. * @param uniform defines the webGL uniform location where to store the value
  119850. * @param array defines the array of float32 to store
  119851. */
  119852. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119853. /**
  119854. * Set the value of an uniform to an array of float32 (stored as vec2)
  119855. * @param uniform defines the webGL uniform location where to store the value
  119856. * @param array defines the array of float32 to store
  119857. */
  119858. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119859. /**
  119860. * Set the value of an uniform to an array of float32 (stored as vec3)
  119861. * @param uniform defines the webGL uniform location where to store the value
  119862. * @param array defines the array of float32 to store
  119863. */
  119864. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119865. /**
  119866. * Set the value of an uniform to an array of float32 (stored as vec4)
  119867. * @param uniform defines the webGL uniform location where to store the value
  119868. * @param array defines the array of float32 to store
  119869. */
  119870. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119871. /**
  119872. * Set the value of an uniform to an array of number
  119873. * @param uniform defines the webGL uniform location where to store the value
  119874. * @param array defines the array of number to store
  119875. */
  119876. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119877. /**
  119878. * Set the value of an uniform to an array of number (stored as vec2)
  119879. * @param uniform defines the webGL uniform location where to store the value
  119880. * @param array defines the array of number to store
  119881. */
  119882. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119883. /**
  119884. * Set the value of an uniform to an array of number (stored as vec3)
  119885. * @param uniform defines the webGL uniform location where to store the value
  119886. * @param array defines the array of number to store
  119887. */
  119888. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119889. /**
  119890. * Set the value of an uniform to an array of number (stored as vec4)
  119891. * @param uniform defines the webGL uniform location where to store the value
  119892. * @param array defines the array of number to store
  119893. */
  119894. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119895. /**
  119896. * Set the value of an uniform to an array of float32 (stored as matrices)
  119897. * @param uniform defines the webGL uniform location where to store the value
  119898. * @param matrices defines the array of float32 to store
  119899. */
  119900. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119901. /**
  119902. * Set the value of an uniform to a matrix (3x3)
  119903. * @param uniform defines the webGL uniform location where to store the value
  119904. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119905. */
  119906. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119907. /**
  119908. * Set the value of an uniform to a matrix (2x2)
  119909. * @param uniform defines the webGL uniform location where to store the value
  119910. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119911. */
  119912. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119913. /**
  119914. * Set the value of an uniform to a number (float)
  119915. * @param uniform defines the webGL uniform location where to store the value
  119916. * @param value defines the float number to store
  119917. */
  119918. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119919. /**
  119920. * Set the value of an uniform to a vec2
  119921. * @param uniform defines the webGL uniform location where to store the value
  119922. * @param x defines the 1st component of the value
  119923. * @param y defines the 2nd component of the value
  119924. */
  119925. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119926. /**
  119927. * Set the value of an uniform to a vec3
  119928. * @param uniform defines the webGL uniform location where to store the value
  119929. * @param x defines the 1st component of the value
  119930. * @param y defines the 2nd component of the value
  119931. * @param z defines the 3rd component of the value
  119932. */
  119933. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119934. /**
  119935. * Set the value of an uniform to a boolean
  119936. * @param uniform defines the webGL uniform location where to store the value
  119937. * @param bool defines the boolean to store
  119938. */
  119939. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119940. /**
  119941. * Set the value of an uniform to a vec4
  119942. * @param uniform defines the webGL uniform location where to store the value
  119943. * @param x defines the 1st component of the value
  119944. * @param y defines the 2nd component of the value
  119945. * @param z defines the 3rd component of the value
  119946. * @param w defines the 4th component of the value
  119947. */
  119948. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119949. /**
  119950. * Sets the current alpha mode
  119951. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119952. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119953. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119954. */
  119955. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119956. /**
  119957. * Bind webGl buffers directly to the webGL context
  119958. * @param vertexBuffers defines the vertex buffer to bind
  119959. * @param indexBuffer defines the index buffer to bind
  119960. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119961. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119962. * @param effect defines the effect associated with the vertex buffer
  119963. */
  119964. bindBuffers(vertexBuffers: {
  119965. [key: string]: VertexBuffer;
  119966. }, indexBuffer: DataBuffer, effect: Effect): void;
  119967. /**
  119968. * Force the entire cache to be cleared
  119969. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119970. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119971. */
  119972. wipeCaches(bruteForce?: boolean): void;
  119973. /**
  119974. * Send a draw order
  119975. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119976. * @param indexStart defines the starting index
  119977. * @param indexCount defines the number of index to draw
  119978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119979. */
  119980. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119981. /**
  119982. * Draw a list of indexed primitives
  119983. * @param fillMode defines the primitive to use
  119984. * @param indexStart defines the starting index
  119985. * @param indexCount defines the number of index to draw
  119986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119987. */
  119988. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119989. /**
  119990. * Draw a list of unindexed primitives
  119991. * @param fillMode defines the primitive to use
  119992. * @param verticesStart defines the index of first vertex to draw
  119993. * @param verticesCount defines the count of vertices to draw
  119994. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119995. */
  119996. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119997. /** @hidden */
  119998. _createTexture(): WebGLTexture;
  119999. /** @hidden */
  120000. _releaseTexture(texture: InternalTexture): void;
  120001. /**
  120002. * Usually called from Texture.ts.
  120003. * Passed information to create a WebGLTexture
  120004. * @param urlArg defines a value which contains one of the following:
  120005. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120006. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120007. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120008. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120009. * @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)
  120010. * @param scene needed for loading to the correct scene
  120011. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120012. * @param onLoad optional callback to be called upon successful completion
  120013. * @param onError optional callback to be called upon failure
  120014. * @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
  120015. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120016. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120017. * @param forcedExtension defines the extension to use to pick the right loader
  120018. * @param mimeType defines an optional mime type
  120019. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120020. */
  120021. 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;
  120022. /**
  120023. * Creates a new render target texture
  120024. * @param size defines the size of the texture
  120025. * @param options defines the options used to create the texture
  120026. * @returns a new render target texture stored in an InternalTexture
  120027. */
  120028. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120029. /**
  120030. * Update the sampling mode of a given texture
  120031. * @param samplingMode defines the required sampling mode
  120032. * @param texture defines the texture to update
  120033. */
  120034. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120035. /**
  120036. * Binds the frame buffer to the specified texture.
  120037. * @param texture The texture to render to or null for the default canvas
  120038. * @param faceIndex The face of the texture to render to in case of cube texture
  120039. * @param requiredWidth The width of the target to render to
  120040. * @param requiredHeight The height of the target to render to
  120041. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120042. * @param lodLevel defines le lod level to bind to the frame buffer
  120043. */
  120044. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120045. /**
  120046. * Unbind the current render target texture from the webGL context
  120047. * @param texture defines the render target texture to unbind
  120048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120050. */
  120051. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120052. /**
  120053. * Creates a dynamic vertex buffer
  120054. * @param vertices the data for the dynamic vertex buffer
  120055. * @returns the new WebGL dynamic buffer
  120056. */
  120057. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120058. /**
  120059. * Update the content of a dynamic texture
  120060. * @param texture defines the texture to update
  120061. * @param canvas defines the canvas containing the source
  120062. * @param invertY defines if data must be stored with Y axis inverted
  120063. * @param premulAlpha defines if alpha is stored as premultiplied
  120064. * @param format defines the format of the data
  120065. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120066. */
  120067. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120068. /**
  120069. * Gets a boolean indicating if all created effects are ready
  120070. * @returns true if all effects are ready
  120071. */
  120072. areAllEffectsReady(): boolean;
  120073. /**
  120074. * @hidden
  120075. * Get the current error code of the webGL context
  120076. * @returns the error code
  120077. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120078. */
  120079. getError(): number;
  120080. /** @hidden */
  120081. _getUnpackAlignement(): number;
  120082. /** @hidden */
  120083. _unpackFlipY(value: boolean): void;
  120084. /**
  120085. * Update a dynamic index buffer
  120086. * @param indexBuffer defines the target index buffer
  120087. * @param indices defines the data to update
  120088. * @param offset defines the offset in the target index buffer where update should start
  120089. */
  120090. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120091. /**
  120092. * Updates a dynamic vertex buffer.
  120093. * @param vertexBuffer the vertex buffer to update
  120094. * @param vertices the data used to update the vertex buffer
  120095. * @param byteOffset the byte offset of the data (optional)
  120096. * @param byteLength the byte length of the data (optional)
  120097. */
  120098. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120099. /** @hidden */
  120100. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120101. /** @hidden */
  120102. _bindTexture(channel: number, texture: InternalTexture): void;
  120103. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120104. /**
  120105. * 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
  120106. */
  120107. releaseEffects(): void;
  120108. displayLoadingUI(): void;
  120109. hideLoadingUI(): void;
  120110. /** @hidden */
  120111. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120112. /** @hidden */
  120113. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120114. /** @hidden */
  120115. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120116. /** @hidden */
  120117. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120118. }
  120119. }
  120120. declare module BABYLON {
  120121. /**
  120122. * @hidden
  120123. **/
  120124. export class _TimeToken {
  120125. _startTimeQuery: Nullable<WebGLQuery>;
  120126. _endTimeQuery: Nullable<WebGLQuery>;
  120127. _timeElapsedQuery: Nullable<WebGLQuery>;
  120128. _timeElapsedQueryEnded: boolean;
  120129. }
  120130. }
  120131. declare module BABYLON {
  120132. /** @hidden */
  120133. export class _OcclusionDataStorage {
  120134. /** @hidden */
  120135. occlusionInternalRetryCounter: number;
  120136. /** @hidden */
  120137. isOcclusionQueryInProgress: boolean;
  120138. /** @hidden */
  120139. isOccluded: boolean;
  120140. /** @hidden */
  120141. occlusionRetryCount: number;
  120142. /** @hidden */
  120143. occlusionType: number;
  120144. /** @hidden */
  120145. occlusionQueryAlgorithmType: number;
  120146. }
  120147. interface Engine {
  120148. /**
  120149. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120150. * @return the new query
  120151. */
  120152. createQuery(): WebGLQuery;
  120153. /**
  120154. * Delete and release a webGL query
  120155. * @param query defines the query to delete
  120156. * @return the current engine
  120157. */
  120158. deleteQuery(query: WebGLQuery): Engine;
  120159. /**
  120160. * Check if a given query has resolved and got its value
  120161. * @param query defines the query to check
  120162. * @returns true if the query got its value
  120163. */
  120164. isQueryResultAvailable(query: WebGLQuery): boolean;
  120165. /**
  120166. * Gets the value of a given query
  120167. * @param query defines the query to check
  120168. * @returns the value of the query
  120169. */
  120170. getQueryResult(query: WebGLQuery): number;
  120171. /**
  120172. * Initiates an occlusion query
  120173. * @param algorithmType defines the algorithm to use
  120174. * @param query defines the query to use
  120175. * @returns the current engine
  120176. * @see http://doc.babylonjs.com/features/occlusionquery
  120177. */
  120178. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120179. /**
  120180. * Ends an occlusion query
  120181. * @see http://doc.babylonjs.com/features/occlusionquery
  120182. * @param algorithmType defines the algorithm to use
  120183. * @returns the current engine
  120184. */
  120185. endOcclusionQuery(algorithmType: number): Engine;
  120186. /**
  120187. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120188. * Please note that only one query can be issued at a time
  120189. * @returns a time token used to track the time span
  120190. */
  120191. startTimeQuery(): Nullable<_TimeToken>;
  120192. /**
  120193. * Ends a time query
  120194. * @param token defines the token used to measure the time span
  120195. * @returns the time spent (in ns)
  120196. */
  120197. endTimeQuery(token: _TimeToken): int;
  120198. /** @hidden */
  120199. _currentNonTimestampToken: Nullable<_TimeToken>;
  120200. /** @hidden */
  120201. _createTimeQuery(): WebGLQuery;
  120202. /** @hidden */
  120203. _deleteTimeQuery(query: WebGLQuery): void;
  120204. /** @hidden */
  120205. _getGlAlgorithmType(algorithmType: number): number;
  120206. /** @hidden */
  120207. _getTimeQueryResult(query: WebGLQuery): any;
  120208. /** @hidden */
  120209. _getTimeQueryAvailability(query: WebGLQuery): any;
  120210. }
  120211. interface AbstractMesh {
  120212. /**
  120213. * Backing filed
  120214. * @hidden
  120215. */
  120216. __occlusionDataStorage: _OcclusionDataStorage;
  120217. /**
  120218. * Access property
  120219. * @hidden
  120220. */
  120221. _occlusionDataStorage: _OcclusionDataStorage;
  120222. /**
  120223. * 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.
  120224. * The default value is -1 which means don't break the query and wait till the result
  120225. * @see http://doc.babylonjs.com/features/occlusionquery
  120226. */
  120227. occlusionRetryCount: number;
  120228. /**
  120229. * 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:
  120230. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120231. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120232. * * 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.
  120233. * @see http://doc.babylonjs.com/features/occlusionquery
  120234. */
  120235. occlusionType: number;
  120236. /**
  120237. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120238. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120239. * * 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.
  120240. * @see http://doc.babylonjs.com/features/occlusionquery
  120241. */
  120242. occlusionQueryAlgorithmType: number;
  120243. /**
  120244. * 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
  120245. * @see http://doc.babylonjs.com/features/occlusionquery
  120246. */
  120247. isOccluded: boolean;
  120248. /**
  120249. * Flag to check the progress status of the query
  120250. * @see http://doc.babylonjs.com/features/occlusionquery
  120251. */
  120252. isOcclusionQueryInProgress: boolean;
  120253. }
  120254. }
  120255. declare module BABYLON {
  120256. /** @hidden */
  120257. export var _forceTransformFeedbackToBundle: boolean;
  120258. interface Engine {
  120259. /**
  120260. * Creates a webGL transform feedback object
  120261. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120262. * @returns the webGL transform feedback object
  120263. */
  120264. createTransformFeedback(): WebGLTransformFeedback;
  120265. /**
  120266. * Delete a webGL transform feedback object
  120267. * @param value defines the webGL transform feedback object to delete
  120268. */
  120269. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120270. /**
  120271. * Bind a webGL transform feedback object to the webgl context
  120272. * @param value defines the webGL transform feedback object to bind
  120273. */
  120274. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120275. /**
  120276. * Begins a transform feedback operation
  120277. * @param usePoints defines if points or triangles must be used
  120278. */
  120279. beginTransformFeedback(usePoints: boolean): void;
  120280. /**
  120281. * Ends a transform feedback operation
  120282. */
  120283. endTransformFeedback(): void;
  120284. /**
  120285. * Specify the varyings to use with transform feedback
  120286. * @param program defines the associated webGL program
  120287. * @param value defines the list of strings representing the varying names
  120288. */
  120289. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120290. /**
  120291. * Bind a webGL buffer for a transform feedback operation
  120292. * @param value defines the webGL buffer to bind
  120293. */
  120294. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120295. }
  120296. }
  120297. declare module BABYLON {
  120298. /**
  120299. * Creation options of the multi render target texture.
  120300. */
  120301. export interface IMultiRenderTargetOptions {
  120302. /**
  120303. * Define if the texture needs to create mip maps after render.
  120304. */
  120305. generateMipMaps?: boolean;
  120306. /**
  120307. * Define the types of all the draw buffers we want to create
  120308. */
  120309. types?: number[];
  120310. /**
  120311. * Define the sampling modes of all the draw buffers we want to create
  120312. */
  120313. samplingModes?: number[];
  120314. /**
  120315. * Define if a depth buffer is required
  120316. */
  120317. generateDepthBuffer?: boolean;
  120318. /**
  120319. * Define if a stencil buffer is required
  120320. */
  120321. generateStencilBuffer?: boolean;
  120322. /**
  120323. * Define if a depth texture is required instead of a depth buffer
  120324. */
  120325. generateDepthTexture?: boolean;
  120326. /**
  120327. * Define the number of desired draw buffers
  120328. */
  120329. textureCount?: number;
  120330. /**
  120331. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120332. */
  120333. doNotChangeAspectRatio?: boolean;
  120334. /**
  120335. * Define the default type of the buffers we are creating
  120336. */
  120337. defaultType?: number;
  120338. }
  120339. /**
  120340. * A multi render target, like a render target provides the ability to render to a texture.
  120341. * Unlike the render target, it can render to several draw buffers in one draw.
  120342. * This is specially interesting in deferred rendering or for any effects requiring more than
  120343. * just one color from a single pass.
  120344. */
  120345. export class MultiRenderTarget extends RenderTargetTexture {
  120346. private _internalTextures;
  120347. private _textures;
  120348. private _multiRenderTargetOptions;
  120349. /**
  120350. * Get if draw buffers are currently supported by the used hardware and browser.
  120351. */
  120352. get isSupported(): boolean;
  120353. /**
  120354. * Get the list of textures generated by the multi render target.
  120355. */
  120356. get textures(): Texture[];
  120357. /**
  120358. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120359. */
  120360. get depthTexture(): Texture;
  120361. /**
  120362. * Set the wrapping mode on U of all the textures we are rendering to.
  120363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120364. */
  120365. set wrapU(wrap: number);
  120366. /**
  120367. * Set the wrapping mode on V of all the textures we are rendering to.
  120368. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120369. */
  120370. set wrapV(wrap: number);
  120371. /**
  120372. * Instantiate a new multi render target texture.
  120373. * A multi render target, like a render target provides the ability to render to a texture.
  120374. * Unlike the render target, it can render to several draw buffers in one draw.
  120375. * This is specially interesting in deferred rendering or for any effects requiring more than
  120376. * just one color from a single pass.
  120377. * @param name Define the name of the texture
  120378. * @param size Define the size of the buffers to render to
  120379. * @param count Define the number of target we are rendering into
  120380. * @param scene Define the scene the texture belongs to
  120381. * @param options Define the options used to create the multi render target
  120382. */
  120383. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120384. /** @hidden */
  120385. _rebuild(): void;
  120386. private _createInternalTextures;
  120387. private _createTextures;
  120388. /**
  120389. * Define the number of samples used if MSAA is enabled.
  120390. */
  120391. get samples(): number;
  120392. set samples(value: number);
  120393. /**
  120394. * Resize all the textures in the multi render target.
  120395. * Be carrefull as it will recreate all the data in the new texture.
  120396. * @param size Define the new size
  120397. */
  120398. resize(size: any): void;
  120399. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120400. /**
  120401. * Dispose the render targets and their associated resources
  120402. */
  120403. dispose(): void;
  120404. /**
  120405. * Release all the underlying texture used as draw buffers.
  120406. */
  120407. releaseInternalTextures(): void;
  120408. }
  120409. }
  120410. declare module BABYLON {
  120411. interface ThinEngine {
  120412. /**
  120413. * Unbind a list of render target textures from the webGL context
  120414. * This is used only when drawBuffer extension or webGL2 are active
  120415. * @param textures defines the render target textures to unbind
  120416. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120417. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120418. */
  120419. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120420. /**
  120421. * Create a multi render target texture
  120422. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120423. * @param size defines the size of the texture
  120424. * @param options defines the creation options
  120425. * @returns the cube texture as an InternalTexture
  120426. */
  120427. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120428. /**
  120429. * Update the sample count for a given multiple render target texture
  120430. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120431. * @param textures defines the textures to update
  120432. * @param samples defines the sample count to set
  120433. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120434. */
  120435. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120436. }
  120437. }
  120438. declare module BABYLON {
  120439. /**
  120440. * Class used to define an additional view for the engine
  120441. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120442. */
  120443. export class EngineView {
  120444. /** Defines the canvas where to render the view */
  120445. target: HTMLCanvasElement;
  120446. /** Defines an optional camera used to render the view (will use active camera else) */
  120447. camera?: Camera;
  120448. }
  120449. interface Engine {
  120450. /**
  120451. * Gets or sets the HTML element to use for attaching events
  120452. */
  120453. inputElement: Nullable<HTMLElement>;
  120454. /**
  120455. * Gets the current engine view
  120456. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120457. */
  120458. activeView: Nullable<EngineView>;
  120459. /** Gets or sets the list of views */
  120460. views: EngineView[];
  120461. /**
  120462. * Register a new child canvas
  120463. * @param canvas defines the canvas to register
  120464. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120465. * @returns the associated view
  120466. */
  120467. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120468. /**
  120469. * Remove a registered child canvas
  120470. * @param canvas defines the canvas to remove
  120471. * @returns the current engine
  120472. */
  120473. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120474. }
  120475. }
  120476. declare module BABYLON {
  120477. /**
  120478. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120479. */
  120480. export interface CubeMapInfo {
  120481. /**
  120482. * The pixel array for the front face.
  120483. * This is stored in format, left to right, up to down format.
  120484. */
  120485. front: Nullable<ArrayBufferView>;
  120486. /**
  120487. * The pixel array for the back face.
  120488. * This is stored in format, left to right, up to down format.
  120489. */
  120490. back: Nullable<ArrayBufferView>;
  120491. /**
  120492. * The pixel array for the left face.
  120493. * This is stored in format, left to right, up to down format.
  120494. */
  120495. left: Nullable<ArrayBufferView>;
  120496. /**
  120497. * The pixel array for the right face.
  120498. * This is stored in format, left to right, up to down format.
  120499. */
  120500. right: Nullable<ArrayBufferView>;
  120501. /**
  120502. * The pixel array for the up face.
  120503. * This is stored in format, left to right, up to down format.
  120504. */
  120505. up: Nullable<ArrayBufferView>;
  120506. /**
  120507. * The pixel array for the down face.
  120508. * This is stored in format, left to right, up to down format.
  120509. */
  120510. down: Nullable<ArrayBufferView>;
  120511. /**
  120512. * The size of the cubemap stored.
  120513. *
  120514. * Each faces will be size * size pixels.
  120515. */
  120516. size: number;
  120517. /**
  120518. * The format of the texture.
  120519. *
  120520. * RGBA, RGB.
  120521. */
  120522. format: number;
  120523. /**
  120524. * The type of the texture data.
  120525. *
  120526. * UNSIGNED_INT, FLOAT.
  120527. */
  120528. type: number;
  120529. /**
  120530. * Specifies whether the texture is in gamma space.
  120531. */
  120532. gammaSpace: boolean;
  120533. }
  120534. /**
  120535. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120536. */
  120537. export class PanoramaToCubeMapTools {
  120538. private static FACE_FRONT;
  120539. private static FACE_BACK;
  120540. private static FACE_RIGHT;
  120541. private static FACE_LEFT;
  120542. private static FACE_DOWN;
  120543. private static FACE_UP;
  120544. /**
  120545. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120546. *
  120547. * @param float32Array The source data.
  120548. * @param inputWidth The width of the input panorama.
  120549. * @param inputHeight The height of the input panorama.
  120550. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120551. * @return The cubemap data
  120552. */
  120553. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120554. private static CreateCubemapTexture;
  120555. private static CalcProjectionSpherical;
  120556. }
  120557. }
  120558. declare module BABYLON {
  120559. /**
  120560. * Helper class dealing with the extraction of spherical polynomial dataArray
  120561. * from a cube map.
  120562. */
  120563. export class CubeMapToSphericalPolynomialTools {
  120564. private static FileFaces;
  120565. /**
  120566. * Converts a texture to the according Spherical Polynomial data.
  120567. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120568. *
  120569. * @param texture The texture to extract the information from.
  120570. * @return The Spherical Polynomial data.
  120571. */
  120572. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120573. /**
  120574. * Converts a cubemap to the according Spherical Polynomial data.
  120575. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120576. *
  120577. * @param cubeInfo The Cube map to extract the information from.
  120578. * @return The Spherical Polynomial data.
  120579. */
  120580. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120581. }
  120582. }
  120583. declare module BABYLON {
  120584. interface BaseTexture {
  120585. /**
  120586. * Get the polynomial representation of the texture data.
  120587. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120588. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120589. */
  120590. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120591. }
  120592. }
  120593. declare module BABYLON {
  120594. /** @hidden */
  120595. export var rgbdEncodePixelShader: {
  120596. name: string;
  120597. shader: string;
  120598. };
  120599. }
  120600. declare module BABYLON {
  120601. /** @hidden */
  120602. export var rgbdDecodePixelShader: {
  120603. name: string;
  120604. shader: string;
  120605. };
  120606. }
  120607. declare module BABYLON {
  120608. /**
  120609. * Raw texture data and descriptor sufficient for WebGL texture upload
  120610. */
  120611. export interface EnvironmentTextureInfo {
  120612. /**
  120613. * Version of the environment map
  120614. */
  120615. version: number;
  120616. /**
  120617. * Width of image
  120618. */
  120619. width: number;
  120620. /**
  120621. * Irradiance information stored in the file.
  120622. */
  120623. irradiance: any;
  120624. /**
  120625. * Specular information stored in the file.
  120626. */
  120627. specular: any;
  120628. }
  120629. /**
  120630. * Defines One Image in the file. It requires only the position in the file
  120631. * as well as the length.
  120632. */
  120633. interface BufferImageData {
  120634. /**
  120635. * Length of the image data.
  120636. */
  120637. length: number;
  120638. /**
  120639. * Position of the data from the null terminator delimiting the end of the JSON.
  120640. */
  120641. position: number;
  120642. }
  120643. /**
  120644. * Defines the specular data enclosed in the file.
  120645. * This corresponds to the version 1 of the data.
  120646. */
  120647. export interface EnvironmentTextureSpecularInfoV1 {
  120648. /**
  120649. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120650. */
  120651. specularDataPosition?: number;
  120652. /**
  120653. * This contains all the images data needed to reconstruct the cubemap.
  120654. */
  120655. mipmaps: Array<BufferImageData>;
  120656. /**
  120657. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120658. */
  120659. lodGenerationScale: number;
  120660. }
  120661. /**
  120662. * Sets of helpers addressing the serialization and deserialization of environment texture
  120663. * stored in a BabylonJS env file.
  120664. * Those files are usually stored as .env files.
  120665. */
  120666. export class EnvironmentTextureTools {
  120667. /**
  120668. * Magic number identifying the env file.
  120669. */
  120670. private static _MagicBytes;
  120671. /**
  120672. * Gets the environment info from an env file.
  120673. * @param data The array buffer containing the .env bytes.
  120674. * @returns the environment file info (the json header) if successfully parsed.
  120675. */
  120676. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120677. /**
  120678. * Creates an environment texture from a loaded cube texture.
  120679. * @param texture defines the cube texture to convert in env file
  120680. * @return a promise containing the environment data if succesfull.
  120681. */
  120682. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120683. /**
  120684. * Creates a JSON representation of the spherical data.
  120685. * @param texture defines the texture containing the polynomials
  120686. * @return the JSON representation of the spherical info
  120687. */
  120688. private static _CreateEnvTextureIrradiance;
  120689. /**
  120690. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120691. * @param data the image data
  120692. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120693. * @return the views described by info providing access to the underlying buffer
  120694. */
  120695. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120696. /**
  120697. * Uploads the texture info contained in the env file to the GPU.
  120698. * @param texture defines the internal texture to upload to
  120699. * @param data defines the data to load
  120700. * @param info defines the texture info retrieved through the GetEnvInfo method
  120701. * @returns a promise
  120702. */
  120703. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120704. private static _OnImageReadyAsync;
  120705. /**
  120706. * Uploads the levels of image data to the GPU.
  120707. * @param texture defines the internal texture to upload to
  120708. * @param imageData defines the array buffer views of image data [mipmap][face]
  120709. * @returns a promise
  120710. */
  120711. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120712. /**
  120713. * Uploads spherical polynomials information to the texture.
  120714. * @param texture defines the texture we are trying to upload the information to
  120715. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120716. */
  120717. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120718. /** @hidden */
  120719. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120720. }
  120721. }
  120722. declare module BABYLON {
  120723. /**
  120724. * Contains position and normal vectors for a vertex
  120725. */
  120726. export class PositionNormalVertex {
  120727. /** the position of the vertex (defaut: 0,0,0) */
  120728. position: Vector3;
  120729. /** the normal of the vertex (defaut: 0,1,0) */
  120730. normal: Vector3;
  120731. /**
  120732. * Creates a PositionNormalVertex
  120733. * @param position the position of the vertex (defaut: 0,0,0)
  120734. * @param normal the normal of the vertex (defaut: 0,1,0)
  120735. */
  120736. constructor(
  120737. /** the position of the vertex (defaut: 0,0,0) */
  120738. position?: Vector3,
  120739. /** the normal of the vertex (defaut: 0,1,0) */
  120740. normal?: Vector3);
  120741. /**
  120742. * Clones the PositionNormalVertex
  120743. * @returns the cloned PositionNormalVertex
  120744. */
  120745. clone(): PositionNormalVertex;
  120746. }
  120747. /**
  120748. * Contains position, normal and uv vectors for a vertex
  120749. */
  120750. export class PositionNormalTextureVertex {
  120751. /** the position of the vertex (defaut: 0,0,0) */
  120752. position: Vector3;
  120753. /** the normal of the vertex (defaut: 0,1,0) */
  120754. normal: Vector3;
  120755. /** the uv of the vertex (default: 0,0) */
  120756. uv: Vector2;
  120757. /**
  120758. * Creates a PositionNormalTextureVertex
  120759. * @param position the position of the vertex (defaut: 0,0,0)
  120760. * @param normal the normal of the vertex (defaut: 0,1,0)
  120761. * @param uv the uv of the vertex (default: 0,0)
  120762. */
  120763. constructor(
  120764. /** the position of the vertex (defaut: 0,0,0) */
  120765. position?: Vector3,
  120766. /** the normal of the vertex (defaut: 0,1,0) */
  120767. normal?: Vector3,
  120768. /** the uv of the vertex (default: 0,0) */
  120769. uv?: Vector2);
  120770. /**
  120771. * Clones the PositionNormalTextureVertex
  120772. * @returns the cloned PositionNormalTextureVertex
  120773. */
  120774. clone(): PositionNormalTextureVertex;
  120775. }
  120776. }
  120777. declare module BABYLON {
  120778. /** @hidden */
  120779. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120780. private _genericAttributeLocation;
  120781. private _varyingLocationCount;
  120782. private _varyingLocationMap;
  120783. private _replacements;
  120784. private _textureCount;
  120785. private _uniforms;
  120786. lineProcessor(line: string): string;
  120787. attributeProcessor(attribute: string): string;
  120788. varyingProcessor(varying: string, isFragment: boolean): string;
  120789. uniformProcessor(uniform: string): string;
  120790. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120791. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120792. }
  120793. }
  120794. declare module BABYLON {
  120795. /**
  120796. * Container for accessors for natively-stored mesh data buffers.
  120797. */
  120798. class NativeDataBuffer extends DataBuffer {
  120799. /**
  120800. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120801. */
  120802. nativeIndexBuffer?: any;
  120803. /**
  120804. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120805. */
  120806. nativeVertexBuffer?: any;
  120807. }
  120808. /** @hidden */
  120809. class NativeTexture extends InternalTexture {
  120810. getInternalTexture(): InternalTexture;
  120811. getViewCount(): number;
  120812. }
  120813. /** @hidden */
  120814. export class NativeEngine extends Engine {
  120815. private readonly _native;
  120816. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120817. private readonly INVALID_HANDLE;
  120818. getHardwareScalingLevel(): number;
  120819. constructor();
  120820. /**
  120821. * Can be used to override the current requestAnimationFrame requester.
  120822. * @hidden
  120823. */
  120824. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120825. /**
  120826. * Override default engine behavior.
  120827. * @param color
  120828. * @param backBuffer
  120829. * @param depth
  120830. * @param stencil
  120831. */
  120832. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120833. /**
  120834. * Gets host document
  120835. * @returns the host document object
  120836. */
  120837. getHostDocument(): Nullable<Document>;
  120838. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120839. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120840. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120841. recordVertexArrayObject(vertexBuffers: {
  120842. [key: string]: VertexBuffer;
  120843. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120844. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120845. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120846. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120847. /**
  120848. * Draw a list of indexed primitives
  120849. * @param fillMode defines the primitive to use
  120850. * @param indexStart defines the starting index
  120851. * @param indexCount defines the number of index to draw
  120852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120853. */
  120854. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120855. /**
  120856. * Draw a list of unindexed primitives
  120857. * @param fillMode defines the primitive to use
  120858. * @param verticesStart defines the index of first vertex to draw
  120859. * @param verticesCount defines the count of vertices to draw
  120860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120861. */
  120862. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120863. createPipelineContext(): IPipelineContext;
  120864. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120865. /** @hidden */
  120866. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120867. /** @hidden */
  120868. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120869. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120870. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120871. protected _setProgram(program: WebGLProgram): void;
  120872. _releaseEffect(effect: Effect): void;
  120873. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120874. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120875. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120876. bindSamplers(effect: Effect): void;
  120877. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120878. getRenderWidth(useScreen?: boolean): number;
  120879. getRenderHeight(useScreen?: boolean): number;
  120880. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120881. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120882. /**
  120883. * Set the z offset to apply to current rendering
  120884. * @param value defines the offset to apply
  120885. */
  120886. setZOffset(value: number): void;
  120887. /**
  120888. * Gets the current value of the zOffset
  120889. * @returns the current zOffset state
  120890. */
  120891. getZOffset(): number;
  120892. /**
  120893. * Enable or disable depth buffering
  120894. * @param enable defines the state to set
  120895. */
  120896. setDepthBuffer(enable: boolean): void;
  120897. /**
  120898. * Gets a boolean indicating if depth writing is enabled
  120899. * @returns the current depth writing state
  120900. */
  120901. getDepthWrite(): boolean;
  120902. /**
  120903. * Enable or disable depth writing
  120904. * @param enable defines the state to set
  120905. */
  120906. setDepthWrite(enable: boolean): void;
  120907. /**
  120908. * Enable or disable color writing
  120909. * @param enable defines the state to set
  120910. */
  120911. setColorWrite(enable: boolean): void;
  120912. /**
  120913. * Gets a boolean indicating if color writing is enabled
  120914. * @returns the current color writing state
  120915. */
  120916. getColorWrite(): boolean;
  120917. /**
  120918. * Sets alpha constants used by some alpha blending modes
  120919. * @param r defines the red component
  120920. * @param g defines the green component
  120921. * @param b defines the blue component
  120922. * @param a defines the alpha component
  120923. */
  120924. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120925. /**
  120926. * Sets the current alpha mode
  120927. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120928. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120929. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120930. */
  120931. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120932. /**
  120933. * Gets the current alpha mode
  120934. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120935. * @returns the current alpha mode
  120936. */
  120937. getAlphaMode(): number;
  120938. setInt(uniform: WebGLUniformLocation, int: number): void;
  120939. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120940. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120941. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120942. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120943. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120944. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120945. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120946. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120947. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120948. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120949. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120950. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120951. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120952. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120953. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120954. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120955. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120956. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120957. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120958. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120959. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120960. wipeCaches(bruteForce?: boolean): void;
  120961. _createTexture(): WebGLTexture;
  120962. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120963. /**
  120964. * Usually called from Texture.ts.
  120965. * Passed information to create a WebGLTexture
  120966. * @param urlArg defines a value which contains one of the following:
  120967. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120968. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120969. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120970. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120971. * @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)
  120972. * @param scene needed for loading to the correct scene
  120973. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120974. * @param onLoad optional callback to be called upon successful completion
  120975. * @param onError optional callback to be called upon failure
  120976. * @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
  120977. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120978. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120979. * @param forcedExtension defines the extension to use to pick the right loader
  120980. * @param mimeType defines an optional mime type
  120981. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120982. */
  120983. 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;
  120984. /**
  120985. * Creates a cube texture
  120986. * @param rootUrl defines the url where the files to load is located
  120987. * @param scene defines the current scene
  120988. * @param files defines the list of files to load (1 per face)
  120989. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120990. * @param onLoad defines an optional callback raised when the texture is loaded
  120991. * @param onError defines an optional callback raised if there is an issue to load the texture
  120992. * @param format defines the format of the data
  120993. * @param forcedExtension defines the extension to use to pick the right loader
  120994. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120995. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120996. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120997. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120998. * @returns the cube texture as an InternalTexture
  120999. */
  121000. 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;
  121001. private _getSamplingFilter;
  121002. private static _GetNativeTextureFormat;
  121003. createRenderTargetTexture(size: number | {
  121004. width: number;
  121005. height: number;
  121006. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121007. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121008. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121009. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121010. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121011. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121012. /**
  121013. * Updates a dynamic vertex buffer.
  121014. * @param vertexBuffer the vertex buffer to update
  121015. * @param data the data used to update the vertex buffer
  121016. * @param byteOffset the byte offset of the data (optional)
  121017. * @param byteLength the byte length of the data (optional)
  121018. */
  121019. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121020. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121021. private _updateAnisotropicLevel;
  121022. private _getAddressMode;
  121023. /** @hidden */
  121024. _bindTexture(channel: number, texture: InternalTexture): void;
  121025. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121026. releaseEffects(): void;
  121027. /** @hidden */
  121028. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121029. /** @hidden */
  121030. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121031. /** @hidden */
  121032. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121033. /** @hidden */
  121034. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121035. }
  121036. }
  121037. declare module BABYLON {
  121038. /**
  121039. * Gather the list of clipboard event types as constants.
  121040. */
  121041. export class ClipboardEventTypes {
  121042. /**
  121043. * The clipboard event is fired when a copy command is active (pressed).
  121044. */
  121045. static readonly COPY: number;
  121046. /**
  121047. * The clipboard event is fired when a cut command is active (pressed).
  121048. */
  121049. static readonly CUT: number;
  121050. /**
  121051. * The clipboard event is fired when a paste command is active (pressed).
  121052. */
  121053. static readonly PASTE: number;
  121054. }
  121055. /**
  121056. * This class is used to store clipboard related info for the onClipboardObservable event.
  121057. */
  121058. export class ClipboardInfo {
  121059. /**
  121060. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121061. */
  121062. type: number;
  121063. /**
  121064. * Defines the related dom event
  121065. */
  121066. event: ClipboardEvent;
  121067. /**
  121068. *Creates an instance of ClipboardInfo.
  121069. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121070. * @param event Defines the related dom event
  121071. */
  121072. constructor(
  121073. /**
  121074. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121075. */
  121076. type: number,
  121077. /**
  121078. * Defines the related dom event
  121079. */
  121080. event: ClipboardEvent);
  121081. /**
  121082. * Get the clipboard event's type from the keycode.
  121083. * @param keyCode Defines the keyCode for the current keyboard event.
  121084. * @return {number}
  121085. */
  121086. static GetTypeFromCharacter(keyCode: number): number;
  121087. }
  121088. }
  121089. declare module BABYLON {
  121090. /**
  121091. * Google Daydream controller
  121092. */
  121093. export class DaydreamController extends WebVRController {
  121094. /**
  121095. * Base Url for the controller model.
  121096. */
  121097. static MODEL_BASE_URL: string;
  121098. /**
  121099. * File name for the controller model.
  121100. */
  121101. static MODEL_FILENAME: string;
  121102. /**
  121103. * Gamepad Id prefix used to identify Daydream Controller.
  121104. */
  121105. static readonly GAMEPAD_ID_PREFIX: string;
  121106. /**
  121107. * Creates a new DaydreamController from a gamepad
  121108. * @param vrGamepad the gamepad that the controller should be created from
  121109. */
  121110. constructor(vrGamepad: any);
  121111. /**
  121112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121113. * @param scene scene in which to add meshes
  121114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121115. */
  121116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121117. /**
  121118. * Called once for each button that changed state since the last frame
  121119. * @param buttonIdx Which button index changed
  121120. * @param state New state of the button
  121121. * @param changes Which properties on the state changed since last frame
  121122. */
  121123. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121124. }
  121125. }
  121126. declare module BABYLON {
  121127. /**
  121128. * Gear VR Controller
  121129. */
  121130. export class GearVRController extends WebVRController {
  121131. /**
  121132. * Base Url for the controller model.
  121133. */
  121134. static MODEL_BASE_URL: string;
  121135. /**
  121136. * File name for the controller model.
  121137. */
  121138. static MODEL_FILENAME: string;
  121139. /**
  121140. * Gamepad Id prefix used to identify this controller.
  121141. */
  121142. static readonly GAMEPAD_ID_PREFIX: string;
  121143. private readonly _buttonIndexToObservableNameMap;
  121144. /**
  121145. * Creates a new GearVRController from a gamepad
  121146. * @param vrGamepad the gamepad that the controller should be created from
  121147. */
  121148. constructor(vrGamepad: any);
  121149. /**
  121150. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121151. * @param scene scene in which to add meshes
  121152. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121153. */
  121154. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121155. /**
  121156. * Called once for each button that changed state since the last frame
  121157. * @param buttonIdx Which button index changed
  121158. * @param state New state of the button
  121159. * @param changes Which properties on the state changed since last frame
  121160. */
  121161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121162. }
  121163. }
  121164. declare module BABYLON {
  121165. /**
  121166. * Generic Controller
  121167. */
  121168. export class GenericController extends WebVRController {
  121169. /**
  121170. * Base Url for the controller model.
  121171. */
  121172. static readonly MODEL_BASE_URL: string;
  121173. /**
  121174. * File name for the controller model.
  121175. */
  121176. static readonly MODEL_FILENAME: string;
  121177. /**
  121178. * Creates a new GenericController from a gamepad
  121179. * @param vrGamepad the gamepad that the controller should be created from
  121180. */
  121181. constructor(vrGamepad: any);
  121182. /**
  121183. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121184. * @param scene scene in which to add meshes
  121185. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121186. */
  121187. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121188. /**
  121189. * Called once for each button that changed state since the last frame
  121190. * @param buttonIdx Which button index changed
  121191. * @param state New state of the button
  121192. * @param changes Which properties on the state changed since last frame
  121193. */
  121194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121195. }
  121196. }
  121197. declare module BABYLON {
  121198. /**
  121199. * Oculus Touch Controller
  121200. */
  121201. export class OculusTouchController extends WebVRController {
  121202. /**
  121203. * Base Url for the controller model.
  121204. */
  121205. static MODEL_BASE_URL: string;
  121206. /**
  121207. * File name for the left controller model.
  121208. */
  121209. static MODEL_LEFT_FILENAME: string;
  121210. /**
  121211. * File name for the right controller model.
  121212. */
  121213. static MODEL_RIGHT_FILENAME: string;
  121214. /**
  121215. * Base Url for the Quest controller model.
  121216. */
  121217. static QUEST_MODEL_BASE_URL: string;
  121218. /**
  121219. * @hidden
  121220. * If the controllers are running on a device that needs the updated Quest controller models
  121221. */
  121222. static _IsQuest: boolean;
  121223. /**
  121224. * Fired when the secondary trigger on this controller is modified
  121225. */
  121226. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121227. /**
  121228. * Fired when the thumb rest on this controller is modified
  121229. */
  121230. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121231. /**
  121232. * Creates a new OculusTouchController from a gamepad
  121233. * @param vrGamepad the gamepad that the controller should be created from
  121234. */
  121235. constructor(vrGamepad: any);
  121236. /**
  121237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121238. * @param scene scene in which to add meshes
  121239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121240. */
  121241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121242. /**
  121243. * Fired when the A button on this controller is modified
  121244. */
  121245. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121246. /**
  121247. * Fired when the B button on this controller is modified
  121248. */
  121249. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121250. /**
  121251. * Fired when the X button on this controller is modified
  121252. */
  121253. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121254. /**
  121255. * Fired when the Y button on this controller is modified
  121256. */
  121257. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121258. /**
  121259. * Called once for each button that changed state since the last frame
  121260. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121261. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121262. * 2) secondary trigger (same)
  121263. * 3) A (right) X (left), touch, pressed = value
  121264. * 4) B / Y
  121265. * 5) thumb rest
  121266. * @param buttonIdx Which button index changed
  121267. * @param state New state of the button
  121268. * @param changes Which properties on the state changed since last frame
  121269. */
  121270. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121271. }
  121272. }
  121273. declare module BABYLON {
  121274. /**
  121275. * Vive Controller
  121276. */
  121277. export class ViveController extends WebVRController {
  121278. /**
  121279. * Base Url for the controller model.
  121280. */
  121281. static MODEL_BASE_URL: string;
  121282. /**
  121283. * File name for the controller model.
  121284. */
  121285. static MODEL_FILENAME: string;
  121286. /**
  121287. * Creates a new ViveController from a gamepad
  121288. * @param vrGamepad the gamepad that the controller should be created from
  121289. */
  121290. constructor(vrGamepad: any);
  121291. /**
  121292. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121293. * @param scene scene in which to add meshes
  121294. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121295. */
  121296. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121297. /**
  121298. * Fired when the left button on this controller is modified
  121299. */
  121300. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121301. /**
  121302. * Fired when the right button on this controller is modified
  121303. */
  121304. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121305. /**
  121306. * Fired when the menu button on this controller is modified
  121307. */
  121308. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121309. /**
  121310. * Called once for each button that changed state since the last frame
  121311. * Vive mapping:
  121312. * 0: touchpad
  121313. * 1: trigger
  121314. * 2: left AND right buttons
  121315. * 3: menu button
  121316. * @param buttonIdx Which button index changed
  121317. * @param state New state of the button
  121318. * @param changes Which properties on the state changed since last frame
  121319. */
  121320. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121321. }
  121322. }
  121323. declare module BABYLON {
  121324. /**
  121325. * Defines the WindowsMotionController object that the state of the windows motion controller
  121326. */
  121327. export class WindowsMotionController extends WebVRController {
  121328. /**
  121329. * The base url used to load the left and right controller models
  121330. */
  121331. static MODEL_BASE_URL: string;
  121332. /**
  121333. * The name of the left controller model file
  121334. */
  121335. static MODEL_LEFT_FILENAME: string;
  121336. /**
  121337. * The name of the right controller model file
  121338. */
  121339. static MODEL_RIGHT_FILENAME: string;
  121340. /**
  121341. * The controller name prefix for this controller type
  121342. */
  121343. static readonly GAMEPAD_ID_PREFIX: string;
  121344. /**
  121345. * The controller id pattern for this controller type
  121346. */
  121347. private static readonly GAMEPAD_ID_PATTERN;
  121348. private _loadedMeshInfo;
  121349. protected readonly _mapping: {
  121350. buttons: string[];
  121351. buttonMeshNames: {
  121352. 'trigger': string;
  121353. 'menu': string;
  121354. 'grip': string;
  121355. 'thumbstick': string;
  121356. 'trackpad': string;
  121357. };
  121358. buttonObservableNames: {
  121359. 'trigger': string;
  121360. 'menu': string;
  121361. 'grip': string;
  121362. 'thumbstick': string;
  121363. 'trackpad': string;
  121364. };
  121365. axisMeshNames: string[];
  121366. pointingPoseMeshName: string;
  121367. };
  121368. /**
  121369. * Fired when the trackpad on this controller is clicked
  121370. */
  121371. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121372. /**
  121373. * Fired when the trackpad on this controller is modified
  121374. */
  121375. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121376. /**
  121377. * The current x and y values of this controller's trackpad
  121378. */
  121379. trackpad: StickValues;
  121380. /**
  121381. * Creates a new WindowsMotionController from a gamepad
  121382. * @param vrGamepad the gamepad that the controller should be created from
  121383. */
  121384. constructor(vrGamepad: any);
  121385. /**
  121386. * Fired when the trigger on this controller is modified
  121387. */
  121388. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121389. /**
  121390. * Fired when the menu button on this controller is modified
  121391. */
  121392. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121393. /**
  121394. * Fired when the grip button on this controller is modified
  121395. */
  121396. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121397. /**
  121398. * Fired when the thumbstick button on this controller is modified
  121399. */
  121400. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121401. /**
  121402. * Fired when the touchpad button on this controller is modified
  121403. */
  121404. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121405. /**
  121406. * Fired when the touchpad values on this controller are modified
  121407. */
  121408. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121409. protected _updateTrackpad(): void;
  121410. /**
  121411. * Called once per frame by the engine.
  121412. */
  121413. update(): void;
  121414. /**
  121415. * Called once for each button that changed state since the last frame
  121416. * @param buttonIdx Which button index changed
  121417. * @param state New state of the button
  121418. * @param changes Which properties on the state changed since last frame
  121419. */
  121420. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121421. /**
  121422. * Moves the buttons on the controller mesh based on their current state
  121423. * @param buttonName the name of the button to move
  121424. * @param buttonValue the value of the button which determines the buttons new position
  121425. */
  121426. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121427. /**
  121428. * Moves the axis on the controller mesh based on its current state
  121429. * @param axis the index of the axis
  121430. * @param axisValue the value of the axis which determines the meshes new position
  121431. * @hidden
  121432. */
  121433. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121434. /**
  121435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121436. * @param scene scene in which to add meshes
  121437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121438. */
  121439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121440. /**
  121441. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121442. * can be transformed by button presses and axes values, based on this._mapping.
  121443. *
  121444. * @param scene scene in which the meshes exist
  121445. * @param meshes list of meshes that make up the controller model to process
  121446. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121447. */
  121448. private processModel;
  121449. private createMeshInfo;
  121450. /**
  121451. * Gets the ray of the controller in the direction the controller is pointing
  121452. * @param length the length the resulting ray should be
  121453. * @returns a ray in the direction the controller is pointing
  121454. */
  121455. getForwardRay(length?: number): Ray;
  121456. /**
  121457. * Disposes of the controller
  121458. */
  121459. dispose(): void;
  121460. }
  121461. /**
  121462. * This class represents a new windows motion controller in XR.
  121463. */
  121464. export class XRWindowsMotionController extends WindowsMotionController {
  121465. /**
  121466. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121467. */
  121468. protected readonly _mapping: {
  121469. buttons: string[];
  121470. buttonMeshNames: {
  121471. 'trigger': string;
  121472. 'menu': string;
  121473. 'grip': string;
  121474. 'thumbstick': string;
  121475. 'trackpad': string;
  121476. };
  121477. buttonObservableNames: {
  121478. 'trigger': string;
  121479. 'menu': string;
  121480. 'grip': string;
  121481. 'thumbstick': string;
  121482. 'trackpad': string;
  121483. };
  121484. axisMeshNames: string[];
  121485. pointingPoseMeshName: string;
  121486. };
  121487. /**
  121488. * Construct a new XR-Based windows motion controller
  121489. *
  121490. * @param gamepadInfo the gamepad object from the browser
  121491. */
  121492. constructor(gamepadInfo: any);
  121493. /**
  121494. * holds the thumbstick values (X,Y)
  121495. */
  121496. thumbstickValues: StickValues;
  121497. /**
  121498. * Fired when the thumbstick on this controller is clicked
  121499. */
  121500. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121501. /**
  121502. * Fired when the thumbstick on this controller is modified
  121503. */
  121504. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121505. /**
  121506. * Fired when the touchpad button on this controller is modified
  121507. */
  121508. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121509. /**
  121510. * Fired when the touchpad values on this controller are modified
  121511. */
  121512. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121513. /**
  121514. * Fired when the thumbstick button on this controller is modified
  121515. * here to prevent breaking changes
  121516. */
  121517. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121518. /**
  121519. * updating the thumbstick(!) and not the trackpad.
  121520. * This is named this way due to the difference between WebVR and XR and to avoid
  121521. * changing the parent class.
  121522. */
  121523. protected _updateTrackpad(): void;
  121524. /**
  121525. * Disposes the class with joy
  121526. */
  121527. dispose(): void;
  121528. }
  121529. }
  121530. declare module BABYLON {
  121531. /**
  121532. * Class containing static functions to help procedurally build meshes
  121533. */
  121534. export class PolyhedronBuilder {
  121535. /**
  121536. * Creates a polyhedron mesh
  121537. * * 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
  121538. * * The parameter `size` (positive float, default 1) sets the polygon size
  121539. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121540. * * 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`
  121541. * * 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
  121542. * * 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)`)
  121543. * * 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
  121544. * * 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
  121545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121548. * @param name defines the name of the mesh
  121549. * @param options defines the options used to create the mesh
  121550. * @param scene defines the hosting scene
  121551. * @returns the polyhedron mesh
  121552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121553. */
  121554. static CreatePolyhedron(name: string, options: {
  121555. type?: number;
  121556. size?: number;
  121557. sizeX?: number;
  121558. sizeY?: number;
  121559. sizeZ?: number;
  121560. custom?: any;
  121561. faceUV?: Vector4[];
  121562. faceColors?: Color4[];
  121563. flat?: boolean;
  121564. updatable?: boolean;
  121565. sideOrientation?: number;
  121566. frontUVs?: Vector4;
  121567. backUVs?: Vector4;
  121568. }, scene?: Nullable<Scene>): Mesh;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Gizmo that enables scaling a mesh along 3 axis
  121574. */
  121575. export class ScaleGizmo extends Gizmo {
  121576. /**
  121577. * Internal gizmo used for interactions on the x axis
  121578. */
  121579. xGizmo: AxisScaleGizmo;
  121580. /**
  121581. * Internal gizmo used for interactions on the y axis
  121582. */
  121583. yGizmo: AxisScaleGizmo;
  121584. /**
  121585. * Internal gizmo used for interactions on the z axis
  121586. */
  121587. zGizmo: AxisScaleGizmo;
  121588. /**
  121589. * Internal gizmo used to scale all axis equally
  121590. */
  121591. uniformScaleGizmo: AxisScaleGizmo;
  121592. private _meshAttached;
  121593. private _updateGizmoRotationToMatchAttachedMesh;
  121594. private _snapDistance;
  121595. private _scaleRatio;
  121596. private _uniformScalingMesh;
  121597. private _octahedron;
  121598. private _sensitivity;
  121599. /** Fires an event when any of it's sub gizmos are dragged */
  121600. onDragStartObservable: Observable<unknown>;
  121601. /** Fires an event when any of it's sub gizmos are released from dragging */
  121602. onDragEndObservable: Observable<unknown>;
  121603. get attachedMesh(): Nullable<AbstractMesh>;
  121604. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121605. /**
  121606. * Creates a ScaleGizmo
  121607. * @param gizmoLayer The utility layer the gizmo will be added to
  121608. */
  121609. constructor(gizmoLayer?: UtilityLayerRenderer);
  121610. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121611. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121612. /**
  121613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121614. */
  121615. set snapDistance(value: number);
  121616. get snapDistance(): number;
  121617. /**
  121618. * Ratio for the scale of the gizmo (Default: 1)
  121619. */
  121620. set scaleRatio(value: number);
  121621. get scaleRatio(): number;
  121622. /**
  121623. * Sensitivity factor for dragging (Default: 1)
  121624. */
  121625. set sensitivity(value: number);
  121626. get sensitivity(): number;
  121627. /**
  121628. * Disposes of the gizmo
  121629. */
  121630. dispose(): void;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Single axis scale gizmo
  121636. */
  121637. export class AxisScaleGizmo extends Gizmo {
  121638. /**
  121639. * Drag behavior responsible for the gizmos dragging interactions
  121640. */
  121641. dragBehavior: PointerDragBehavior;
  121642. private _pointerObserver;
  121643. /**
  121644. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121645. */
  121646. snapDistance: number;
  121647. /**
  121648. * Event that fires each time the gizmo snaps to a new location.
  121649. * * snapDistance is the the change in distance
  121650. */
  121651. onSnapObservable: Observable<{
  121652. snapDistance: number;
  121653. }>;
  121654. /**
  121655. * If the scaling operation should be done on all axis (default: false)
  121656. */
  121657. uniformScaling: boolean;
  121658. /**
  121659. * Custom sensitivity value for the drag strength
  121660. */
  121661. sensitivity: number;
  121662. private _isEnabled;
  121663. private _parent;
  121664. private _arrow;
  121665. private _coloredMaterial;
  121666. private _hoverMaterial;
  121667. /**
  121668. * Creates an AxisScaleGizmo
  121669. * @param gizmoLayer The utility layer the gizmo will be added to
  121670. * @param dragAxis The axis which the gizmo will be able to scale on
  121671. * @param color The color of the gizmo
  121672. */
  121673. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121675. /**
  121676. * If the gizmo is enabled
  121677. */
  121678. set isEnabled(value: boolean);
  121679. get isEnabled(): boolean;
  121680. /**
  121681. * Disposes of the gizmo
  121682. */
  121683. dispose(): void;
  121684. /**
  121685. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121686. * @param mesh The mesh to replace the default mesh of the gizmo
  121687. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121688. */
  121689. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121690. }
  121691. }
  121692. declare module BABYLON {
  121693. /**
  121694. * Bounding box gizmo
  121695. */
  121696. export class BoundingBoxGizmo extends Gizmo {
  121697. private _lineBoundingBox;
  121698. private _rotateSpheresParent;
  121699. private _scaleBoxesParent;
  121700. private _boundingDimensions;
  121701. private _renderObserver;
  121702. private _pointerObserver;
  121703. private _scaleDragSpeed;
  121704. private _tmpQuaternion;
  121705. private _tmpVector;
  121706. private _tmpRotationMatrix;
  121707. /**
  121708. * 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)
  121709. */
  121710. ignoreChildren: boolean;
  121711. /**
  121712. * 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)
  121713. */
  121714. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121715. /**
  121716. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121717. */
  121718. rotationSphereSize: number;
  121719. /**
  121720. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121721. */
  121722. scaleBoxSize: number;
  121723. /**
  121724. * 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)
  121725. */
  121726. fixedDragMeshScreenSize: boolean;
  121727. /**
  121728. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121729. */
  121730. fixedDragMeshScreenSizeDistanceFactor: number;
  121731. /**
  121732. * Fired when a rotation sphere or scale box is dragged
  121733. */
  121734. onDragStartObservable: Observable<{}>;
  121735. /**
  121736. * Fired when a scale box is dragged
  121737. */
  121738. onScaleBoxDragObservable: Observable<{}>;
  121739. /**
  121740. * Fired when a scale box drag is ended
  121741. */
  121742. onScaleBoxDragEndObservable: Observable<{}>;
  121743. /**
  121744. * Fired when a rotation sphere is dragged
  121745. */
  121746. onRotationSphereDragObservable: Observable<{}>;
  121747. /**
  121748. * Fired when a rotation sphere drag is ended
  121749. */
  121750. onRotationSphereDragEndObservable: Observable<{}>;
  121751. /**
  121752. * 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)
  121753. */
  121754. scalePivot: Nullable<Vector3>;
  121755. /**
  121756. * Mesh used as a pivot to rotate the attached mesh
  121757. */
  121758. private _anchorMesh;
  121759. private _existingMeshScale;
  121760. private _dragMesh;
  121761. private pointerDragBehavior;
  121762. private coloredMaterial;
  121763. private hoverColoredMaterial;
  121764. /**
  121765. * Sets the color of the bounding box gizmo
  121766. * @param color the color to set
  121767. */
  121768. setColor(color: Color3): void;
  121769. /**
  121770. * Creates an BoundingBoxGizmo
  121771. * @param gizmoLayer The utility layer the gizmo will be added to
  121772. * @param color The color of the gizmo
  121773. */
  121774. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121776. private _selectNode;
  121777. /**
  121778. * Updates the bounding box information for the Gizmo
  121779. */
  121780. updateBoundingBox(): void;
  121781. private _updateRotationSpheres;
  121782. private _updateScaleBoxes;
  121783. /**
  121784. * Enables rotation on the specified axis and disables rotation on the others
  121785. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121786. */
  121787. setEnabledRotationAxis(axis: string): void;
  121788. /**
  121789. * Enables/disables scaling
  121790. * @param enable if scaling should be enabled
  121791. */
  121792. setEnabledScaling(enable: boolean): void;
  121793. private _updateDummy;
  121794. /**
  121795. * Enables a pointer drag behavior on the bounding box of the gizmo
  121796. */
  121797. enableDragBehavior(): void;
  121798. /**
  121799. * Disposes of the gizmo
  121800. */
  121801. dispose(): void;
  121802. /**
  121803. * 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)
  121804. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121805. * @returns the bounding box mesh with the passed in mesh as a child
  121806. */
  121807. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121808. /**
  121809. * CustomMeshes are not supported by this gizmo
  121810. * @param mesh The mesh to replace the default mesh of the gizmo
  121811. */
  121812. setCustomMesh(mesh: Mesh): void;
  121813. }
  121814. }
  121815. declare module BABYLON {
  121816. /**
  121817. * Single plane rotation gizmo
  121818. */
  121819. export class PlaneRotationGizmo extends Gizmo {
  121820. /**
  121821. * Drag behavior responsible for the gizmos dragging interactions
  121822. */
  121823. dragBehavior: PointerDragBehavior;
  121824. private _pointerObserver;
  121825. /**
  121826. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121827. */
  121828. snapDistance: number;
  121829. /**
  121830. * Event that fires each time the gizmo snaps to a new location.
  121831. * * snapDistance is the the change in distance
  121832. */
  121833. onSnapObservable: Observable<{
  121834. snapDistance: number;
  121835. }>;
  121836. private _isEnabled;
  121837. private _parent;
  121838. /**
  121839. * Creates a PlaneRotationGizmo
  121840. * @param gizmoLayer The utility layer the gizmo will be added to
  121841. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121842. * @param color The color of the gizmo
  121843. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121844. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121845. */
  121846. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121847. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121848. /**
  121849. * If the gizmo is enabled
  121850. */
  121851. set isEnabled(value: boolean);
  121852. get isEnabled(): boolean;
  121853. /**
  121854. * Disposes of the gizmo
  121855. */
  121856. dispose(): void;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * Gizmo that enables rotating a mesh along 3 axis
  121862. */
  121863. export class RotationGizmo extends Gizmo {
  121864. /**
  121865. * Internal gizmo used for interactions on the x axis
  121866. */
  121867. xGizmo: PlaneRotationGizmo;
  121868. /**
  121869. * Internal gizmo used for interactions on the y axis
  121870. */
  121871. yGizmo: PlaneRotationGizmo;
  121872. /**
  121873. * Internal gizmo used for interactions on the z axis
  121874. */
  121875. zGizmo: PlaneRotationGizmo;
  121876. /** Fires an event when any of it's sub gizmos are dragged */
  121877. onDragStartObservable: Observable<unknown>;
  121878. /** Fires an event when any of it's sub gizmos are released from dragging */
  121879. onDragEndObservable: Observable<unknown>;
  121880. private _meshAttached;
  121881. get attachedMesh(): Nullable<AbstractMesh>;
  121882. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121883. /**
  121884. * Creates a RotationGizmo
  121885. * @param gizmoLayer The utility layer the gizmo will be added to
  121886. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121887. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121888. */
  121889. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121890. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121891. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121892. /**
  121893. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121894. */
  121895. set snapDistance(value: number);
  121896. get snapDistance(): number;
  121897. /**
  121898. * Ratio for the scale of the gizmo (Default: 1)
  121899. */
  121900. set scaleRatio(value: number);
  121901. get scaleRatio(): number;
  121902. /**
  121903. * Disposes of the gizmo
  121904. */
  121905. dispose(): void;
  121906. /**
  121907. * CustomMeshes are not supported by this gizmo
  121908. * @param mesh The mesh to replace the default mesh of the gizmo
  121909. */
  121910. setCustomMesh(mesh: Mesh): void;
  121911. }
  121912. }
  121913. declare module BABYLON {
  121914. /**
  121915. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121916. */
  121917. export class GizmoManager implements IDisposable {
  121918. private scene;
  121919. /**
  121920. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121921. */
  121922. gizmos: {
  121923. positionGizmo: Nullable<PositionGizmo>;
  121924. rotationGizmo: Nullable<RotationGizmo>;
  121925. scaleGizmo: Nullable<ScaleGizmo>;
  121926. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121927. };
  121928. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121929. clearGizmoOnEmptyPointerEvent: boolean;
  121930. /** Fires an event when the manager is attached to a mesh */
  121931. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121932. private _gizmosEnabled;
  121933. private _pointerObserver;
  121934. private _attachedMesh;
  121935. private _boundingBoxColor;
  121936. private _defaultUtilityLayer;
  121937. private _defaultKeepDepthUtilityLayer;
  121938. /**
  121939. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121940. */
  121941. boundingBoxDragBehavior: SixDofDragBehavior;
  121942. /**
  121943. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121944. */
  121945. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121946. /**
  121947. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121948. */
  121949. usePointerToAttachGizmos: boolean;
  121950. /**
  121951. * Utility layer that the bounding box gizmo belongs to
  121952. */
  121953. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121954. /**
  121955. * Utility layer that all gizmos besides bounding box belong to
  121956. */
  121957. get utilityLayer(): UtilityLayerRenderer;
  121958. /**
  121959. * Instatiates a gizmo manager
  121960. * @param scene the scene to overlay the gizmos on top of
  121961. */
  121962. constructor(scene: Scene);
  121963. /**
  121964. * Attaches a set of gizmos to the specified mesh
  121965. * @param mesh The mesh the gizmo's should be attached to
  121966. */
  121967. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121968. /**
  121969. * If the position gizmo is enabled
  121970. */
  121971. set positionGizmoEnabled(value: boolean);
  121972. get positionGizmoEnabled(): boolean;
  121973. /**
  121974. * If the rotation gizmo is enabled
  121975. */
  121976. set rotationGizmoEnabled(value: boolean);
  121977. get rotationGizmoEnabled(): boolean;
  121978. /**
  121979. * If the scale gizmo is enabled
  121980. */
  121981. set scaleGizmoEnabled(value: boolean);
  121982. get scaleGizmoEnabled(): boolean;
  121983. /**
  121984. * If the boundingBox gizmo is enabled
  121985. */
  121986. set boundingBoxGizmoEnabled(value: boolean);
  121987. get boundingBoxGizmoEnabled(): boolean;
  121988. /**
  121989. * Disposes of the gizmo manager
  121990. */
  121991. dispose(): void;
  121992. }
  121993. }
  121994. declare module BABYLON {
  121995. /**
  121996. * A directional light is defined by a direction (what a surprise!).
  121997. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121998. * 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.
  121999. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122000. */
  122001. export class DirectionalLight extends ShadowLight {
  122002. private _shadowFrustumSize;
  122003. /**
  122004. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122005. */
  122006. get shadowFrustumSize(): number;
  122007. /**
  122008. * Specifies a fix frustum size for the shadow generation.
  122009. */
  122010. set shadowFrustumSize(value: number);
  122011. private _shadowOrthoScale;
  122012. /**
  122013. * Gets the shadow projection scale against the optimal computed one.
  122014. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122015. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122016. */
  122017. get shadowOrthoScale(): number;
  122018. /**
  122019. * Sets the shadow projection scale against the optimal computed one.
  122020. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122021. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122022. */
  122023. set shadowOrthoScale(value: number);
  122024. /**
  122025. * Automatically compute the projection matrix to best fit (including all the casters)
  122026. * on each frame.
  122027. */
  122028. autoUpdateExtends: boolean;
  122029. /**
  122030. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122031. * on each frame. autoUpdateExtends must be set to true for this to work
  122032. */
  122033. autoCalcShadowZBounds: boolean;
  122034. private _orthoLeft;
  122035. private _orthoRight;
  122036. private _orthoTop;
  122037. private _orthoBottom;
  122038. /**
  122039. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122040. * The directional light is emitted from everywhere in the given direction.
  122041. * It can cast shadows.
  122042. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122043. * @param name The friendly name of the light
  122044. * @param direction The direction of the light
  122045. * @param scene The scene the light belongs to
  122046. */
  122047. constructor(name: string, direction: Vector3, scene: Scene);
  122048. /**
  122049. * Returns the string "DirectionalLight".
  122050. * @return The class name
  122051. */
  122052. getClassName(): string;
  122053. /**
  122054. * Returns the integer 1.
  122055. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122056. */
  122057. getTypeID(): number;
  122058. /**
  122059. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122060. * Returns the DirectionalLight Shadow projection matrix.
  122061. */
  122062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122063. /**
  122064. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122065. * Returns the DirectionalLight Shadow projection matrix.
  122066. */
  122067. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122068. /**
  122069. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122070. * Returns the DirectionalLight Shadow projection matrix.
  122071. */
  122072. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122073. protected _buildUniformLayout(): void;
  122074. /**
  122075. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122076. * @param effect The effect to update
  122077. * @param lightIndex The index of the light in the effect to update
  122078. * @returns The directional light
  122079. */
  122080. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122082. /**
  122083. * Gets the minZ used for shadow according to both the scene and the light.
  122084. *
  122085. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122086. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122087. * @param activeCamera The camera we are returning the min for
  122088. * @returns the depth min z
  122089. */
  122090. getDepthMinZ(activeCamera: Camera): number;
  122091. /**
  122092. * Gets the maxZ used for shadow according to both the scene and the light.
  122093. *
  122094. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122095. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122096. * @param activeCamera The camera we are returning the max for
  122097. * @returns the depth max z
  122098. */
  122099. getDepthMaxZ(activeCamera: Camera): number;
  122100. /**
  122101. * Prepares the list of defines specific to the light type.
  122102. * @param defines the list of defines
  122103. * @param lightIndex defines the index of the light for the effect
  122104. */
  122105. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122106. }
  122107. }
  122108. declare module BABYLON {
  122109. /**
  122110. * Class containing static functions to help procedurally build meshes
  122111. */
  122112. export class HemisphereBuilder {
  122113. /**
  122114. * Creates a hemisphere mesh
  122115. * @param name defines the name of the mesh
  122116. * @param options defines the options used to create the mesh
  122117. * @param scene defines the hosting scene
  122118. * @returns the hemisphere mesh
  122119. */
  122120. static CreateHemisphere(name: string, options: {
  122121. segments?: number;
  122122. diameter?: number;
  122123. sideOrientation?: number;
  122124. }, scene: any): Mesh;
  122125. }
  122126. }
  122127. declare module BABYLON {
  122128. /**
  122129. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122130. * These values define a cone of light starting from the position, emitting toward the direction.
  122131. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122132. * and the exponent defines the speed of the decay of the light with distance (reach).
  122133. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122134. */
  122135. export class SpotLight extends ShadowLight {
  122136. private _angle;
  122137. private _innerAngle;
  122138. private _cosHalfAngle;
  122139. private _lightAngleScale;
  122140. private _lightAngleOffset;
  122141. /**
  122142. * Gets the cone angle of the spot light in Radians.
  122143. */
  122144. get angle(): number;
  122145. /**
  122146. * Sets the cone angle of the spot light in Radians.
  122147. */
  122148. set angle(value: number);
  122149. /**
  122150. * Only used in gltf falloff mode, this defines the angle where
  122151. * the directional falloff will start before cutting at angle which could be seen
  122152. * as outer angle.
  122153. */
  122154. get innerAngle(): number;
  122155. /**
  122156. * Only used in gltf falloff mode, this defines the angle where
  122157. * the directional falloff will start before cutting at angle which could be seen
  122158. * as outer angle.
  122159. */
  122160. set innerAngle(value: number);
  122161. private _shadowAngleScale;
  122162. /**
  122163. * Allows scaling the angle of the light for shadow generation only.
  122164. */
  122165. get shadowAngleScale(): number;
  122166. /**
  122167. * Allows scaling the angle of the light for shadow generation only.
  122168. */
  122169. set shadowAngleScale(value: number);
  122170. /**
  122171. * The light decay speed with the distance from the emission spot.
  122172. */
  122173. exponent: number;
  122174. private _projectionTextureMatrix;
  122175. /**
  122176. * Allows reading the projecton texture
  122177. */
  122178. get projectionTextureMatrix(): Matrix;
  122179. protected _projectionTextureLightNear: number;
  122180. /**
  122181. * Gets the near clip of the Spotlight for texture projection.
  122182. */
  122183. get projectionTextureLightNear(): number;
  122184. /**
  122185. * Sets the near clip of the Spotlight for texture projection.
  122186. */
  122187. set projectionTextureLightNear(value: number);
  122188. protected _projectionTextureLightFar: number;
  122189. /**
  122190. * Gets the far clip of the Spotlight for texture projection.
  122191. */
  122192. get projectionTextureLightFar(): number;
  122193. /**
  122194. * Sets the far clip of the Spotlight for texture projection.
  122195. */
  122196. set projectionTextureLightFar(value: number);
  122197. protected _projectionTextureUpDirection: Vector3;
  122198. /**
  122199. * Gets the Up vector of the Spotlight for texture projection.
  122200. */
  122201. get projectionTextureUpDirection(): Vector3;
  122202. /**
  122203. * Sets the Up vector of the Spotlight for texture projection.
  122204. */
  122205. set projectionTextureUpDirection(value: Vector3);
  122206. private _projectionTexture;
  122207. /**
  122208. * Gets the projection texture of the light.
  122209. */
  122210. get projectionTexture(): Nullable<BaseTexture>;
  122211. /**
  122212. * Sets the projection texture of the light.
  122213. */
  122214. set projectionTexture(value: Nullable<BaseTexture>);
  122215. private _projectionTextureViewLightDirty;
  122216. private _projectionTextureProjectionLightDirty;
  122217. private _projectionTextureDirty;
  122218. private _projectionTextureViewTargetVector;
  122219. private _projectionTextureViewLightMatrix;
  122220. private _projectionTextureProjectionLightMatrix;
  122221. private _projectionTextureScalingMatrix;
  122222. /**
  122223. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122224. * It can cast shadows.
  122225. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122226. * @param name The light friendly name
  122227. * @param position The position of the spot light in the scene
  122228. * @param direction The direction of the light in the scene
  122229. * @param angle The cone angle of the light in Radians
  122230. * @param exponent The light decay speed with the distance from the emission spot
  122231. * @param scene The scene the lights belongs to
  122232. */
  122233. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122234. /**
  122235. * Returns the string "SpotLight".
  122236. * @returns the class name
  122237. */
  122238. getClassName(): string;
  122239. /**
  122240. * Returns the integer 2.
  122241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122242. */
  122243. getTypeID(): number;
  122244. /**
  122245. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122246. */
  122247. protected _setDirection(value: Vector3): void;
  122248. /**
  122249. * Overrides the position setter to recompute the projection texture view light Matrix.
  122250. */
  122251. protected _setPosition(value: Vector3): void;
  122252. /**
  122253. * 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.
  122254. * Returns the SpotLight.
  122255. */
  122256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122257. protected _computeProjectionTextureViewLightMatrix(): void;
  122258. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122259. /**
  122260. * Main function for light texture projection matrix computing.
  122261. */
  122262. protected _computeProjectionTextureMatrix(): void;
  122263. protected _buildUniformLayout(): void;
  122264. private _computeAngleValues;
  122265. /**
  122266. * Sets the passed Effect "effect" with the Light textures.
  122267. * @param effect The effect to update
  122268. * @param lightIndex The index of the light in the effect to update
  122269. * @returns The light
  122270. */
  122271. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122272. /**
  122273. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122274. * @param effect The effect to update
  122275. * @param lightIndex The index of the light in the effect to update
  122276. * @returns The spot light
  122277. */
  122278. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122279. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122280. /**
  122281. * Disposes the light and the associated resources.
  122282. */
  122283. dispose(): void;
  122284. /**
  122285. * Prepares the list of defines specific to the light type.
  122286. * @param defines the list of defines
  122287. * @param lightIndex defines the index of the light for the effect
  122288. */
  122289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122290. }
  122291. }
  122292. declare module BABYLON {
  122293. /**
  122294. * Gizmo that enables viewing a light
  122295. */
  122296. export class LightGizmo extends Gizmo {
  122297. private _lightMesh;
  122298. private _material;
  122299. private _cachedPosition;
  122300. private _cachedForward;
  122301. private _attachedMeshParent;
  122302. /**
  122303. * Creates a LightGizmo
  122304. * @param gizmoLayer The utility layer the gizmo will be added to
  122305. */
  122306. constructor(gizmoLayer?: UtilityLayerRenderer);
  122307. private _light;
  122308. /**
  122309. * The light that the gizmo is attached to
  122310. */
  122311. set light(light: Nullable<Light>);
  122312. get light(): Nullable<Light>;
  122313. /**
  122314. * Gets the material used to render the light gizmo
  122315. */
  122316. get material(): StandardMaterial;
  122317. /**
  122318. * @hidden
  122319. * Updates the gizmo to match the attached mesh's position/rotation
  122320. */
  122321. protected _update(): void;
  122322. private static _Scale;
  122323. /**
  122324. * Creates the lines for a light mesh
  122325. */
  122326. private static _CreateLightLines;
  122327. /**
  122328. * Disposes of the light gizmo
  122329. */
  122330. dispose(): void;
  122331. private static _CreateHemisphericLightMesh;
  122332. private static _CreatePointLightMesh;
  122333. private static _CreateSpotLightMesh;
  122334. private static _CreateDirectionalLightMesh;
  122335. }
  122336. }
  122337. declare module BABYLON {
  122338. /** @hidden */
  122339. export var backgroundFragmentDeclaration: {
  122340. name: string;
  122341. shader: string;
  122342. };
  122343. }
  122344. declare module BABYLON {
  122345. /** @hidden */
  122346. export var backgroundUboDeclaration: {
  122347. name: string;
  122348. shader: string;
  122349. };
  122350. }
  122351. declare module BABYLON {
  122352. /** @hidden */
  122353. export var backgroundPixelShader: {
  122354. name: string;
  122355. shader: string;
  122356. };
  122357. }
  122358. declare module BABYLON {
  122359. /** @hidden */
  122360. export var backgroundVertexDeclaration: {
  122361. name: string;
  122362. shader: string;
  122363. };
  122364. }
  122365. declare module BABYLON {
  122366. /** @hidden */
  122367. export var backgroundVertexShader: {
  122368. name: string;
  122369. shader: string;
  122370. };
  122371. }
  122372. declare module BABYLON {
  122373. /**
  122374. * Background material used to create an efficient environement around your scene.
  122375. */
  122376. export class BackgroundMaterial extends PushMaterial {
  122377. /**
  122378. * Standard reflectance value at parallel view angle.
  122379. */
  122380. static StandardReflectance0: number;
  122381. /**
  122382. * Standard reflectance value at grazing angle.
  122383. */
  122384. static StandardReflectance90: number;
  122385. protected _primaryColor: Color3;
  122386. /**
  122387. * Key light Color (multiply against the environement texture)
  122388. */
  122389. primaryColor: Color3;
  122390. protected __perceptualColor: Nullable<Color3>;
  122391. /**
  122392. * Experimental Internal Use Only.
  122393. *
  122394. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122395. * This acts as a helper to set the primary color to a more "human friendly" value.
  122396. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122397. * output color as close as possible from the chosen value.
  122398. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122399. * part of lighting setup.)
  122400. */
  122401. get _perceptualColor(): Nullable<Color3>;
  122402. set _perceptualColor(value: Nullable<Color3>);
  122403. protected _primaryColorShadowLevel: float;
  122404. /**
  122405. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122406. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122407. */
  122408. get primaryColorShadowLevel(): float;
  122409. set primaryColorShadowLevel(value: float);
  122410. protected _primaryColorHighlightLevel: float;
  122411. /**
  122412. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122413. * The primary color is used at the level chosen to define what the white area would look.
  122414. */
  122415. get primaryColorHighlightLevel(): float;
  122416. set primaryColorHighlightLevel(value: float);
  122417. protected _reflectionTexture: Nullable<BaseTexture>;
  122418. /**
  122419. * Reflection Texture used in the material.
  122420. * Should be author in a specific way for the best result (refer to the documentation).
  122421. */
  122422. reflectionTexture: Nullable<BaseTexture>;
  122423. protected _reflectionBlur: float;
  122424. /**
  122425. * Reflection Texture level of blur.
  122426. *
  122427. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122428. * texture twice.
  122429. */
  122430. reflectionBlur: float;
  122431. protected _diffuseTexture: Nullable<BaseTexture>;
  122432. /**
  122433. * Diffuse Texture used in the material.
  122434. * Should be author in a specific way for the best result (refer to the documentation).
  122435. */
  122436. diffuseTexture: Nullable<BaseTexture>;
  122437. protected _shadowLights: Nullable<IShadowLight[]>;
  122438. /**
  122439. * Specify the list of lights casting shadow on the material.
  122440. * All scene shadow lights will be included if null.
  122441. */
  122442. shadowLights: Nullable<IShadowLight[]>;
  122443. protected _shadowLevel: float;
  122444. /**
  122445. * Helps adjusting the shadow to a softer level if required.
  122446. * 0 means black shadows and 1 means no shadows.
  122447. */
  122448. shadowLevel: float;
  122449. protected _sceneCenter: Vector3;
  122450. /**
  122451. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122452. * It is usually zero but might be interesting to modify according to your setup.
  122453. */
  122454. sceneCenter: Vector3;
  122455. protected _opacityFresnel: boolean;
  122456. /**
  122457. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122458. * This helps ensuring a nice transition when the camera goes under the ground.
  122459. */
  122460. opacityFresnel: boolean;
  122461. protected _reflectionFresnel: boolean;
  122462. /**
  122463. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122464. * This helps adding a mirror texture on the ground.
  122465. */
  122466. reflectionFresnel: boolean;
  122467. protected _reflectionFalloffDistance: number;
  122468. /**
  122469. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122470. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122471. */
  122472. reflectionFalloffDistance: number;
  122473. protected _reflectionAmount: number;
  122474. /**
  122475. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122476. */
  122477. reflectionAmount: number;
  122478. protected _reflectionReflectance0: number;
  122479. /**
  122480. * This specifies the weight of the reflection at grazing angle.
  122481. */
  122482. reflectionReflectance0: number;
  122483. protected _reflectionReflectance90: number;
  122484. /**
  122485. * This specifies the weight of the reflection at a perpendicular point of view.
  122486. */
  122487. reflectionReflectance90: number;
  122488. /**
  122489. * Sets the reflection reflectance fresnel values according to the default standard
  122490. * empirically know to work well :-)
  122491. */
  122492. set reflectionStandardFresnelWeight(value: number);
  122493. protected _useRGBColor: boolean;
  122494. /**
  122495. * Helps to directly use the maps channels instead of their level.
  122496. */
  122497. useRGBColor: boolean;
  122498. protected _enableNoise: boolean;
  122499. /**
  122500. * This helps reducing the banding effect that could occur on the background.
  122501. */
  122502. enableNoise: boolean;
  122503. /**
  122504. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122505. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122506. * Recommended to be keep at 1.0 except for special cases.
  122507. */
  122508. get fovMultiplier(): number;
  122509. set fovMultiplier(value: number);
  122510. private _fovMultiplier;
  122511. /**
  122512. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122513. */
  122514. useEquirectangularFOV: boolean;
  122515. private _maxSimultaneousLights;
  122516. /**
  122517. * Number of Simultaneous lights allowed on the material.
  122518. */
  122519. maxSimultaneousLights: int;
  122520. /**
  122521. * Default configuration related to image processing available in the Background Material.
  122522. */
  122523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122524. /**
  122525. * Keep track of the image processing observer to allow dispose and replace.
  122526. */
  122527. private _imageProcessingObserver;
  122528. /**
  122529. * Attaches a new image processing configuration to the PBR Material.
  122530. * @param configuration (if null the scene configuration will be use)
  122531. */
  122532. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122533. /**
  122534. * Gets the image processing configuration used either in this material.
  122535. */
  122536. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122537. /**
  122538. * Sets the Default image processing configuration used either in the this material.
  122539. *
  122540. * If sets to null, the scene one is in use.
  122541. */
  122542. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122543. /**
  122544. * Gets wether the color curves effect is enabled.
  122545. */
  122546. get cameraColorCurvesEnabled(): boolean;
  122547. /**
  122548. * Sets wether the color curves effect is enabled.
  122549. */
  122550. set cameraColorCurvesEnabled(value: boolean);
  122551. /**
  122552. * Gets wether the color grading effect is enabled.
  122553. */
  122554. get cameraColorGradingEnabled(): boolean;
  122555. /**
  122556. * Gets wether the color grading effect is enabled.
  122557. */
  122558. set cameraColorGradingEnabled(value: boolean);
  122559. /**
  122560. * Gets wether tonemapping is enabled or not.
  122561. */
  122562. get cameraToneMappingEnabled(): boolean;
  122563. /**
  122564. * Sets wether tonemapping is enabled or not
  122565. */
  122566. set cameraToneMappingEnabled(value: boolean);
  122567. /**
  122568. * The camera exposure used on this material.
  122569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122570. * This corresponds to a photographic exposure.
  122571. */
  122572. get cameraExposure(): float;
  122573. /**
  122574. * The camera exposure used on this material.
  122575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122576. * This corresponds to a photographic exposure.
  122577. */
  122578. set cameraExposure(value: float);
  122579. /**
  122580. * Gets The camera contrast used on this material.
  122581. */
  122582. get cameraContrast(): float;
  122583. /**
  122584. * Sets The camera contrast used on this material.
  122585. */
  122586. set cameraContrast(value: float);
  122587. /**
  122588. * Gets the Color Grading 2D Lookup Texture.
  122589. */
  122590. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122591. /**
  122592. * Sets the Color Grading 2D Lookup Texture.
  122593. */
  122594. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122595. /**
  122596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122598. * 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;
  122599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122600. */
  122601. get cameraColorCurves(): Nullable<ColorCurves>;
  122602. /**
  122603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122605. * 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;
  122606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122607. */
  122608. set cameraColorCurves(value: Nullable<ColorCurves>);
  122609. /**
  122610. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122611. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122612. */
  122613. switchToBGR: boolean;
  122614. private _renderTargets;
  122615. private _reflectionControls;
  122616. private _white;
  122617. private _primaryShadowColor;
  122618. private _primaryHighlightColor;
  122619. /**
  122620. * Instantiates a Background Material in the given scene
  122621. * @param name The friendly name of the material
  122622. * @param scene The scene to add the material to
  122623. */
  122624. constructor(name: string, scene: Scene);
  122625. /**
  122626. * Gets a boolean indicating that current material needs to register RTT
  122627. */
  122628. get hasRenderTargetTextures(): boolean;
  122629. /**
  122630. * The entire material has been created in order to prevent overdraw.
  122631. * @returns false
  122632. */
  122633. needAlphaTesting(): boolean;
  122634. /**
  122635. * The entire material has been created in order to prevent overdraw.
  122636. * @returns true if blending is enable
  122637. */
  122638. needAlphaBlending(): boolean;
  122639. /**
  122640. * Checks wether the material is ready to be rendered for a given mesh.
  122641. * @param mesh The mesh to render
  122642. * @param subMesh The submesh to check against
  122643. * @param useInstances Specify wether or not the material is used with instances
  122644. * @returns true if all the dependencies are ready (Textures, Effects...)
  122645. */
  122646. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122647. /**
  122648. * Compute the primary color according to the chosen perceptual color.
  122649. */
  122650. private _computePrimaryColorFromPerceptualColor;
  122651. /**
  122652. * Compute the highlights and shadow colors according to their chosen levels.
  122653. */
  122654. private _computePrimaryColors;
  122655. /**
  122656. * Build the uniform buffer used in the material.
  122657. */
  122658. buildUniformLayout(): void;
  122659. /**
  122660. * Unbind the material.
  122661. */
  122662. unbind(): void;
  122663. /**
  122664. * Bind only the world matrix to the material.
  122665. * @param world The world matrix to bind.
  122666. */
  122667. bindOnlyWorldMatrix(world: Matrix): void;
  122668. /**
  122669. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122670. * @param world The world matrix to bind.
  122671. * @param subMesh The submesh to bind for.
  122672. */
  122673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122674. /**
  122675. * Checks to see if a texture is used in the material.
  122676. * @param texture - Base texture to use.
  122677. * @returns - Boolean specifying if a texture is used in the material.
  122678. */
  122679. hasTexture(texture: BaseTexture): boolean;
  122680. /**
  122681. * Dispose the material.
  122682. * @param forceDisposeEffect Force disposal of the associated effect.
  122683. * @param forceDisposeTextures Force disposal of the associated textures.
  122684. */
  122685. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122686. /**
  122687. * Clones the material.
  122688. * @param name The cloned name.
  122689. * @returns The cloned material.
  122690. */
  122691. clone(name: string): BackgroundMaterial;
  122692. /**
  122693. * Serializes the current material to its JSON representation.
  122694. * @returns The JSON representation.
  122695. */
  122696. serialize(): any;
  122697. /**
  122698. * Gets the class name of the material
  122699. * @returns "BackgroundMaterial"
  122700. */
  122701. getClassName(): string;
  122702. /**
  122703. * Parse a JSON input to create back a background material.
  122704. * @param source The JSON data to parse
  122705. * @param scene The scene to create the parsed material in
  122706. * @param rootUrl The root url of the assets the material depends upon
  122707. * @returns the instantiated BackgroundMaterial.
  122708. */
  122709. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122710. }
  122711. }
  122712. declare module BABYLON {
  122713. /**
  122714. * Represents the different options available during the creation of
  122715. * a Environment helper.
  122716. *
  122717. * This can control the default ground, skybox and image processing setup of your scene.
  122718. */
  122719. export interface IEnvironmentHelperOptions {
  122720. /**
  122721. * Specifies whether or not to create a ground.
  122722. * True by default.
  122723. */
  122724. createGround: boolean;
  122725. /**
  122726. * Specifies the ground size.
  122727. * 15 by default.
  122728. */
  122729. groundSize: number;
  122730. /**
  122731. * The texture used on the ground for the main color.
  122732. * Comes from the BabylonJS CDN by default.
  122733. *
  122734. * Remarks: Can be either a texture or a url.
  122735. */
  122736. groundTexture: string | BaseTexture;
  122737. /**
  122738. * The color mixed in the ground texture by default.
  122739. * BabylonJS clearColor by default.
  122740. */
  122741. groundColor: Color3;
  122742. /**
  122743. * Specifies the ground opacity.
  122744. * 1 by default.
  122745. */
  122746. groundOpacity: number;
  122747. /**
  122748. * Enables the ground to receive shadows.
  122749. * True by default.
  122750. */
  122751. enableGroundShadow: boolean;
  122752. /**
  122753. * Helps preventing the shadow to be fully black on the ground.
  122754. * 0.5 by default.
  122755. */
  122756. groundShadowLevel: number;
  122757. /**
  122758. * Creates a mirror texture attach to the ground.
  122759. * false by default.
  122760. */
  122761. enableGroundMirror: boolean;
  122762. /**
  122763. * Specifies the ground mirror size ratio.
  122764. * 0.3 by default as the default kernel is 64.
  122765. */
  122766. groundMirrorSizeRatio: number;
  122767. /**
  122768. * Specifies the ground mirror blur kernel size.
  122769. * 64 by default.
  122770. */
  122771. groundMirrorBlurKernel: number;
  122772. /**
  122773. * Specifies the ground mirror visibility amount.
  122774. * 1 by default
  122775. */
  122776. groundMirrorAmount: number;
  122777. /**
  122778. * Specifies the ground mirror reflectance weight.
  122779. * This uses the standard weight of the background material to setup the fresnel effect
  122780. * of the mirror.
  122781. * 1 by default.
  122782. */
  122783. groundMirrorFresnelWeight: number;
  122784. /**
  122785. * Specifies the ground mirror Falloff distance.
  122786. * This can helps reducing the size of the reflection.
  122787. * 0 by Default.
  122788. */
  122789. groundMirrorFallOffDistance: number;
  122790. /**
  122791. * Specifies the ground mirror texture type.
  122792. * Unsigned Int by Default.
  122793. */
  122794. groundMirrorTextureType: number;
  122795. /**
  122796. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122797. * the shown objects.
  122798. */
  122799. groundYBias: number;
  122800. /**
  122801. * Specifies whether or not to create a skybox.
  122802. * True by default.
  122803. */
  122804. createSkybox: boolean;
  122805. /**
  122806. * Specifies the skybox size.
  122807. * 20 by default.
  122808. */
  122809. skyboxSize: number;
  122810. /**
  122811. * The texture used on the skybox for the main color.
  122812. * Comes from the BabylonJS CDN by default.
  122813. *
  122814. * Remarks: Can be either a texture or a url.
  122815. */
  122816. skyboxTexture: string | BaseTexture;
  122817. /**
  122818. * The color mixed in the skybox texture by default.
  122819. * BabylonJS clearColor by default.
  122820. */
  122821. skyboxColor: Color3;
  122822. /**
  122823. * The background rotation around the Y axis of the scene.
  122824. * This helps aligning the key lights of your scene with the background.
  122825. * 0 by default.
  122826. */
  122827. backgroundYRotation: number;
  122828. /**
  122829. * Compute automatically the size of the elements to best fit with the scene.
  122830. */
  122831. sizeAuto: boolean;
  122832. /**
  122833. * Default position of the rootMesh if autoSize is not true.
  122834. */
  122835. rootPosition: Vector3;
  122836. /**
  122837. * Sets up the image processing in the scene.
  122838. * true by default.
  122839. */
  122840. setupImageProcessing: boolean;
  122841. /**
  122842. * The texture used as your environment texture in the scene.
  122843. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122844. *
  122845. * Remarks: Can be either a texture or a url.
  122846. */
  122847. environmentTexture: string | BaseTexture;
  122848. /**
  122849. * The value of the exposure to apply to the scene.
  122850. * 0.6 by default if setupImageProcessing is true.
  122851. */
  122852. cameraExposure: number;
  122853. /**
  122854. * The value of the contrast to apply to the scene.
  122855. * 1.6 by default if setupImageProcessing is true.
  122856. */
  122857. cameraContrast: number;
  122858. /**
  122859. * Specifies whether or not tonemapping should be enabled in the scene.
  122860. * true by default if setupImageProcessing is true.
  122861. */
  122862. toneMappingEnabled: boolean;
  122863. }
  122864. /**
  122865. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122866. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122867. * It also helps with the default setup of your imageProcessing configuration.
  122868. */
  122869. export class EnvironmentHelper {
  122870. /**
  122871. * Default ground texture URL.
  122872. */
  122873. private static _groundTextureCDNUrl;
  122874. /**
  122875. * Default skybox texture URL.
  122876. */
  122877. private static _skyboxTextureCDNUrl;
  122878. /**
  122879. * Default environment texture URL.
  122880. */
  122881. private static _environmentTextureCDNUrl;
  122882. /**
  122883. * Creates the default options for the helper.
  122884. */
  122885. private static _getDefaultOptions;
  122886. private _rootMesh;
  122887. /**
  122888. * Gets the root mesh created by the helper.
  122889. */
  122890. get rootMesh(): Mesh;
  122891. private _skybox;
  122892. /**
  122893. * Gets the skybox created by the helper.
  122894. */
  122895. get skybox(): Nullable<Mesh>;
  122896. private _skyboxTexture;
  122897. /**
  122898. * Gets the skybox texture created by the helper.
  122899. */
  122900. get skyboxTexture(): Nullable<BaseTexture>;
  122901. private _skyboxMaterial;
  122902. /**
  122903. * Gets the skybox material created by the helper.
  122904. */
  122905. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122906. private _ground;
  122907. /**
  122908. * Gets the ground mesh created by the helper.
  122909. */
  122910. get ground(): Nullable<Mesh>;
  122911. private _groundTexture;
  122912. /**
  122913. * Gets the ground texture created by the helper.
  122914. */
  122915. get groundTexture(): Nullable<BaseTexture>;
  122916. private _groundMirror;
  122917. /**
  122918. * Gets the ground mirror created by the helper.
  122919. */
  122920. get groundMirror(): Nullable<MirrorTexture>;
  122921. /**
  122922. * Gets the ground mirror render list to helps pushing the meshes
  122923. * you wish in the ground reflection.
  122924. */
  122925. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122926. private _groundMaterial;
  122927. /**
  122928. * Gets the ground material created by the helper.
  122929. */
  122930. get groundMaterial(): Nullable<BackgroundMaterial>;
  122931. /**
  122932. * Stores the creation options.
  122933. */
  122934. private readonly _scene;
  122935. private _options;
  122936. /**
  122937. * This observable will be notified with any error during the creation of the environment,
  122938. * mainly texture creation errors.
  122939. */
  122940. onErrorObservable: Observable<{
  122941. message?: string;
  122942. exception?: any;
  122943. }>;
  122944. /**
  122945. * constructor
  122946. * @param options Defines the options we want to customize the helper
  122947. * @param scene The scene to add the material to
  122948. */
  122949. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122950. /**
  122951. * Updates the background according to the new options
  122952. * @param options
  122953. */
  122954. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122955. /**
  122956. * Sets the primary color of all the available elements.
  122957. * @param color the main color to affect to the ground and the background
  122958. */
  122959. setMainColor(color: Color3): void;
  122960. /**
  122961. * Setup the image processing according to the specified options.
  122962. */
  122963. private _setupImageProcessing;
  122964. /**
  122965. * Setup the environment texture according to the specified options.
  122966. */
  122967. private _setupEnvironmentTexture;
  122968. /**
  122969. * Setup the background according to the specified options.
  122970. */
  122971. private _setupBackground;
  122972. /**
  122973. * Get the scene sizes according to the setup.
  122974. */
  122975. private _getSceneSize;
  122976. /**
  122977. * Setup the ground according to the specified options.
  122978. */
  122979. private _setupGround;
  122980. /**
  122981. * Setup the ground material according to the specified options.
  122982. */
  122983. private _setupGroundMaterial;
  122984. /**
  122985. * Setup the ground diffuse texture according to the specified options.
  122986. */
  122987. private _setupGroundDiffuseTexture;
  122988. /**
  122989. * Setup the ground mirror texture according to the specified options.
  122990. */
  122991. private _setupGroundMirrorTexture;
  122992. /**
  122993. * Setup the ground to receive the mirror texture.
  122994. */
  122995. private _setupMirrorInGroundMaterial;
  122996. /**
  122997. * Setup the skybox according to the specified options.
  122998. */
  122999. private _setupSkybox;
  123000. /**
  123001. * Setup the skybox material according to the specified options.
  123002. */
  123003. private _setupSkyboxMaterial;
  123004. /**
  123005. * Setup the skybox reflection texture according to the specified options.
  123006. */
  123007. private _setupSkyboxReflectionTexture;
  123008. private _errorHandler;
  123009. /**
  123010. * Dispose all the elements created by the Helper.
  123011. */
  123012. dispose(): void;
  123013. }
  123014. }
  123015. declare module BABYLON {
  123016. /**
  123017. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123018. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123019. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123020. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123021. */
  123022. export class PhotoDome extends TransformNode {
  123023. /**
  123024. * Define the image as a Monoscopic panoramic 360 image.
  123025. */
  123026. static readonly MODE_MONOSCOPIC: number;
  123027. /**
  123028. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123029. */
  123030. static readonly MODE_TOPBOTTOM: number;
  123031. /**
  123032. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123033. */
  123034. static readonly MODE_SIDEBYSIDE: number;
  123035. private _useDirectMapping;
  123036. /**
  123037. * The texture being displayed on the sphere
  123038. */
  123039. protected _photoTexture: Texture;
  123040. /**
  123041. * Gets or sets the texture being displayed on the sphere
  123042. */
  123043. get photoTexture(): Texture;
  123044. set photoTexture(value: Texture);
  123045. /**
  123046. * Observable raised when an error occured while loading the 360 image
  123047. */
  123048. onLoadErrorObservable: Observable<string>;
  123049. /**
  123050. * The skybox material
  123051. */
  123052. protected _material: BackgroundMaterial;
  123053. /**
  123054. * The surface used for the skybox
  123055. */
  123056. protected _mesh: Mesh;
  123057. /**
  123058. * Gets the mesh used for the skybox.
  123059. */
  123060. get mesh(): Mesh;
  123061. /**
  123062. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123063. * Also see the options.resolution property.
  123064. */
  123065. get fovMultiplier(): number;
  123066. set fovMultiplier(value: number);
  123067. private _imageMode;
  123068. /**
  123069. * Gets or set the current video mode for the video. It can be:
  123070. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123071. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123072. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123073. */
  123074. get imageMode(): number;
  123075. set imageMode(value: number);
  123076. /**
  123077. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123078. * @param name Element's name, child elements will append suffixes for their own names.
  123079. * @param urlsOfPhoto defines the url of the photo to display
  123080. * @param options defines an object containing optional or exposed sub element properties
  123081. * @param onError defines a callback called when an error occured while loading the texture
  123082. */
  123083. constructor(name: string, urlOfPhoto: string, options: {
  123084. resolution?: number;
  123085. size?: number;
  123086. useDirectMapping?: boolean;
  123087. faceForward?: boolean;
  123088. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123089. private _onBeforeCameraRenderObserver;
  123090. private _changeImageMode;
  123091. /**
  123092. * Releases resources associated with this node.
  123093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123095. */
  123096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123097. }
  123098. }
  123099. declare module BABYLON {
  123100. /**
  123101. * Class used to host RGBD texture specific utilities
  123102. */
  123103. export class RGBDTextureTools {
  123104. /**
  123105. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123106. * @param texture the texture to expand.
  123107. */
  123108. static ExpandRGBDTexture(texture: Texture): void;
  123109. }
  123110. }
  123111. declare module BABYLON {
  123112. /**
  123113. * Class used to host texture specific utilities
  123114. */
  123115. export class BRDFTextureTools {
  123116. /**
  123117. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123118. * @param scene defines the hosting scene
  123119. * @returns the environment BRDF texture
  123120. */
  123121. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123122. private static _environmentBRDFBase64Texture;
  123123. }
  123124. }
  123125. declare module BABYLON {
  123126. /**
  123127. * @hidden
  123128. */
  123129. export interface IMaterialClearCoatDefines {
  123130. CLEARCOAT: boolean;
  123131. CLEARCOAT_DEFAULTIOR: boolean;
  123132. CLEARCOAT_TEXTURE: boolean;
  123133. CLEARCOAT_TEXTUREDIRECTUV: number;
  123134. CLEARCOAT_BUMP: boolean;
  123135. CLEARCOAT_BUMPDIRECTUV: number;
  123136. CLEARCOAT_TINT: boolean;
  123137. CLEARCOAT_TINT_TEXTURE: boolean;
  123138. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123139. /** @hidden */
  123140. _areTexturesDirty: boolean;
  123141. }
  123142. /**
  123143. * Define the code related to the clear coat parameters of the pbr material.
  123144. */
  123145. export class PBRClearCoatConfiguration {
  123146. /**
  123147. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123148. * The default fits with a polyurethane material.
  123149. */
  123150. private static readonly _DefaultIndexOfRefraction;
  123151. private _isEnabled;
  123152. /**
  123153. * Defines if the clear coat is enabled in the material.
  123154. */
  123155. isEnabled: boolean;
  123156. /**
  123157. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123158. */
  123159. intensity: number;
  123160. /**
  123161. * Defines the clear coat layer roughness.
  123162. */
  123163. roughness: number;
  123164. private _indexOfRefraction;
  123165. /**
  123166. * Defines the index of refraction of the clear coat.
  123167. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123168. * The default fits with a polyurethane material.
  123169. * Changing the default value is more performance intensive.
  123170. */
  123171. indexOfRefraction: number;
  123172. private _texture;
  123173. /**
  123174. * Stores the clear coat values in a texture.
  123175. */
  123176. texture: Nullable<BaseTexture>;
  123177. private _bumpTexture;
  123178. /**
  123179. * Define the clear coat specific bump texture.
  123180. */
  123181. bumpTexture: Nullable<BaseTexture>;
  123182. private _isTintEnabled;
  123183. /**
  123184. * Defines if the clear coat tint is enabled in the material.
  123185. */
  123186. isTintEnabled: boolean;
  123187. /**
  123188. * Defines the clear coat tint of the material.
  123189. * This is only use if tint is enabled
  123190. */
  123191. tintColor: Color3;
  123192. /**
  123193. * Defines the distance at which the tint color should be found in the
  123194. * clear coat media.
  123195. * This is only use if tint is enabled
  123196. */
  123197. tintColorAtDistance: number;
  123198. /**
  123199. * Defines the clear coat layer thickness.
  123200. * This is only use if tint is enabled
  123201. */
  123202. tintThickness: number;
  123203. private _tintTexture;
  123204. /**
  123205. * Stores the clear tint values in a texture.
  123206. * rgb is tint
  123207. * a is a thickness factor
  123208. */
  123209. tintTexture: Nullable<BaseTexture>;
  123210. /** @hidden */
  123211. private _internalMarkAllSubMeshesAsTexturesDirty;
  123212. /** @hidden */
  123213. _markAllSubMeshesAsTexturesDirty(): void;
  123214. /**
  123215. * Instantiate a new istance of clear coat configuration.
  123216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123217. */
  123218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123219. /**
  123220. * Gets wehter the submesh is ready to be used or not.
  123221. * @param defines the list of "defines" to update.
  123222. * @param scene defines the scene the material belongs to.
  123223. * @param engine defines the engine the material belongs to.
  123224. * @param disableBumpMap defines wether the material disables bump or not.
  123225. * @returns - boolean indicating that the submesh is ready or not.
  123226. */
  123227. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123228. /**
  123229. * Checks to see if a texture is used in the material.
  123230. * @param defines the list of "defines" to update.
  123231. * @param scene defines the scene to the material belongs to.
  123232. */
  123233. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123234. /**
  123235. * Binds the material data.
  123236. * @param uniformBuffer defines the Uniform buffer to fill in.
  123237. * @param scene defines the scene the material belongs to.
  123238. * @param engine defines the engine the material belongs to.
  123239. * @param disableBumpMap defines wether the material disables bump or not.
  123240. * @param isFrozen defines wether the material is frozen or not.
  123241. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123242. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123243. */
  123244. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123245. /**
  123246. * Checks to see if a texture is used in the material.
  123247. * @param texture - Base texture to use.
  123248. * @returns - Boolean specifying if a texture is used in the material.
  123249. */
  123250. hasTexture(texture: BaseTexture): boolean;
  123251. /**
  123252. * Returns an array of the actively used textures.
  123253. * @param activeTextures Array of BaseTextures
  123254. */
  123255. getActiveTextures(activeTextures: BaseTexture[]): void;
  123256. /**
  123257. * Returns the animatable textures.
  123258. * @param animatables Array of animatable textures.
  123259. */
  123260. getAnimatables(animatables: IAnimatable[]): void;
  123261. /**
  123262. * Disposes the resources of the material.
  123263. * @param forceDisposeTextures - Forces the disposal of all textures.
  123264. */
  123265. dispose(forceDisposeTextures?: boolean): void;
  123266. /**
  123267. * Get the current class name of the texture useful for serialization or dynamic coding.
  123268. * @returns "PBRClearCoatConfiguration"
  123269. */
  123270. getClassName(): string;
  123271. /**
  123272. * Add fallbacks to the effect fallbacks list.
  123273. * @param defines defines the Base texture to use.
  123274. * @param fallbacks defines the current fallback list.
  123275. * @param currentRank defines the current fallback rank.
  123276. * @returns the new fallback rank.
  123277. */
  123278. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123279. /**
  123280. * Add the required uniforms to the current list.
  123281. * @param uniforms defines the current uniform list.
  123282. */
  123283. static AddUniforms(uniforms: string[]): void;
  123284. /**
  123285. * Add the required samplers to the current list.
  123286. * @param samplers defines the current sampler list.
  123287. */
  123288. static AddSamplers(samplers: string[]): void;
  123289. /**
  123290. * Add the required uniforms to the current buffer.
  123291. * @param uniformBuffer defines the current uniform buffer.
  123292. */
  123293. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123294. /**
  123295. * Makes a duplicate of the current configuration into another one.
  123296. * @param clearCoatConfiguration define the config where to copy the info
  123297. */
  123298. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123299. /**
  123300. * Serializes this clear coat configuration.
  123301. * @returns - An object with the serialized config.
  123302. */
  123303. serialize(): any;
  123304. /**
  123305. * Parses a anisotropy Configuration from a serialized object.
  123306. * @param source - Serialized object.
  123307. * @param scene Defines the scene we are parsing for
  123308. * @param rootUrl Defines the rootUrl to load from
  123309. */
  123310. parse(source: any, scene: Scene, rootUrl: string): void;
  123311. }
  123312. }
  123313. declare module BABYLON {
  123314. /**
  123315. * @hidden
  123316. */
  123317. export interface IMaterialAnisotropicDefines {
  123318. ANISOTROPIC: boolean;
  123319. ANISOTROPIC_TEXTURE: boolean;
  123320. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123321. MAINUV1: boolean;
  123322. _areTexturesDirty: boolean;
  123323. _needUVs: boolean;
  123324. }
  123325. /**
  123326. * Define the code related to the anisotropic parameters of the pbr material.
  123327. */
  123328. export class PBRAnisotropicConfiguration {
  123329. private _isEnabled;
  123330. /**
  123331. * Defines if the anisotropy is enabled in the material.
  123332. */
  123333. isEnabled: boolean;
  123334. /**
  123335. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123336. */
  123337. intensity: number;
  123338. /**
  123339. * Defines if the effect is along the tangents, bitangents or in between.
  123340. * By default, the effect is "strectching" the highlights along the tangents.
  123341. */
  123342. direction: Vector2;
  123343. private _texture;
  123344. /**
  123345. * Stores the anisotropy values in a texture.
  123346. * rg is direction (like normal from -1 to 1)
  123347. * b is a intensity
  123348. */
  123349. texture: Nullable<BaseTexture>;
  123350. /** @hidden */
  123351. private _internalMarkAllSubMeshesAsTexturesDirty;
  123352. /** @hidden */
  123353. _markAllSubMeshesAsTexturesDirty(): void;
  123354. /**
  123355. * Instantiate a new istance of anisotropy configuration.
  123356. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123357. */
  123358. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123359. /**
  123360. * Specifies that the submesh is ready to be used.
  123361. * @param defines the list of "defines" to update.
  123362. * @param scene defines the scene the material belongs to.
  123363. * @returns - boolean indicating that the submesh is ready or not.
  123364. */
  123365. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123366. /**
  123367. * Checks to see if a texture is used in the material.
  123368. * @param defines the list of "defines" to update.
  123369. * @param mesh the mesh we are preparing the defines for.
  123370. * @param scene defines the scene the material belongs to.
  123371. */
  123372. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123373. /**
  123374. * Binds the material data.
  123375. * @param uniformBuffer defines the Uniform buffer to fill in.
  123376. * @param scene defines the scene the material belongs to.
  123377. * @param isFrozen defines wether the material is frozen or not.
  123378. */
  123379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123380. /**
  123381. * Checks to see if a texture is used in the material.
  123382. * @param texture - Base texture to use.
  123383. * @returns - Boolean specifying if a texture is used in the material.
  123384. */
  123385. hasTexture(texture: BaseTexture): boolean;
  123386. /**
  123387. * Returns an array of the actively used textures.
  123388. * @param activeTextures Array of BaseTextures
  123389. */
  123390. getActiveTextures(activeTextures: BaseTexture[]): void;
  123391. /**
  123392. * Returns the animatable textures.
  123393. * @param animatables Array of animatable textures.
  123394. */
  123395. getAnimatables(animatables: IAnimatable[]): void;
  123396. /**
  123397. * Disposes the resources of the material.
  123398. * @param forceDisposeTextures - Forces the disposal of all textures.
  123399. */
  123400. dispose(forceDisposeTextures?: boolean): void;
  123401. /**
  123402. * Get the current class name of the texture useful for serialization or dynamic coding.
  123403. * @returns "PBRAnisotropicConfiguration"
  123404. */
  123405. getClassName(): string;
  123406. /**
  123407. * Add fallbacks to the effect fallbacks list.
  123408. * @param defines defines the Base texture to use.
  123409. * @param fallbacks defines the current fallback list.
  123410. * @param currentRank defines the current fallback rank.
  123411. * @returns the new fallback rank.
  123412. */
  123413. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123414. /**
  123415. * Add the required uniforms to the current list.
  123416. * @param uniforms defines the current uniform list.
  123417. */
  123418. static AddUniforms(uniforms: string[]): void;
  123419. /**
  123420. * Add the required uniforms to the current buffer.
  123421. * @param uniformBuffer defines the current uniform buffer.
  123422. */
  123423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123424. /**
  123425. * Add the required samplers to the current list.
  123426. * @param samplers defines the current sampler list.
  123427. */
  123428. static AddSamplers(samplers: string[]): void;
  123429. /**
  123430. * Makes a duplicate of the current configuration into another one.
  123431. * @param anisotropicConfiguration define the config where to copy the info
  123432. */
  123433. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123434. /**
  123435. * Serializes this anisotropy configuration.
  123436. * @returns - An object with the serialized config.
  123437. */
  123438. serialize(): any;
  123439. /**
  123440. * Parses a anisotropy Configuration from a serialized object.
  123441. * @param source - Serialized object.
  123442. * @param scene Defines the scene we are parsing for
  123443. * @param rootUrl Defines the rootUrl to load from
  123444. */
  123445. parse(source: any, scene: Scene, rootUrl: string): void;
  123446. }
  123447. }
  123448. declare module BABYLON {
  123449. /**
  123450. * @hidden
  123451. */
  123452. export interface IMaterialBRDFDefines {
  123453. BRDF_V_HEIGHT_CORRELATED: boolean;
  123454. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123455. SPHERICAL_HARMONICS: boolean;
  123456. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123457. /** @hidden */
  123458. _areMiscDirty: boolean;
  123459. }
  123460. /**
  123461. * Define the code related to the BRDF parameters of the pbr material.
  123462. */
  123463. export class PBRBRDFConfiguration {
  123464. /**
  123465. * Default value used for the energy conservation.
  123466. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123467. */
  123468. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123469. /**
  123470. * Default value used for the Smith Visibility Height Correlated mode.
  123471. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123472. */
  123473. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123474. /**
  123475. * Default value used for the IBL diffuse part.
  123476. * This can help switching back to the polynomials mode globally which is a tiny bit
  123477. * less GPU intensive at the drawback of a lower quality.
  123478. */
  123479. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123480. /**
  123481. * Default value used for activating energy conservation for the specular workflow.
  123482. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123483. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123484. */
  123485. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123486. private _useEnergyConservation;
  123487. /**
  123488. * Defines if the material uses energy conservation.
  123489. */
  123490. useEnergyConservation: boolean;
  123491. private _useSmithVisibilityHeightCorrelated;
  123492. /**
  123493. * LEGACY Mode set to false
  123494. * Defines if the material uses height smith correlated visibility term.
  123495. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123496. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123497. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123498. * Not relying on height correlated will also disable energy conservation.
  123499. */
  123500. useSmithVisibilityHeightCorrelated: boolean;
  123501. private _useSphericalHarmonics;
  123502. /**
  123503. * LEGACY Mode set to false
  123504. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123505. * diffuse part of the IBL.
  123506. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123507. * to the ground truth.
  123508. */
  123509. useSphericalHarmonics: boolean;
  123510. private _useSpecularGlossinessInputEnergyConservation;
  123511. /**
  123512. * Defines if the material uses energy conservation, when the specular workflow is active.
  123513. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123514. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123515. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123516. */
  123517. useSpecularGlossinessInputEnergyConservation: boolean;
  123518. /** @hidden */
  123519. private _internalMarkAllSubMeshesAsMiscDirty;
  123520. /** @hidden */
  123521. _markAllSubMeshesAsMiscDirty(): void;
  123522. /**
  123523. * Instantiate a new istance of clear coat configuration.
  123524. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123525. */
  123526. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123527. /**
  123528. * Checks to see if a texture is used in the material.
  123529. * @param defines the list of "defines" to update.
  123530. */
  123531. prepareDefines(defines: IMaterialBRDFDefines): void;
  123532. /**
  123533. * Get the current class name of the texture useful for serialization or dynamic coding.
  123534. * @returns "PBRClearCoatConfiguration"
  123535. */
  123536. getClassName(): string;
  123537. /**
  123538. * Makes a duplicate of the current configuration into another one.
  123539. * @param brdfConfiguration define the config where to copy the info
  123540. */
  123541. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123542. /**
  123543. * Serializes this BRDF configuration.
  123544. * @returns - An object with the serialized config.
  123545. */
  123546. serialize(): any;
  123547. /**
  123548. * Parses a anisotropy Configuration from a serialized object.
  123549. * @param source - Serialized object.
  123550. * @param scene Defines the scene we are parsing for
  123551. * @param rootUrl Defines the rootUrl to load from
  123552. */
  123553. parse(source: any, scene: Scene, rootUrl: string): void;
  123554. }
  123555. }
  123556. declare module BABYLON {
  123557. /**
  123558. * @hidden
  123559. */
  123560. export interface IMaterialSheenDefines {
  123561. SHEEN: boolean;
  123562. SHEEN_TEXTURE: boolean;
  123563. SHEEN_TEXTUREDIRECTUV: number;
  123564. SHEEN_LINKWITHALBEDO: boolean;
  123565. /** @hidden */
  123566. _areTexturesDirty: boolean;
  123567. }
  123568. /**
  123569. * Define the code related to the Sheen parameters of the pbr material.
  123570. */
  123571. export class PBRSheenConfiguration {
  123572. private _isEnabled;
  123573. /**
  123574. * Defines if the material uses sheen.
  123575. */
  123576. isEnabled: boolean;
  123577. private _linkSheenWithAlbedo;
  123578. /**
  123579. * Defines if the sheen is linked to the sheen color.
  123580. */
  123581. linkSheenWithAlbedo: boolean;
  123582. /**
  123583. * Defines the sheen intensity.
  123584. */
  123585. intensity: number;
  123586. /**
  123587. * Defines the sheen color.
  123588. */
  123589. color: Color3;
  123590. private _texture;
  123591. /**
  123592. * Stores the sheen tint values in a texture.
  123593. * rgb is tint
  123594. * a is a intensity
  123595. */
  123596. texture: Nullable<BaseTexture>;
  123597. /** @hidden */
  123598. private _internalMarkAllSubMeshesAsTexturesDirty;
  123599. /** @hidden */
  123600. _markAllSubMeshesAsTexturesDirty(): void;
  123601. /**
  123602. * Instantiate a new istance of clear coat configuration.
  123603. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123604. */
  123605. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123606. /**
  123607. * Specifies that the submesh is ready to be used.
  123608. * @param defines the list of "defines" to update.
  123609. * @param scene defines the scene the material belongs to.
  123610. * @returns - boolean indicating that the submesh is ready or not.
  123611. */
  123612. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123613. /**
  123614. * Checks to see if a texture is used in the material.
  123615. * @param defines the list of "defines" to update.
  123616. * @param scene defines the scene the material belongs to.
  123617. */
  123618. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123619. /**
  123620. * Binds the material data.
  123621. * @param uniformBuffer defines the Uniform buffer to fill in.
  123622. * @param scene defines the scene the material belongs to.
  123623. * @param isFrozen defines wether the material is frozen or not.
  123624. */
  123625. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123626. /**
  123627. * Checks to see if a texture is used in the material.
  123628. * @param texture - Base texture to use.
  123629. * @returns - Boolean specifying if a texture is used in the material.
  123630. */
  123631. hasTexture(texture: BaseTexture): boolean;
  123632. /**
  123633. * Returns an array of the actively used textures.
  123634. * @param activeTextures Array of BaseTextures
  123635. */
  123636. getActiveTextures(activeTextures: BaseTexture[]): void;
  123637. /**
  123638. * Returns the animatable textures.
  123639. * @param animatables Array of animatable textures.
  123640. */
  123641. getAnimatables(animatables: IAnimatable[]): void;
  123642. /**
  123643. * Disposes the resources of the material.
  123644. * @param forceDisposeTextures - Forces the disposal of all textures.
  123645. */
  123646. dispose(forceDisposeTextures?: boolean): void;
  123647. /**
  123648. * Get the current class name of the texture useful for serialization or dynamic coding.
  123649. * @returns "PBRSheenConfiguration"
  123650. */
  123651. getClassName(): string;
  123652. /**
  123653. * Add fallbacks to the effect fallbacks list.
  123654. * @param defines defines the Base texture to use.
  123655. * @param fallbacks defines the current fallback list.
  123656. * @param currentRank defines the current fallback rank.
  123657. * @returns the new fallback rank.
  123658. */
  123659. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123660. /**
  123661. * Add the required uniforms to the current list.
  123662. * @param uniforms defines the current uniform list.
  123663. */
  123664. static AddUniforms(uniforms: string[]): void;
  123665. /**
  123666. * Add the required uniforms to the current buffer.
  123667. * @param uniformBuffer defines the current uniform buffer.
  123668. */
  123669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123670. /**
  123671. * Add the required samplers to the current list.
  123672. * @param samplers defines the current sampler list.
  123673. */
  123674. static AddSamplers(samplers: string[]): void;
  123675. /**
  123676. * Makes a duplicate of the current configuration into another one.
  123677. * @param sheenConfiguration define the config where to copy the info
  123678. */
  123679. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123680. /**
  123681. * Serializes this BRDF configuration.
  123682. * @returns - An object with the serialized config.
  123683. */
  123684. serialize(): any;
  123685. /**
  123686. * Parses a anisotropy Configuration from a serialized object.
  123687. * @param source - Serialized object.
  123688. * @param scene Defines the scene we are parsing for
  123689. * @param rootUrl Defines the rootUrl to load from
  123690. */
  123691. parse(source: any, scene: Scene, rootUrl: string): void;
  123692. }
  123693. }
  123694. declare module BABYLON {
  123695. /**
  123696. * @hidden
  123697. */
  123698. export interface IMaterialSubSurfaceDefines {
  123699. SUBSURFACE: boolean;
  123700. SS_REFRACTION: boolean;
  123701. SS_TRANSLUCENCY: boolean;
  123702. SS_SCATERRING: boolean;
  123703. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123704. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123705. SS_REFRACTIONMAP_3D: boolean;
  123706. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123707. SS_LODINREFRACTIONALPHA: boolean;
  123708. SS_GAMMAREFRACTION: boolean;
  123709. SS_RGBDREFRACTION: boolean;
  123710. SS_LINEARSPECULARREFRACTION: boolean;
  123711. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123712. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123713. /** @hidden */
  123714. _areTexturesDirty: boolean;
  123715. }
  123716. /**
  123717. * Define the code related to the sub surface parameters of the pbr material.
  123718. */
  123719. export class PBRSubSurfaceConfiguration {
  123720. private _isRefractionEnabled;
  123721. /**
  123722. * Defines if the refraction is enabled in the material.
  123723. */
  123724. isRefractionEnabled: boolean;
  123725. private _isTranslucencyEnabled;
  123726. /**
  123727. * Defines if the translucency is enabled in the material.
  123728. */
  123729. isTranslucencyEnabled: boolean;
  123730. private _isScatteringEnabled;
  123731. /**
  123732. * Defines the refraction intensity of the material.
  123733. * The refraction when enabled replaces the Diffuse part of the material.
  123734. * The intensity helps transitionning between diffuse and refraction.
  123735. */
  123736. refractionIntensity: number;
  123737. /**
  123738. * Defines the translucency intensity of the material.
  123739. * When translucency has been enabled, this defines how much of the "translucency"
  123740. * is addded to the diffuse part of the material.
  123741. */
  123742. translucencyIntensity: number;
  123743. /**
  123744. * Defines the scattering intensity of the material.
  123745. * When scattering has been enabled, this defines how much of the "scattered light"
  123746. * is addded to the diffuse part of the material.
  123747. */
  123748. scatteringIntensity: number;
  123749. private _thicknessTexture;
  123750. /**
  123751. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123752. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123753. * 0 would mean minimumThickness
  123754. * 1 would mean maximumThickness
  123755. * The other channels might be use as a mask to vary the different effects intensity.
  123756. */
  123757. thicknessTexture: Nullable<BaseTexture>;
  123758. private _refractionTexture;
  123759. /**
  123760. * Defines the texture to use for refraction.
  123761. */
  123762. refractionTexture: Nullable<BaseTexture>;
  123763. private _indexOfRefraction;
  123764. /**
  123765. * Defines the index of refraction used in the material.
  123766. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123767. */
  123768. indexOfRefraction: number;
  123769. private _invertRefractionY;
  123770. /**
  123771. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123772. */
  123773. invertRefractionY: boolean;
  123774. private _linkRefractionWithTransparency;
  123775. /**
  123776. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123777. * Materials half opaque for instance using refraction could benefit from this control.
  123778. */
  123779. linkRefractionWithTransparency: boolean;
  123780. /**
  123781. * Defines the minimum thickness stored in the thickness map.
  123782. * If no thickness map is defined, this value will be used to simulate thickness.
  123783. */
  123784. minimumThickness: number;
  123785. /**
  123786. * Defines the maximum thickness stored in the thickness map.
  123787. */
  123788. maximumThickness: number;
  123789. /**
  123790. * Defines the volume tint of the material.
  123791. * This is used for both translucency and scattering.
  123792. */
  123793. tintColor: Color3;
  123794. /**
  123795. * Defines the distance at which the tint color should be found in the media.
  123796. * This is used for refraction only.
  123797. */
  123798. tintColorAtDistance: number;
  123799. /**
  123800. * Defines how far each channel transmit through the media.
  123801. * It is defined as a color to simplify it selection.
  123802. */
  123803. diffusionDistance: Color3;
  123804. private _useMaskFromThicknessTexture;
  123805. /**
  123806. * Stores the intensity of the different subsurface effects in the thickness texture.
  123807. * * the green channel is the translucency intensity.
  123808. * * the blue channel is the scattering intensity.
  123809. * * the alpha channel is the refraction intensity.
  123810. */
  123811. useMaskFromThicknessTexture: boolean;
  123812. /** @hidden */
  123813. private _internalMarkAllSubMeshesAsTexturesDirty;
  123814. /** @hidden */
  123815. _markAllSubMeshesAsTexturesDirty(): void;
  123816. /**
  123817. * Instantiate a new istance of sub surface configuration.
  123818. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123819. */
  123820. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123821. /**
  123822. * Gets wehter the submesh is ready to be used or not.
  123823. * @param defines the list of "defines" to update.
  123824. * @param scene defines the scene the material belongs to.
  123825. * @returns - boolean indicating that the submesh is ready or not.
  123826. */
  123827. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123828. /**
  123829. * Checks to see if a texture is used in the material.
  123830. * @param defines the list of "defines" to update.
  123831. * @param scene defines the scene to the material belongs to.
  123832. */
  123833. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123834. /**
  123835. * Binds the material data.
  123836. * @param uniformBuffer defines the Uniform buffer to fill in.
  123837. * @param scene defines the scene the material belongs to.
  123838. * @param engine defines the engine the material belongs to.
  123839. * @param isFrozen defines wether the material is frozen or not.
  123840. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123841. */
  123842. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123843. /**
  123844. * Unbinds the material from the mesh.
  123845. * @param activeEffect defines the effect that should be unbound from.
  123846. * @returns true if unbound, otherwise false
  123847. */
  123848. unbind(activeEffect: Effect): boolean;
  123849. /**
  123850. * Returns the texture used for refraction or null if none is used.
  123851. * @param scene defines the scene the material belongs to.
  123852. * @returns - Refraction texture if present. If no refraction texture and refraction
  123853. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123854. */
  123855. private _getRefractionTexture;
  123856. /**
  123857. * Returns true if alpha blending should be disabled.
  123858. */
  123859. get disableAlphaBlending(): boolean;
  123860. /**
  123861. * Fills the list of render target textures.
  123862. * @param renderTargets the list of render targets to update
  123863. */
  123864. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123865. /**
  123866. * Checks to see if a texture is used in the material.
  123867. * @param texture - Base texture to use.
  123868. * @returns - Boolean specifying if a texture is used in the material.
  123869. */
  123870. hasTexture(texture: BaseTexture): boolean;
  123871. /**
  123872. * Gets a boolean indicating that current material needs to register RTT
  123873. * @returns true if this uses a render target otherwise false.
  123874. */
  123875. hasRenderTargetTextures(): boolean;
  123876. /**
  123877. * Returns an array of the actively used textures.
  123878. * @param activeTextures Array of BaseTextures
  123879. */
  123880. getActiveTextures(activeTextures: BaseTexture[]): void;
  123881. /**
  123882. * Returns the animatable textures.
  123883. * @param animatables Array of animatable textures.
  123884. */
  123885. getAnimatables(animatables: IAnimatable[]): void;
  123886. /**
  123887. * Disposes the resources of the material.
  123888. * @param forceDisposeTextures - Forces the disposal of all textures.
  123889. */
  123890. dispose(forceDisposeTextures?: boolean): void;
  123891. /**
  123892. * Get the current class name of the texture useful for serialization or dynamic coding.
  123893. * @returns "PBRSubSurfaceConfiguration"
  123894. */
  123895. getClassName(): string;
  123896. /**
  123897. * Add fallbacks to the effect fallbacks list.
  123898. * @param defines defines the Base texture to use.
  123899. * @param fallbacks defines the current fallback list.
  123900. * @param currentRank defines the current fallback rank.
  123901. * @returns the new fallback rank.
  123902. */
  123903. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123904. /**
  123905. * Add the required uniforms to the current list.
  123906. * @param uniforms defines the current uniform list.
  123907. */
  123908. static AddUniforms(uniforms: string[]): void;
  123909. /**
  123910. * Add the required samplers to the current list.
  123911. * @param samplers defines the current sampler list.
  123912. */
  123913. static AddSamplers(samplers: string[]): void;
  123914. /**
  123915. * Add the required uniforms to the current buffer.
  123916. * @param uniformBuffer defines the current uniform buffer.
  123917. */
  123918. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123919. /**
  123920. * Makes a duplicate of the current configuration into another one.
  123921. * @param configuration define the config where to copy the info
  123922. */
  123923. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123924. /**
  123925. * Serializes this Sub Surface configuration.
  123926. * @returns - An object with the serialized config.
  123927. */
  123928. serialize(): any;
  123929. /**
  123930. * Parses a anisotropy Configuration from a serialized object.
  123931. * @param source - Serialized object.
  123932. * @param scene Defines the scene we are parsing for
  123933. * @param rootUrl Defines the rootUrl to load from
  123934. */
  123935. parse(source: any, scene: Scene, rootUrl: string): void;
  123936. }
  123937. }
  123938. declare module BABYLON {
  123939. /** @hidden */
  123940. export var pbrFragmentDeclaration: {
  123941. name: string;
  123942. shader: string;
  123943. };
  123944. }
  123945. declare module BABYLON {
  123946. /** @hidden */
  123947. export var pbrUboDeclaration: {
  123948. name: string;
  123949. shader: string;
  123950. };
  123951. }
  123952. declare module BABYLON {
  123953. /** @hidden */
  123954. export var pbrFragmentExtraDeclaration: {
  123955. name: string;
  123956. shader: string;
  123957. };
  123958. }
  123959. declare module BABYLON {
  123960. /** @hidden */
  123961. export var pbrFragmentSamplersDeclaration: {
  123962. name: string;
  123963. shader: string;
  123964. };
  123965. }
  123966. declare module BABYLON {
  123967. /** @hidden */
  123968. export var pbrHelperFunctions: {
  123969. name: string;
  123970. shader: string;
  123971. };
  123972. }
  123973. declare module BABYLON {
  123974. /** @hidden */
  123975. export var harmonicsFunctions: {
  123976. name: string;
  123977. shader: string;
  123978. };
  123979. }
  123980. declare module BABYLON {
  123981. /** @hidden */
  123982. export var pbrDirectLightingSetupFunctions: {
  123983. name: string;
  123984. shader: string;
  123985. };
  123986. }
  123987. declare module BABYLON {
  123988. /** @hidden */
  123989. export var pbrDirectLightingFalloffFunctions: {
  123990. name: string;
  123991. shader: string;
  123992. };
  123993. }
  123994. declare module BABYLON {
  123995. /** @hidden */
  123996. export var pbrBRDFFunctions: {
  123997. name: string;
  123998. shader: string;
  123999. };
  124000. }
  124001. declare module BABYLON {
  124002. /** @hidden */
  124003. export var pbrDirectLightingFunctions: {
  124004. name: string;
  124005. shader: string;
  124006. };
  124007. }
  124008. declare module BABYLON {
  124009. /** @hidden */
  124010. export var pbrIBLFunctions: {
  124011. name: string;
  124012. shader: string;
  124013. };
  124014. }
  124015. declare module BABYLON {
  124016. /** @hidden */
  124017. export var pbrDebug: {
  124018. name: string;
  124019. shader: string;
  124020. };
  124021. }
  124022. declare module BABYLON {
  124023. /** @hidden */
  124024. export var pbrPixelShader: {
  124025. name: string;
  124026. shader: string;
  124027. };
  124028. }
  124029. declare module BABYLON {
  124030. /** @hidden */
  124031. export var pbrVertexDeclaration: {
  124032. name: string;
  124033. shader: string;
  124034. };
  124035. }
  124036. declare module BABYLON {
  124037. /** @hidden */
  124038. export var pbrVertexShader: {
  124039. name: string;
  124040. shader: string;
  124041. };
  124042. }
  124043. declare module BABYLON {
  124044. /**
  124045. * Manages the defines for the PBR Material.
  124046. * @hidden
  124047. */
  124048. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124049. PBR: boolean;
  124050. MAINUV1: boolean;
  124051. MAINUV2: boolean;
  124052. UV1: boolean;
  124053. UV2: boolean;
  124054. ALBEDO: boolean;
  124055. GAMMAALBEDO: boolean;
  124056. ALBEDODIRECTUV: number;
  124057. VERTEXCOLOR: boolean;
  124058. AMBIENT: boolean;
  124059. AMBIENTDIRECTUV: number;
  124060. AMBIENTINGRAYSCALE: boolean;
  124061. OPACITY: boolean;
  124062. VERTEXALPHA: boolean;
  124063. OPACITYDIRECTUV: number;
  124064. OPACITYRGB: boolean;
  124065. ALPHATEST: boolean;
  124066. DEPTHPREPASS: boolean;
  124067. ALPHABLEND: boolean;
  124068. ALPHAFROMALBEDO: boolean;
  124069. ALPHATESTVALUE: string;
  124070. SPECULAROVERALPHA: boolean;
  124071. RADIANCEOVERALPHA: boolean;
  124072. ALPHAFRESNEL: boolean;
  124073. LINEARALPHAFRESNEL: boolean;
  124074. PREMULTIPLYALPHA: boolean;
  124075. EMISSIVE: boolean;
  124076. EMISSIVEDIRECTUV: number;
  124077. REFLECTIVITY: boolean;
  124078. REFLECTIVITYDIRECTUV: number;
  124079. SPECULARTERM: boolean;
  124080. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124081. MICROSURFACEAUTOMATIC: boolean;
  124082. LODBASEDMICROSFURACE: boolean;
  124083. MICROSURFACEMAP: boolean;
  124084. MICROSURFACEMAPDIRECTUV: number;
  124085. METALLICWORKFLOW: boolean;
  124086. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124087. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124088. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124089. AOSTOREINMETALMAPRED: boolean;
  124090. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124091. ENVIRONMENTBRDF: boolean;
  124092. ENVIRONMENTBRDF_RGBD: boolean;
  124093. NORMAL: boolean;
  124094. TANGENT: boolean;
  124095. BUMP: boolean;
  124096. BUMPDIRECTUV: number;
  124097. OBJECTSPACE_NORMALMAP: boolean;
  124098. PARALLAX: boolean;
  124099. PARALLAXOCCLUSION: boolean;
  124100. NORMALXYSCALE: boolean;
  124101. LIGHTMAP: boolean;
  124102. LIGHTMAPDIRECTUV: number;
  124103. USELIGHTMAPASSHADOWMAP: boolean;
  124104. GAMMALIGHTMAP: boolean;
  124105. RGBDLIGHTMAP: boolean;
  124106. REFLECTION: boolean;
  124107. REFLECTIONMAP_3D: boolean;
  124108. REFLECTIONMAP_SPHERICAL: boolean;
  124109. REFLECTIONMAP_PLANAR: boolean;
  124110. REFLECTIONMAP_CUBIC: boolean;
  124111. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124112. REFLECTIONMAP_PROJECTION: boolean;
  124113. REFLECTIONMAP_SKYBOX: boolean;
  124114. REFLECTIONMAP_EXPLICIT: boolean;
  124115. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124116. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124117. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124118. INVERTCUBICMAP: boolean;
  124119. USESPHERICALFROMREFLECTIONMAP: boolean;
  124120. USEIRRADIANCEMAP: boolean;
  124121. SPHERICAL_HARMONICS: boolean;
  124122. USESPHERICALINVERTEX: boolean;
  124123. REFLECTIONMAP_OPPOSITEZ: boolean;
  124124. LODINREFLECTIONALPHA: boolean;
  124125. GAMMAREFLECTION: boolean;
  124126. RGBDREFLECTION: boolean;
  124127. LINEARSPECULARREFLECTION: boolean;
  124128. RADIANCEOCCLUSION: boolean;
  124129. HORIZONOCCLUSION: boolean;
  124130. INSTANCES: boolean;
  124131. NUM_BONE_INFLUENCERS: number;
  124132. BonesPerMesh: number;
  124133. BONETEXTURE: boolean;
  124134. NONUNIFORMSCALING: boolean;
  124135. MORPHTARGETS: boolean;
  124136. MORPHTARGETS_NORMAL: boolean;
  124137. MORPHTARGETS_TANGENT: boolean;
  124138. MORPHTARGETS_UV: boolean;
  124139. NUM_MORPH_INFLUENCERS: number;
  124140. IMAGEPROCESSING: boolean;
  124141. VIGNETTE: boolean;
  124142. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124143. VIGNETTEBLENDMODEOPAQUE: boolean;
  124144. TONEMAPPING: boolean;
  124145. TONEMAPPING_ACES: boolean;
  124146. CONTRAST: boolean;
  124147. COLORCURVES: boolean;
  124148. COLORGRADING: boolean;
  124149. COLORGRADING3D: boolean;
  124150. SAMPLER3DGREENDEPTH: boolean;
  124151. SAMPLER3DBGRMAP: boolean;
  124152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124153. EXPOSURE: boolean;
  124154. MULTIVIEW: boolean;
  124155. USEPHYSICALLIGHTFALLOFF: boolean;
  124156. USEGLTFLIGHTFALLOFF: boolean;
  124157. TWOSIDEDLIGHTING: boolean;
  124158. SHADOWFLOAT: boolean;
  124159. CLIPPLANE: boolean;
  124160. CLIPPLANE2: boolean;
  124161. CLIPPLANE3: boolean;
  124162. CLIPPLANE4: boolean;
  124163. CLIPPLANE5: boolean;
  124164. CLIPPLANE6: boolean;
  124165. POINTSIZE: boolean;
  124166. FOG: boolean;
  124167. LOGARITHMICDEPTH: boolean;
  124168. FORCENORMALFORWARD: boolean;
  124169. SPECULARAA: boolean;
  124170. CLEARCOAT: boolean;
  124171. CLEARCOAT_DEFAULTIOR: boolean;
  124172. CLEARCOAT_TEXTURE: boolean;
  124173. CLEARCOAT_TEXTUREDIRECTUV: number;
  124174. CLEARCOAT_BUMP: boolean;
  124175. CLEARCOAT_BUMPDIRECTUV: number;
  124176. CLEARCOAT_TINT: boolean;
  124177. CLEARCOAT_TINT_TEXTURE: boolean;
  124178. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124179. ANISOTROPIC: boolean;
  124180. ANISOTROPIC_TEXTURE: boolean;
  124181. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124182. BRDF_V_HEIGHT_CORRELATED: boolean;
  124183. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124184. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124185. SHEEN: boolean;
  124186. SHEEN_TEXTURE: boolean;
  124187. SHEEN_TEXTUREDIRECTUV: number;
  124188. SHEEN_LINKWITHALBEDO: boolean;
  124189. SUBSURFACE: boolean;
  124190. SS_REFRACTION: boolean;
  124191. SS_TRANSLUCENCY: boolean;
  124192. SS_SCATERRING: boolean;
  124193. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124194. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124195. SS_REFRACTIONMAP_3D: boolean;
  124196. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124197. SS_LODINREFRACTIONALPHA: boolean;
  124198. SS_GAMMAREFRACTION: boolean;
  124199. SS_RGBDREFRACTION: boolean;
  124200. SS_LINEARSPECULARREFRACTION: boolean;
  124201. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124202. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124203. UNLIT: boolean;
  124204. DEBUGMODE: number;
  124205. /**
  124206. * Initializes the PBR Material defines.
  124207. */
  124208. constructor();
  124209. /**
  124210. * Resets the PBR Material defines.
  124211. */
  124212. reset(): void;
  124213. }
  124214. /**
  124215. * The Physically based material base class of BJS.
  124216. *
  124217. * This offers the main features of a standard PBR material.
  124218. * For more information, please refer to the documentation :
  124219. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124220. */
  124221. export abstract class PBRBaseMaterial extends PushMaterial {
  124222. /**
  124223. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124224. */
  124225. static readonly PBRMATERIAL_OPAQUE: number;
  124226. /**
  124227. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124228. */
  124229. static readonly PBRMATERIAL_ALPHATEST: number;
  124230. /**
  124231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124232. */
  124233. static readonly PBRMATERIAL_ALPHABLEND: number;
  124234. /**
  124235. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124236. * They are also discarded below the alpha cutoff threshold to improve performances.
  124237. */
  124238. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124239. /**
  124240. * Defines the default value of how much AO map is occluding the analytical lights
  124241. * (point spot...).
  124242. */
  124243. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124244. /**
  124245. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124246. */
  124247. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124248. /**
  124249. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124250. * to enhance interoperability with other engines.
  124251. */
  124252. static readonly LIGHTFALLOFF_GLTF: number;
  124253. /**
  124254. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124255. * to enhance interoperability with other materials.
  124256. */
  124257. static readonly LIGHTFALLOFF_STANDARD: number;
  124258. /**
  124259. * Intensity of the direct lights e.g. the four lights available in your scene.
  124260. * This impacts both the direct diffuse and specular highlights.
  124261. */
  124262. protected _directIntensity: number;
  124263. /**
  124264. * Intensity of the emissive part of the material.
  124265. * This helps controlling the emissive effect without modifying the emissive color.
  124266. */
  124267. protected _emissiveIntensity: number;
  124268. /**
  124269. * Intensity of the environment e.g. how much the environment will light the object
  124270. * either through harmonics for rough material or through the refelction for shiny ones.
  124271. */
  124272. protected _environmentIntensity: number;
  124273. /**
  124274. * This is a special control allowing the reduction of the specular highlights coming from the
  124275. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124276. */
  124277. protected _specularIntensity: number;
  124278. /**
  124279. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124280. */
  124281. private _lightingInfos;
  124282. /**
  124283. * Debug Control allowing disabling the bump map on this material.
  124284. */
  124285. protected _disableBumpMap: boolean;
  124286. /**
  124287. * AKA Diffuse Texture in standard nomenclature.
  124288. */
  124289. protected _albedoTexture: Nullable<BaseTexture>;
  124290. /**
  124291. * AKA Occlusion Texture in other nomenclature.
  124292. */
  124293. protected _ambientTexture: Nullable<BaseTexture>;
  124294. /**
  124295. * AKA Occlusion Texture Intensity in other nomenclature.
  124296. */
  124297. protected _ambientTextureStrength: number;
  124298. /**
  124299. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124300. * 1 means it completely occludes it
  124301. * 0 mean it has no impact
  124302. */
  124303. protected _ambientTextureImpactOnAnalyticalLights: number;
  124304. /**
  124305. * Stores the alpha values in a texture.
  124306. */
  124307. protected _opacityTexture: Nullable<BaseTexture>;
  124308. /**
  124309. * Stores the reflection values in a texture.
  124310. */
  124311. protected _reflectionTexture: Nullable<BaseTexture>;
  124312. /**
  124313. * Stores the emissive values in a texture.
  124314. */
  124315. protected _emissiveTexture: Nullable<BaseTexture>;
  124316. /**
  124317. * AKA Specular texture in other nomenclature.
  124318. */
  124319. protected _reflectivityTexture: Nullable<BaseTexture>;
  124320. /**
  124321. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124322. */
  124323. protected _metallicTexture: Nullable<BaseTexture>;
  124324. /**
  124325. * Specifies the metallic scalar of the metallic/roughness workflow.
  124326. * Can also be used to scale the metalness values of the metallic texture.
  124327. */
  124328. protected _metallic: Nullable<number>;
  124329. /**
  124330. * Specifies the roughness scalar of the metallic/roughness workflow.
  124331. * Can also be used to scale the roughness values of the metallic texture.
  124332. */
  124333. protected _roughness: Nullable<number>;
  124334. /**
  124335. * Specifies the an F0 factor to help configuring the material F0.
  124336. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124337. * to 0.5 the previously hard coded value stays the same.
  124338. * Can also be used to scale the F0 values of the metallic texture.
  124339. */
  124340. protected _metallicF0Factor: number;
  124341. /**
  124342. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124343. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124344. * your expectation as it multiplies with the texture data.
  124345. */
  124346. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124347. /**
  124348. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124349. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124350. */
  124351. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124352. /**
  124353. * Stores surface normal data used to displace a mesh in a texture.
  124354. */
  124355. protected _bumpTexture: Nullable<BaseTexture>;
  124356. /**
  124357. * Stores the pre-calculated light information of a mesh in a texture.
  124358. */
  124359. protected _lightmapTexture: Nullable<BaseTexture>;
  124360. /**
  124361. * The color of a material in ambient lighting.
  124362. */
  124363. protected _ambientColor: Color3;
  124364. /**
  124365. * AKA Diffuse Color in other nomenclature.
  124366. */
  124367. protected _albedoColor: Color3;
  124368. /**
  124369. * AKA Specular Color in other nomenclature.
  124370. */
  124371. protected _reflectivityColor: Color3;
  124372. /**
  124373. * The color applied when light is reflected from a material.
  124374. */
  124375. protected _reflectionColor: Color3;
  124376. /**
  124377. * The color applied when light is emitted from a material.
  124378. */
  124379. protected _emissiveColor: Color3;
  124380. /**
  124381. * AKA Glossiness in other nomenclature.
  124382. */
  124383. protected _microSurface: number;
  124384. /**
  124385. * Specifies that the material will use the light map as a show map.
  124386. */
  124387. protected _useLightmapAsShadowmap: boolean;
  124388. /**
  124389. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124390. * makes the reflect vector face the model (under horizon).
  124391. */
  124392. protected _useHorizonOcclusion: boolean;
  124393. /**
  124394. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124395. * too much the area relying on ambient texture to define their ambient occlusion.
  124396. */
  124397. protected _useRadianceOcclusion: boolean;
  124398. /**
  124399. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124400. */
  124401. protected _useAlphaFromAlbedoTexture: boolean;
  124402. /**
  124403. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124405. */
  124406. protected _useSpecularOverAlpha: boolean;
  124407. /**
  124408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124409. */
  124410. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124411. /**
  124412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124413. */
  124414. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124415. /**
  124416. * Specifies if the metallic texture contains the roughness information in its green channel.
  124417. */
  124418. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124419. /**
  124420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124421. */
  124422. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124423. /**
  124424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124425. */
  124426. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124427. /**
  124428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124429. */
  124430. protected _useAmbientInGrayScale: boolean;
  124431. /**
  124432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124433. * The material will try to infer what glossiness each pixel should be.
  124434. */
  124435. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124436. /**
  124437. * Defines the falloff type used in this material.
  124438. * It by default is Physical.
  124439. */
  124440. protected _lightFalloff: number;
  124441. /**
  124442. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124443. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124444. */
  124445. protected _useRadianceOverAlpha: boolean;
  124446. /**
  124447. * Allows using an object space normal map (instead of tangent space).
  124448. */
  124449. protected _useObjectSpaceNormalMap: boolean;
  124450. /**
  124451. * Allows using the bump map in parallax mode.
  124452. */
  124453. protected _useParallax: boolean;
  124454. /**
  124455. * Allows using the bump map in parallax occlusion mode.
  124456. */
  124457. protected _useParallaxOcclusion: boolean;
  124458. /**
  124459. * Controls the scale bias of the parallax mode.
  124460. */
  124461. protected _parallaxScaleBias: number;
  124462. /**
  124463. * If sets to true, disables all the lights affecting the material.
  124464. */
  124465. protected _disableLighting: boolean;
  124466. /**
  124467. * Number of Simultaneous lights allowed on the material.
  124468. */
  124469. protected _maxSimultaneousLights: number;
  124470. /**
  124471. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124472. */
  124473. protected _invertNormalMapX: boolean;
  124474. /**
  124475. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124476. */
  124477. protected _invertNormalMapY: boolean;
  124478. /**
  124479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124480. */
  124481. protected _twoSidedLighting: boolean;
  124482. /**
  124483. * Defines the alpha limits in alpha test mode.
  124484. */
  124485. protected _alphaCutOff: number;
  124486. /**
  124487. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124488. */
  124489. protected _forceAlphaTest: boolean;
  124490. /**
  124491. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124492. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124493. */
  124494. protected _useAlphaFresnel: boolean;
  124495. /**
  124496. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124497. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124498. */
  124499. protected _useLinearAlphaFresnel: boolean;
  124500. /**
  124501. * The transparency mode of the material.
  124502. */
  124503. protected _transparencyMode: Nullable<number>;
  124504. /**
  124505. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124506. * from cos thetav and roughness:
  124507. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124508. */
  124509. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124510. /**
  124511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124512. */
  124513. protected _forceIrradianceInFragment: boolean;
  124514. /**
  124515. * Force normal to face away from face.
  124516. */
  124517. protected _forceNormalForward: boolean;
  124518. /**
  124519. * Enables specular anti aliasing in the PBR shader.
  124520. * It will both interacts on the Geometry for analytical and IBL lighting.
  124521. * It also prefilter the roughness map based on the bump values.
  124522. */
  124523. protected _enableSpecularAntiAliasing: boolean;
  124524. /**
  124525. * Default configuration related to image processing available in the PBR Material.
  124526. */
  124527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124528. /**
  124529. * Keep track of the image processing observer to allow dispose and replace.
  124530. */
  124531. private _imageProcessingObserver;
  124532. /**
  124533. * Attaches a new image processing configuration to the PBR Material.
  124534. * @param configuration
  124535. */
  124536. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124537. /**
  124538. * Stores the available render targets.
  124539. */
  124540. private _renderTargets;
  124541. /**
  124542. * Sets the global ambient color for the material used in lighting calculations.
  124543. */
  124544. private _globalAmbientColor;
  124545. /**
  124546. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124547. */
  124548. private _useLogarithmicDepth;
  124549. /**
  124550. * If set to true, no lighting calculations will be applied.
  124551. */
  124552. private _unlit;
  124553. private _debugMode;
  124554. /**
  124555. * @hidden
  124556. * This is reserved for the inspector.
  124557. * Defines the material debug mode.
  124558. * It helps seeing only some components of the material while troubleshooting.
  124559. */
  124560. debugMode: number;
  124561. /**
  124562. * @hidden
  124563. * This is reserved for the inspector.
  124564. * Specify from where on screen the debug mode should start.
  124565. * The value goes from -1 (full screen) to 1 (not visible)
  124566. * It helps with side by side comparison against the final render
  124567. * This defaults to -1
  124568. */
  124569. private debugLimit;
  124570. /**
  124571. * @hidden
  124572. * This is reserved for the inspector.
  124573. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124574. * You can use the factor to better multiply the final value.
  124575. */
  124576. private debugFactor;
  124577. /**
  124578. * Defines the clear coat layer parameters for the material.
  124579. */
  124580. readonly clearCoat: PBRClearCoatConfiguration;
  124581. /**
  124582. * Defines the anisotropic parameters for the material.
  124583. */
  124584. readonly anisotropy: PBRAnisotropicConfiguration;
  124585. /**
  124586. * Defines the BRDF parameters for the material.
  124587. */
  124588. readonly brdf: PBRBRDFConfiguration;
  124589. /**
  124590. * Defines the Sheen parameters for the material.
  124591. */
  124592. readonly sheen: PBRSheenConfiguration;
  124593. /**
  124594. * Defines the SubSurface parameters for the material.
  124595. */
  124596. readonly subSurface: PBRSubSurfaceConfiguration;
  124597. /**
  124598. * Custom callback helping to override the default shader used in the material.
  124599. */
  124600. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124601. protected _rebuildInParallel: boolean;
  124602. /**
  124603. * Instantiates a new PBRMaterial instance.
  124604. *
  124605. * @param name The material name
  124606. * @param scene The scene the material will be use in.
  124607. */
  124608. constructor(name: string, scene: Scene);
  124609. /**
  124610. * Gets a boolean indicating that current material needs to register RTT
  124611. */
  124612. get hasRenderTargetTextures(): boolean;
  124613. /**
  124614. * Gets the name of the material class.
  124615. */
  124616. getClassName(): string;
  124617. /**
  124618. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124619. */
  124620. get useLogarithmicDepth(): boolean;
  124621. /**
  124622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124623. */
  124624. set useLogarithmicDepth(value: boolean);
  124625. /**
  124626. * Gets the current transparency mode.
  124627. */
  124628. get transparencyMode(): Nullable<number>;
  124629. /**
  124630. * Sets the transparency mode of the material.
  124631. *
  124632. * | Value | Type | Description |
  124633. * | ----- | ----------------------------------- | ----------- |
  124634. * | 0 | OPAQUE | |
  124635. * | 1 | ALPHATEST | |
  124636. * | 2 | ALPHABLEND | |
  124637. * | 3 | ALPHATESTANDBLEND | |
  124638. *
  124639. */
  124640. set transparencyMode(value: Nullable<number>);
  124641. /**
  124642. * Returns true if alpha blending should be disabled.
  124643. */
  124644. private get _disableAlphaBlending();
  124645. /**
  124646. * Specifies whether or not this material should be rendered in alpha blend mode.
  124647. */
  124648. needAlphaBlending(): boolean;
  124649. /**
  124650. * Specifies if the mesh will require alpha blending.
  124651. * @param mesh - BJS mesh.
  124652. */
  124653. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124654. /**
  124655. * Specifies whether or not this material should be rendered in alpha test mode.
  124656. */
  124657. needAlphaTesting(): boolean;
  124658. /**
  124659. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124660. */
  124661. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124662. /**
  124663. * Gets the texture used for the alpha test.
  124664. */
  124665. getAlphaTestTexture(): Nullable<BaseTexture>;
  124666. /**
  124667. * Specifies that the submesh is ready to be used.
  124668. * @param mesh - BJS mesh.
  124669. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124670. * @param useInstances - Specifies that instances should be used.
  124671. * @returns - boolean indicating that the submesh is ready or not.
  124672. */
  124673. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124674. /**
  124675. * Specifies if the material uses metallic roughness workflow.
  124676. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124677. */
  124678. isMetallicWorkflow(): boolean;
  124679. private _prepareEffect;
  124680. private _prepareDefines;
  124681. /**
  124682. * Force shader compilation
  124683. */
  124684. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124685. /**
  124686. * Initializes the uniform buffer layout for the shader.
  124687. */
  124688. buildUniformLayout(): void;
  124689. /**
  124690. * Unbinds the material from the mesh
  124691. */
  124692. unbind(): void;
  124693. /**
  124694. * Binds the submesh data.
  124695. * @param world - The world matrix.
  124696. * @param mesh - The BJS mesh.
  124697. * @param subMesh - A submesh of the BJS mesh.
  124698. */
  124699. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124700. /**
  124701. * Returns the animatable textures.
  124702. * @returns - Array of animatable textures.
  124703. */
  124704. getAnimatables(): IAnimatable[];
  124705. /**
  124706. * Returns the texture used for reflections.
  124707. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124708. */
  124709. private _getReflectionTexture;
  124710. /**
  124711. * Returns an array of the actively used textures.
  124712. * @returns - Array of BaseTextures
  124713. */
  124714. getActiveTextures(): BaseTexture[];
  124715. /**
  124716. * Checks to see if a texture is used in the material.
  124717. * @param texture - Base texture to use.
  124718. * @returns - Boolean specifying if a texture is used in the material.
  124719. */
  124720. hasTexture(texture: BaseTexture): boolean;
  124721. /**
  124722. * Disposes the resources of the material.
  124723. * @param forceDisposeEffect - Forces the disposal of effects.
  124724. * @param forceDisposeTextures - Forces the disposal of all textures.
  124725. */
  124726. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124727. }
  124728. }
  124729. declare module BABYLON {
  124730. /**
  124731. * The Physically based material of BJS.
  124732. *
  124733. * This offers the main features of a standard PBR material.
  124734. * For more information, please refer to the documentation :
  124735. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124736. */
  124737. export class PBRMaterial extends PBRBaseMaterial {
  124738. /**
  124739. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124740. */
  124741. static readonly PBRMATERIAL_OPAQUE: number;
  124742. /**
  124743. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124744. */
  124745. static readonly PBRMATERIAL_ALPHATEST: number;
  124746. /**
  124747. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124748. */
  124749. static readonly PBRMATERIAL_ALPHABLEND: number;
  124750. /**
  124751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124752. * They are also discarded below the alpha cutoff threshold to improve performances.
  124753. */
  124754. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124755. /**
  124756. * Defines the default value of how much AO map is occluding the analytical lights
  124757. * (point spot...).
  124758. */
  124759. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124760. /**
  124761. * Intensity of the direct lights e.g. the four lights available in your scene.
  124762. * This impacts both the direct diffuse and specular highlights.
  124763. */
  124764. directIntensity: number;
  124765. /**
  124766. * Intensity of the emissive part of the material.
  124767. * This helps controlling the emissive effect without modifying the emissive color.
  124768. */
  124769. emissiveIntensity: number;
  124770. /**
  124771. * Intensity of the environment e.g. how much the environment will light the object
  124772. * either through harmonics for rough material or through the refelction for shiny ones.
  124773. */
  124774. environmentIntensity: number;
  124775. /**
  124776. * This is a special control allowing the reduction of the specular highlights coming from the
  124777. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124778. */
  124779. specularIntensity: number;
  124780. /**
  124781. * Debug Control allowing disabling the bump map on this material.
  124782. */
  124783. disableBumpMap: boolean;
  124784. /**
  124785. * AKA Diffuse Texture in standard nomenclature.
  124786. */
  124787. albedoTexture: BaseTexture;
  124788. /**
  124789. * AKA Occlusion Texture in other nomenclature.
  124790. */
  124791. ambientTexture: BaseTexture;
  124792. /**
  124793. * AKA Occlusion Texture Intensity in other nomenclature.
  124794. */
  124795. ambientTextureStrength: number;
  124796. /**
  124797. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124798. * 1 means it completely occludes it
  124799. * 0 mean it has no impact
  124800. */
  124801. ambientTextureImpactOnAnalyticalLights: number;
  124802. /**
  124803. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124804. */
  124805. opacityTexture: BaseTexture;
  124806. /**
  124807. * Stores the reflection values in a texture.
  124808. */
  124809. reflectionTexture: Nullable<BaseTexture>;
  124810. /**
  124811. * Stores the emissive values in a texture.
  124812. */
  124813. emissiveTexture: BaseTexture;
  124814. /**
  124815. * AKA Specular texture in other nomenclature.
  124816. */
  124817. reflectivityTexture: BaseTexture;
  124818. /**
  124819. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124820. */
  124821. metallicTexture: BaseTexture;
  124822. /**
  124823. * Specifies the metallic scalar of the metallic/roughness workflow.
  124824. * Can also be used to scale the metalness values of the metallic texture.
  124825. */
  124826. metallic: Nullable<number>;
  124827. /**
  124828. * Specifies the roughness scalar of the metallic/roughness workflow.
  124829. * Can also be used to scale the roughness values of the metallic texture.
  124830. */
  124831. roughness: Nullable<number>;
  124832. /**
  124833. * Specifies the an F0 factor to help configuring the material F0.
  124834. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124835. * to 0.5 the previously hard coded value stays the same.
  124836. * Can also be used to scale the F0 values of the metallic texture.
  124837. */
  124838. metallicF0Factor: number;
  124839. /**
  124840. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124841. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124842. * your expectation as it multiplies with the texture data.
  124843. */
  124844. useMetallicF0FactorFromMetallicTexture: boolean;
  124845. /**
  124846. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124847. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124848. */
  124849. microSurfaceTexture: BaseTexture;
  124850. /**
  124851. * Stores surface normal data used to displace a mesh in a texture.
  124852. */
  124853. bumpTexture: BaseTexture;
  124854. /**
  124855. * Stores the pre-calculated light information of a mesh in a texture.
  124856. */
  124857. lightmapTexture: BaseTexture;
  124858. /**
  124859. * Stores the refracted light information in a texture.
  124860. */
  124861. get refractionTexture(): Nullable<BaseTexture>;
  124862. set refractionTexture(value: Nullable<BaseTexture>);
  124863. /**
  124864. * The color of a material in ambient lighting.
  124865. */
  124866. ambientColor: Color3;
  124867. /**
  124868. * AKA Diffuse Color in other nomenclature.
  124869. */
  124870. albedoColor: Color3;
  124871. /**
  124872. * AKA Specular Color in other nomenclature.
  124873. */
  124874. reflectivityColor: Color3;
  124875. /**
  124876. * The color reflected from the material.
  124877. */
  124878. reflectionColor: Color3;
  124879. /**
  124880. * The color emitted from the material.
  124881. */
  124882. emissiveColor: Color3;
  124883. /**
  124884. * AKA Glossiness in other nomenclature.
  124885. */
  124886. microSurface: number;
  124887. /**
  124888. * source material index of refraction (IOR)' / 'destination material IOR.
  124889. */
  124890. get indexOfRefraction(): number;
  124891. set indexOfRefraction(value: number);
  124892. /**
  124893. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124894. */
  124895. get invertRefractionY(): boolean;
  124896. set invertRefractionY(value: boolean);
  124897. /**
  124898. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124899. * Materials half opaque for instance using refraction could benefit from this control.
  124900. */
  124901. get linkRefractionWithTransparency(): boolean;
  124902. set linkRefractionWithTransparency(value: boolean);
  124903. /**
  124904. * If true, the light map contains occlusion information instead of lighting info.
  124905. */
  124906. useLightmapAsShadowmap: boolean;
  124907. /**
  124908. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124909. */
  124910. useAlphaFromAlbedoTexture: boolean;
  124911. /**
  124912. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124913. */
  124914. forceAlphaTest: boolean;
  124915. /**
  124916. * Defines the alpha limits in alpha test mode.
  124917. */
  124918. alphaCutOff: number;
  124919. /**
  124920. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124921. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124922. */
  124923. useSpecularOverAlpha: boolean;
  124924. /**
  124925. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124926. */
  124927. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124928. /**
  124929. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124930. */
  124931. useRoughnessFromMetallicTextureAlpha: boolean;
  124932. /**
  124933. * Specifies if the metallic texture contains the roughness information in its green channel.
  124934. */
  124935. useRoughnessFromMetallicTextureGreen: boolean;
  124936. /**
  124937. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124938. */
  124939. useMetallnessFromMetallicTextureBlue: boolean;
  124940. /**
  124941. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124942. */
  124943. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124944. /**
  124945. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124946. */
  124947. useAmbientInGrayScale: boolean;
  124948. /**
  124949. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124950. * The material will try to infer what glossiness each pixel should be.
  124951. */
  124952. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124953. /**
  124954. * BJS is using an harcoded light falloff based on a manually sets up range.
  124955. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124956. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124957. */
  124958. get usePhysicalLightFalloff(): boolean;
  124959. /**
  124960. * BJS is using an harcoded light falloff based on a manually sets up range.
  124961. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124962. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124963. */
  124964. set usePhysicalLightFalloff(value: boolean);
  124965. /**
  124966. * In order to support the falloff compatibility with gltf, a special mode has been added
  124967. * to reproduce the gltf light falloff.
  124968. */
  124969. get useGLTFLightFalloff(): boolean;
  124970. /**
  124971. * In order to support the falloff compatibility with gltf, a special mode has been added
  124972. * to reproduce the gltf light falloff.
  124973. */
  124974. set useGLTFLightFalloff(value: boolean);
  124975. /**
  124976. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124977. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124978. */
  124979. useRadianceOverAlpha: boolean;
  124980. /**
  124981. * Allows using an object space normal map (instead of tangent space).
  124982. */
  124983. useObjectSpaceNormalMap: boolean;
  124984. /**
  124985. * Allows using the bump map in parallax mode.
  124986. */
  124987. useParallax: boolean;
  124988. /**
  124989. * Allows using the bump map in parallax occlusion mode.
  124990. */
  124991. useParallaxOcclusion: boolean;
  124992. /**
  124993. * Controls the scale bias of the parallax mode.
  124994. */
  124995. parallaxScaleBias: number;
  124996. /**
  124997. * If sets to true, disables all the lights affecting the material.
  124998. */
  124999. disableLighting: boolean;
  125000. /**
  125001. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125002. */
  125003. forceIrradianceInFragment: boolean;
  125004. /**
  125005. * Number of Simultaneous lights allowed on the material.
  125006. */
  125007. maxSimultaneousLights: number;
  125008. /**
  125009. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125010. */
  125011. invertNormalMapX: boolean;
  125012. /**
  125013. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125014. */
  125015. invertNormalMapY: boolean;
  125016. /**
  125017. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125018. */
  125019. twoSidedLighting: boolean;
  125020. /**
  125021. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125022. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125023. */
  125024. useAlphaFresnel: boolean;
  125025. /**
  125026. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125027. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125028. */
  125029. useLinearAlphaFresnel: boolean;
  125030. /**
  125031. * Let user defines the brdf lookup texture used for IBL.
  125032. * A default 8bit version is embedded but you could point at :
  125033. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125034. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125035. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125036. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125037. */
  125038. environmentBRDFTexture: Nullable<BaseTexture>;
  125039. /**
  125040. * Force normal to face away from face.
  125041. */
  125042. forceNormalForward: boolean;
  125043. /**
  125044. * Enables specular anti aliasing in the PBR shader.
  125045. * It will both interacts on the Geometry for analytical and IBL lighting.
  125046. * It also prefilter the roughness map based on the bump values.
  125047. */
  125048. enableSpecularAntiAliasing: boolean;
  125049. /**
  125050. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125051. * makes the reflect vector face the model (under horizon).
  125052. */
  125053. useHorizonOcclusion: boolean;
  125054. /**
  125055. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125056. * too much the area relying on ambient texture to define their ambient occlusion.
  125057. */
  125058. useRadianceOcclusion: boolean;
  125059. /**
  125060. * If set to true, no lighting calculations will be applied.
  125061. */
  125062. unlit: boolean;
  125063. /**
  125064. * Gets the image processing configuration used either in this material.
  125065. */
  125066. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125067. /**
  125068. * Sets the Default image processing configuration used either in the this material.
  125069. *
  125070. * If sets to null, the scene one is in use.
  125071. */
  125072. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125073. /**
  125074. * Gets wether the color curves effect is enabled.
  125075. */
  125076. get cameraColorCurvesEnabled(): boolean;
  125077. /**
  125078. * Sets wether the color curves effect is enabled.
  125079. */
  125080. set cameraColorCurvesEnabled(value: boolean);
  125081. /**
  125082. * Gets wether the color grading effect is enabled.
  125083. */
  125084. get cameraColorGradingEnabled(): boolean;
  125085. /**
  125086. * Gets wether the color grading effect is enabled.
  125087. */
  125088. set cameraColorGradingEnabled(value: boolean);
  125089. /**
  125090. * Gets wether tonemapping is enabled or not.
  125091. */
  125092. get cameraToneMappingEnabled(): boolean;
  125093. /**
  125094. * Sets wether tonemapping is enabled or not
  125095. */
  125096. set cameraToneMappingEnabled(value: boolean);
  125097. /**
  125098. * The camera exposure used on this material.
  125099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125100. * This corresponds to a photographic exposure.
  125101. */
  125102. get cameraExposure(): number;
  125103. /**
  125104. * The camera exposure used on this material.
  125105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125106. * This corresponds to a photographic exposure.
  125107. */
  125108. set cameraExposure(value: number);
  125109. /**
  125110. * Gets The camera contrast used on this material.
  125111. */
  125112. get cameraContrast(): number;
  125113. /**
  125114. * Sets The camera contrast used on this material.
  125115. */
  125116. set cameraContrast(value: number);
  125117. /**
  125118. * Gets the Color Grading 2D Lookup Texture.
  125119. */
  125120. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125121. /**
  125122. * Sets the Color Grading 2D Lookup Texture.
  125123. */
  125124. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125125. /**
  125126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125128. * 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;
  125129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125130. */
  125131. get cameraColorCurves(): Nullable<ColorCurves>;
  125132. /**
  125133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125135. * 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;
  125136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125137. */
  125138. set cameraColorCurves(value: Nullable<ColorCurves>);
  125139. /**
  125140. * Instantiates a new PBRMaterial instance.
  125141. *
  125142. * @param name The material name
  125143. * @param scene The scene the material will be use in.
  125144. */
  125145. constructor(name: string, scene: Scene);
  125146. /**
  125147. * Returns the name of this material class.
  125148. */
  125149. getClassName(): string;
  125150. /**
  125151. * Makes a duplicate of the current material.
  125152. * @param name - name to use for the new material.
  125153. */
  125154. clone(name: string): PBRMaterial;
  125155. /**
  125156. * Serializes this PBR Material.
  125157. * @returns - An object with the serialized material.
  125158. */
  125159. serialize(): any;
  125160. /**
  125161. * Parses a PBR Material from a serialized object.
  125162. * @param source - Serialized object.
  125163. * @param scene - BJS scene instance.
  125164. * @param rootUrl - url for the scene object
  125165. * @returns - PBRMaterial
  125166. */
  125167. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125168. }
  125169. }
  125170. declare module BABYLON {
  125171. /**
  125172. * Direct draw surface info
  125173. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125174. */
  125175. export interface DDSInfo {
  125176. /**
  125177. * Width of the texture
  125178. */
  125179. width: number;
  125180. /**
  125181. * Width of the texture
  125182. */
  125183. height: number;
  125184. /**
  125185. * Number of Mipmaps for the texture
  125186. * @see https://en.wikipedia.org/wiki/Mipmap
  125187. */
  125188. mipmapCount: number;
  125189. /**
  125190. * If the textures format is a known fourCC format
  125191. * @see https://www.fourcc.org/
  125192. */
  125193. isFourCC: boolean;
  125194. /**
  125195. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125196. */
  125197. isRGB: boolean;
  125198. /**
  125199. * If the texture is a lumincance format
  125200. */
  125201. isLuminance: boolean;
  125202. /**
  125203. * If this is a cube texture
  125204. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125205. */
  125206. isCube: boolean;
  125207. /**
  125208. * If the texture is a compressed format eg. FOURCC_DXT1
  125209. */
  125210. isCompressed: boolean;
  125211. /**
  125212. * The dxgiFormat of the texture
  125213. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125214. */
  125215. dxgiFormat: number;
  125216. /**
  125217. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125218. */
  125219. textureType: number;
  125220. /**
  125221. * Sphericle polynomial created for the dds texture
  125222. */
  125223. sphericalPolynomial?: SphericalPolynomial;
  125224. }
  125225. /**
  125226. * Class used to provide DDS decompression tools
  125227. */
  125228. export class DDSTools {
  125229. /**
  125230. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125231. */
  125232. static StoreLODInAlphaChannel: boolean;
  125233. /**
  125234. * Gets DDS information from an array buffer
  125235. * @param data defines the array buffer view to read data from
  125236. * @returns the DDS information
  125237. */
  125238. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125239. private static _FloatView;
  125240. private static _Int32View;
  125241. private static _ToHalfFloat;
  125242. private static _FromHalfFloat;
  125243. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125244. private static _GetHalfFloatRGBAArrayBuffer;
  125245. private static _GetFloatRGBAArrayBuffer;
  125246. private static _GetFloatAsUIntRGBAArrayBuffer;
  125247. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125248. private static _GetRGBAArrayBuffer;
  125249. private static _ExtractLongWordOrder;
  125250. private static _GetRGBArrayBuffer;
  125251. private static _GetLuminanceArrayBuffer;
  125252. /**
  125253. * Uploads DDS Levels to a Babylon Texture
  125254. * @hidden
  125255. */
  125256. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125257. }
  125258. interface ThinEngine {
  125259. /**
  125260. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125261. * @param rootUrl defines the url where the file to load is located
  125262. * @param scene defines the current scene
  125263. * @param lodScale defines scale to apply to the mip map selection
  125264. * @param lodOffset defines offset to apply to the mip map selection
  125265. * @param onLoad defines an optional callback raised when the texture is loaded
  125266. * @param onError defines an optional callback raised if there is an issue to load the texture
  125267. * @param format defines the format of the data
  125268. * @param forcedExtension defines the extension to use to pick the right loader
  125269. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125270. * @returns the cube texture as an InternalTexture
  125271. */
  125272. 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;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. /**
  125277. * Implementation of the DDS Texture Loader.
  125278. * @hidden
  125279. */
  125280. export class _DDSTextureLoader implements IInternalTextureLoader {
  125281. /**
  125282. * Defines wether the loader supports cascade loading the different faces.
  125283. */
  125284. readonly supportCascades: boolean;
  125285. /**
  125286. * This returns if the loader support the current file information.
  125287. * @param extension defines the file extension of the file being loaded
  125288. * @returns true if the loader can load the specified file
  125289. */
  125290. canLoad(extension: string): boolean;
  125291. /**
  125292. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125293. * @param data contains the texture data
  125294. * @param texture defines the BabylonJS internal texture
  125295. * @param createPolynomials will be true if polynomials have been requested
  125296. * @param onLoad defines the callback to trigger once the texture is ready
  125297. * @param onError defines the callback to trigger in case of error
  125298. */
  125299. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125300. /**
  125301. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125302. * @param data contains the texture data
  125303. * @param texture defines the BabylonJS internal texture
  125304. * @param callback defines the method to call once ready to upload
  125305. */
  125306. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125307. }
  125308. }
  125309. declare module BABYLON {
  125310. /**
  125311. * Implementation of the ENV Texture Loader.
  125312. * @hidden
  125313. */
  125314. export class _ENVTextureLoader implements IInternalTextureLoader {
  125315. /**
  125316. * Defines wether the loader supports cascade loading the different faces.
  125317. */
  125318. readonly supportCascades: boolean;
  125319. /**
  125320. * This returns if the loader support the current file information.
  125321. * @param extension defines the file extension of the file being loaded
  125322. * @returns true if the loader can load the specified file
  125323. */
  125324. canLoad(extension: string): boolean;
  125325. /**
  125326. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125327. * @param data contains the texture data
  125328. * @param texture defines the BabylonJS internal texture
  125329. * @param createPolynomials will be true if polynomials have been requested
  125330. * @param onLoad defines the callback to trigger once the texture is ready
  125331. * @param onError defines the callback to trigger in case of error
  125332. */
  125333. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125334. /**
  125335. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125336. * @param data contains the texture data
  125337. * @param texture defines the BabylonJS internal texture
  125338. * @param callback defines the method to call once ready to upload
  125339. */
  125340. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125341. }
  125342. }
  125343. declare module BABYLON {
  125344. /**
  125345. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125346. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125347. */
  125348. export class KhronosTextureContainer {
  125349. /** contents of the KTX container file */
  125350. data: ArrayBufferView;
  125351. private static HEADER_LEN;
  125352. private static COMPRESSED_2D;
  125353. private static COMPRESSED_3D;
  125354. private static TEX_2D;
  125355. private static TEX_3D;
  125356. /**
  125357. * Gets the openGL type
  125358. */
  125359. glType: number;
  125360. /**
  125361. * Gets the openGL type size
  125362. */
  125363. glTypeSize: number;
  125364. /**
  125365. * Gets the openGL format
  125366. */
  125367. glFormat: number;
  125368. /**
  125369. * Gets the openGL internal format
  125370. */
  125371. glInternalFormat: number;
  125372. /**
  125373. * Gets the base internal format
  125374. */
  125375. glBaseInternalFormat: number;
  125376. /**
  125377. * Gets image width in pixel
  125378. */
  125379. pixelWidth: number;
  125380. /**
  125381. * Gets image height in pixel
  125382. */
  125383. pixelHeight: number;
  125384. /**
  125385. * Gets image depth in pixels
  125386. */
  125387. pixelDepth: number;
  125388. /**
  125389. * Gets the number of array elements
  125390. */
  125391. numberOfArrayElements: number;
  125392. /**
  125393. * Gets the number of faces
  125394. */
  125395. numberOfFaces: number;
  125396. /**
  125397. * Gets the number of mipmap levels
  125398. */
  125399. numberOfMipmapLevels: number;
  125400. /**
  125401. * Gets the bytes of key value data
  125402. */
  125403. bytesOfKeyValueData: number;
  125404. /**
  125405. * Gets the load type
  125406. */
  125407. loadType: number;
  125408. /**
  125409. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125410. */
  125411. isInvalid: boolean;
  125412. /**
  125413. * Creates a new KhronosTextureContainer
  125414. * @param data contents of the KTX container file
  125415. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125416. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125417. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125418. */
  125419. constructor(
  125420. /** contents of the KTX container file */
  125421. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125422. /**
  125423. * Uploads KTX content to a Babylon Texture.
  125424. * It is assumed that the texture has already been created & is currently bound
  125425. * @hidden
  125426. */
  125427. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125428. private _upload2DCompressedLevels;
  125429. /**
  125430. * Checks if the given data starts with a KTX file identifier.
  125431. * @param data the data to check
  125432. * @returns true if the data is a KTX file or false otherwise
  125433. */
  125434. static IsValid(data: ArrayBufferView): boolean;
  125435. }
  125436. }
  125437. declare module BABYLON {
  125438. /**
  125439. * Class for loading KTX2 files
  125440. * !!! Experimental Extension Subject to Changes !!!
  125441. * @hidden
  125442. */
  125443. export class KhronosTextureContainer2 {
  125444. private static _ModulePromise;
  125445. private static _TranscodeFormat;
  125446. constructor(engine: ThinEngine);
  125447. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125448. private _determineTranscodeFormat;
  125449. /**
  125450. * Checks if the given data starts with a KTX2 file identifier.
  125451. * @param data the data to check
  125452. * @returns true if the data is a KTX2 file or false otherwise
  125453. */
  125454. static IsValid(data: ArrayBufferView): boolean;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Implementation of the KTX Texture Loader.
  125460. * @hidden
  125461. */
  125462. export class _KTXTextureLoader implements IInternalTextureLoader {
  125463. /**
  125464. * Defines wether the loader supports cascade loading the different faces.
  125465. */
  125466. readonly supportCascades: boolean;
  125467. /**
  125468. * This returns if the loader support the current file information.
  125469. * @param extension defines the file extension of the file being loaded
  125470. * @returns true if the loader can load the specified file
  125471. */
  125472. canLoad(extension: string): boolean;
  125473. /**
  125474. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125475. * @param data contains the texture data
  125476. * @param texture defines the BabylonJS internal texture
  125477. * @param createPolynomials will be true if polynomials have been requested
  125478. * @param onLoad defines the callback to trigger once the texture is ready
  125479. * @param onError defines the callback to trigger in case of error
  125480. */
  125481. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125482. /**
  125483. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125484. * @param data contains the texture data
  125485. * @param texture defines the BabylonJS internal texture
  125486. * @param callback defines the method to call once ready to upload
  125487. */
  125488. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125489. }
  125490. }
  125491. declare module BABYLON {
  125492. /** @hidden */
  125493. export var _forceSceneHelpersToBundle: boolean;
  125494. interface Scene {
  125495. /**
  125496. * Creates a default light for the scene.
  125497. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125498. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125499. */
  125500. createDefaultLight(replace?: boolean): void;
  125501. /**
  125502. * Creates a default camera for the scene.
  125503. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125504. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125505. * @param replace has default false, when true replaces the active camera in the scene
  125506. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125507. */
  125508. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125509. /**
  125510. * Creates a default camera and a default light.
  125511. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125512. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125513. * @param replace has the default false, when true replaces the active camera/light in the scene
  125514. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125515. */
  125516. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125517. /**
  125518. * Creates a new sky box
  125519. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125520. * @param environmentTexture defines the texture to use as environment texture
  125521. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125522. * @param scale defines the overall scale of the skybox
  125523. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125524. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125525. * @returns a new mesh holding the sky box
  125526. */
  125527. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125528. /**
  125529. * Creates a new environment
  125530. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125531. * @param options defines the options you can use to configure the environment
  125532. * @returns the new EnvironmentHelper
  125533. */
  125534. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125535. /**
  125536. * Creates a new VREXperienceHelper
  125537. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125538. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125539. * @returns a new VREXperienceHelper
  125540. */
  125541. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125542. /**
  125543. * Creates a new WebXRDefaultExperience
  125544. * @see http://doc.babylonjs.com/how_to/webxr
  125545. * @param options experience options
  125546. * @returns a promise for a new WebXRDefaultExperience
  125547. */
  125548. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125549. }
  125550. }
  125551. declare module BABYLON {
  125552. /**
  125553. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125554. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125555. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125556. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125557. */
  125558. export class VideoDome extends TransformNode {
  125559. /**
  125560. * Define the video source as a Monoscopic panoramic 360 video.
  125561. */
  125562. static readonly MODE_MONOSCOPIC: number;
  125563. /**
  125564. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125565. */
  125566. static readonly MODE_TOPBOTTOM: number;
  125567. /**
  125568. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125569. */
  125570. static readonly MODE_SIDEBYSIDE: number;
  125571. private _halfDome;
  125572. private _useDirectMapping;
  125573. /**
  125574. * The video texture being displayed on the sphere
  125575. */
  125576. protected _videoTexture: VideoTexture;
  125577. /**
  125578. * Gets the video texture being displayed on the sphere
  125579. */
  125580. get videoTexture(): VideoTexture;
  125581. /**
  125582. * The skybox material
  125583. */
  125584. protected _material: BackgroundMaterial;
  125585. /**
  125586. * The surface used for the skybox
  125587. */
  125588. protected _mesh: Mesh;
  125589. /**
  125590. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125591. */
  125592. private _halfDomeMask;
  125593. /**
  125594. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125595. * Also see the options.resolution property.
  125596. */
  125597. get fovMultiplier(): number;
  125598. set fovMultiplier(value: number);
  125599. private _videoMode;
  125600. /**
  125601. * Gets or set the current video mode for the video. It can be:
  125602. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125603. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125604. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125605. */
  125606. get videoMode(): number;
  125607. set videoMode(value: number);
  125608. /**
  125609. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125610. *
  125611. */
  125612. get halfDome(): boolean;
  125613. /**
  125614. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125615. */
  125616. set halfDome(enabled: boolean);
  125617. /**
  125618. * Oberserver used in Stereoscopic VR Mode.
  125619. */
  125620. private _onBeforeCameraRenderObserver;
  125621. /**
  125622. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125623. * @param name Element's name, child elements will append suffixes for their own names.
  125624. * @param urlsOrVideo defines the url(s) or the video element to use
  125625. * @param options An object containing optional or exposed sub element properties
  125626. */
  125627. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125628. resolution?: number;
  125629. clickToPlay?: boolean;
  125630. autoPlay?: boolean;
  125631. loop?: boolean;
  125632. size?: number;
  125633. poster?: string;
  125634. faceForward?: boolean;
  125635. useDirectMapping?: boolean;
  125636. halfDomeMode?: boolean;
  125637. }, scene: Scene);
  125638. private _changeVideoMode;
  125639. /**
  125640. * Releases resources associated with this node.
  125641. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125642. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125643. */
  125644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125645. }
  125646. }
  125647. declare module BABYLON {
  125648. /**
  125649. * This class can be used to get instrumentation data from a Babylon engine
  125650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125651. */
  125652. export class EngineInstrumentation implements IDisposable {
  125653. /**
  125654. * Define the instrumented engine.
  125655. */
  125656. engine: Engine;
  125657. private _captureGPUFrameTime;
  125658. private _gpuFrameTimeToken;
  125659. private _gpuFrameTime;
  125660. private _captureShaderCompilationTime;
  125661. private _shaderCompilationTime;
  125662. private _onBeginFrameObserver;
  125663. private _onEndFrameObserver;
  125664. private _onBeforeShaderCompilationObserver;
  125665. private _onAfterShaderCompilationObserver;
  125666. /**
  125667. * Gets the perf counter used for GPU frame time
  125668. */
  125669. get gpuFrameTimeCounter(): PerfCounter;
  125670. /**
  125671. * Gets the GPU frame time capture status
  125672. */
  125673. get captureGPUFrameTime(): boolean;
  125674. /**
  125675. * Enable or disable the GPU frame time capture
  125676. */
  125677. set captureGPUFrameTime(value: boolean);
  125678. /**
  125679. * Gets the perf counter used for shader compilation time
  125680. */
  125681. get shaderCompilationTimeCounter(): PerfCounter;
  125682. /**
  125683. * Gets the shader compilation time capture status
  125684. */
  125685. get captureShaderCompilationTime(): boolean;
  125686. /**
  125687. * Enable or disable the shader compilation time capture
  125688. */
  125689. set captureShaderCompilationTime(value: boolean);
  125690. /**
  125691. * Instantiates a new engine instrumentation.
  125692. * This class can be used to get instrumentation data from a Babylon engine
  125693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125694. * @param engine Defines the engine to instrument
  125695. */
  125696. constructor(
  125697. /**
  125698. * Define the instrumented engine.
  125699. */
  125700. engine: Engine);
  125701. /**
  125702. * Dispose and release associated resources.
  125703. */
  125704. dispose(): void;
  125705. }
  125706. }
  125707. declare module BABYLON {
  125708. /**
  125709. * This class can be used to get instrumentation data from a Babylon engine
  125710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125711. */
  125712. export class SceneInstrumentation implements IDisposable {
  125713. /**
  125714. * Defines the scene to instrument
  125715. */
  125716. scene: Scene;
  125717. private _captureActiveMeshesEvaluationTime;
  125718. private _activeMeshesEvaluationTime;
  125719. private _captureRenderTargetsRenderTime;
  125720. private _renderTargetsRenderTime;
  125721. private _captureFrameTime;
  125722. private _frameTime;
  125723. private _captureRenderTime;
  125724. private _renderTime;
  125725. private _captureInterFrameTime;
  125726. private _interFrameTime;
  125727. private _captureParticlesRenderTime;
  125728. private _particlesRenderTime;
  125729. private _captureSpritesRenderTime;
  125730. private _spritesRenderTime;
  125731. private _capturePhysicsTime;
  125732. private _physicsTime;
  125733. private _captureAnimationsTime;
  125734. private _animationsTime;
  125735. private _captureCameraRenderTime;
  125736. private _cameraRenderTime;
  125737. private _onBeforeActiveMeshesEvaluationObserver;
  125738. private _onAfterActiveMeshesEvaluationObserver;
  125739. private _onBeforeRenderTargetsRenderObserver;
  125740. private _onAfterRenderTargetsRenderObserver;
  125741. private _onAfterRenderObserver;
  125742. private _onBeforeDrawPhaseObserver;
  125743. private _onAfterDrawPhaseObserver;
  125744. private _onBeforeAnimationsObserver;
  125745. private _onBeforeParticlesRenderingObserver;
  125746. private _onAfterParticlesRenderingObserver;
  125747. private _onBeforeSpritesRenderingObserver;
  125748. private _onAfterSpritesRenderingObserver;
  125749. private _onBeforePhysicsObserver;
  125750. private _onAfterPhysicsObserver;
  125751. private _onAfterAnimationsObserver;
  125752. private _onBeforeCameraRenderObserver;
  125753. private _onAfterCameraRenderObserver;
  125754. /**
  125755. * Gets the perf counter used for active meshes evaluation time
  125756. */
  125757. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125758. /**
  125759. * Gets the active meshes evaluation time capture status
  125760. */
  125761. get captureActiveMeshesEvaluationTime(): boolean;
  125762. /**
  125763. * Enable or disable the active meshes evaluation time capture
  125764. */
  125765. set captureActiveMeshesEvaluationTime(value: boolean);
  125766. /**
  125767. * Gets the perf counter used for render targets render time
  125768. */
  125769. get renderTargetsRenderTimeCounter(): PerfCounter;
  125770. /**
  125771. * Gets the render targets render time capture status
  125772. */
  125773. get captureRenderTargetsRenderTime(): boolean;
  125774. /**
  125775. * Enable or disable the render targets render time capture
  125776. */
  125777. set captureRenderTargetsRenderTime(value: boolean);
  125778. /**
  125779. * Gets the perf counter used for particles render time
  125780. */
  125781. get particlesRenderTimeCounter(): PerfCounter;
  125782. /**
  125783. * Gets the particles render time capture status
  125784. */
  125785. get captureParticlesRenderTime(): boolean;
  125786. /**
  125787. * Enable or disable the particles render time capture
  125788. */
  125789. set captureParticlesRenderTime(value: boolean);
  125790. /**
  125791. * Gets the perf counter used for sprites render time
  125792. */
  125793. get spritesRenderTimeCounter(): PerfCounter;
  125794. /**
  125795. * Gets the sprites render time capture status
  125796. */
  125797. get captureSpritesRenderTime(): boolean;
  125798. /**
  125799. * Enable or disable the sprites render time capture
  125800. */
  125801. set captureSpritesRenderTime(value: boolean);
  125802. /**
  125803. * Gets the perf counter used for physics time
  125804. */
  125805. get physicsTimeCounter(): PerfCounter;
  125806. /**
  125807. * Gets the physics time capture status
  125808. */
  125809. get capturePhysicsTime(): boolean;
  125810. /**
  125811. * Enable or disable the physics time capture
  125812. */
  125813. set capturePhysicsTime(value: boolean);
  125814. /**
  125815. * Gets the perf counter used for animations time
  125816. */
  125817. get animationsTimeCounter(): PerfCounter;
  125818. /**
  125819. * Gets the animations time capture status
  125820. */
  125821. get captureAnimationsTime(): boolean;
  125822. /**
  125823. * Enable or disable the animations time capture
  125824. */
  125825. set captureAnimationsTime(value: boolean);
  125826. /**
  125827. * Gets the perf counter used for frame time capture
  125828. */
  125829. get frameTimeCounter(): PerfCounter;
  125830. /**
  125831. * Gets the frame time capture status
  125832. */
  125833. get captureFrameTime(): boolean;
  125834. /**
  125835. * Enable or disable the frame time capture
  125836. */
  125837. set captureFrameTime(value: boolean);
  125838. /**
  125839. * Gets the perf counter used for inter-frames time capture
  125840. */
  125841. get interFrameTimeCounter(): PerfCounter;
  125842. /**
  125843. * Gets the inter-frames time capture status
  125844. */
  125845. get captureInterFrameTime(): boolean;
  125846. /**
  125847. * Enable or disable the inter-frames time capture
  125848. */
  125849. set captureInterFrameTime(value: boolean);
  125850. /**
  125851. * Gets the perf counter used for render time capture
  125852. */
  125853. get renderTimeCounter(): PerfCounter;
  125854. /**
  125855. * Gets the render time capture status
  125856. */
  125857. get captureRenderTime(): boolean;
  125858. /**
  125859. * Enable or disable the render time capture
  125860. */
  125861. set captureRenderTime(value: boolean);
  125862. /**
  125863. * Gets the perf counter used for camera render time capture
  125864. */
  125865. get cameraRenderTimeCounter(): PerfCounter;
  125866. /**
  125867. * Gets the camera render time capture status
  125868. */
  125869. get captureCameraRenderTime(): boolean;
  125870. /**
  125871. * Enable or disable the camera render time capture
  125872. */
  125873. set captureCameraRenderTime(value: boolean);
  125874. /**
  125875. * Gets the perf counter used for draw calls
  125876. */
  125877. get drawCallsCounter(): PerfCounter;
  125878. /**
  125879. * Instantiates a new scene instrumentation.
  125880. * This class can be used to get instrumentation data from a Babylon engine
  125881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125882. * @param scene Defines the scene to instrument
  125883. */
  125884. constructor(
  125885. /**
  125886. * Defines the scene to instrument
  125887. */
  125888. scene: Scene);
  125889. /**
  125890. * Dispose and release associated resources.
  125891. */
  125892. dispose(): void;
  125893. }
  125894. }
  125895. declare module BABYLON {
  125896. /** @hidden */
  125897. export var glowMapGenerationPixelShader: {
  125898. name: string;
  125899. shader: string;
  125900. };
  125901. }
  125902. declare module BABYLON {
  125903. /** @hidden */
  125904. export var glowMapGenerationVertexShader: {
  125905. name: string;
  125906. shader: string;
  125907. };
  125908. }
  125909. declare module BABYLON {
  125910. /**
  125911. * Effect layer options. This helps customizing the behaviour
  125912. * of the effect layer.
  125913. */
  125914. export interface IEffectLayerOptions {
  125915. /**
  125916. * Multiplication factor apply to the canvas size to compute the render target size
  125917. * used to generated the objects (the smaller the faster).
  125918. */
  125919. mainTextureRatio: number;
  125920. /**
  125921. * Enforces a fixed size texture to ensure effect stability across devices.
  125922. */
  125923. mainTextureFixedSize?: number;
  125924. /**
  125925. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125926. */
  125927. alphaBlendingMode: number;
  125928. /**
  125929. * The camera attached to the layer.
  125930. */
  125931. camera: Nullable<Camera>;
  125932. /**
  125933. * The rendering group to draw the layer in.
  125934. */
  125935. renderingGroupId: number;
  125936. }
  125937. /**
  125938. * The effect layer Helps adding post process effect blended with the main pass.
  125939. *
  125940. * This can be for instance use to generate glow or higlight effects on the scene.
  125941. *
  125942. * The effect layer class can not be used directly and is intented to inherited from to be
  125943. * customized per effects.
  125944. */
  125945. export abstract class EffectLayer {
  125946. private _vertexBuffers;
  125947. private _indexBuffer;
  125948. private _cachedDefines;
  125949. private _effectLayerMapGenerationEffect;
  125950. private _effectLayerOptions;
  125951. private _mergeEffect;
  125952. protected _scene: Scene;
  125953. protected _engine: Engine;
  125954. protected _maxSize: number;
  125955. protected _mainTextureDesiredSize: ISize;
  125956. protected _mainTexture: RenderTargetTexture;
  125957. protected _shouldRender: boolean;
  125958. protected _postProcesses: PostProcess[];
  125959. protected _textures: BaseTexture[];
  125960. protected _emissiveTextureAndColor: {
  125961. texture: Nullable<BaseTexture>;
  125962. color: Color4;
  125963. };
  125964. /**
  125965. * The name of the layer
  125966. */
  125967. name: string;
  125968. /**
  125969. * The clear color of the texture used to generate the glow map.
  125970. */
  125971. neutralColor: Color4;
  125972. /**
  125973. * Specifies whether the highlight layer is enabled or not.
  125974. */
  125975. isEnabled: boolean;
  125976. /**
  125977. * Gets the camera attached to the layer.
  125978. */
  125979. get camera(): Nullable<Camera>;
  125980. /**
  125981. * Gets the rendering group id the layer should render in.
  125982. */
  125983. get renderingGroupId(): number;
  125984. set renderingGroupId(renderingGroupId: number);
  125985. /**
  125986. * An event triggered when the effect layer has been disposed.
  125987. */
  125988. onDisposeObservable: Observable<EffectLayer>;
  125989. /**
  125990. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125991. */
  125992. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125993. /**
  125994. * An event triggered when the generated texture is being merged in the scene.
  125995. */
  125996. onBeforeComposeObservable: Observable<EffectLayer>;
  125997. /**
  125998. * An event triggered when the mesh is rendered into the effect render target.
  125999. */
  126000. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126001. /**
  126002. * An event triggered after the mesh has been rendered into the effect render target.
  126003. */
  126004. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126005. /**
  126006. * An event triggered when the generated texture has been merged in the scene.
  126007. */
  126008. onAfterComposeObservable: Observable<EffectLayer>;
  126009. /**
  126010. * An event triggered when the efffect layer changes its size.
  126011. */
  126012. onSizeChangedObservable: Observable<EffectLayer>;
  126013. /** @hidden */
  126014. static _SceneComponentInitialization: (scene: Scene) => void;
  126015. /**
  126016. * Instantiates a new effect Layer and references it in the scene.
  126017. * @param name The name of the layer
  126018. * @param scene The scene to use the layer in
  126019. */
  126020. constructor(
  126021. /** The Friendly of the effect in the scene */
  126022. name: string, scene: Scene);
  126023. /**
  126024. * Get the effect name of the layer.
  126025. * @return The effect name
  126026. */
  126027. abstract getEffectName(): string;
  126028. /**
  126029. * Checks for the readiness of the element composing the layer.
  126030. * @param subMesh the mesh to check for
  126031. * @param useInstances specify whether or not to use instances to render the mesh
  126032. * @return true if ready otherwise, false
  126033. */
  126034. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126035. /**
  126036. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126037. * @returns true if the effect requires stencil during the main canvas render pass.
  126038. */
  126039. abstract needStencil(): boolean;
  126040. /**
  126041. * Create the merge effect. This is the shader use to blit the information back
  126042. * to the main canvas at the end of the scene rendering.
  126043. * @returns The effect containing the shader used to merge the effect on the main canvas
  126044. */
  126045. protected abstract _createMergeEffect(): Effect;
  126046. /**
  126047. * Creates the render target textures and post processes used in the effect layer.
  126048. */
  126049. protected abstract _createTextureAndPostProcesses(): void;
  126050. /**
  126051. * Implementation specific of rendering the generating effect on the main canvas.
  126052. * @param effect The effect used to render through
  126053. */
  126054. protected abstract _internalRender(effect: Effect): void;
  126055. /**
  126056. * Sets the required values for both the emissive texture and and the main color.
  126057. */
  126058. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126059. /**
  126060. * Free any resources and references associated to a mesh.
  126061. * Internal use
  126062. * @param mesh The mesh to free.
  126063. */
  126064. abstract _disposeMesh(mesh: Mesh): void;
  126065. /**
  126066. * Serializes this layer (Glow or Highlight for example)
  126067. * @returns a serialized layer object
  126068. */
  126069. abstract serialize?(): any;
  126070. /**
  126071. * Initializes the effect layer with the required options.
  126072. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126073. */
  126074. protected _init(options: Partial<IEffectLayerOptions>): void;
  126075. /**
  126076. * Generates the index buffer of the full screen quad blending to the main canvas.
  126077. */
  126078. private _generateIndexBuffer;
  126079. /**
  126080. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126081. */
  126082. private _generateVertexBuffer;
  126083. /**
  126084. * Sets the main texture desired size which is the closest power of two
  126085. * of the engine canvas size.
  126086. */
  126087. private _setMainTextureSize;
  126088. /**
  126089. * Creates the main texture for the effect layer.
  126090. */
  126091. protected _createMainTexture(): void;
  126092. /**
  126093. * Adds specific effects defines.
  126094. * @param defines The defines to add specifics to.
  126095. */
  126096. protected _addCustomEffectDefines(defines: string[]): void;
  126097. /**
  126098. * Checks for the readiness of the element composing the layer.
  126099. * @param subMesh the mesh to check for
  126100. * @param useInstances specify whether or not to use instances to render the mesh
  126101. * @param emissiveTexture the associated emissive texture used to generate the glow
  126102. * @return true if ready otherwise, false
  126103. */
  126104. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126105. /**
  126106. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126107. */
  126108. render(): void;
  126109. /**
  126110. * Determine if a given mesh will be used in the current effect.
  126111. * @param mesh mesh to test
  126112. * @returns true if the mesh will be used
  126113. */
  126114. hasMesh(mesh: AbstractMesh): boolean;
  126115. /**
  126116. * Returns true if the layer contains information to display, otherwise false.
  126117. * @returns true if the glow layer should be rendered
  126118. */
  126119. shouldRender(): boolean;
  126120. /**
  126121. * Returns true if the mesh should render, otherwise false.
  126122. * @param mesh The mesh to render
  126123. * @returns true if it should render otherwise false
  126124. */
  126125. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126126. /**
  126127. * Returns true if the mesh can be rendered, otherwise false.
  126128. * @param mesh The mesh to render
  126129. * @param material The material used on the mesh
  126130. * @returns true if it can be rendered otherwise false
  126131. */
  126132. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126133. /**
  126134. * Returns true if the mesh should render, otherwise false.
  126135. * @param mesh The mesh to render
  126136. * @returns true if it should render otherwise false
  126137. */
  126138. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126139. /**
  126140. * Renders the submesh passed in parameter to the generation map.
  126141. */
  126142. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126143. /**
  126144. * Defines whether the current material of the mesh should be use to render the effect.
  126145. * @param mesh defines the current mesh to render
  126146. */
  126147. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126148. /**
  126149. * Rebuild the required buffers.
  126150. * @hidden Internal use only.
  126151. */
  126152. _rebuild(): void;
  126153. /**
  126154. * Dispose only the render target textures and post process.
  126155. */
  126156. private _disposeTextureAndPostProcesses;
  126157. /**
  126158. * Dispose the highlight layer and free resources.
  126159. */
  126160. dispose(): void;
  126161. /**
  126162. * Gets the class name of the effect layer
  126163. * @returns the string with the class name of the effect layer
  126164. */
  126165. getClassName(): string;
  126166. /**
  126167. * Creates an effect layer from parsed effect layer data
  126168. * @param parsedEffectLayer defines effect layer data
  126169. * @param scene defines the current scene
  126170. * @param rootUrl defines the root URL containing the effect layer information
  126171. * @returns a parsed effect Layer
  126172. */
  126173. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126174. }
  126175. }
  126176. declare module BABYLON {
  126177. interface AbstractScene {
  126178. /**
  126179. * The list of effect layers (highlights/glow) added to the scene
  126180. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126181. * @see http://doc.babylonjs.com/how_to/glow_layer
  126182. */
  126183. effectLayers: Array<EffectLayer>;
  126184. /**
  126185. * Removes the given effect layer from this scene.
  126186. * @param toRemove defines the effect layer to remove
  126187. * @returns the index of the removed effect layer
  126188. */
  126189. removeEffectLayer(toRemove: EffectLayer): number;
  126190. /**
  126191. * Adds the given effect layer to this scene
  126192. * @param newEffectLayer defines the effect layer to add
  126193. */
  126194. addEffectLayer(newEffectLayer: EffectLayer): void;
  126195. }
  126196. /**
  126197. * Defines the layer scene component responsible to manage any effect layers
  126198. * in a given scene.
  126199. */
  126200. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126201. /**
  126202. * The component name helpfull to identify the component in the list of scene components.
  126203. */
  126204. readonly name: string;
  126205. /**
  126206. * The scene the component belongs to.
  126207. */
  126208. scene: Scene;
  126209. private _engine;
  126210. private _renderEffects;
  126211. private _needStencil;
  126212. private _previousStencilState;
  126213. /**
  126214. * Creates a new instance of the component for the given scene
  126215. * @param scene Defines the scene to register the component in
  126216. */
  126217. constructor(scene: Scene);
  126218. /**
  126219. * Registers the component in a given scene
  126220. */
  126221. register(): void;
  126222. /**
  126223. * Rebuilds the elements related to this component in case of
  126224. * context lost for instance.
  126225. */
  126226. rebuild(): void;
  126227. /**
  126228. * Serializes the component data to the specified json object
  126229. * @param serializationObject The object to serialize to
  126230. */
  126231. serialize(serializationObject: any): void;
  126232. /**
  126233. * Adds all the elements from the container to the scene
  126234. * @param container the container holding the elements
  126235. */
  126236. addFromContainer(container: AbstractScene): void;
  126237. /**
  126238. * Removes all the elements in the container from the scene
  126239. * @param container contains the elements to remove
  126240. * @param dispose if the removed element should be disposed (default: false)
  126241. */
  126242. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126243. /**
  126244. * Disposes the component and the associated ressources.
  126245. */
  126246. dispose(): void;
  126247. private _isReadyForMesh;
  126248. private _renderMainTexture;
  126249. private _setStencil;
  126250. private _setStencilBack;
  126251. private _draw;
  126252. private _drawCamera;
  126253. private _drawRenderingGroup;
  126254. }
  126255. }
  126256. declare module BABYLON {
  126257. /** @hidden */
  126258. export var glowMapMergePixelShader: {
  126259. name: string;
  126260. shader: string;
  126261. };
  126262. }
  126263. declare module BABYLON {
  126264. /** @hidden */
  126265. export var glowMapMergeVertexShader: {
  126266. name: string;
  126267. shader: string;
  126268. };
  126269. }
  126270. declare module BABYLON {
  126271. interface AbstractScene {
  126272. /**
  126273. * Return a the first highlight layer of the scene with a given name.
  126274. * @param name The name of the highlight layer to look for.
  126275. * @return The highlight layer if found otherwise null.
  126276. */
  126277. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126278. }
  126279. /**
  126280. * Glow layer options. This helps customizing the behaviour
  126281. * of the glow layer.
  126282. */
  126283. export interface IGlowLayerOptions {
  126284. /**
  126285. * Multiplication factor apply to the canvas size to compute the render target size
  126286. * used to generated the glowing objects (the smaller the faster).
  126287. */
  126288. mainTextureRatio: number;
  126289. /**
  126290. * Enforces a fixed size texture to ensure resize independant blur.
  126291. */
  126292. mainTextureFixedSize?: number;
  126293. /**
  126294. * How big is the kernel of the blur texture.
  126295. */
  126296. blurKernelSize: number;
  126297. /**
  126298. * The camera attached to the layer.
  126299. */
  126300. camera: Nullable<Camera>;
  126301. /**
  126302. * Enable MSAA by chosing the number of samples.
  126303. */
  126304. mainTextureSamples?: number;
  126305. /**
  126306. * The rendering group to draw the layer in.
  126307. */
  126308. renderingGroupId: number;
  126309. }
  126310. /**
  126311. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126312. *
  126313. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126314. *
  126315. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126316. */
  126317. export class GlowLayer extends EffectLayer {
  126318. /**
  126319. * Effect Name of the layer.
  126320. */
  126321. static readonly EffectName: string;
  126322. /**
  126323. * The default blur kernel size used for the glow.
  126324. */
  126325. static DefaultBlurKernelSize: number;
  126326. /**
  126327. * The default texture size ratio used for the glow.
  126328. */
  126329. static DefaultTextureRatio: number;
  126330. /**
  126331. * Sets the kernel size of the blur.
  126332. */
  126333. set blurKernelSize(value: number);
  126334. /**
  126335. * Gets the kernel size of the blur.
  126336. */
  126337. get blurKernelSize(): number;
  126338. /**
  126339. * Sets the glow intensity.
  126340. */
  126341. set intensity(value: number);
  126342. /**
  126343. * Gets the glow intensity.
  126344. */
  126345. get intensity(): number;
  126346. private _options;
  126347. private _intensity;
  126348. private _horizontalBlurPostprocess1;
  126349. private _verticalBlurPostprocess1;
  126350. private _horizontalBlurPostprocess2;
  126351. private _verticalBlurPostprocess2;
  126352. private _blurTexture1;
  126353. private _blurTexture2;
  126354. private _postProcesses1;
  126355. private _postProcesses2;
  126356. private _includedOnlyMeshes;
  126357. private _excludedMeshes;
  126358. private _meshesUsingTheirOwnMaterials;
  126359. /**
  126360. * Callback used to let the user override the color selection on a per mesh basis
  126361. */
  126362. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126363. /**
  126364. * Callback used to let the user override the texture selection on a per mesh basis
  126365. */
  126366. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126367. /**
  126368. * Instantiates a new glow Layer and references it to the scene.
  126369. * @param name The name of the layer
  126370. * @param scene The scene to use the layer in
  126371. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126372. */
  126373. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126374. /**
  126375. * Get the effect name of the layer.
  126376. * @return The effect name
  126377. */
  126378. getEffectName(): string;
  126379. /**
  126380. * Create the merge effect. This is the shader use to blit the information back
  126381. * to the main canvas at the end of the scene rendering.
  126382. */
  126383. protected _createMergeEffect(): Effect;
  126384. /**
  126385. * Creates the render target textures and post processes used in the glow layer.
  126386. */
  126387. protected _createTextureAndPostProcesses(): void;
  126388. /**
  126389. * Checks for the readiness of the element composing the layer.
  126390. * @param subMesh the mesh to check for
  126391. * @param useInstances specify wether or not to use instances to render the mesh
  126392. * @param emissiveTexture the associated emissive texture used to generate the glow
  126393. * @return true if ready otherwise, false
  126394. */
  126395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126396. /**
  126397. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126398. */
  126399. needStencil(): boolean;
  126400. /**
  126401. * Returns true if the mesh can be rendered, otherwise false.
  126402. * @param mesh The mesh to render
  126403. * @param material The material used on the mesh
  126404. * @returns true if it can be rendered otherwise false
  126405. */
  126406. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126407. /**
  126408. * Implementation specific of rendering the generating effect on the main canvas.
  126409. * @param effect The effect used to render through
  126410. */
  126411. protected _internalRender(effect: Effect): void;
  126412. /**
  126413. * Sets the required values for both the emissive texture and and the main color.
  126414. */
  126415. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126416. /**
  126417. * Returns true if the mesh should render, otherwise false.
  126418. * @param mesh The mesh to render
  126419. * @returns true if it should render otherwise false
  126420. */
  126421. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126422. /**
  126423. * Adds specific effects defines.
  126424. * @param defines The defines to add specifics to.
  126425. */
  126426. protected _addCustomEffectDefines(defines: string[]): void;
  126427. /**
  126428. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126429. * @param mesh The mesh to exclude from the glow layer
  126430. */
  126431. addExcludedMesh(mesh: Mesh): void;
  126432. /**
  126433. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126434. * @param mesh The mesh to remove
  126435. */
  126436. removeExcludedMesh(mesh: Mesh): void;
  126437. /**
  126438. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126439. * @param mesh The mesh to include in the glow layer
  126440. */
  126441. addIncludedOnlyMesh(mesh: Mesh): void;
  126442. /**
  126443. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126444. * @param mesh The mesh to remove
  126445. */
  126446. removeIncludedOnlyMesh(mesh: Mesh): void;
  126447. /**
  126448. * Determine if a given mesh will be used in the glow layer
  126449. * @param mesh The mesh to test
  126450. * @returns true if the mesh will be highlighted by the current glow layer
  126451. */
  126452. hasMesh(mesh: AbstractMesh): boolean;
  126453. /**
  126454. * Defines whether the current material of the mesh should be use to render the effect.
  126455. * @param mesh defines the current mesh to render
  126456. */
  126457. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126458. /**
  126459. * Add a mesh to be rendered through its own material and not with emissive only.
  126460. * @param mesh The mesh for which we need to use its material
  126461. */
  126462. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126463. /**
  126464. * Remove a mesh from being rendered through its own material and not with emissive only.
  126465. * @param mesh The mesh for which we need to not use its material
  126466. */
  126467. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126468. /**
  126469. * Free any resources and references associated to a mesh.
  126470. * Internal use
  126471. * @param mesh The mesh to free.
  126472. * @hidden
  126473. */
  126474. _disposeMesh(mesh: Mesh): void;
  126475. /**
  126476. * Gets the class name of the effect layer
  126477. * @returns the string with the class name of the effect layer
  126478. */
  126479. getClassName(): string;
  126480. /**
  126481. * Serializes this glow layer
  126482. * @returns a serialized glow layer object
  126483. */
  126484. serialize(): any;
  126485. /**
  126486. * Creates a Glow Layer from parsed glow layer data
  126487. * @param parsedGlowLayer defines glow layer data
  126488. * @param scene defines the current scene
  126489. * @param rootUrl defines the root URL containing the glow layer information
  126490. * @returns a parsed Glow Layer
  126491. */
  126492. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126493. }
  126494. }
  126495. declare module BABYLON {
  126496. /** @hidden */
  126497. export var glowBlurPostProcessPixelShader: {
  126498. name: string;
  126499. shader: string;
  126500. };
  126501. }
  126502. declare module BABYLON {
  126503. interface AbstractScene {
  126504. /**
  126505. * Return a the first highlight layer of the scene with a given name.
  126506. * @param name The name of the highlight layer to look for.
  126507. * @return The highlight layer if found otherwise null.
  126508. */
  126509. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126510. }
  126511. /**
  126512. * Highlight layer options. This helps customizing the behaviour
  126513. * of the highlight layer.
  126514. */
  126515. export interface IHighlightLayerOptions {
  126516. /**
  126517. * Multiplication factor apply to the canvas size to compute the render target size
  126518. * used to generated the glowing objects (the smaller the faster).
  126519. */
  126520. mainTextureRatio: number;
  126521. /**
  126522. * Enforces a fixed size texture to ensure resize independant blur.
  126523. */
  126524. mainTextureFixedSize?: number;
  126525. /**
  126526. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126527. * of the picture to blur (the smaller the faster).
  126528. */
  126529. blurTextureSizeRatio: number;
  126530. /**
  126531. * How big in texel of the blur texture is the vertical blur.
  126532. */
  126533. blurVerticalSize: number;
  126534. /**
  126535. * How big in texel of the blur texture is the horizontal blur.
  126536. */
  126537. blurHorizontalSize: number;
  126538. /**
  126539. * Alpha blending mode used to apply the blur. Default is combine.
  126540. */
  126541. alphaBlendingMode: number;
  126542. /**
  126543. * The camera attached to the layer.
  126544. */
  126545. camera: Nullable<Camera>;
  126546. /**
  126547. * Should we display highlight as a solid stroke?
  126548. */
  126549. isStroke?: boolean;
  126550. /**
  126551. * The rendering group to draw the layer in.
  126552. */
  126553. renderingGroupId: number;
  126554. }
  126555. /**
  126556. * The highlight layer Helps adding a glow effect around a mesh.
  126557. *
  126558. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126559. * glowy meshes to your scene.
  126560. *
  126561. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126562. */
  126563. export class HighlightLayer extends EffectLayer {
  126564. name: string;
  126565. /**
  126566. * Effect Name of the highlight layer.
  126567. */
  126568. static readonly EffectName: string;
  126569. /**
  126570. * The neutral color used during the preparation of the glow effect.
  126571. * This is black by default as the blend operation is a blend operation.
  126572. */
  126573. static NeutralColor: Color4;
  126574. /**
  126575. * Stencil value used for glowing meshes.
  126576. */
  126577. static GlowingMeshStencilReference: number;
  126578. /**
  126579. * Stencil value used for the other meshes in the scene.
  126580. */
  126581. static NormalMeshStencilReference: number;
  126582. /**
  126583. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126584. */
  126585. innerGlow: boolean;
  126586. /**
  126587. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126588. */
  126589. outerGlow: boolean;
  126590. /**
  126591. * Specifies the horizontal size of the blur.
  126592. */
  126593. set blurHorizontalSize(value: number);
  126594. /**
  126595. * Specifies the vertical size of the blur.
  126596. */
  126597. set blurVerticalSize(value: number);
  126598. /**
  126599. * Gets the horizontal size of the blur.
  126600. */
  126601. get blurHorizontalSize(): number;
  126602. /**
  126603. * Gets the vertical size of the blur.
  126604. */
  126605. get blurVerticalSize(): number;
  126606. /**
  126607. * An event triggered when the highlight layer is being blurred.
  126608. */
  126609. onBeforeBlurObservable: Observable<HighlightLayer>;
  126610. /**
  126611. * An event triggered when the highlight layer has been blurred.
  126612. */
  126613. onAfterBlurObservable: Observable<HighlightLayer>;
  126614. private _instanceGlowingMeshStencilReference;
  126615. private _options;
  126616. private _downSamplePostprocess;
  126617. private _horizontalBlurPostprocess;
  126618. private _verticalBlurPostprocess;
  126619. private _blurTexture;
  126620. private _meshes;
  126621. private _excludedMeshes;
  126622. /**
  126623. * Instantiates a new highlight Layer and references it to the scene..
  126624. * @param name The name of the layer
  126625. * @param scene The scene to use the layer in
  126626. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126627. */
  126628. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126629. /**
  126630. * Get the effect name of the layer.
  126631. * @return The effect name
  126632. */
  126633. getEffectName(): string;
  126634. /**
  126635. * Create the merge effect. This is the shader use to blit the information back
  126636. * to the main canvas at the end of the scene rendering.
  126637. */
  126638. protected _createMergeEffect(): Effect;
  126639. /**
  126640. * Creates the render target textures and post processes used in the highlight layer.
  126641. */
  126642. protected _createTextureAndPostProcesses(): void;
  126643. /**
  126644. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126645. */
  126646. needStencil(): boolean;
  126647. /**
  126648. * Checks for the readiness of the element composing the layer.
  126649. * @param subMesh the mesh to check for
  126650. * @param useInstances specify wether or not to use instances to render the mesh
  126651. * @param emissiveTexture the associated emissive texture used to generate the glow
  126652. * @return true if ready otherwise, false
  126653. */
  126654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126655. /**
  126656. * Implementation specific of rendering the generating effect on the main canvas.
  126657. * @param effect The effect used to render through
  126658. */
  126659. protected _internalRender(effect: Effect): void;
  126660. /**
  126661. * Returns true if the layer contains information to display, otherwise false.
  126662. */
  126663. shouldRender(): boolean;
  126664. /**
  126665. * Returns true if the mesh should render, otherwise false.
  126666. * @param mesh The mesh to render
  126667. * @returns true if it should render otherwise false
  126668. */
  126669. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126670. /**
  126671. * Sets the required values for both the emissive texture and and the main color.
  126672. */
  126673. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126674. /**
  126675. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126676. * @param mesh The mesh to exclude from the highlight layer
  126677. */
  126678. addExcludedMesh(mesh: Mesh): void;
  126679. /**
  126680. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126681. * @param mesh The mesh to highlight
  126682. */
  126683. removeExcludedMesh(mesh: Mesh): void;
  126684. /**
  126685. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126686. * @param mesh mesh to test
  126687. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126688. */
  126689. hasMesh(mesh: AbstractMesh): boolean;
  126690. /**
  126691. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126692. * @param mesh The mesh to highlight
  126693. * @param color The color of the highlight
  126694. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126695. */
  126696. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126697. /**
  126698. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126699. * @param mesh The mesh to highlight
  126700. */
  126701. removeMesh(mesh: Mesh): void;
  126702. /**
  126703. * Remove all the meshes currently referenced in the highlight layer
  126704. */
  126705. removeAllMeshes(): void;
  126706. /**
  126707. * Force the stencil to the normal expected value for none glowing parts
  126708. */
  126709. private _defaultStencilReference;
  126710. /**
  126711. * Free any resources and references associated to a mesh.
  126712. * Internal use
  126713. * @param mesh The mesh to free.
  126714. * @hidden
  126715. */
  126716. _disposeMesh(mesh: Mesh): void;
  126717. /**
  126718. * Dispose the highlight layer and free resources.
  126719. */
  126720. dispose(): void;
  126721. /**
  126722. * Gets the class name of the effect layer
  126723. * @returns the string with the class name of the effect layer
  126724. */
  126725. getClassName(): string;
  126726. /**
  126727. * Serializes this Highlight layer
  126728. * @returns a serialized Highlight layer object
  126729. */
  126730. serialize(): any;
  126731. /**
  126732. * Creates a Highlight layer from parsed Highlight layer data
  126733. * @param parsedHightlightLayer defines the Highlight layer data
  126734. * @param scene defines the current scene
  126735. * @param rootUrl defines the root URL containing the Highlight layer information
  126736. * @returns a parsed Highlight layer
  126737. */
  126738. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126739. }
  126740. }
  126741. declare module BABYLON {
  126742. interface AbstractScene {
  126743. /**
  126744. * The list of layers (background and foreground) of the scene
  126745. */
  126746. layers: Array<Layer>;
  126747. }
  126748. /**
  126749. * Defines the layer scene component responsible to manage any layers
  126750. * in a given scene.
  126751. */
  126752. export class LayerSceneComponent implements ISceneComponent {
  126753. /**
  126754. * The component name helpfull to identify the component in the list of scene components.
  126755. */
  126756. readonly name: string;
  126757. /**
  126758. * The scene the component belongs to.
  126759. */
  126760. scene: Scene;
  126761. private _engine;
  126762. /**
  126763. * Creates a new instance of the component for the given scene
  126764. * @param scene Defines the scene to register the component in
  126765. */
  126766. constructor(scene: Scene);
  126767. /**
  126768. * Registers the component in a given scene
  126769. */
  126770. register(): void;
  126771. /**
  126772. * Rebuilds the elements related to this component in case of
  126773. * context lost for instance.
  126774. */
  126775. rebuild(): void;
  126776. /**
  126777. * Disposes the component and the associated ressources.
  126778. */
  126779. dispose(): void;
  126780. private _draw;
  126781. private _drawCameraPredicate;
  126782. private _drawCameraBackground;
  126783. private _drawCameraForeground;
  126784. private _drawRenderTargetPredicate;
  126785. private _drawRenderTargetBackground;
  126786. private _drawRenderTargetForeground;
  126787. /**
  126788. * Adds all the elements from the container to the scene
  126789. * @param container the container holding the elements
  126790. */
  126791. addFromContainer(container: AbstractScene): void;
  126792. /**
  126793. * Removes all the elements in the container from the scene
  126794. * @param container contains the elements to remove
  126795. * @param dispose if the removed element should be disposed (default: false)
  126796. */
  126797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126798. }
  126799. }
  126800. declare module BABYLON {
  126801. /** @hidden */
  126802. export var layerPixelShader: {
  126803. name: string;
  126804. shader: string;
  126805. };
  126806. }
  126807. declare module BABYLON {
  126808. /** @hidden */
  126809. export var layerVertexShader: {
  126810. name: string;
  126811. shader: string;
  126812. };
  126813. }
  126814. declare module BABYLON {
  126815. /**
  126816. * This represents a full screen 2d layer.
  126817. * This can be useful to display a picture in the background of your scene for instance.
  126818. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126819. */
  126820. export class Layer {
  126821. /**
  126822. * Define the name of the layer.
  126823. */
  126824. name: string;
  126825. /**
  126826. * Define the texture the layer should display.
  126827. */
  126828. texture: Nullable<Texture>;
  126829. /**
  126830. * Is the layer in background or foreground.
  126831. */
  126832. isBackground: boolean;
  126833. /**
  126834. * Define the color of the layer (instead of texture).
  126835. */
  126836. color: Color4;
  126837. /**
  126838. * Define the scale of the layer in order to zoom in out of the texture.
  126839. */
  126840. scale: Vector2;
  126841. /**
  126842. * Define an offset for the layer in order to shift the texture.
  126843. */
  126844. offset: Vector2;
  126845. /**
  126846. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126847. */
  126848. alphaBlendingMode: number;
  126849. /**
  126850. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126851. * Alpha test will not mix with the background color in case of transparency.
  126852. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126853. */
  126854. alphaTest: boolean;
  126855. /**
  126856. * Define a mask to restrict the layer to only some of the scene cameras.
  126857. */
  126858. layerMask: number;
  126859. /**
  126860. * Define the list of render target the layer is visible into.
  126861. */
  126862. renderTargetTextures: RenderTargetTexture[];
  126863. /**
  126864. * Define if the layer is only used in renderTarget or if it also
  126865. * renders in the main frame buffer of the canvas.
  126866. */
  126867. renderOnlyInRenderTargetTextures: boolean;
  126868. private _scene;
  126869. private _vertexBuffers;
  126870. private _indexBuffer;
  126871. private _effect;
  126872. private _previousDefines;
  126873. /**
  126874. * An event triggered when the layer is disposed.
  126875. */
  126876. onDisposeObservable: Observable<Layer>;
  126877. private _onDisposeObserver;
  126878. /**
  126879. * Back compatibility with callback before the onDisposeObservable existed.
  126880. * The set callback will be triggered when the layer has been disposed.
  126881. */
  126882. set onDispose(callback: () => void);
  126883. /**
  126884. * An event triggered before rendering the scene
  126885. */
  126886. onBeforeRenderObservable: Observable<Layer>;
  126887. private _onBeforeRenderObserver;
  126888. /**
  126889. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126890. * The set callback will be triggered just before rendering the layer.
  126891. */
  126892. set onBeforeRender(callback: () => void);
  126893. /**
  126894. * An event triggered after rendering the scene
  126895. */
  126896. onAfterRenderObservable: Observable<Layer>;
  126897. private _onAfterRenderObserver;
  126898. /**
  126899. * Back compatibility with callback before the onAfterRenderObservable existed.
  126900. * The set callback will be triggered just after rendering the layer.
  126901. */
  126902. set onAfterRender(callback: () => void);
  126903. /**
  126904. * Instantiates a new layer.
  126905. * This represents a full screen 2d layer.
  126906. * This can be useful to display a picture in the background of your scene for instance.
  126907. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126908. * @param name Define the name of the layer in the scene
  126909. * @param imgUrl Define the url of the texture to display in the layer
  126910. * @param scene Define the scene the layer belongs to
  126911. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126912. * @param color Defines a color for the layer
  126913. */
  126914. constructor(
  126915. /**
  126916. * Define the name of the layer.
  126917. */
  126918. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126919. private _createIndexBuffer;
  126920. /** @hidden */
  126921. _rebuild(): void;
  126922. /**
  126923. * Renders the layer in the scene.
  126924. */
  126925. render(): void;
  126926. /**
  126927. * Disposes and releases the associated ressources.
  126928. */
  126929. dispose(): void;
  126930. }
  126931. }
  126932. declare module BABYLON {
  126933. /** @hidden */
  126934. export var lensFlarePixelShader: {
  126935. name: string;
  126936. shader: string;
  126937. };
  126938. }
  126939. declare module BABYLON {
  126940. /** @hidden */
  126941. export var lensFlareVertexShader: {
  126942. name: string;
  126943. shader: string;
  126944. };
  126945. }
  126946. declare module BABYLON {
  126947. /**
  126948. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126949. * It is usually composed of several `lensFlare`.
  126950. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126951. */
  126952. export class LensFlareSystem {
  126953. /**
  126954. * Define the name of the lens flare system
  126955. */
  126956. name: string;
  126957. /**
  126958. * List of lens flares used in this system.
  126959. */
  126960. lensFlares: LensFlare[];
  126961. /**
  126962. * Define a limit from the border the lens flare can be visible.
  126963. */
  126964. borderLimit: number;
  126965. /**
  126966. * Define a viewport border we do not want to see the lens flare in.
  126967. */
  126968. viewportBorder: number;
  126969. /**
  126970. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126971. */
  126972. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126973. /**
  126974. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126975. */
  126976. layerMask: number;
  126977. /**
  126978. * Define the id of the lens flare system in the scene.
  126979. * (equal to name by default)
  126980. */
  126981. id: string;
  126982. private _scene;
  126983. private _emitter;
  126984. private _vertexBuffers;
  126985. private _indexBuffer;
  126986. private _effect;
  126987. private _positionX;
  126988. private _positionY;
  126989. private _isEnabled;
  126990. /** @hidden */
  126991. static _SceneComponentInitialization: (scene: Scene) => void;
  126992. /**
  126993. * Instantiates a lens flare system.
  126994. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126995. * It is usually composed of several `lensFlare`.
  126996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126997. * @param name Define the name of the lens flare system in the scene
  126998. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126999. * @param scene Define the scene the lens flare system belongs to
  127000. */
  127001. constructor(
  127002. /**
  127003. * Define the name of the lens flare system
  127004. */
  127005. name: string, emitter: any, scene: Scene);
  127006. /**
  127007. * Define if the lens flare system is enabled.
  127008. */
  127009. get isEnabled(): boolean;
  127010. set isEnabled(value: boolean);
  127011. /**
  127012. * Get the scene the effects belongs to.
  127013. * @returns the scene holding the lens flare system
  127014. */
  127015. getScene(): Scene;
  127016. /**
  127017. * Get the emitter of the lens flare system.
  127018. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127019. * @returns the emitter of the lens flare system
  127020. */
  127021. getEmitter(): any;
  127022. /**
  127023. * Set the emitter of the lens flare system.
  127024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127025. * @param newEmitter Define the new emitter of the system
  127026. */
  127027. setEmitter(newEmitter: any): void;
  127028. /**
  127029. * Get the lens flare system emitter position.
  127030. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127031. * @returns the position
  127032. */
  127033. getEmitterPosition(): Vector3;
  127034. /**
  127035. * @hidden
  127036. */
  127037. computeEffectivePosition(globalViewport: Viewport): boolean;
  127038. /** @hidden */
  127039. _isVisible(): boolean;
  127040. /**
  127041. * @hidden
  127042. */
  127043. render(): boolean;
  127044. /**
  127045. * Dispose and release the lens flare with its associated resources.
  127046. */
  127047. dispose(): void;
  127048. /**
  127049. * Parse a lens flare system from a JSON repressentation
  127050. * @param parsedLensFlareSystem Define the JSON to parse
  127051. * @param scene Define the scene the parsed system should be instantiated in
  127052. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127053. * @returns the parsed system
  127054. */
  127055. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127056. /**
  127057. * Serialize the current Lens Flare System into a JSON representation.
  127058. * @returns the serialized JSON
  127059. */
  127060. serialize(): any;
  127061. }
  127062. }
  127063. declare module BABYLON {
  127064. /**
  127065. * This represents one of the lens effect in a `lensFlareSystem`.
  127066. * It controls one of the indiviual texture used in the effect.
  127067. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127068. */
  127069. export class LensFlare {
  127070. /**
  127071. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127072. */
  127073. size: number;
  127074. /**
  127075. * 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.
  127076. */
  127077. position: number;
  127078. /**
  127079. * Define the lens color.
  127080. */
  127081. color: Color3;
  127082. /**
  127083. * Define the lens texture.
  127084. */
  127085. texture: Nullable<Texture>;
  127086. /**
  127087. * Define the alpha mode to render this particular lens.
  127088. */
  127089. alphaMode: number;
  127090. private _system;
  127091. /**
  127092. * Creates a new Lens Flare.
  127093. * This represents one of the lens effect in a `lensFlareSystem`.
  127094. * It controls one of the indiviual texture used in the effect.
  127095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127096. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127097. * @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.
  127098. * @param color Define the lens color
  127099. * @param imgUrl Define the lens texture url
  127100. * @param system Define the `lensFlareSystem` this flare is part of
  127101. * @returns The newly created Lens Flare
  127102. */
  127103. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127104. /**
  127105. * Instantiates a new Lens Flare.
  127106. * This represents one of the lens effect in a `lensFlareSystem`.
  127107. * It controls one of the indiviual texture used in the effect.
  127108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127109. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127110. * @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.
  127111. * @param color Define the lens color
  127112. * @param imgUrl Define the lens texture url
  127113. * @param system Define the `lensFlareSystem` this flare is part of
  127114. */
  127115. constructor(
  127116. /**
  127117. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127118. */
  127119. size: number,
  127120. /**
  127121. * 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.
  127122. */
  127123. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127124. /**
  127125. * Dispose and release the lens flare with its associated resources.
  127126. */
  127127. dispose(): void;
  127128. }
  127129. }
  127130. declare module BABYLON {
  127131. interface AbstractScene {
  127132. /**
  127133. * The list of lens flare system added to the scene
  127134. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127135. */
  127136. lensFlareSystems: Array<LensFlareSystem>;
  127137. /**
  127138. * Removes the given lens flare system from this scene.
  127139. * @param toRemove The lens flare system to remove
  127140. * @returns The index of the removed lens flare system
  127141. */
  127142. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127143. /**
  127144. * Adds the given lens flare system to this scene
  127145. * @param newLensFlareSystem The lens flare system to add
  127146. */
  127147. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127148. /**
  127149. * Gets a lens flare system using its name
  127150. * @param name defines the name to look for
  127151. * @returns the lens flare system or null if not found
  127152. */
  127153. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127154. /**
  127155. * Gets a lens flare system using its id
  127156. * @param id defines the id to look for
  127157. * @returns the lens flare system or null if not found
  127158. */
  127159. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127160. }
  127161. /**
  127162. * Defines the lens flare scene component responsible to manage any lens flares
  127163. * in a given scene.
  127164. */
  127165. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127166. /**
  127167. * The component name helpfull to identify the component in the list of scene components.
  127168. */
  127169. readonly name: string;
  127170. /**
  127171. * The scene the component belongs to.
  127172. */
  127173. scene: Scene;
  127174. /**
  127175. * Creates a new instance of the component for the given scene
  127176. * @param scene Defines the scene to register the component in
  127177. */
  127178. constructor(scene: Scene);
  127179. /**
  127180. * Registers the component in a given scene
  127181. */
  127182. register(): void;
  127183. /**
  127184. * Rebuilds the elements related to this component in case of
  127185. * context lost for instance.
  127186. */
  127187. rebuild(): void;
  127188. /**
  127189. * Adds all the elements from the container to the scene
  127190. * @param container the container holding the elements
  127191. */
  127192. addFromContainer(container: AbstractScene): void;
  127193. /**
  127194. * Removes all the elements in the container from the scene
  127195. * @param container contains the elements to remove
  127196. * @param dispose if the removed element should be disposed (default: false)
  127197. */
  127198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127199. /**
  127200. * Serializes the component data to the specified json object
  127201. * @param serializationObject The object to serialize to
  127202. */
  127203. serialize(serializationObject: any): void;
  127204. /**
  127205. * Disposes the component and the associated ressources.
  127206. */
  127207. dispose(): void;
  127208. private _draw;
  127209. }
  127210. }
  127211. declare module BABYLON {
  127212. /** @hidden */
  127213. export var depthPixelShader: {
  127214. name: string;
  127215. shader: string;
  127216. };
  127217. }
  127218. declare module BABYLON {
  127219. /** @hidden */
  127220. export var depthVertexShader: {
  127221. name: string;
  127222. shader: string;
  127223. };
  127224. }
  127225. declare module BABYLON {
  127226. /**
  127227. * This represents a depth renderer in Babylon.
  127228. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127229. */
  127230. export class DepthRenderer {
  127231. private _scene;
  127232. private _depthMap;
  127233. private _effect;
  127234. private readonly _storeNonLinearDepth;
  127235. private readonly _clearColor;
  127236. /** Get if the depth renderer is using packed depth or not */
  127237. readonly isPacked: boolean;
  127238. private _cachedDefines;
  127239. private _camera;
  127240. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127241. enabled: boolean;
  127242. /**
  127243. * Specifiess that the depth renderer will only be used within
  127244. * the camera it is created for.
  127245. * This can help forcing its rendering during the camera processing.
  127246. */
  127247. useOnlyInActiveCamera: boolean;
  127248. /** @hidden */
  127249. static _SceneComponentInitialization: (scene: Scene) => void;
  127250. /**
  127251. * Instantiates a depth renderer
  127252. * @param scene The scene the renderer belongs to
  127253. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127254. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127255. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127256. */
  127257. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127258. /**
  127259. * Creates the depth rendering effect and checks if the effect is ready.
  127260. * @param subMesh The submesh to be used to render the depth map of
  127261. * @param useInstances If multiple world instances should be used
  127262. * @returns if the depth renderer is ready to render the depth map
  127263. */
  127264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127265. /**
  127266. * Gets the texture which the depth map will be written to.
  127267. * @returns The depth map texture
  127268. */
  127269. getDepthMap(): RenderTargetTexture;
  127270. /**
  127271. * Disposes of the depth renderer.
  127272. */
  127273. dispose(): void;
  127274. }
  127275. }
  127276. declare module BABYLON {
  127277. /** @hidden */
  127278. export var minmaxReduxPixelShader: {
  127279. name: string;
  127280. shader: string;
  127281. };
  127282. }
  127283. declare module BABYLON {
  127284. /**
  127285. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127286. * and maximum values from all values of the texture.
  127287. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127288. * The source values are read from the red channel of the texture.
  127289. */
  127290. export class MinMaxReducer {
  127291. /**
  127292. * Observable triggered when the computation has been performed
  127293. */
  127294. onAfterReductionPerformed: Observable<{
  127295. min: number;
  127296. max: number;
  127297. }>;
  127298. protected _camera: Camera;
  127299. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127300. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127301. protected _postProcessManager: PostProcessManager;
  127302. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127303. protected _forceFullscreenViewport: boolean;
  127304. /**
  127305. * Creates a min/max reducer
  127306. * @param camera The camera to use for the post processes
  127307. */
  127308. constructor(camera: Camera);
  127309. /**
  127310. * Gets the texture used to read the values from.
  127311. */
  127312. get sourceTexture(): Nullable<RenderTargetTexture>;
  127313. /**
  127314. * Sets the source texture to read the values from.
  127315. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127316. * because in such textures '1' value must not be taken into account to compute the maximum
  127317. * as this value is used to clear the texture.
  127318. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127319. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127320. * @param depthRedux Indicates if the texture is a depth texture or not
  127321. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127322. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127323. */
  127324. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127325. /**
  127326. * Defines the refresh rate of the computation.
  127327. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127328. */
  127329. get refreshRate(): number;
  127330. set refreshRate(value: number);
  127331. protected _activated: boolean;
  127332. /**
  127333. * Gets the activation status of the reducer
  127334. */
  127335. get activated(): boolean;
  127336. /**
  127337. * Activates the reduction computation.
  127338. * When activated, the observers registered in onAfterReductionPerformed are
  127339. * called after the compuation is performed
  127340. */
  127341. activate(): void;
  127342. /**
  127343. * Deactivates the reduction computation.
  127344. */
  127345. deactivate(): void;
  127346. /**
  127347. * Disposes the min/max reducer
  127348. * @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.
  127349. */
  127350. dispose(disposeAll?: boolean): void;
  127351. }
  127352. }
  127353. declare module BABYLON {
  127354. /**
  127355. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127356. */
  127357. export class DepthReducer extends MinMaxReducer {
  127358. private _depthRenderer;
  127359. private _depthRendererId;
  127360. /**
  127361. * Gets the depth renderer used for the computation.
  127362. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127363. */
  127364. get depthRenderer(): Nullable<DepthRenderer>;
  127365. /**
  127366. * Creates a depth reducer
  127367. * @param camera The camera used to render the depth texture
  127368. */
  127369. constructor(camera: Camera);
  127370. /**
  127371. * Sets the depth renderer to use to generate the depth map
  127372. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127373. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127374. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127375. */
  127376. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127377. /** @hidden */
  127378. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127379. /**
  127380. * Activates the reduction computation.
  127381. * When activated, the observers registered in onAfterReductionPerformed are
  127382. * called after the compuation is performed
  127383. */
  127384. activate(): void;
  127385. /**
  127386. * Deactivates the reduction computation.
  127387. */
  127388. deactivate(): void;
  127389. /**
  127390. * Disposes the depth reducer
  127391. * @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.
  127392. */
  127393. dispose(disposeAll?: boolean): void;
  127394. }
  127395. }
  127396. declare module BABYLON {
  127397. /**
  127398. * A CSM implementation allowing casting shadows on large scenes.
  127399. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127400. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127401. */
  127402. export class CascadedShadowGenerator extends ShadowGenerator {
  127403. private static readonly frustumCornersNDCSpace;
  127404. /**
  127405. * Name of the CSM class
  127406. */
  127407. static CLASSNAME: string;
  127408. /**
  127409. * Defines the default number of cascades used by the CSM.
  127410. */
  127411. static readonly DEFAULT_CASCADES_COUNT: number;
  127412. /**
  127413. * Defines the minimum number of cascades used by the CSM.
  127414. */
  127415. static readonly MIN_CASCADES_COUNT: number;
  127416. /**
  127417. * Defines the maximum number of cascades used by the CSM.
  127418. */
  127419. static readonly MAX_CASCADES_COUNT: number;
  127420. protected _validateFilter(filter: number): number;
  127421. /**
  127422. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127423. */
  127424. penumbraDarkness: number;
  127425. private _numCascades;
  127426. /**
  127427. * Gets or set the number of cascades used by the CSM.
  127428. */
  127429. get numCascades(): number;
  127430. set numCascades(value: number);
  127431. /**
  127432. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127433. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127434. */
  127435. stabilizeCascades: boolean;
  127436. private _freezeShadowCastersBoundingInfo;
  127437. private _freezeShadowCastersBoundingInfoObservable;
  127438. /**
  127439. * Enables or disables the shadow casters bounding info computation.
  127440. * If your shadow casters don't move, you can disable this feature.
  127441. * If it is enabled, the bounding box computation is done every frame.
  127442. */
  127443. get freezeShadowCastersBoundingInfo(): boolean;
  127444. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127445. private _scbiMin;
  127446. private _scbiMax;
  127447. protected _computeShadowCastersBoundingInfo(): void;
  127448. protected _shadowCastersBoundingInfo: BoundingInfo;
  127449. /**
  127450. * Gets or sets the shadow casters bounding info.
  127451. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127452. * so that the system won't overwrite the bounds you provide
  127453. */
  127454. get shadowCastersBoundingInfo(): BoundingInfo;
  127455. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127456. protected _breaksAreDirty: boolean;
  127457. protected _minDistance: number;
  127458. protected _maxDistance: number;
  127459. /**
  127460. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127461. *
  127462. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127463. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127464. * @param min minimal distance for the breaks (default to 0.)
  127465. * @param max maximal distance for the breaks (default to 1.)
  127466. */
  127467. setMinMaxDistance(min: number, max: number): void;
  127468. /** Gets the minimal distance used in the cascade break computation */
  127469. get minDistance(): number;
  127470. /** Gets the maximal distance used in the cascade break computation */
  127471. get maxDistance(): number;
  127472. /**
  127473. * Gets the class name of that object
  127474. * @returns "CascadedShadowGenerator"
  127475. */
  127476. getClassName(): string;
  127477. private _cascadeMinExtents;
  127478. private _cascadeMaxExtents;
  127479. /**
  127480. * Gets a cascade minimum extents
  127481. * @param cascadeIndex index of the cascade
  127482. * @returns the minimum cascade extents
  127483. */
  127484. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127485. /**
  127486. * Gets a cascade maximum extents
  127487. * @param cascadeIndex index of the cascade
  127488. * @returns the maximum cascade extents
  127489. */
  127490. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127491. private _cascades;
  127492. private _currentLayer;
  127493. private _viewSpaceFrustumsZ;
  127494. private _viewMatrices;
  127495. private _projectionMatrices;
  127496. private _transformMatrices;
  127497. private _transformMatricesAsArray;
  127498. private _frustumLengths;
  127499. private _lightSizeUVCorrection;
  127500. private _depthCorrection;
  127501. private _frustumCornersWorldSpace;
  127502. private _frustumCenter;
  127503. private _shadowCameraPos;
  127504. private _shadowMaxZ;
  127505. /**
  127506. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127507. * It defaults to camera.maxZ
  127508. */
  127509. get shadowMaxZ(): number;
  127510. /**
  127511. * Sets the shadow max z distance.
  127512. */
  127513. set shadowMaxZ(value: number);
  127514. protected _debug: boolean;
  127515. /**
  127516. * Gets or sets the debug flag.
  127517. * When enabled, the cascades are materialized by different colors on the screen.
  127518. */
  127519. get debug(): boolean;
  127520. set debug(dbg: boolean);
  127521. private _depthClamp;
  127522. /**
  127523. * Gets or sets the depth clamping value.
  127524. *
  127525. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127526. * to account for the shadow casters far away.
  127527. *
  127528. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127529. */
  127530. get depthClamp(): boolean;
  127531. set depthClamp(value: boolean);
  127532. private _cascadeBlendPercentage;
  127533. /**
  127534. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127535. * It defaults to 0.1 (10% blending).
  127536. */
  127537. get cascadeBlendPercentage(): number;
  127538. set cascadeBlendPercentage(value: number);
  127539. private _lambda;
  127540. /**
  127541. * Gets or set the lambda parameter.
  127542. * This parameter is used to split the camera frustum and create the cascades.
  127543. * 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.
  127544. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127545. */
  127546. get lambda(): number;
  127547. set lambda(value: number);
  127548. /**
  127549. * Gets the view matrix corresponding to a given cascade
  127550. * @param cascadeNum cascade to retrieve the view matrix from
  127551. * @returns the cascade view matrix
  127552. */
  127553. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127554. /**
  127555. * Gets the projection matrix corresponding to a given cascade
  127556. * @param cascadeNum cascade to retrieve the projection matrix from
  127557. * @returns the cascade projection matrix
  127558. */
  127559. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127560. /**
  127561. * Gets the transformation matrix corresponding to a given cascade
  127562. * @param cascadeNum cascade to retrieve the transformation matrix from
  127563. * @returns the cascade transformation matrix
  127564. */
  127565. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127566. private _depthRenderer;
  127567. /**
  127568. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127569. *
  127570. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127571. *
  127572. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127573. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127574. * @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
  127575. */
  127576. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127577. private _depthReducer;
  127578. private _autoCalcDepthBounds;
  127579. /**
  127580. * Gets or sets the autoCalcDepthBounds property.
  127581. *
  127582. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127583. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127584. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127585. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127586. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127587. */
  127588. get autoCalcDepthBounds(): boolean;
  127589. set autoCalcDepthBounds(value: boolean);
  127590. /**
  127591. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127592. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127593. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127594. * for setting the refresh rate on the renderer yourself!
  127595. */
  127596. get autoCalcDepthBoundsRefreshRate(): number;
  127597. set autoCalcDepthBoundsRefreshRate(value: number);
  127598. /**
  127599. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127600. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127601. * you change the camera near/far planes!
  127602. */
  127603. splitFrustum(): void;
  127604. private _splitFrustum;
  127605. private _computeMatrices;
  127606. private _computeFrustumInWorldSpace;
  127607. private _computeCascadeFrustum;
  127608. /** @hidden */
  127609. static _SceneComponentInitialization: (scene: Scene) => void;
  127610. /**
  127611. * Creates a Cascaded Shadow Generator object.
  127612. * A ShadowGenerator is the required tool to use the shadows.
  127613. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127614. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127615. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127616. * @param light The directional light object generating the shadows.
  127617. * @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.
  127618. */
  127619. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127620. protected _initializeGenerator(): void;
  127621. protected _createTargetRenderTexture(): void;
  127622. protected _initializeShadowMap(): void;
  127623. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127624. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127625. /**
  127626. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127627. * @param defines Defines of the material we want to update
  127628. * @param lightIndex Index of the light in the enabled light list of the material
  127629. */
  127630. prepareDefines(defines: any, lightIndex: number): void;
  127631. /**
  127632. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127633. * defined in the generator but impacting the effect).
  127634. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127635. * @param effect The effect we are binfing the information for
  127636. */
  127637. bindShadowLight(lightIndex: string, effect: Effect): void;
  127638. /**
  127639. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127640. * (eq to view projection * shadow projection matrices)
  127641. * @returns The transform matrix used to create the shadow map
  127642. */
  127643. getTransformMatrix(): Matrix;
  127644. /**
  127645. * Disposes the ShadowGenerator.
  127646. * Returns nothing.
  127647. */
  127648. dispose(): void;
  127649. /**
  127650. * Serializes the shadow generator setup to a json object.
  127651. * @returns The serialized JSON object
  127652. */
  127653. serialize(): any;
  127654. /**
  127655. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127656. * @param parsedShadowGenerator The JSON object to parse
  127657. * @param scene The scene to create the shadow map for
  127658. * @returns The parsed shadow generator
  127659. */
  127660. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127661. }
  127662. }
  127663. declare module BABYLON {
  127664. /**
  127665. * Defines the shadow generator component responsible to manage any shadow generators
  127666. * in a given scene.
  127667. */
  127668. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127669. /**
  127670. * The component name helpfull to identify the component in the list of scene components.
  127671. */
  127672. readonly name: string;
  127673. /**
  127674. * The scene the component belongs to.
  127675. */
  127676. scene: Scene;
  127677. /**
  127678. * Creates a new instance of the component for the given scene
  127679. * @param scene Defines the scene to register the component in
  127680. */
  127681. constructor(scene: Scene);
  127682. /**
  127683. * Registers the component in a given scene
  127684. */
  127685. register(): void;
  127686. /**
  127687. * Rebuilds the elements related to this component in case of
  127688. * context lost for instance.
  127689. */
  127690. rebuild(): void;
  127691. /**
  127692. * Serializes the component data to the specified json object
  127693. * @param serializationObject The object to serialize to
  127694. */
  127695. serialize(serializationObject: any): void;
  127696. /**
  127697. * Adds all the elements from the container to the scene
  127698. * @param container the container holding the elements
  127699. */
  127700. addFromContainer(container: AbstractScene): void;
  127701. /**
  127702. * Removes all the elements in the container from the scene
  127703. * @param container contains the elements to remove
  127704. * @param dispose if the removed element should be disposed (default: false)
  127705. */
  127706. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127707. /**
  127708. * Rebuilds the elements related to this component in case of
  127709. * context lost for instance.
  127710. */
  127711. dispose(): void;
  127712. private _gatherRenderTargets;
  127713. }
  127714. }
  127715. declare module BABYLON {
  127716. /**
  127717. * A point light is a light defined by an unique point in world space.
  127718. * The light is emitted in every direction from this point.
  127719. * A good example of a point light is a standard light bulb.
  127720. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127721. */
  127722. export class PointLight extends ShadowLight {
  127723. private _shadowAngle;
  127724. /**
  127725. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127726. * This specifies what angle the shadow will use to be created.
  127727. *
  127728. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127729. */
  127730. get shadowAngle(): number;
  127731. /**
  127732. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127733. * This specifies what angle the shadow will use to be created.
  127734. *
  127735. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127736. */
  127737. set shadowAngle(value: number);
  127738. /**
  127739. * Gets the direction if it has been set.
  127740. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127741. */
  127742. get direction(): Vector3;
  127743. /**
  127744. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127745. */
  127746. set direction(value: Vector3);
  127747. /**
  127748. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127749. * A PointLight emits the light in every direction.
  127750. * It can cast shadows.
  127751. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127752. * ```javascript
  127753. * var pointLight = new PointLight("pl", camera.position, scene);
  127754. * ```
  127755. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127756. * @param name The light friendly name
  127757. * @param position The position of the point light in the scene
  127758. * @param scene The scene the lights belongs to
  127759. */
  127760. constructor(name: string, position: Vector3, scene: Scene);
  127761. /**
  127762. * Returns the string "PointLight"
  127763. * @returns the class name
  127764. */
  127765. getClassName(): string;
  127766. /**
  127767. * Returns the integer 0.
  127768. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127769. */
  127770. getTypeID(): number;
  127771. /**
  127772. * Specifies wether or not the shadowmap should be a cube texture.
  127773. * @returns true if the shadowmap needs to be a cube texture.
  127774. */
  127775. needCube(): boolean;
  127776. /**
  127777. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127778. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127779. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127780. */
  127781. getShadowDirection(faceIndex?: number): Vector3;
  127782. /**
  127783. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127784. * - fov = PI / 2
  127785. * - aspect ratio : 1.0
  127786. * - z-near and far equal to the active camera minZ and maxZ.
  127787. * Returns the PointLight.
  127788. */
  127789. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127790. protected _buildUniformLayout(): void;
  127791. /**
  127792. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127793. * @param effect The effect to update
  127794. * @param lightIndex The index of the light in the effect to update
  127795. * @returns The point light
  127796. */
  127797. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127798. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127799. /**
  127800. * Prepares the list of defines specific to the light type.
  127801. * @param defines the list of defines
  127802. * @param lightIndex defines the index of the light for the effect
  127803. */
  127804. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127805. }
  127806. }
  127807. declare module BABYLON {
  127808. /**
  127809. * Header information of HDR texture files.
  127810. */
  127811. export interface HDRInfo {
  127812. /**
  127813. * The height of the texture in pixels.
  127814. */
  127815. height: number;
  127816. /**
  127817. * The width of the texture in pixels.
  127818. */
  127819. width: number;
  127820. /**
  127821. * The index of the beginning of the data in the binary file.
  127822. */
  127823. dataPosition: number;
  127824. }
  127825. /**
  127826. * This groups tools to convert HDR texture to native colors array.
  127827. */
  127828. export class HDRTools {
  127829. private static Ldexp;
  127830. private static Rgbe2float;
  127831. private static readStringLine;
  127832. /**
  127833. * Reads header information from an RGBE texture stored in a native array.
  127834. * More information on this format are available here:
  127835. * https://en.wikipedia.org/wiki/RGBE_image_format
  127836. *
  127837. * @param uint8array The binary file stored in native array.
  127838. * @return The header information.
  127839. */
  127840. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127841. /**
  127842. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127843. * This RGBE texture needs to store the information as a panorama.
  127844. *
  127845. * More information on this format are available here:
  127846. * https://en.wikipedia.org/wiki/RGBE_image_format
  127847. *
  127848. * @param buffer The binary file stored in an array buffer.
  127849. * @param size The expected size of the extracted cubemap.
  127850. * @return The Cube Map information.
  127851. */
  127852. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127853. /**
  127854. * Returns the pixels data extracted from an RGBE texture.
  127855. * This pixels will be stored left to right up to down in the R G B order in one array.
  127856. *
  127857. * More information on this format are available here:
  127858. * https://en.wikipedia.org/wiki/RGBE_image_format
  127859. *
  127860. * @param uint8array The binary file stored in an array buffer.
  127861. * @param hdrInfo The header information of the file.
  127862. * @return The pixels data in RGB right to left up to down order.
  127863. */
  127864. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127865. private static RGBE_ReadPixels_RLE;
  127866. }
  127867. }
  127868. declare module BABYLON {
  127869. /**
  127870. * This represents a texture coming from an HDR input.
  127871. *
  127872. * The only supported format is currently panorama picture stored in RGBE format.
  127873. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127874. */
  127875. export class HDRCubeTexture extends BaseTexture {
  127876. private static _facesMapping;
  127877. private _generateHarmonics;
  127878. private _noMipmap;
  127879. private _textureMatrix;
  127880. private _size;
  127881. private _onLoad;
  127882. private _onError;
  127883. /**
  127884. * The texture URL.
  127885. */
  127886. url: string;
  127887. /**
  127888. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127889. */
  127890. coordinatesMode: number;
  127891. protected _isBlocking: boolean;
  127892. /**
  127893. * Sets wether or not the texture is blocking during loading.
  127894. */
  127895. set isBlocking(value: boolean);
  127896. /**
  127897. * Gets wether or not the texture is blocking during loading.
  127898. */
  127899. get isBlocking(): boolean;
  127900. protected _rotationY: number;
  127901. /**
  127902. * Sets texture matrix rotation angle around Y axis in radians.
  127903. */
  127904. set rotationY(value: number);
  127905. /**
  127906. * Gets texture matrix rotation angle around Y axis radians.
  127907. */
  127908. get rotationY(): number;
  127909. /**
  127910. * Gets or sets the center of the bounding box associated with the cube texture
  127911. * It must define where the camera used to render the texture was set
  127912. */
  127913. boundingBoxPosition: Vector3;
  127914. private _boundingBoxSize;
  127915. /**
  127916. * Gets or sets the size of the bounding box associated with the cube texture
  127917. * When defined, the cubemap will switch to local mode
  127918. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127919. * @example https://www.babylonjs-playground.com/#RNASML
  127920. */
  127921. set boundingBoxSize(value: Vector3);
  127922. get boundingBoxSize(): Vector3;
  127923. /**
  127924. * Instantiates an HDRTexture from the following parameters.
  127925. *
  127926. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127927. * @param scene The scene the texture will be used in
  127928. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127929. * @param noMipmap Forces to not generate the mipmap if true
  127930. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127931. * @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)
  127932. * @param reserved Reserved flag for internal use.
  127933. */
  127934. 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>);
  127935. /**
  127936. * Get the current class name of the texture useful for serialization or dynamic coding.
  127937. * @returns "HDRCubeTexture"
  127938. */
  127939. getClassName(): string;
  127940. /**
  127941. * Occurs when the file is raw .hdr file.
  127942. */
  127943. private loadTexture;
  127944. clone(): HDRCubeTexture;
  127945. delayLoad(): void;
  127946. /**
  127947. * Get the texture reflection matrix used to rotate/transform the reflection.
  127948. * @returns the reflection matrix
  127949. */
  127950. getReflectionTextureMatrix(): Matrix;
  127951. /**
  127952. * Set the texture reflection matrix used to rotate/transform the reflection.
  127953. * @param value Define the reflection matrix to set
  127954. */
  127955. setReflectionTextureMatrix(value: Matrix): void;
  127956. /**
  127957. * Parses a JSON representation of an HDR Texture in order to create the texture
  127958. * @param parsedTexture Define the JSON representation
  127959. * @param scene Define the scene the texture should be created in
  127960. * @param rootUrl Define the root url in case we need to load relative dependencies
  127961. * @returns the newly created texture after parsing
  127962. */
  127963. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127964. serialize(): any;
  127965. }
  127966. }
  127967. declare module BABYLON {
  127968. /**
  127969. * Class used to control physics engine
  127970. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127971. */
  127972. export class PhysicsEngine implements IPhysicsEngine {
  127973. private _physicsPlugin;
  127974. /**
  127975. * Global value used to control the smallest number supported by the simulation
  127976. */
  127977. static Epsilon: number;
  127978. private _impostors;
  127979. private _joints;
  127980. private _subTimeStep;
  127981. /**
  127982. * Gets the gravity vector used by the simulation
  127983. */
  127984. gravity: Vector3;
  127985. /**
  127986. * Factory used to create the default physics plugin.
  127987. * @returns The default physics plugin
  127988. */
  127989. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127990. /**
  127991. * Creates a new Physics Engine
  127992. * @param gravity defines the gravity vector used by the simulation
  127993. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127994. */
  127995. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127996. /**
  127997. * Sets the gravity vector used by the simulation
  127998. * @param gravity defines the gravity vector to use
  127999. */
  128000. setGravity(gravity: Vector3): void;
  128001. /**
  128002. * Set the time step of the physics engine.
  128003. * Default is 1/60.
  128004. * To slow it down, enter 1/600 for example.
  128005. * To speed it up, 1/30
  128006. * @param newTimeStep defines the new timestep to apply to this world.
  128007. */
  128008. setTimeStep(newTimeStep?: number): void;
  128009. /**
  128010. * Get the time step of the physics engine.
  128011. * @returns the current time step
  128012. */
  128013. getTimeStep(): number;
  128014. /**
  128015. * Set the sub time step of the physics engine.
  128016. * Default is 0 meaning there is no sub steps
  128017. * To increase physics resolution precision, set a small value (like 1 ms)
  128018. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128019. */
  128020. setSubTimeStep(subTimeStep?: number): void;
  128021. /**
  128022. * Get the sub time step of the physics engine.
  128023. * @returns the current sub time step
  128024. */
  128025. getSubTimeStep(): number;
  128026. /**
  128027. * Release all resources
  128028. */
  128029. dispose(): void;
  128030. /**
  128031. * Gets the name of the current physics plugin
  128032. * @returns the name of the plugin
  128033. */
  128034. getPhysicsPluginName(): string;
  128035. /**
  128036. * Adding a new impostor for the impostor tracking.
  128037. * This will be done by the impostor itself.
  128038. * @param impostor the impostor to add
  128039. */
  128040. addImpostor(impostor: PhysicsImpostor): void;
  128041. /**
  128042. * Remove an impostor from the engine.
  128043. * This impostor and its mesh will not longer be updated by the physics engine.
  128044. * @param impostor the impostor to remove
  128045. */
  128046. removeImpostor(impostor: PhysicsImpostor): void;
  128047. /**
  128048. * Add a joint to the physics engine
  128049. * @param mainImpostor defines the main impostor to which the joint is added.
  128050. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128051. * @param joint defines the joint that will connect both impostors.
  128052. */
  128053. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128054. /**
  128055. * Removes a joint from the simulation
  128056. * @param mainImpostor defines the impostor used with the joint
  128057. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128058. * @param joint defines the joint to remove
  128059. */
  128060. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128061. /**
  128062. * Called by the scene. No need to call it.
  128063. * @param delta defines the timespam between frames
  128064. */
  128065. _step(delta: number): void;
  128066. /**
  128067. * Gets the current plugin used to run the simulation
  128068. * @returns current plugin
  128069. */
  128070. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128071. /**
  128072. * Gets the list of physic impostors
  128073. * @returns an array of PhysicsImpostor
  128074. */
  128075. getImpostors(): Array<PhysicsImpostor>;
  128076. /**
  128077. * Gets the impostor for a physics enabled object
  128078. * @param object defines the object impersonated by the impostor
  128079. * @returns the PhysicsImpostor or null if not found
  128080. */
  128081. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128082. /**
  128083. * Gets the impostor for a physics body object
  128084. * @param body defines physics body used by the impostor
  128085. * @returns the PhysicsImpostor or null if not found
  128086. */
  128087. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128088. /**
  128089. * Does a raycast in the physics world
  128090. * @param from when should the ray start?
  128091. * @param to when should the ray end?
  128092. * @returns PhysicsRaycastResult
  128093. */
  128094. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128095. }
  128096. }
  128097. declare module BABYLON {
  128098. /** @hidden */
  128099. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128100. private _useDeltaForWorldStep;
  128101. world: any;
  128102. name: string;
  128103. private _physicsMaterials;
  128104. private _fixedTimeStep;
  128105. private _cannonRaycastResult;
  128106. private _raycastResult;
  128107. private _physicsBodysToRemoveAfterStep;
  128108. BJSCANNON: any;
  128109. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128110. setGravity(gravity: Vector3): void;
  128111. setTimeStep(timeStep: number): void;
  128112. getTimeStep(): number;
  128113. executeStep(delta: number): void;
  128114. private _removeMarkedPhysicsBodiesFromWorld;
  128115. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128116. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128117. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128118. private _processChildMeshes;
  128119. removePhysicsBody(impostor: PhysicsImpostor): void;
  128120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128122. private _addMaterial;
  128123. private _checkWithEpsilon;
  128124. private _createShape;
  128125. private _createHeightmap;
  128126. private _minus90X;
  128127. private _plus90X;
  128128. private _tmpPosition;
  128129. private _tmpDeltaPosition;
  128130. private _tmpUnityRotation;
  128131. private _updatePhysicsBodyTransformation;
  128132. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128133. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128134. isSupported(): boolean;
  128135. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128136. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128138. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128139. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128140. getBodyMass(impostor: PhysicsImpostor): number;
  128141. getBodyFriction(impostor: PhysicsImpostor): number;
  128142. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128143. getBodyRestitution(impostor: PhysicsImpostor): number;
  128144. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128145. sleepBody(impostor: PhysicsImpostor): void;
  128146. wakeUpBody(impostor: PhysicsImpostor): void;
  128147. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128148. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128150. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128151. getRadius(impostor: PhysicsImpostor): number;
  128152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128153. dispose(): void;
  128154. private _extendNamespace;
  128155. /**
  128156. * Does a raycast in the physics world
  128157. * @param from when should the ray start?
  128158. * @param to when should the ray end?
  128159. * @returns PhysicsRaycastResult
  128160. */
  128161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128162. }
  128163. }
  128164. declare module BABYLON {
  128165. /** @hidden */
  128166. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128167. world: any;
  128168. name: string;
  128169. BJSOIMO: any;
  128170. private _raycastResult;
  128171. constructor(iterations?: number, oimoInjection?: any);
  128172. setGravity(gravity: Vector3): void;
  128173. setTimeStep(timeStep: number): void;
  128174. getTimeStep(): number;
  128175. private _tmpImpostorsArray;
  128176. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128177. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128178. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128179. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128180. private _tmpPositionVector;
  128181. removePhysicsBody(impostor: PhysicsImpostor): void;
  128182. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128183. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128184. isSupported(): boolean;
  128185. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128186. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128187. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128188. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128189. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128190. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128191. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128192. getBodyMass(impostor: PhysicsImpostor): number;
  128193. getBodyFriction(impostor: PhysicsImpostor): number;
  128194. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128195. getBodyRestitution(impostor: PhysicsImpostor): number;
  128196. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128197. sleepBody(impostor: PhysicsImpostor): void;
  128198. wakeUpBody(impostor: PhysicsImpostor): void;
  128199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128200. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128203. getRadius(impostor: PhysicsImpostor): number;
  128204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128205. dispose(): void;
  128206. /**
  128207. * Does a raycast in the physics world
  128208. * @param from when should the ray start?
  128209. * @param to when should the ray end?
  128210. * @returns PhysicsRaycastResult
  128211. */
  128212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128213. }
  128214. }
  128215. declare module BABYLON {
  128216. /**
  128217. * Class containing static functions to help procedurally build meshes
  128218. */
  128219. export class RibbonBuilder {
  128220. /**
  128221. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128222. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128223. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128224. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128225. * * 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
  128226. * * 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
  128227. * * 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
  128228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128230. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128231. * * 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
  128232. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128233. * * 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
  128234. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128236. * @param name defines the name of the mesh
  128237. * @param options defines the options used to create the mesh
  128238. * @param scene defines the hosting scene
  128239. * @returns the ribbon mesh
  128240. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128242. */
  128243. static CreateRibbon(name: string, options: {
  128244. pathArray: Vector3[][];
  128245. closeArray?: boolean;
  128246. closePath?: boolean;
  128247. offset?: number;
  128248. updatable?: boolean;
  128249. sideOrientation?: number;
  128250. frontUVs?: Vector4;
  128251. backUVs?: Vector4;
  128252. instance?: Mesh;
  128253. invertUV?: boolean;
  128254. uvs?: Vector2[];
  128255. colors?: Color4[];
  128256. }, scene?: Nullable<Scene>): Mesh;
  128257. }
  128258. }
  128259. declare module BABYLON {
  128260. /**
  128261. * Class containing static functions to help procedurally build meshes
  128262. */
  128263. export class ShapeBuilder {
  128264. /**
  128265. * 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.
  128266. * * 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.
  128267. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128268. * * 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.
  128269. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128270. * * 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
  128271. * * 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
  128272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128277. * @param name defines the name of the mesh
  128278. * @param options defines the options used to create the mesh
  128279. * @param scene defines the hosting scene
  128280. * @returns the extruded shape mesh
  128281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128283. */
  128284. static ExtrudeShape(name: string, options: {
  128285. shape: Vector3[];
  128286. path: Vector3[];
  128287. scale?: number;
  128288. rotation?: number;
  128289. cap?: number;
  128290. updatable?: boolean;
  128291. sideOrientation?: number;
  128292. frontUVs?: Vector4;
  128293. backUVs?: Vector4;
  128294. instance?: Mesh;
  128295. invertUV?: boolean;
  128296. }, scene?: Nullable<Scene>): Mesh;
  128297. /**
  128298. * Creates an custom extruded shape mesh.
  128299. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128300. * * 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.
  128301. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128302. * * 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
  128303. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128304. * * 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
  128305. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128306. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128307. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128308. * * 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
  128309. * * 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
  128310. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128315. * @param name defines the name of the mesh
  128316. * @param options defines the options used to create the mesh
  128317. * @param scene defines the hosting scene
  128318. * @returns the custom extruded shape mesh
  128319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128322. */
  128323. static ExtrudeShapeCustom(name: string, options: {
  128324. shape: Vector3[];
  128325. path: Vector3[];
  128326. scaleFunction?: any;
  128327. rotationFunction?: any;
  128328. ribbonCloseArray?: boolean;
  128329. ribbonClosePath?: boolean;
  128330. cap?: number;
  128331. updatable?: boolean;
  128332. sideOrientation?: number;
  128333. frontUVs?: Vector4;
  128334. backUVs?: Vector4;
  128335. instance?: Mesh;
  128336. invertUV?: boolean;
  128337. }, scene?: Nullable<Scene>): Mesh;
  128338. private static _ExtrudeShapeGeneric;
  128339. }
  128340. }
  128341. declare module BABYLON {
  128342. /**
  128343. * AmmoJS Physics plugin
  128344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128345. * @see https://github.com/kripken/ammo.js/
  128346. */
  128347. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128348. private _useDeltaForWorldStep;
  128349. /**
  128350. * Reference to the Ammo library
  128351. */
  128352. bjsAMMO: any;
  128353. /**
  128354. * Created ammoJS world which physics bodies are added to
  128355. */
  128356. world: any;
  128357. /**
  128358. * Name of the plugin
  128359. */
  128360. name: string;
  128361. private _timeStep;
  128362. private _fixedTimeStep;
  128363. private _maxSteps;
  128364. private _tmpQuaternion;
  128365. private _tmpAmmoTransform;
  128366. private _tmpAmmoQuaternion;
  128367. private _tmpAmmoConcreteContactResultCallback;
  128368. private _collisionConfiguration;
  128369. private _dispatcher;
  128370. private _overlappingPairCache;
  128371. private _solver;
  128372. private _softBodySolver;
  128373. private _tmpAmmoVectorA;
  128374. private _tmpAmmoVectorB;
  128375. private _tmpAmmoVectorC;
  128376. private _tmpAmmoVectorD;
  128377. private _tmpContactCallbackResult;
  128378. private _tmpAmmoVectorRCA;
  128379. private _tmpAmmoVectorRCB;
  128380. private _raycastResult;
  128381. private static readonly DISABLE_COLLISION_FLAG;
  128382. private static readonly KINEMATIC_FLAG;
  128383. private static readonly DISABLE_DEACTIVATION_FLAG;
  128384. /**
  128385. * Initializes the ammoJS plugin
  128386. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128387. * @param ammoInjection can be used to inject your own ammo reference
  128388. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128389. */
  128390. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128391. /**
  128392. * Sets the gravity of the physics world (m/(s^2))
  128393. * @param gravity Gravity to set
  128394. */
  128395. setGravity(gravity: Vector3): void;
  128396. /**
  128397. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128398. * @param timeStep timestep to use in seconds
  128399. */
  128400. setTimeStep(timeStep: number): void;
  128401. /**
  128402. * 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)
  128403. * @param fixedTimeStep fixedTimeStep to use in seconds
  128404. */
  128405. setFixedTimeStep(fixedTimeStep: number): void;
  128406. /**
  128407. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128408. * @param maxSteps the maximum number of steps by the physics engine per frame
  128409. */
  128410. setMaxSteps(maxSteps: number): void;
  128411. /**
  128412. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128413. * @returns the current timestep in seconds
  128414. */
  128415. getTimeStep(): number;
  128416. /**
  128417. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128418. */
  128419. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128420. private _isImpostorInContact;
  128421. private _isImpostorPairInContact;
  128422. private _stepSimulation;
  128423. /**
  128424. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128425. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128426. * After the step the babylon meshes are set to the position of the physics imposters
  128427. * @param delta amount of time to step forward
  128428. * @param impostors array of imposters to update before/after the step
  128429. */
  128430. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128431. /**
  128432. * Update babylon mesh to match physics world object
  128433. * @param impostor imposter to match
  128434. */
  128435. private _afterSoftStep;
  128436. /**
  128437. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128438. * @param impostor imposter to match
  128439. */
  128440. private _ropeStep;
  128441. /**
  128442. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128443. * @param impostor imposter to match
  128444. */
  128445. private _softbodyOrClothStep;
  128446. private _tmpVector;
  128447. private _tmpMatrix;
  128448. /**
  128449. * Applies an impulse on the imposter
  128450. * @param impostor imposter to apply impulse to
  128451. * @param force amount of force to be applied to the imposter
  128452. * @param contactPoint the location to apply the impulse on the imposter
  128453. */
  128454. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128455. /**
  128456. * Applies a force on the imposter
  128457. * @param impostor imposter to apply force
  128458. * @param force amount of force to be applied to the imposter
  128459. * @param contactPoint the location to apply the force on the imposter
  128460. */
  128461. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128462. /**
  128463. * Creates a physics body using the plugin
  128464. * @param impostor the imposter to create the physics body on
  128465. */
  128466. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128467. /**
  128468. * Removes the physics body from the imposter and disposes of the body's memory
  128469. * @param impostor imposter to remove the physics body from
  128470. */
  128471. removePhysicsBody(impostor: PhysicsImpostor): void;
  128472. /**
  128473. * Generates a joint
  128474. * @param impostorJoint the imposter joint to create the joint with
  128475. */
  128476. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128477. /**
  128478. * Removes a joint
  128479. * @param impostorJoint the imposter joint to remove the joint from
  128480. */
  128481. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128482. private _addMeshVerts;
  128483. /**
  128484. * Initialise the soft body vertices to match its object's (mesh) vertices
  128485. * Softbody vertices (nodes) are in world space and to match this
  128486. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128487. * @param impostor to create the softbody for
  128488. */
  128489. private _softVertexData;
  128490. /**
  128491. * Create an impostor's soft body
  128492. * @param impostor to create the softbody for
  128493. */
  128494. private _createSoftbody;
  128495. /**
  128496. * Create cloth for an impostor
  128497. * @param impostor to create the softbody for
  128498. */
  128499. private _createCloth;
  128500. /**
  128501. * Create rope for an impostor
  128502. * @param impostor to create the softbody for
  128503. */
  128504. private _createRope;
  128505. /**
  128506. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128507. * @param impostor to create the custom physics shape for
  128508. */
  128509. private _createCustom;
  128510. private _addHullVerts;
  128511. private _createShape;
  128512. /**
  128513. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128514. * @param impostor imposter containing the physics body and babylon object
  128515. */
  128516. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128517. /**
  128518. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128519. * @param impostor imposter containing the physics body and babylon object
  128520. * @param newPosition new position
  128521. * @param newRotation new rotation
  128522. */
  128523. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128524. /**
  128525. * If this plugin is supported
  128526. * @returns true if its supported
  128527. */
  128528. isSupported(): boolean;
  128529. /**
  128530. * Sets the linear velocity of the physics body
  128531. * @param impostor imposter to set the velocity on
  128532. * @param velocity velocity to set
  128533. */
  128534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128535. /**
  128536. * Sets the angular velocity of the physics body
  128537. * @param impostor imposter to set the velocity on
  128538. * @param velocity velocity to set
  128539. */
  128540. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128541. /**
  128542. * gets the linear velocity
  128543. * @param impostor imposter to get linear velocity from
  128544. * @returns linear velocity
  128545. */
  128546. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128547. /**
  128548. * gets the angular velocity
  128549. * @param impostor imposter to get angular velocity from
  128550. * @returns angular velocity
  128551. */
  128552. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128553. /**
  128554. * Sets the mass of physics body
  128555. * @param impostor imposter to set the mass on
  128556. * @param mass mass to set
  128557. */
  128558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128559. /**
  128560. * Gets the mass of the physics body
  128561. * @param impostor imposter to get the mass from
  128562. * @returns mass
  128563. */
  128564. getBodyMass(impostor: PhysicsImpostor): number;
  128565. /**
  128566. * Gets friction of the impostor
  128567. * @param impostor impostor to get friction from
  128568. * @returns friction value
  128569. */
  128570. getBodyFriction(impostor: PhysicsImpostor): number;
  128571. /**
  128572. * Sets friction of the impostor
  128573. * @param impostor impostor to set friction on
  128574. * @param friction friction value
  128575. */
  128576. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128577. /**
  128578. * Gets restitution of the impostor
  128579. * @param impostor impostor to get restitution from
  128580. * @returns restitution value
  128581. */
  128582. getBodyRestitution(impostor: PhysicsImpostor): number;
  128583. /**
  128584. * Sets resitution of the impostor
  128585. * @param impostor impostor to set resitution on
  128586. * @param restitution resitution value
  128587. */
  128588. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128589. /**
  128590. * Gets pressure inside the impostor
  128591. * @param impostor impostor to get pressure from
  128592. * @returns pressure value
  128593. */
  128594. getBodyPressure(impostor: PhysicsImpostor): number;
  128595. /**
  128596. * Sets pressure inside a soft body impostor
  128597. * Cloth and rope must remain 0 pressure
  128598. * @param impostor impostor to set pressure on
  128599. * @param pressure pressure value
  128600. */
  128601. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128602. /**
  128603. * Gets stiffness of the impostor
  128604. * @param impostor impostor to get stiffness from
  128605. * @returns pressure value
  128606. */
  128607. getBodyStiffness(impostor: PhysicsImpostor): number;
  128608. /**
  128609. * Sets stiffness of the impostor
  128610. * @param impostor impostor to set stiffness on
  128611. * @param stiffness stiffness value from 0 to 1
  128612. */
  128613. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128614. /**
  128615. * Gets velocityIterations of the impostor
  128616. * @param impostor impostor to get velocity iterations from
  128617. * @returns velocityIterations value
  128618. */
  128619. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128620. /**
  128621. * Sets velocityIterations of the impostor
  128622. * @param impostor impostor to set velocity iterations on
  128623. * @param velocityIterations velocityIterations value
  128624. */
  128625. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128626. /**
  128627. * Gets positionIterations of the impostor
  128628. * @param impostor impostor to get position iterations from
  128629. * @returns positionIterations value
  128630. */
  128631. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128632. /**
  128633. * Sets positionIterations of the impostor
  128634. * @param impostor impostor to set position on
  128635. * @param positionIterations positionIterations value
  128636. */
  128637. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128638. /**
  128639. * Append an anchor to a cloth object
  128640. * @param impostor is the cloth impostor to add anchor to
  128641. * @param otherImpostor is the rigid impostor to anchor to
  128642. * @param width ratio across width from 0 to 1
  128643. * @param height ratio up height from 0 to 1
  128644. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128645. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128646. */
  128647. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128648. /**
  128649. * Append an hook to a rope object
  128650. * @param impostor is the rope impostor to add hook to
  128651. * @param otherImpostor is the rigid impostor to hook to
  128652. * @param length ratio along the rope from 0 to 1
  128653. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128654. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128655. */
  128656. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128657. /**
  128658. * Sleeps the physics body and stops it from being active
  128659. * @param impostor impostor to sleep
  128660. */
  128661. sleepBody(impostor: PhysicsImpostor): void;
  128662. /**
  128663. * Activates the physics body
  128664. * @param impostor impostor to activate
  128665. */
  128666. wakeUpBody(impostor: PhysicsImpostor): void;
  128667. /**
  128668. * Updates the distance parameters of the joint
  128669. * @param joint joint to update
  128670. * @param maxDistance maximum distance of the joint
  128671. * @param minDistance minimum distance of the joint
  128672. */
  128673. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128674. /**
  128675. * Sets a motor on the joint
  128676. * @param joint joint to set motor on
  128677. * @param speed speed of the motor
  128678. * @param maxForce maximum force of the motor
  128679. * @param motorIndex index of the motor
  128680. */
  128681. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128682. /**
  128683. * Sets the motors limit
  128684. * @param joint joint to set limit on
  128685. * @param upperLimit upper limit
  128686. * @param lowerLimit lower limit
  128687. */
  128688. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128689. /**
  128690. * Syncs the position and rotation of a mesh with the impostor
  128691. * @param mesh mesh to sync
  128692. * @param impostor impostor to update the mesh with
  128693. */
  128694. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128695. /**
  128696. * Gets the radius of the impostor
  128697. * @param impostor impostor to get radius from
  128698. * @returns the radius
  128699. */
  128700. getRadius(impostor: PhysicsImpostor): number;
  128701. /**
  128702. * Gets the box size of the impostor
  128703. * @param impostor impostor to get box size from
  128704. * @param result the resulting box size
  128705. */
  128706. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128707. /**
  128708. * Disposes of the impostor
  128709. */
  128710. dispose(): void;
  128711. /**
  128712. * Does a raycast in the physics world
  128713. * @param from when should the ray start?
  128714. * @param to when should the ray end?
  128715. * @returns PhysicsRaycastResult
  128716. */
  128717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128718. }
  128719. }
  128720. declare module BABYLON {
  128721. interface AbstractScene {
  128722. /**
  128723. * The list of reflection probes added to the scene
  128724. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128725. */
  128726. reflectionProbes: Array<ReflectionProbe>;
  128727. /**
  128728. * Removes the given reflection probe from this scene.
  128729. * @param toRemove The reflection probe to remove
  128730. * @returns The index of the removed reflection probe
  128731. */
  128732. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128733. /**
  128734. * Adds the given reflection probe to this scene.
  128735. * @param newReflectionProbe The reflection probe to add
  128736. */
  128737. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128738. }
  128739. /**
  128740. * Class used to generate realtime reflection / refraction cube textures
  128741. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128742. */
  128743. export class ReflectionProbe {
  128744. /** defines the name of the probe */
  128745. name: string;
  128746. private _scene;
  128747. private _renderTargetTexture;
  128748. private _projectionMatrix;
  128749. private _viewMatrix;
  128750. private _target;
  128751. private _add;
  128752. private _attachedMesh;
  128753. private _invertYAxis;
  128754. /** Gets or sets probe position (center of the cube map) */
  128755. position: Vector3;
  128756. /**
  128757. * Creates a new reflection probe
  128758. * @param name defines the name of the probe
  128759. * @param size defines the texture resolution (for each face)
  128760. * @param scene defines the hosting scene
  128761. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128762. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128763. */
  128764. constructor(
  128765. /** defines the name of the probe */
  128766. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128767. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128768. get samples(): number;
  128769. set samples(value: number);
  128770. /** Gets or sets the refresh rate to use (on every frame by default) */
  128771. get refreshRate(): number;
  128772. set refreshRate(value: number);
  128773. /**
  128774. * Gets the hosting scene
  128775. * @returns a Scene
  128776. */
  128777. getScene(): Scene;
  128778. /** Gets the internal CubeTexture used to render to */
  128779. get cubeTexture(): RenderTargetTexture;
  128780. /** Gets the list of meshes to render */
  128781. get renderList(): Nullable<AbstractMesh[]>;
  128782. /**
  128783. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128784. * @param mesh defines the mesh to attach to
  128785. */
  128786. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128787. /**
  128788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128789. * @param renderingGroupId The rendering group id corresponding to its index
  128790. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128791. */
  128792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128793. /**
  128794. * Clean all associated resources
  128795. */
  128796. dispose(): void;
  128797. /**
  128798. * Converts the reflection probe information to a readable string for debug purpose.
  128799. * @param fullDetails Supports for multiple levels of logging within scene loading
  128800. * @returns the human readable reflection probe info
  128801. */
  128802. toString(fullDetails?: boolean): string;
  128803. /**
  128804. * Get the class name of the relfection probe.
  128805. * @returns "ReflectionProbe"
  128806. */
  128807. getClassName(): string;
  128808. /**
  128809. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128810. * @returns The JSON representation of the texture
  128811. */
  128812. serialize(): any;
  128813. /**
  128814. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128815. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128816. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128817. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128818. * @returns The parsed reflection probe if successful
  128819. */
  128820. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128821. }
  128822. }
  128823. declare module BABYLON {
  128824. /** @hidden */
  128825. export var _BabylonLoaderRegistered: boolean;
  128826. /**
  128827. * Helps setting up some configuration for the babylon file loader.
  128828. */
  128829. export class BabylonFileLoaderConfiguration {
  128830. /**
  128831. * The loader does not allow injecting custom physix engine into the plugins.
  128832. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128833. * So you could set this variable to your engine import to make it work.
  128834. */
  128835. static LoaderInjectedPhysicsEngine: any;
  128836. }
  128837. }
  128838. declare module BABYLON {
  128839. /**
  128840. * The Physically based simple base material of BJS.
  128841. *
  128842. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128843. * It is used as the base class for both the specGloss and metalRough conventions.
  128844. */
  128845. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128846. /**
  128847. * Number of Simultaneous lights allowed on the material.
  128848. */
  128849. maxSimultaneousLights: number;
  128850. /**
  128851. * If sets to true, disables all the lights affecting the material.
  128852. */
  128853. disableLighting: boolean;
  128854. /**
  128855. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128856. */
  128857. environmentTexture: BaseTexture;
  128858. /**
  128859. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128860. */
  128861. invertNormalMapX: boolean;
  128862. /**
  128863. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128864. */
  128865. invertNormalMapY: boolean;
  128866. /**
  128867. * Normal map used in the model.
  128868. */
  128869. normalTexture: BaseTexture;
  128870. /**
  128871. * Emissivie color used to self-illuminate the model.
  128872. */
  128873. emissiveColor: Color3;
  128874. /**
  128875. * Emissivie texture used to self-illuminate the model.
  128876. */
  128877. emissiveTexture: BaseTexture;
  128878. /**
  128879. * Occlusion Channel Strenght.
  128880. */
  128881. occlusionStrength: number;
  128882. /**
  128883. * Occlusion Texture of the material (adding extra occlusion effects).
  128884. */
  128885. occlusionTexture: BaseTexture;
  128886. /**
  128887. * Defines the alpha limits in alpha test mode.
  128888. */
  128889. alphaCutOff: number;
  128890. /**
  128891. * Gets the current double sided mode.
  128892. */
  128893. get doubleSided(): boolean;
  128894. /**
  128895. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128896. */
  128897. set doubleSided(value: boolean);
  128898. /**
  128899. * Stores the pre-calculated light information of a mesh in a texture.
  128900. */
  128901. lightmapTexture: BaseTexture;
  128902. /**
  128903. * If true, the light map contains occlusion information instead of lighting info.
  128904. */
  128905. useLightmapAsShadowmap: boolean;
  128906. /**
  128907. * Instantiates a new PBRMaterial instance.
  128908. *
  128909. * @param name The material name
  128910. * @param scene The scene the material will be use in.
  128911. */
  128912. constructor(name: string, scene: Scene);
  128913. getClassName(): string;
  128914. }
  128915. }
  128916. declare module BABYLON {
  128917. /**
  128918. * The PBR material of BJS following the metal roughness convention.
  128919. *
  128920. * This fits to the PBR convention in the GLTF definition:
  128921. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128922. */
  128923. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128924. /**
  128925. * The base color has two different interpretations depending on the value of metalness.
  128926. * When the material is a metal, the base color is the specific measured reflectance value
  128927. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128928. * of the material.
  128929. */
  128930. baseColor: Color3;
  128931. /**
  128932. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128933. * well as opacity information in the alpha channel.
  128934. */
  128935. baseTexture: BaseTexture;
  128936. /**
  128937. * Specifies the metallic scalar value of the material.
  128938. * Can also be used to scale the metalness values of the metallic texture.
  128939. */
  128940. metallic: number;
  128941. /**
  128942. * Specifies the roughness scalar value of the material.
  128943. * Can also be used to scale the roughness values of the metallic texture.
  128944. */
  128945. roughness: number;
  128946. /**
  128947. * Texture containing both the metallic value in the B channel and the
  128948. * roughness value in the G channel to keep better precision.
  128949. */
  128950. metallicRoughnessTexture: BaseTexture;
  128951. /**
  128952. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128953. *
  128954. * @param name The material name
  128955. * @param scene The scene the material will be use in.
  128956. */
  128957. constructor(name: string, scene: Scene);
  128958. /**
  128959. * Return the currrent class name of the material.
  128960. */
  128961. getClassName(): string;
  128962. /**
  128963. * Makes a duplicate of the current material.
  128964. * @param name - name to use for the new material.
  128965. */
  128966. clone(name: string): PBRMetallicRoughnessMaterial;
  128967. /**
  128968. * Serialize the material to a parsable JSON object.
  128969. */
  128970. serialize(): any;
  128971. /**
  128972. * Parses a JSON object correponding to the serialize function.
  128973. */
  128974. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128975. }
  128976. }
  128977. declare module BABYLON {
  128978. /**
  128979. * The PBR material of BJS following the specular glossiness convention.
  128980. *
  128981. * This fits to the PBR convention in the GLTF definition:
  128982. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128983. */
  128984. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128985. /**
  128986. * Specifies the diffuse color of the material.
  128987. */
  128988. diffuseColor: Color3;
  128989. /**
  128990. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128991. * channel.
  128992. */
  128993. diffuseTexture: BaseTexture;
  128994. /**
  128995. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128996. */
  128997. specularColor: Color3;
  128998. /**
  128999. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129000. */
  129001. glossiness: number;
  129002. /**
  129003. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129004. */
  129005. specularGlossinessTexture: BaseTexture;
  129006. /**
  129007. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129008. *
  129009. * @param name The material name
  129010. * @param scene The scene the material will be use in.
  129011. */
  129012. constructor(name: string, scene: Scene);
  129013. /**
  129014. * Return the currrent class name of the material.
  129015. */
  129016. getClassName(): string;
  129017. /**
  129018. * Makes a duplicate of the current material.
  129019. * @param name - name to use for the new material.
  129020. */
  129021. clone(name: string): PBRSpecularGlossinessMaterial;
  129022. /**
  129023. * Serialize the material to a parsable JSON object.
  129024. */
  129025. serialize(): any;
  129026. /**
  129027. * Parses a JSON object correponding to the serialize function.
  129028. */
  129029. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129030. }
  129031. }
  129032. declare module BABYLON {
  129033. /**
  129034. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129035. * It can help converting any input color in a desired output one. This can then be used to create effects
  129036. * from sepia, black and white to sixties or futuristic rendering...
  129037. *
  129038. * The only supported format is currently 3dl.
  129039. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129040. */
  129041. export class ColorGradingTexture extends BaseTexture {
  129042. /**
  129043. * The current texture matrix. (will always be identity in color grading texture)
  129044. */
  129045. private _textureMatrix;
  129046. /**
  129047. * The texture URL.
  129048. */
  129049. url: string;
  129050. /**
  129051. * Empty line regex stored for GC.
  129052. */
  129053. private static _noneEmptyLineRegex;
  129054. private _engine;
  129055. /**
  129056. * Instantiates a ColorGradingTexture from the following parameters.
  129057. *
  129058. * @param url The location of the color gradind data (currently only supporting 3dl)
  129059. * @param scene The scene the texture will be used in
  129060. */
  129061. constructor(url: string, scene: Scene);
  129062. /**
  129063. * Returns the texture matrix used in most of the material.
  129064. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129065. */
  129066. getTextureMatrix(): Matrix;
  129067. /**
  129068. * Occurs when the file being loaded is a .3dl LUT file.
  129069. */
  129070. private load3dlTexture;
  129071. /**
  129072. * Starts the loading process of the texture.
  129073. */
  129074. private loadTexture;
  129075. /**
  129076. * Clones the color gradind texture.
  129077. */
  129078. clone(): ColorGradingTexture;
  129079. /**
  129080. * Called during delayed load for textures.
  129081. */
  129082. delayLoad(): void;
  129083. /**
  129084. * Parses a color grading texture serialized by Babylon.
  129085. * @param parsedTexture The texture information being parsedTexture
  129086. * @param scene The scene to load the texture in
  129087. * @param rootUrl The root url of the data assets to load
  129088. * @return A color gradind texture
  129089. */
  129090. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129091. /**
  129092. * Serializes the LUT texture to json format.
  129093. */
  129094. serialize(): any;
  129095. }
  129096. }
  129097. declare module BABYLON {
  129098. /**
  129099. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129100. */
  129101. export class EquiRectangularCubeTexture extends BaseTexture {
  129102. /** The six faces of the cube. */
  129103. private static _FacesMapping;
  129104. private _noMipmap;
  129105. private _onLoad;
  129106. private _onError;
  129107. /** The size of the cubemap. */
  129108. private _size;
  129109. /** The buffer of the image. */
  129110. private _buffer;
  129111. /** The width of the input image. */
  129112. private _width;
  129113. /** The height of the input image. */
  129114. private _height;
  129115. /** The URL to the image. */
  129116. url: string;
  129117. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129118. coordinatesMode: number;
  129119. /**
  129120. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129121. * @param url The location of the image
  129122. * @param scene The scene the texture will be used in
  129123. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129124. * @param noMipmap Forces to not generate the mipmap if true
  129125. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129126. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129127. * @param onLoad — defines a callback called when texture is loaded
  129128. * @param onError — defines a callback called if there is an error
  129129. */
  129130. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129131. /**
  129132. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129133. */
  129134. private loadImage;
  129135. /**
  129136. * Convert the image buffer into a cubemap and create a CubeTexture.
  129137. */
  129138. private loadTexture;
  129139. /**
  129140. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129141. * @param buffer The ArrayBuffer that should be converted.
  129142. * @returns The buffer as Float32Array.
  129143. */
  129144. private getFloat32ArrayFromArrayBuffer;
  129145. /**
  129146. * Get the current class name of the texture useful for serialization or dynamic coding.
  129147. * @returns "EquiRectangularCubeTexture"
  129148. */
  129149. getClassName(): string;
  129150. /**
  129151. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129152. * @returns A clone of the current EquiRectangularCubeTexture.
  129153. */
  129154. clone(): EquiRectangularCubeTexture;
  129155. }
  129156. }
  129157. declare module BABYLON {
  129158. /**
  129159. * Based on jsTGALoader - Javascript loader for TGA file
  129160. * By Vincent Thibault
  129161. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129162. */
  129163. export class TGATools {
  129164. private static _TYPE_INDEXED;
  129165. private static _TYPE_RGB;
  129166. private static _TYPE_GREY;
  129167. private static _TYPE_RLE_INDEXED;
  129168. private static _TYPE_RLE_RGB;
  129169. private static _TYPE_RLE_GREY;
  129170. private static _ORIGIN_MASK;
  129171. private static _ORIGIN_SHIFT;
  129172. private static _ORIGIN_BL;
  129173. private static _ORIGIN_BR;
  129174. private static _ORIGIN_UL;
  129175. private static _ORIGIN_UR;
  129176. /**
  129177. * Gets the header of a TGA file
  129178. * @param data defines the TGA data
  129179. * @returns the header
  129180. */
  129181. static GetTGAHeader(data: Uint8Array): any;
  129182. /**
  129183. * Uploads TGA content to a Babylon Texture
  129184. * @hidden
  129185. */
  129186. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129187. /** @hidden */
  129188. 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;
  129189. /** @hidden */
  129190. 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;
  129191. /** @hidden */
  129192. 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;
  129193. /** @hidden */
  129194. 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;
  129195. /** @hidden */
  129196. 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;
  129197. /** @hidden */
  129198. 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;
  129199. }
  129200. }
  129201. declare module BABYLON {
  129202. /**
  129203. * Implementation of the TGA Texture Loader.
  129204. * @hidden
  129205. */
  129206. export class _TGATextureLoader implements IInternalTextureLoader {
  129207. /**
  129208. * Defines wether the loader supports cascade loading the different faces.
  129209. */
  129210. readonly supportCascades: boolean;
  129211. /**
  129212. * This returns if the loader support the current file information.
  129213. * @param extension defines the file extension of the file being loaded
  129214. * @returns true if the loader can load the specified file
  129215. */
  129216. canLoad(extension: string): boolean;
  129217. /**
  129218. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129219. * @param data contains the texture data
  129220. * @param texture defines the BabylonJS internal texture
  129221. * @param createPolynomials will be true if polynomials have been requested
  129222. * @param onLoad defines the callback to trigger once the texture is ready
  129223. * @param onError defines the callback to trigger in case of error
  129224. */
  129225. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129226. /**
  129227. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129228. * @param data contains the texture data
  129229. * @param texture defines the BabylonJS internal texture
  129230. * @param callback defines the method to call once ready to upload
  129231. */
  129232. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129233. }
  129234. }
  129235. declare module BABYLON {
  129236. /**
  129237. * Info about the .basis files
  129238. */
  129239. class BasisFileInfo {
  129240. /**
  129241. * If the file has alpha
  129242. */
  129243. hasAlpha: boolean;
  129244. /**
  129245. * Info about each image of the basis file
  129246. */
  129247. images: Array<{
  129248. levels: Array<{
  129249. width: number;
  129250. height: number;
  129251. transcodedPixels: ArrayBufferView;
  129252. }>;
  129253. }>;
  129254. }
  129255. /**
  129256. * Result of transcoding a basis file
  129257. */
  129258. class TranscodeResult {
  129259. /**
  129260. * Info about the .basis file
  129261. */
  129262. fileInfo: BasisFileInfo;
  129263. /**
  129264. * Format to use when loading the file
  129265. */
  129266. format: number;
  129267. }
  129268. /**
  129269. * Configuration options for the Basis transcoder
  129270. */
  129271. export class BasisTranscodeConfiguration {
  129272. /**
  129273. * Supported compression formats used to determine the supported output format of the transcoder
  129274. */
  129275. supportedCompressionFormats?: {
  129276. /**
  129277. * etc1 compression format
  129278. */
  129279. etc1?: boolean;
  129280. /**
  129281. * s3tc compression format
  129282. */
  129283. s3tc?: boolean;
  129284. /**
  129285. * pvrtc compression format
  129286. */
  129287. pvrtc?: boolean;
  129288. /**
  129289. * etc2 compression format
  129290. */
  129291. etc2?: boolean;
  129292. };
  129293. /**
  129294. * If mipmap levels should be loaded for transcoded images (Default: true)
  129295. */
  129296. loadMipmapLevels?: boolean;
  129297. /**
  129298. * Index of a single image to load (Default: all images)
  129299. */
  129300. loadSingleImage?: number;
  129301. }
  129302. /**
  129303. * Used to load .Basis files
  129304. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129305. */
  129306. export class BasisTools {
  129307. private static _IgnoreSupportedFormats;
  129308. /**
  129309. * URL to use when loading the basis transcoder
  129310. */
  129311. static JSModuleURL: string;
  129312. /**
  129313. * URL to use when loading the wasm module for the transcoder
  129314. */
  129315. static WasmModuleURL: string;
  129316. /**
  129317. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129318. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129319. * @returns internal format corresponding to the Basis format
  129320. */
  129321. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129322. private static _WorkerPromise;
  129323. private static _Worker;
  129324. private static _actionId;
  129325. private static _CreateWorkerAsync;
  129326. /**
  129327. * Transcodes a loaded image file to compressed pixel data
  129328. * @param data image data to transcode
  129329. * @param config configuration options for the transcoding
  129330. * @returns a promise resulting in the transcoded image
  129331. */
  129332. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129333. /**
  129334. * Loads a texture from the transcode result
  129335. * @param texture texture load to
  129336. * @param transcodeResult the result of transcoding the basis file to load from
  129337. */
  129338. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129339. }
  129340. }
  129341. declare module BABYLON {
  129342. /**
  129343. * Loader for .basis file format
  129344. */
  129345. export class _BasisTextureLoader implements IInternalTextureLoader {
  129346. /**
  129347. * Defines whether the loader supports cascade loading the different faces.
  129348. */
  129349. readonly supportCascades: boolean;
  129350. /**
  129351. * This returns if the loader support the current file information.
  129352. * @param extension defines the file extension of the file being loaded
  129353. * @returns true if the loader can load the specified file
  129354. */
  129355. canLoad(extension: string): boolean;
  129356. /**
  129357. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129358. * @param data contains the texture data
  129359. * @param texture defines the BabylonJS internal texture
  129360. * @param createPolynomials will be true if polynomials have been requested
  129361. * @param onLoad defines the callback to trigger once the texture is ready
  129362. * @param onError defines the callback to trigger in case of error
  129363. */
  129364. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129365. /**
  129366. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129367. * @param data contains the texture data
  129368. * @param texture defines the BabylonJS internal texture
  129369. * @param callback defines the method to call once ready to upload
  129370. */
  129371. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129372. }
  129373. }
  129374. declare module BABYLON {
  129375. /**
  129376. * 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.
  129377. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129378. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129379. */
  129380. export class CustomProceduralTexture extends ProceduralTexture {
  129381. private _animate;
  129382. private _time;
  129383. private _config;
  129384. private _texturePath;
  129385. /**
  129386. * Instantiates a new Custom Procedural Texture.
  129387. * 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.
  129388. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129390. * @param name Define the name of the texture
  129391. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129392. * @param size Define the size of the texture to create
  129393. * @param scene Define the scene the texture belongs to
  129394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129395. * @param generateMipMaps Define if the texture should creates mip maps or not
  129396. */
  129397. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129398. private _loadJson;
  129399. /**
  129400. * Is the texture ready to be used ? (rendered at least once)
  129401. * @returns true if ready, otherwise, false.
  129402. */
  129403. isReady(): boolean;
  129404. /**
  129405. * Render the texture to its associated render target.
  129406. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129407. */
  129408. render(useCameraPostProcess?: boolean): void;
  129409. /**
  129410. * Update the list of dependant textures samplers in the shader.
  129411. */
  129412. updateTextures(): void;
  129413. /**
  129414. * Update the uniform values of the procedural texture in the shader.
  129415. */
  129416. updateShaderUniforms(): void;
  129417. /**
  129418. * Define if the texture animates or not.
  129419. */
  129420. get animate(): boolean;
  129421. set animate(value: boolean);
  129422. }
  129423. }
  129424. declare module BABYLON {
  129425. /** @hidden */
  129426. export var noisePixelShader: {
  129427. name: string;
  129428. shader: string;
  129429. };
  129430. }
  129431. declare module BABYLON {
  129432. /**
  129433. * Class used to generate noise procedural textures
  129434. */
  129435. export class NoiseProceduralTexture extends ProceduralTexture {
  129436. private _time;
  129437. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129438. brightness: number;
  129439. /** Defines the number of octaves to process */
  129440. octaves: number;
  129441. /** Defines the level of persistence (0.8 by default) */
  129442. persistence: number;
  129443. /** Gets or sets animation speed factor (default is 1) */
  129444. animationSpeedFactor: number;
  129445. /**
  129446. * Creates a new NoiseProceduralTexture
  129447. * @param name defines the name fo the texture
  129448. * @param size defines the size of the texture (default is 256)
  129449. * @param scene defines the hosting scene
  129450. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129451. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129452. */
  129453. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129454. private _updateShaderUniforms;
  129455. protected _getDefines(): string;
  129456. /** Generate the current state of the procedural texture */
  129457. render(useCameraPostProcess?: boolean): void;
  129458. /**
  129459. * Serializes this noise procedural texture
  129460. * @returns a serialized noise procedural texture object
  129461. */
  129462. serialize(): any;
  129463. /**
  129464. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129465. * @param parsedTexture defines parsed texture data
  129466. * @param scene defines the current scene
  129467. * @param rootUrl defines the root URL containing noise procedural texture information
  129468. * @returns a parsed NoiseProceduralTexture
  129469. */
  129470. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129471. }
  129472. }
  129473. declare module BABYLON {
  129474. /**
  129475. * Raw cube texture where the raw buffers are passed in
  129476. */
  129477. export class RawCubeTexture extends CubeTexture {
  129478. /**
  129479. * Creates a cube texture where the raw buffers are passed in.
  129480. * @param scene defines the scene the texture is attached to
  129481. * @param data defines the array of data to use to create each face
  129482. * @param size defines the size of the textures
  129483. * @param format defines the format of the data
  129484. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129485. * @param generateMipMaps defines if the engine should generate the mip levels
  129486. * @param invertY defines if data must be stored with Y axis inverted
  129487. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129488. * @param compression defines the compression used (null by default)
  129489. */
  129490. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129491. /**
  129492. * Updates the raw cube texture.
  129493. * @param data defines the data to store
  129494. * @param format defines the data format
  129495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129496. * @param invertY defines if data must be stored with Y axis inverted
  129497. * @param compression defines the compression used (null by default)
  129498. * @param level defines which level of the texture to update
  129499. */
  129500. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129501. /**
  129502. * Updates a raw cube texture with RGBD encoded data.
  129503. * @param data defines the array of data [mipmap][face] to use to create each face
  129504. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129505. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129506. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129507. * @returns a promsie that resolves when the operation is complete
  129508. */
  129509. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129510. /**
  129511. * Clones the raw cube texture.
  129512. * @return a new cube texture
  129513. */
  129514. clone(): CubeTexture;
  129515. /** @hidden */
  129516. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129517. }
  129518. }
  129519. declare module BABYLON {
  129520. /**
  129521. * Class used to store 3D textures containing user data
  129522. */
  129523. export class RawTexture3D extends Texture {
  129524. /** Gets or sets the texture format to use */
  129525. format: number;
  129526. private _engine;
  129527. /**
  129528. * Create a new RawTexture3D
  129529. * @param data defines the data of the texture
  129530. * @param width defines the width of the texture
  129531. * @param height defines the height of the texture
  129532. * @param depth defines the depth of the texture
  129533. * @param format defines the texture format to use
  129534. * @param scene defines the hosting scene
  129535. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129536. * @param invertY defines if texture must be stored with Y axis inverted
  129537. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129538. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129539. */
  129540. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129541. /** Gets or sets the texture format to use */
  129542. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129543. /**
  129544. * Update the texture with new data
  129545. * @param data defines the data to store in the texture
  129546. */
  129547. update(data: ArrayBufferView): void;
  129548. }
  129549. }
  129550. declare module BABYLON {
  129551. /**
  129552. * Class used to store 2D array textures containing user data
  129553. */
  129554. export class RawTexture2DArray extends Texture {
  129555. /** Gets or sets the texture format to use */
  129556. format: number;
  129557. private _engine;
  129558. /**
  129559. * Create a new RawTexture2DArray
  129560. * @param data defines the data of the texture
  129561. * @param width defines the width of the texture
  129562. * @param height defines the height of the texture
  129563. * @param depth defines the number of layers of the texture
  129564. * @param format defines the texture format to use
  129565. * @param scene defines the hosting scene
  129566. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129567. * @param invertY defines if texture must be stored with Y axis inverted
  129568. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129569. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129570. */
  129571. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129572. /** Gets or sets the texture format to use */
  129573. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129574. /**
  129575. * Update the texture with new data
  129576. * @param data defines the data to store in the texture
  129577. */
  129578. update(data: ArrayBufferView): void;
  129579. }
  129580. }
  129581. declare module BABYLON {
  129582. /**
  129583. * Creates a refraction texture used by refraction channel of the standard material.
  129584. * It is like a mirror but to see through a material.
  129585. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129586. */
  129587. export class RefractionTexture extends RenderTargetTexture {
  129588. /**
  129589. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129590. * 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.
  129591. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129592. */
  129593. refractionPlane: Plane;
  129594. /**
  129595. * Define how deep under the surface we should see.
  129596. */
  129597. depth: number;
  129598. /**
  129599. * Creates a refraction texture used by refraction channel of the standard material.
  129600. * It is like a mirror but to see through a material.
  129601. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129602. * @param name Define the texture name
  129603. * @param size Define the size of the underlying texture
  129604. * @param scene Define the scene the refraction belongs to
  129605. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129606. */
  129607. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129608. /**
  129609. * Clone the refraction texture.
  129610. * @returns the cloned texture
  129611. */
  129612. clone(): RefractionTexture;
  129613. /**
  129614. * Serialize the texture to a JSON representation you could use in Parse later on
  129615. * @returns the serialized JSON representation
  129616. */
  129617. serialize(): any;
  129618. }
  129619. }
  129620. declare module BABYLON {
  129621. /**
  129622. * Defines the options related to the creation of an HtmlElementTexture
  129623. */
  129624. export interface IHtmlElementTextureOptions {
  129625. /**
  129626. * Defines wether mip maps should be created or not.
  129627. */
  129628. generateMipMaps?: boolean;
  129629. /**
  129630. * Defines the sampling mode of the texture.
  129631. */
  129632. samplingMode?: number;
  129633. /**
  129634. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129635. */
  129636. engine: Nullable<ThinEngine>;
  129637. /**
  129638. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129639. */
  129640. scene: Nullable<Scene>;
  129641. }
  129642. /**
  129643. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129644. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129645. * is automatically managed.
  129646. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129647. * in your application.
  129648. *
  129649. * As the update is not automatic, you need to call them manually.
  129650. */
  129651. export class HtmlElementTexture extends BaseTexture {
  129652. /**
  129653. * The texture URL.
  129654. */
  129655. element: HTMLVideoElement | HTMLCanvasElement;
  129656. private static readonly DefaultOptions;
  129657. private _textureMatrix;
  129658. private _engine;
  129659. private _isVideo;
  129660. private _generateMipMaps;
  129661. private _samplingMode;
  129662. /**
  129663. * Instantiates a HtmlElementTexture from the following parameters.
  129664. *
  129665. * @param name Defines the name of the texture
  129666. * @param element Defines the video or canvas the texture is filled with
  129667. * @param options Defines the other none mandatory texture creation options
  129668. */
  129669. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129670. private _createInternalTexture;
  129671. /**
  129672. * Returns the texture matrix used in most of the material.
  129673. */
  129674. getTextureMatrix(): Matrix;
  129675. /**
  129676. * Updates the content of the texture.
  129677. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129678. */
  129679. update(invertY?: Nullable<boolean>): void;
  129680. }
  129681. }
  129682. declare module BABYLON {
  129683. /**
  129684. * Defines the basic options interface of a TexturePacker Frame
  129685. */
  129686. export interface ITexturePackerFrame {
  129687. /**
  129688. * The frame ID
  129689. */
  129690. id: number;
  129691. /**
  129692. * The frames Scale
  129693. */
  129694. scale: Vector2;
  129695. /**
  129696. * The Frames offset
  129697. */
  129698. offset: Vector2;
  129699. }
  129700. /**
  129701. * This is a support class for frame Data on texture packer sets.
  129702. */
  129703. export class TexturePackerFrame implements ITexturePackerFrame {
  129704. /**
  129705. * The frame ID
  129706. */
  129707. id: number;
  129708. /**
  129709. * The frames Scale
  129710. */
  129711. scale: Vector2;
  129712. /**
  129713. * The Frames offset
  129714. */
  129715. offset: Vector2;
  129716. /**
  129717. * Initializes a texture package frame.
  129718. * @param id The numerical frame identifier
  129719. * @param scale Scalar Vector2 for UV frame
  129720. * @param offset Vector2 for the frame position in UV units.
  129721. * @returns TexturePackerFrame
  129722. */
  129723. constructor(id: number, scale: Vector2, offset: Vector2);
  129724. }
  129725. }
  129726. declare module BABYLON {
  129727. /**
  129728. * Defines the basic options interface of a TexturePacker
  129729. */
  129730. export interface ITexturePackerOptions {
  129731. /**
  129732. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129733. */
  129734. map?: string[];
  129735. /**
  129736. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129737. */
  129738. uvsIn?: string;
  129739. /**
  129740. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129741. */
  129742. uvsOut?: string;
  129743. /**
  129744. * number representing the layout style. Defaults to LAYOUT_STRIP
  129745. */
  129746. layout?: number;
  129747. /**
  129748. * number of columns if using custom column count layout(2). This defaults to 4.
  129749. */
  129750. colnum?: number;
  129751. /**
  129752. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129753. */
  129754. updateInputMeshes?: boolean;
  129755. /**
  129756. * boolean flag to dispose all the source textures. Defaults to true.
  129757. */
  129758. disposeSources?: boolean;
  129759. /**
  129760. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129761. */
  129762. fillBlanks?: boolean;
  129763. /**
  129764. * string value representing the context fill style color. Defaults to 'black'.
  129765. */
  129766. customFillColor?: string;
  129767. /**
  129768. * Width and Height Value of each Frame in the TexturePacker Sets
  129769. */
  129770. frameSize?: number;
  129771. /**
  129772. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129773. */
  129774. paddingRatio?: number;
  129775. /**
  129776. * Number that declares the fill method for the padding gutter.
  129777. */
  129778. paddingMode?: number;
  129779. /**
  129780. * If in SUBUV_COLOR padding mode what color to use.
  129781. */
  129782. paddingColor?: Color3 | Color4;
  129783. }
  129784. /**
  129785. * Defines the basic interface of a TexturePacker JSON File
  129786. */
  129787. export interface ITexturePackerJSON {
  129788. /**
  129789. * The frame ID
  129790. */
  129791. name: string;
  129792. /**
  129793. * The base64 channel data
  129794. */
  129795. sets: any;
  129796. /**
  129797. * The options of the Packer
  129798. */
  129799. options: ITexturePackerOptions;
  129800. /**
  129801. * The frame data of the Packer
  129802. */
  129803. frames: Array<number>;
  129804. }
  129805. /**
  129806. * This is a support class that generates a series of packed texture sets.
  129807. * @see https://doc.babylonjs.com/babylon101/materials
  129808. */
  129809. export class TexturePacker {
  129810. /** Packer Layout Constant 0 */
  129811. static readonly LAYOUT_STRIP: number;
  129812. /** Packer Layout Constant 1 */
  129813. static readonly LAYOUT_POWER2: number;
  129814. /** Packer Layout Constant 2 */
  129815. static readonly LAYOUT_COLNUM: number;
  129816. /** Packer Layout Constant 0 */
  129817. static readonly SUBUV_WRAP: number;
  129818. /** Packer Layout Constant 1 */
  129819. static readonly SUBUV_EXTEND: number;
  129820. /** Packer Layout Constant 2 */
  129821. static readonly SUBUV_COLOR: number;
  129822. /** The Name of the Texture Package */
  129823. name: string;
  129824. /** The scene scope of the TexturePacker */
  129825. scene: Scene;
  129826. /** The Meshes to target */
  129827. meshes: AbstractMesh[];
  129828. /** Arguments passed with the Constructor */
  129829. options: ITexturePackerOptions;
  129830. /** The promise that is started upon initialization */
  129831. promise: Nullable<Promise<TexturePacker | string>>;
  129832. /** The Container object for the channel sets that are generated */
  129833. sets: object;
  129834. /** The Container array for the frames that are generated */
  129835. frames: TexturePackerFrame[];
  129836. /** The expected number of textures the system is parsing. */
  129837. private _expecting;
  129838. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129839. private _paddingValue;
  129840. /**
  129841. * Initializes a texture package series from an array of meshes or a single mesh.
  129842. * @param name The name of the package
  129843. * @param meshes The target meshes to compose the package from
  129844. * @param options The arguments that texture packer should follow while building.
  129845. * @param scene The scene which the textures are scoped to.
  129846. * @returns TexturePacker
  129847. */
  129848. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129849. /**
  129850. * Starts the package process
  129851. * @param resolve The promises resolution function
  129852. * @returns TexturePacker
  129853. */
  129854. private _createFrames;
  129855. /**
  129856. * Calculates the Size of the Channel Sets
  129857. * @returns Vector2
  129858. */
  129859. private _calculateSize;
  129860. /**
  129861. * Calculates the UV data for the frames.
  129862. * @param baseSize the base frameSize
  129863. * @param padding the base frame padding
  129864. * @param dtSize size of the Dynamic Texture for that channel
  129865. * @param dtUnits is 1/dtSize
  129866. * @param update flag to update the input meshes
  129867. */
  129868. private _calculateMeshUVFrames;
  129869. /**
  129870. * Calculates the frames Offset.
  129871. * @param index of the frame
  129872. * @returns Vector2
  129873. */
  129874. private _getFrameOffset;
  129875. /**
  129876. * Updates a Mesh to the frame data
  129877. * @param mesh that is the target
  129878. * @param frameID or the frame index
  129879. */
  129880. private _updateMeshUV;
  129881. /**
  129882. * Updates a Meshes materials to use the texture packer channels
  129883. * @param m is the mesh to target
  129884. * @param force all channels on the packer to be set.
  129885. */
  129886. private _updateTextureReferences;
  129887. /**
  129888. * Public method to set a Mesh to a frame
  129889. * @param m that is the target
  129890. * @param frameID or the frame index
  129891. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129892. */
  129893. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129894. /**
  129895. * Starts the async promise to compile the texture packer.
  129896. * @returns Promise<void>
  129897. */
  129898. processAsync(): Promise<void>;
  129899. /**
  129900. * Disposes all textures associated with this packer
  129901. */
  129902. dispose(): void;
  129903. /**
  129904. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129905. * @param imageType is the image type to use.
  129906. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129907. */
  129908. download(imageType?: string, quality?: number): void;
  129909. /**
  129910. * Public method to load a texturePacker JSON file.
  129911. * @param data of the JSON file in string format.
  129912. */
  129913. updateFromJSON(data: string): void;
  129914. }
  129915. }
  129916. declare module BABYLON {
  129917. /**
  129918. * Enum used to define the target of a block
  129919. */
  129920. export enum NodeMaterialBlockTargets {
  129921. /** Vertex shader */
  129922. Vertex = 1,
  129923. /** Fragment shader */
  129924. Fragment = 2,
  129925. /** Neutral */
  129926. Neutral = 4,
  129927. /** Vertex and Fragment */
  129928. VertexAndFragment = 3
  129929. }
  129930. }
  129931. declare module BABYLON {
  129932. /**
  129933. * Defines the kind of connection point for node based material
  129934. */
  129935. export enum NodeMaterialBlockConnectionPointTypes {
  129936. /** Float */
  129937. Float = 1,
  129938. /** Int */
  129939. Int = 2,
  129940. /** Vector2 */
  129941. Vector2 = 4,
  129942. /** Vector3 */
  129943. Vector3 = 8,
  129944. /** Vector4 */
  129945. Vector4 = 16,
  129946. /** Color3 */
  129947. Color3 = 32,
  129948. /** Color4 */
  129949. Color4 = 64,
  129950. /** Matrix */
  129951. Matrix = 128,
  129952. /** Detect type based on connection */
  129953. AutoDetect = 1024,
  129954. /** Output type that will be defined by input type */
  129955. BasedOnInput = 2048
  129956. }
  129957. }
  129958. declare module BABYLON {
  129959. /**
  129960. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129961. */
  129962. export enum NodeMaterialBlockConnectionPointMode {
  129963. /** Value is an uniform */
  129964. Uniform = 0,
  129965. /** Value is a mesh attribute */
  129966. Attribute = 1,
  129967. /** Value is a varying between vertex and fragment shaders */
  129968. Varying = 2,
  129969. /** Mode is undefined */
  129970. Undefined = 3
  129971. }
  129972. }
  129973. declare module BABYLON {
  129974. /**
  129975. * Enum used to define system values e.g. values automatically provided by the system
  129976. */
  129977. export enum NodeMaterialSystemValues {
  129978. /** World */
  129979. World = 1,
  129980. /** View */
  129981. View = 2,
  129982. /** Projection */
  129983. Projection = 3,
  129984. /** ViewProjection */
  129985. ViewProjection = 4,
  129986. /** WorldView */
  129987. WorldView = 5,
  129988. /** WorldViewProjection */
  129989. WorldViewProjection = 6,
  129990. /** CameraPosition */
  129991. CameraPosition = 7,
  129992. /** Fog Color */
  129993. FogColor = 8,
  129994. /** Delta time */
  129995. DeltaTime = 9
  129996. }
  129997. }
  129998. declare module BABYLON {
  129999. /**
  130000. * Root class for all node material optimizers
  130001. */
  130002. export class NodeMaterialOptimizer {
  130003. /**
  130004. * Function used to optimize a NodeMaterial graph
  130005. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130006. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130007. */
  130008. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130009. }
  130010. }
  130011. declare module BABYLON {
  130012. /**
  130013. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130014. */
  130015. export class TransformBlock extends NodeMaterialBlock {
  130016. /**
  130017. * Defines the value to use to complement W value to transform it to a Vector4
  130018. */
  130019. complementW: number;
  130020. /**
  130021. * Defines the value to use to complement z value to transform it to a Vector4
  130022. */
  130023. complementZ: number;
  130024. /**
  130025. * Creates a new TransformBlock
  130026. * @param name defines the block name
  130027. */
  130028. constructor(name: string);
  130029. /**
  130030. * Gets the current class name
  130031. * @returns the class name
  130032. */
  130033. getClassName(): string;
  130034. /**
  130035. * Gets the vector input
  130036. */
  130037. get vector(): NodeMaterialConnectionPoint;
  130038. /**
  130039. * Gets the output component
  130040. */
  130041. get output(): NodeMaterialConnectionPoint;
  130042. /**
  130043. * Gets the xyz output component
  130044. */
  130045. get xyz(): NodeMaterialConnectionPoint;
  130046. /**
  130047. * Gets the matrix transform input
  130048. */
  130049. get transform(): NodeMaterialConnectionPoint;
  130050. protected _buildBlock(state: NodeMaterialBuildState): this;
  130051. serialize(): any;
  130052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130053. protected _dumpPropertiesCode(): string;
  130054. }
  130055. }
  130056. declare module BABYLON {
  130057. /**
  130058. * Block used to output the vertex position
  130059. */
  130060. export class VertexOutputBlock extends NodeMaterialBlock {
  130061. /**
  130062. * Creates a new VertexOutputBlock
  130063. * @param name defines the block name
  130064. */
  130065. constructor(name: string);
  130066. /**
  130067. * Gets the current class name
  130068. * @returns the class name
  130069. */
  130070. getClassName(): string;
  130071. /**
  130072. * Gets the vector input component
  130073. */
  130074. get vector(): NodeMaterialConnectionPoint;
  130075. protected _buildBlock(state: NodeMaterialBuildState): this;
  130076. }
  130077. }
  130078. declare module BABYLON {
  130079. /**
  130080. * Block used to output the final color
  130081. */
  130082. export class FragmentOutputBlock extends NodeMaterialBlock {
  130083. /**
  130084. * Create a new FragmentOutputBlock
  130085. * @param name defines the block name
  130086. */
  130087. constructor(name: string);
  130088. /**
  130089. * Gets the current class name
  130090. * @returns the class name
  130091. */
  130092. getClassName(): string;
  130093. /**
  130094. * Gets the rgba input component
  130095. */
  130096. get rgba(): NodeMaterialConnectionPoint;
  130097. /**
  130098. * Gets the rgb input component
  130099. */
  130100. get rgb(): NodeMaterialConnectionPoint;
  130101. /**
  130102. * Gets the a input component
  130103. */
  130104. get a(): NodeMaterialConnectionPoint;
  130105. protected _buildBlock(state: NodeMaterialBuildState): this;
  130106. }
  130107. }
  130108. declare module BABYLON {
  130109. /**
  130110. * Block used to read a reflection texture from a sampler
  130111. */
  130112. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130113. private _define3DName;
  130114. private _defineCubicName;
  130115. private _defineExplicitName;
  130116. private _defineProjectionName;
  130117. private _defineLocalCubicName;
  130118. private _defineSphericalName;
  130119. private _definePlanarName;
  130120. private _defineEquirectangularName;
  130121. private _defineMirroredEquirectangularFixedName;
  130122. private _defineEquirectangularFixedName;
  130123. private _defineSkyboxName;
  130124. private _cubeSamplerName;
  130125. private _2DSamplerName;
  130126. private _positionUVWName;
  130127. private _directionWName;
  130128. private _reflectionCoordsName;
  130129. private _reflection2DCoordsName;
  130130. private _reflectionColorName;
  130131. private _reflectionMatrixName;
  130132. /**
  130133. * Gets or sets the texture associated with the node
  130134. */
  130135. texture: Nullable<BaseTexture>;
  130136. /**
  130137. * Create a new TextureBlock
  130138. * @param name defines the block name
  130139. */
  130140. constructor(name: string);
  130141. /**
  130142. * Gets the current class name
  130143. * @returns the class name
  130144. */
  130145. getClassName(): string;
  130146. /**
  130147. * Gets the world position input component
  130148. */
  130149. get position(): NodeMaterialConnectionPoint;
  130150. /**
  130151. * Gets the world position input component
  130152. */
  130153. get worldPosition(): NodeMaterialConnectionPoint;
  130154. /**
  130155. * Gets the world normal input component
  130156. */
  130157. get worldNormal(): NodeMaterialConnectionPoint;
  130158. /**
  130159. * Gets the world input component
  130160. */
  130161. get world(): NodeMaterialConnectionPoint;
  130162. /**
  130163. * Gets the camera (or eye) position component
  130164. */
  130165. get cameraPosition(): NodeMaterialConnectionPoint;
  130166. /**
  130167. * Gets the view input component
  130168. */
  130169. get view(): NodeMaterialConnectionPoint;
  130170. /**
  130171. * Gets the rgb output component
  130172. */
  130173. get rgb(): NodeMaterialConnectionPoint;
  130174. /**
  130175. * Gets the r output component
  130176. */
  130177. get r(): NodeMaterialConnectionPoint;
  130178. /**
  130179. * Gets the g output component
  130180. */
  130181. get g(): NodeMaterialConnectionPoint;
  130182. /**
  130183. * Gets the b output component
  130184. */
  130185. get b(): NodeMaterialConnectionPoint;
  130186. autoConfigure(material: NodeMaterial): void;
  130187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130188. isReady(): boolean;
  130189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130190. private _injectVertexCode;
  130191. private _writeOutput;
  130192. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130193. protected _dumpPropertiesCode(): string;
  130194. serialize(): any;
  130195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130196. }
  130197. }
  130198. declare module BABYLON {
  130199. /**
  130200. * Interface used to configure the node material editor
  130201. */
  130202. export interface INodeMaterialEditorOptions {
  130203. /** Define the URl to load node editor script */
  130204. editorURL?: string;
  130205. }
  130206. /** @hidden */
  130207. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130208. NORMAL: boolean;
  130209. TANGENT: boolean;
  130210. UV1: boolean;
  130211. /** BONES */
  130212. NUM_BONE_INFLUENCERS: number;
  130213. BonesPerMesh: number;
  130214. BONETEXTURE: boolean;
  130215. /** MORPH TARGETS */
  130216. MORPHTARGETS: boolean;
  130217. MORPHTARGETS_NORMAL: boolean;
  130218. MORPHTARGETS_TANGENT: boolean;
  130219. MORPHTARGETS_UV: boolean;
  130220. NUM_MORPH_INFLUENCERS: number;
  130221. /** IMAGE PROCESSING */
  130222. IMAGEPROCESSING: boolean;
  130223. VIGNETTE: boolean;
  130224. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130225. VIGNETTEBLENDMODEOPAQUE: boolean;
  130226. TONEMAPPING: boolean;
  130227. TONEMAPPING_ACES: boolean;
  130228. CONTRAST: boolean;
  130229. EXPOSURE: boolean;
  130230. COLORCURVES: boolean;
  130231. COLORGRADING: boolean;
  130232. COLORGRADING3D: boolean;
  130233. SAMPLER3DGREENDEPTH: boolean;
  130234. SAMPLER3DBGRMAP: boolean;
  130235. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130236. /** MISC. */
  130237. BUMPDIRECTUV: number;
  130238. constructor();
  130239. setValue(name: string, value: boolean): void;
  130240. }
  130241. /**
  130242. * Class used to configure NodeMaterial
  130243. */
  130244. export interface INodeMaterialOptions {
  130245. /**
  130246. * Defines if blocks should emit comments
  130247. */
  130248. emitComments: boolean;
  130249. }
  130250. /**
  130251. * Class used to create a node based material built by assembling shader blocks
  130252. */
  130253. export class NodeMaterial extends PushMaterial {
  130254. private static _BuildIdGenerator;
  130255. private _options;
  130256. private _vertexCompilationState;
  130257. private _fragmentCompilationState;
  130258. private _sharedData;
  130259. private _buildId;
  130260. private _buildWasSuccessful;
  130261. private _cachedWorldViewMatrix;
  130262. private _cachedWorldViewProjectionMatrix;
  130263. private _optimizers;
  130264. private _animationFrame;
  130265. /** Define the Url to load node editor script */
  130266. static EditorURL: string;
  130267. /** Define the Url to load snippets */
  130268. static SnippetUrl: string;
  130269. private BJSNODEMATERIALEDITOR;
  130270. /** Get the inspector from bundle or global */
  130271. private _getGlobalNodeMaterialEditor;
  130272. /**
  130273. * Gets or sets data used by visual editor
  130274. * @see https://nme.babylonjs.com
  130275. */
  130276. editorData: any;
  130277. /**
  130278. * 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)
  130279. */
  130280. ignoreAlpha: boolean;
  130281. /**
  130282. * Defines the maximum number of lights that can be used in the material
  130283. */
  130284. maxSimultaneousLights: number;
  130285. /**
  130286. * Observable raised when the material is built
  130287. */
  130288. onBuildObservable: Observable<NodeMaterial>;
  130289. /**
  130290. * Gets or sets the root nodes of the material vertex shader
  130291. */
  130292. _vertexOutputNodes: NodeMaterialBlock[];
  130293. /**
  130294. * Gets or sets the root nodes of the material fragment (pixel) shader
  130295. */
  130296. _fragmentOutputNodes: NodeMaterialBlock[];
  130297. /** Gets or sets options to control the node material overall behavior */
  130298. get options(): INodeMaterialOptions;
  130299. set options(options: INodeMaterialOptions);
  130300. /**
  130301. * Default configuration related to image processing available in the standard Material.
  130302. */
  130303. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130304. /**
  130305. * Gets the image processing configuration used either in this material.
  130306. */
  130307. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130308. /**
  130309. * Sets the Default image processing configuration used either in the this material.
  130310. *
  130311. * If sets to null, the scene one is in use.
  130312. */
  130313. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130314. /**
  130315. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130316. */
  130317. attachedBlocks: NodeMaterialBlock[];
  130318. /**
  130319. * Create a new node based material
  130320. * @param name defines the material name
  130321. * @param scene defines the hosting scene
  130322. * @param options defines creation option
  130323. */
  130324. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130325. /**
  130326. * Gets the current class name of the material e.g. "NodeMaterial"
  130327. * @returns the class name
  130328. */
  130329. getClassName(): string;
  130330. /**
  130331. * Keep track of the image processing observer to allow dispose and replace.
  130332. */
  130333. private _imageProcessingObserver;
  130334. /**
  130335. * Attaches a new image processing configuration to the Standard Material.
  130336. * @param configuration
  130337. */
  130338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130339. /**
  130340. * Get a block by its name
  130341. * @param name defines the name of the block to retrieve
  130342. * @returns the required block or null if not found
  130343. */
  130344. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130345. /**
  130346. * Get a block by its name
  130347. * @param predicate defines the predicate used to find the good candidate
  130348. * @returns the required block or null if not found
  130349. */
  130350. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130351. /**
  130352. * Get an input block by its name
  130353. * @param predicate defines the predicate used to find the good candidate
  130354. * @returns the required input block or null if not found
  130355. */
  130356. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130357. /**
  130358. * Gets the list of input blocks attached to this material
  130359. * @returns an array of InputBlocks
  130360. */
  130361. getInputBlocks(): InputBlock[];
  130362. /**
  130363. * Adds a new optimizer to the list of optimizers
  130364. * @param optimizer defines the optimizers to add
  130365. * @returns the current material
  130366. */
  130367. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130368. /**
  130369. * Remove an optimizer from the list of optimizers
  130370. * @param optimizer defines the optimizers to remove
  130371. * @returns the current material
  130372. */
  130373. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130374. /**
  130375. * Add a new block to the list of output nodes
  130376. * @param node defines the node to add
  130377. * @returns the current material
  130378. */
  130379. addOutputNode(node: NodeMaterialBlock): this;
  130380. /**
  130381. * Remove a block from the list of root nodes
  130382. * @param node defines the node to remove
  130383. * @returns the current material
  130384. */
  130385. removeOutputNode(node: NodeMaterialBlock): this;
  130386. private _addVertexOutputNode;
  130387. private _removeVertexOutputNode;
  130388. private _addFragmentOutputNode;
  130389. private _removeFragmentOutputNode;
  130390. /**
  130391. * Specifies if the material will require alpha blending
  130392. * @returns a boolean specifying if alpha blending is needed
  130393. */
  130394. needAlphaBlending(): boolean;
  130395. /**
  130396. * Specifies if this material should be rendered in alpha test mode
  130397. * @returns a boolean specifying if an alpha test is needed.
  130398. */
  130399. needAlphaTesting(): boolean;
  130400. private _initializeBlock;
  130401. private _resetDualBlocks;
  130402. /**
  130403. * Remove a block from the current node material
  130404. * @param block defines the block to remove
  130405. */
  130406. removeBlock(block: NodeMaterialBlock): void;
  130407. /**
  130408. * Build the material and generates the inner effect
  130409. * @param verbose defines if the build should log activity
  130410. */
  130411. build(verbose?: boolean): void;
  130412. /**
  130413. * Runs an otpimization phase to try to improve the shader code
  130414. */
  130415. optimize(): void;
  130416. private _prepareDefinesForAttributes;
  130417. /**
  130418. * Get if the submesh is ready to be used and all its information available.
  130419. * Child classes can use it to update shaders
  130420. * @param mesh defines the mesh to check
  130421. * @param subMesh defines which submesh to check
  130422. * @param useInstances specifies that instances should be used
  130423. * @returns a boolean indicating that the submesh is ready or not
  130424. */
  130425. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130426. /**
  130427. * Get a string representing the shaders built by the current node graph
  130428. */
  130429. get compiledShaders(): string;
  130430. /**
  130431. * Binds the world matrix to the material
  130432. * @param world defines the world transformation matrix
  130433. */
  130434. bindOnlyWorldMatrix(world: Matrix): void;
  130435. /**
  130436. * Binds the submesh to this material by preparing the effect and shader to draw
  130437. * @param world defines the world transformation matrix
  130438. * @param mesh defines the mesh containing the submesh
  130439. * @param subMesh defines the submesh to bind the material to
  130440. */
  130441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130442. /**
  130443. * Gets the active textures from the material
  130444. * @returns an array of textures
  130445. */
  130446. getActiveTextures(): BaseTexture[];
  130447. /**
  130448. * Gets the list of texture blocks
  130449. * @returns an array of texture blocks
  130450. */
  130451. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130452. /**
  130453. * Specifies if the material uses a texture
  130454. * @param texture defines the texture to check against the material
  130455. * @returns a boolean specifying if the material uses the texture
  130456. */
  130457. hasTexture(texture: BaseTexture): boolean;
  130458. /**
  130459. * Disposes the material
  130460. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130461. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130462. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130463. */
  130464. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130465. /** Creates the node editor window. */
  130466. private _createNodeEditor;
  130467. /**
  130468. * Launch the node material editor
  130469. * @param config Define the configuration of the editor
  130470. * @return a promise fulfilled when the node editor is visible
  130471. */
  130472. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130473. /**
  130474. * Clear the current material
  130475. */
  130476. clear(): void;
  130477. /**
  130478. * Clear the current material and set it to a default state
  130479. */
  130480. setToDefault(): void;
  130481. /**
  130482. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130483. * @param url defines the url to load from
  130484. * @returns a promise that will fullfil when the material is fully loaded
  130485. */
  130486. loadAsync(url: string): Promise<void>;
  130487. private _gatherBlocks;
  130488. /**
  130489. * Generate a string containing the code declaration required to create an equivalent of this material
  130490. * @returns a string
  130491. */
  130492. generateCode(): string;
  130493. /**
  130494. * Serializes this material in a JSON representation
  130495. * @returns the serialized material object
  130496. */
  130497. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130498. private _restoreConnections;
  130499. /**
  130500. * Clear the current graph and load a new one from a serialization object
  130501. * @param source defines the JSON representation of the material
  130502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130503. */
  130504. loadFromSerialization(source: any, rootUrl?: string): void;
  130505. /**
  130506. * Creates a node material from parsed material data
  130507. * @param source defines the JSON representation of the material
  130508. * @param scene defines the hosting scene
  130509. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130510. * @returns a new node material
  130511. */
  130512. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130513. /**
  130514. * Creates a node material from a snippet saved in a remote file
  130515. * @param name defines the name of the material to create
  130516. * @param url defines the url to load from
  130517. * @param scene defines the hosting scene
  130518. * @returns a promise that will resolve to the new node material
  130519. */
  130520. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130521. /**
  130522. * Creates a node material from a snippet saved by the node material editor
  130523. * @param snippetId defines the snippet to load
  130524. * @param scene defines the hosting scene
  130525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130526. * @returns a promise that will resolve to the new node material
  130527. */
  130528. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130529. /**
  130530. * Creates a new node material set to default basic configuration
  130531. * @param name defines the name of the material
  130532. * @param scene defines the hosting scene
  130533. * @returns a new NodeMaterial
  130534. */
  130535. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130536. }
  130537. }
  130538. declare module BABYLON {
  130539. /**
  130540. * Block used to read a texture from a sampler
  130541. */
  130542. export class TextureBlock extends NodeMaterialBlock {
  130543. private _defineName;
  130544. private _linearDefineName;
  130545. private _tempTextureRead;
  130546. private _samplerName;
  130547. private _transformedUVName;
  130548. private _textureTransformName;
  130549. private _textureInfoName;
  130550. private _mainUVName;
  130551. private _mainUVDefineName;
  130552. /**
  130553. * Gets or sets the texture associated with the node
  130554. */
  130555. texture: Nullable<Texture>;
  130556. /**
  130557. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130558. */
  130559. convertToGammaSpace: boolean;
  130560. /**
  130561. * Create a new TextureBlock
  130562. * @param name defines the block name
  130563. */
  130564. constructor(name: string);
  130565. /**
  130566. * Gets the current class name
  130567. * @returns the class name
  130568. */
  130569. getClassName(): string;
  130570. /**
  130571. * Gets the uv input component
  130572. */
  130573. get uv(): NodeMaterialConnectionPoint;
  130574. /**
  130575. * Gets the rgba output component
  130576. */
  130577. get rgba(): NodeMaterialConnectionPoint;
  130578. /**
  130579. * Gets the rgb output component
  130580. */
  130581. get rgb(): NodeMaterialConnectionPoint;
  130582. /**
  130583. * Gets the r output component
  130584. */
  130585. get r(): NodeMaterialConnectionPoint;
  130586. /**
  130587. * Gets the g output component
  130588. */
  130589. get g(): NodeMaterialConnectionPoint;
  130590. /**
  130591. * Gets the b output component
  130592. */
  130593. get b(): NodeMaterialConnectionPoint;
  130594. /**
  130595. * Gets the a output component
  130596. */
  130597. get a(): NodeMaterialConnectionPoint;
  130598. get target(): NodeMaterialBlockTargets;
  130599. autoConfigure(material: NodeMaterial): void;
  130600. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130602. isReady(): boolean;
  130603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130604. private get _isMixed();
  130605. private _injectVertexCode;
  130606. private _writeTextureRead;
  130607. private _writeOutput;
  130608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130609. protected _dumpPropertiesCode(): string;
  130610. serialize(): any;
  130611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130612. }
  130613. }
  130614. declare module BABYLON {
  130615. /**
  130616. * Class used to store shared data between 2 NodeMaterialBuildState
  130617. */
  130618. export class NodeMaterialBuildStateSharedData {
  130619. /**
  130620. * Gets the list of emitted varyings
  130621. */
  130622. temps: string[];
  130623. /**
  130624. * Gets the list of emitted varyings
  130625. */
  130626. varyings: string[];
  130627. /**
  130628. * Gets the varying declaration string
  130629. */
  130630. varyingDeclaration: string;
  130631. /**
  130632. * Input blocks
  130633. */
  130634. inputBlocks: InputBlock[];
  130635. /**
  130636. * Input blocks
  130637. */
  130638. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130639. /**
  130640. * Bindable blocks (Blocks that need to set data to the effect)
  130641. */
  130642. bindableBlocks: NodeMaterialBlock[];
  130643. /**
  130644. * List of blocks that can provide a compilation fallback
  130645. */
  130646. blocksWithFallbacks: NodeMaterialBlock[];
  130647. /**
  130648. * List of blocks that can provide a define update
  130649. */
  130650. blocksWithDefines: NodeMaterialBlock[];
  130651. /**
  130652. * List of blocks that can provide a repeatable content
  130653. */
  130654. repeatableContentBlocks: NodeMaterialBlock[];
  130655. /**
  130656. * List of blocks that can provide a dynamic list of uniforms
  130657. */
  130658. dynamicUniformBlocks: NodeMaterialBlock[];
  130659. /**
  130660. * List of blocks that can block the isReady function for the material
  130661. */
  130662. blockingBlocks: NodeMaterialBlock[];
  130663. /**
  130664. * Gets the list of animated inputs
  130665. */
  130666. animatedInputs: InputBlock[];
  130667. /**
  130668. * Build Id used to avoid multiple recompilations
  130669. */
  130670. buildId: number;
  130671. /** List of emitted variables */
  130672. variableNames: {
  130673. [key: string]: number;
  130674. };
  130675. /** List of emitted defines */
  130676. defineNames: {
  130677. [key: string]: number;
  130678. };
  130679. /** Should emit comments? */
  130680. emitComments: boolean;
  130681. /** Emit build activity */
  130682. verbose: boolean;
  130683. /** Gets or sets the hosting scene */
  130684. scene: Scene;
  130685. /**
  130686. * Gets the compilation hints emitted at compilation time
  130687. */
  130688. hints: {
  130689. needWorldViewMatrix: boolean;
  130690. needWorldViewProjectionMatrix: boolean;
  130691. needAlphaBlending: boolean;
  130692. needAlphaTesting: boolean;
  130693. };
  130694. /**
  130695. * List of compilation checks
  130696. */
  130697. checks: {
  130698. emitVertex: boolean;
  130699. emitFragment: boolean;
  130700. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130701. };
  130702. /** Creates a new shared data */
  130703. constructor();
  130704. /**
  130705. * Emits console errors and exceptions if there is a failing check
  130706. */
  130707. emitErrors(): void;
  130708. }
  130709. }
  130710. declare module BABYLON {
  130711. /**
  130712. * Class used to store node based material build state
  130713. */
  130714. export class NodeMaterialBuildState {
  130715. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130716. supportUniformBuffers: boolean;
  130717. /**
  130718. * Gets the list of emitted attributes
  130719. */
  130720. attributes: string[];
  130721. /**
  130722. * Gets the list of emitted uniforms
  130723. */
  130724. uniforms: string[];
  130725. /**
  130726. * Gets the list of emitted constants
  130727. */
  130728. constants: string[];
  130729. /**
  130730. * Gets the list of emitted samplers
  130731. */
  130732. samplers: string[];
  130733. /**
  130734. * Gets the list of emitted functions
  130735. */
  130736. functions: {
  130737. [key: string]: string;
  130738. };
  130739. /**
  130740. * Gets the list of emitted extensions
  130741. */
  130742. extensions: {
  130743. [key: string]: string;
  130744. };
  130745. /**
  130746. * Gets the target of the compilation state
  130747. */
  130748. target: NodeMaterialBlockTargets;
  130749. /**
  130750. * Gets the list of emitted counters
  130751. */
  130752. counters: {
  130753. [key: string]: number;
  130754. };
  130755. /**
  130756. * Shared data between multiple NodeMaterialBuildState instances
  130757. */
  130758. sharedData: NodeMaterialBuildStateSharedData;
  130759. /** @hidden */
  130760. _vertexState: NodeMaterialBuildState;
  130761. /** @hidden */
  130762. _attributeDeclaration: string;
  130763. /** @hidden */
  130764. _uniformDeclaration: string;
  130765. /** @hidden */
  130766. _constantDeclaration: string;
  130767. /** @hidden */
  130768. _samplerDeclaration: string;
  130769. /** @hidden */
  130770. _varyingTransfer: string;
  130771. private _repeatableContentAnchorIndex;
  130772. /** @hidden */
  130773. _builtCompilationString: string;
  130774. /**
  130775. * Gets the emitted compilation strings
  130776. */
  130777. compilationString: string;
  130778. /**
  130779. * Finalize the compilation strings
  130780. * @param state defines the current compilation state
  130781. */
  130782. finalize(state: NodeMaterialBuildState): void;
  130783. /** @hidden */
  130784. get _repeatableContentAnchor(): string;
  130785. /** @hidden */
  130786. _getFreeVariableName(prefix: string): string;
  130787. /** @hidden */
  130788. _getFreeDefineName(prefix: string): string;
  130789. /** @hidden */
  130790. _excludeVariableName(name: string): void;
  130791. /** @hidden */
  130792. _emit2DSampler(name: string): void;
  130793. /** @hidden */
  130794. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130795. /** @hidden */
  130796. _emitExtension(name: string, extension: string): void;
  130797. /** @hidden */
  130798. _emitFunction(name: string, code: string, comments: string): void;
  130799. /** @hidden */
  130800. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130801. replaceStrings?: {
  130802. search: RegExp;
  130803. replace: string;
  130804. }[];
  130805. repeatKey?: string;
  130806. }): string;
  130807. /** @hidden */
  130808. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130809. repeatKey?: string;
  130810. removeAttributes?: boolean;
  130811. removeUniforms?: boolean;
  130812. removeVaryings?: boolean;
  130813. removeIfDef?: boolean;
  130814. replaceStrings?: {
  130815. search: RegExp;
  130816. replace: string;
  130817. }[];
  130818. }, storeKey?: string): void;
  130819. /** @hidden */
  130820. _registerTempVariable(name: string): boolean;
  130821. /** @hidden */
  130822. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130823. /** @hidden */
  130824. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130825. /** @hidden */
  130826. _emitFloat(value: number): string;
  130827. }
  130828. }
  130829. declare module BABYLON {
  130830. /**
  130831. * Defines a block that can be used inside a node based material
  130832. */
  130833. export class NodeMaterialBlock {
  130834. private _buildId;
  130835. private _buildTarget;
  130836. private _target;
  130837. private _isFinalMerger;
  130838. private _isInput;
  130839. protected _isUnique: boolean;
  130840. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130841. inputsAreExclusive: boolean;
  130842. /** @hidden */
  130843. _codeVariableName: string;
  130844. /** @hidden */
  130845. _inputs: NodeMaterialConnectionPoint[];
  130846. /** @hidden */
  130847. _outputs: NodeMaterialConnectionPoint[];
  130848. /** @hidden */
  130849. _preparationId: number;
  130850. /**
  130851. * Gets or sets the name of the block
  130852. */
  130853. name: string;
  130854. /**
  130855. * Gets or sets the unique id of the node
  130856. */
  130857. uniqueId: number;
  130858. /**
  130859. * Gets or sets the comments associated with this block
  130860. */
  130861. comments: string;
  130862. /**
  130863. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130864. */
  130865. get isUnique(): boolean;
  130866. /**
  130867. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130868. */
  130869. get isFinalMerger(): boolean;
  130870. /**
  130871. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130872. */
  130873. get isInput(): boolean;
  130874. /**
  130875. * Gets or sets the build Id
  130876. */
  130877. get buildId(): number;
  130878. set buildId(value: number);
  130879. /**
  130880. * Gets or sets the target of the block
  130881. */
  130882. get target(): NodeMaterialBlockTargets;
  130883. set target(value: NodeMaterialBlockTargets);
  130884. /**
  130885. * Gets the list of input points
  130886. */
  130887. get inputs(): NodeMaterialConnectionPoint[];
  130888. /** Gets the list of output points */
  130889. get outputs(): NodeMaterialConnectionPoint[];
  130890. /**
  130891. * Find an input by its name
  130892. * @param name defines the name of the input to look for
  130893. * @returns the input or null if not found
  130894. */
  130895. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130896. /**
  130897. * Find an output by its name
  130898. * @param name defines the name of the outputto look for
  130899. * @returns the output or null if not found
  130900. */
  130901. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130902. /**
  130903. * Creates a new NodeMaterialBlock
  130904. * @param name defines the block name
  130905. * @param target defines the target of that block (Vertex by default)
  130906. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130907. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130908. */
  130909. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130910. /**
  130911. * Initialize the block and prepare the context for build
  130912. * @param state defines the state that will be used for the build
  130913. */
  130914. initialize(state: NodeMaterialBuildState): void;
  130915. /**
  130916. * Bind data to effect. Will only be called for blocks with isBindable === true
  130917. * @param effect defines the effect to bind data to
  130918. * @param nodeMaterial defines the hosting NodeMaterial
  130919. * @param mesh defines the mesh that will be rendered
  130920. */
  130921. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130922. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130923. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130924. protected _writeFloat(value: number): string;
  130925. /**
  130926. * Gets the current class name e.g. "NodeMaterialBlock"
  130927. * @returns the class name
  130928. */
  130929. getClassName(): string;
  130930. /**
  130931. * Register a new input. Must be called inside a block constructor
  130932. * @param name defines the connection point name
  130933. * @param type defines the connection point type
  130934. * @param isOptional defines a boolean indicating that this input can be omitted
  130935. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130936. * @returns the current block
  130937. */
  130938. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130939. /**
  130940. * Register a new output. Must be called inside a block constructor
  130941. * @param name defines the connection point name
  130942. * @param type defines the connection point type
  130943. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130944. * @returns the current block
  130945. */
  130946. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130947. /**
  130948. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130949. * @param forOutput defines an optional connection point to check compatibility with
  130950. * @returns the first available input or null
  130951. */
  130952. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130953. /**
  130954. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130955. * @param forBlock defines an optional block to check compatibility with
  130956. * @returns the first available input or null
  130957. */
  130958. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130959. /**
  130960. * Gets the sibling of the given output
  130961. * @param current defines the current output
  130962. * @returns the next output in the list or null
  130963. */
  130964. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130965. /**
  130966. * Connect current block with another block
  130967. * @param other defines the block to connect with
  130968. * @param options define the various options to help pick the right connections
  130969. * @returns the current block
  130970. */
  130971. connectTo(other: NodeMaterialBlock, options?: {
  130972. input?: string;
  130973. output?: string;
  130974. outputSwizzle?: string;
  130975. }): this | undefined;
  130976. protected _buildBlock(state: NodeMaterialBuildState): void;
  130977. /**
  130978. * Add uniforms, samplers and uniform buffers at compilation time
  130979. * @param state defines the state to update
  130980. * @param nodeMaterial defines the node material requesting the update
  130981. * @param defines defines the material defines to update
  130982. * @param uniformBuffers defines the list of uniform buffer names
  130983. */
  130984. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130985. /**
  130986. * Add potential fallbacks if shader compilation fails
  130987. * @param mesh defines the mesh to be rendered
  130988. * @param fallbacks defines the current prioritized list of fallbacks
  130989. */
  130990. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130991. /**
  130992. * Initialize defines for shader compilation
  130993. * @param mesh defines the mesh to be rendered
  130994. * @param nodeMaterial defines the node material requesting the update
  130995. * @param defines defines the material defines to update
  130996. * @param useInstances specifies that instances should be used
  130997. */
  130998. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130999. /**
  131000. * Update defines for shader compilation
  131001. * @param mesh defines the mesh to be rendered
  131002. * @param nodeMaterial defines the node material requesting the update
  131003. * @param defines defines the material defines to update
  131004. * @param useInstances specifies that instances should be used
  131005. */
  131006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131007. /**
  131008. * Lets the block try to connect some inputs automatically
  131009. * @param material defines the hosting NodeMaterial
  131010. */
  131011. autoConfigure(material: NodeMaterial): void;
  131012. /**
  131013. * Function called when a block is declared as repeatable content generator
  131014. * @param vertexShaderState defines the current compilation state for the vertex shader
  131015. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131016. * @param mesh defines the mesh to be rendered
  131017. * @param defines defines the material defines to update
  131018. */
  131019. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131020. /**
  131021. * Checks if the block is ready
  131022. * @param mesh defines the mesh to be rendered
  131023. * @param nodeMaterial defines the node material requesting the update
  131024. * @param defines defines the material defines to update
  131025. * @param useInstances specifies that instances should be used
  131026. * @returns true if the block is ready
  131027. */
  131028. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131029. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131030. private _processBuild;
  131031. /**
  131032. * Compile the current node and generate the shader code
  131033. * @param state defines the current compilation state (uniforms, samplers, current string)
  131034. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131035. * @returns true if already built
  131036. */
  131037. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131038. protected _inputRename(name: string): string;
  131039. protected _outputRename(name: string): string;
  131040. protected _dumpPropertiesCode(): string;
  131041. /** @hidden */
  131042. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131043. /** @hidden */
  131044. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131045. /**
  131046. * Clone the current block to a new identical block
  131047. * @param scene defines the hosting scene
  131048. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131049. * @returns a copy of the current block
  131050. */
  131051. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131052. /**
  131053. * Serializes this block in a JSON representation
  131054. * @returns the serialized block object
  131055. */
  131056. serialize(): any;
  131057. /** @hidden */
  131058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131059. /**
  131060. * Release resources
  131061. */
  131062. dispose(): void;
  131063. }
  131064. }
  131065. declare module BABYLON {
  131066. /**
  131067. * Enum defining the type of animations supported by InputBlock
  131068. */
  131069. export enum AnimatedInputBlockTypes {
  131070. /** No animation */
  131071. None = 0,
  131072. /** Time based animation. Will only work for floats */
  131073. Time = 1
  131074. }
  131075. }
  131076. declare module BABYLON {
  131077. /**
  131078. * Block used to expose an input value
  131079. */
  131080. export class InputBlock extends NodeMaterialBlock {
  131081. private _mode;
  131082. private _associatedVariableName;
  131083. private _storedValue;
  131084. private _valueCallback;
  131085. private _type;
  131086. private _animationType;
  131087. /** Gets or set a value used to limit the range of float values */
  131088. min: number;
  131089. /** Gets or set a value used to limit the range of float values */
  131090. max: number;
  131091. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131092. isBoolean: boolean;
  131093. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131094. matrixMode: number;
  131095. /** @hidden */
  131096. _systemValue: Nullable<NodeMaterialSystemValues>;
  131097. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131098. visibleInInspector: boolean;
  131099. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131100. isConstant: boolean;
  131101. /** Gets or sets the group to use to display this block in the Inspector */
  131102. groupInInspector: string;
  131103. /** Gets an observable raised when the value is changed */
  131104. onValueChangedObservable: Observable<InputBlock>;
  131105. /**
  131106. * Gets or sets the connection point type (default is float)
  131107. */
  131108. get type(): NodeMaterialBlockConnectionPointTypes;
  131109. /**
  131110. * Creates a new InputBlock
  131111. * @param name defines the block name
  131112. * @param target defines the target of that block (Vertex by default)
  131113. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131114. */
  131115. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131116. /**
  131117. * Gets the output component
  131118. */
  131119. get output(): NodeMaterialConnectionPoint;
  131120. /**
  131121. * Set the source of this connection point to a vertex attribute
  131122. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131123. * @returns the current connection point
  131124. */
  131125. setAsAttribute(attributeName?: string): InputBlock;
  131126. /**
  131127. * Set the source of this connection point to a system value
  131128. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131129. * @returns the current connection point
  131130. */
  131131. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131132. /**
  131133. * Gets or sets the value of that point.
  131134. * Please note that this value will be ignored if valueCallback is defined
  131135. */
  131136. get value(): any;
  131137. set value(value: any);
  131138. /**
  131139. * Gets or sets a callback used to get the value of that point.
  131140. * Please note that setting this value will force the connection point to ignore the value property
  131141. */
  131142. get valueCallback(): () => any;
  131143. set valueCallback(value: () => any);
  131144. /**
  131145. * Gets or sets the associated variable name in the shader
  131146. */
  131147. get associatedVariableName(): string;
  131148. set associatedVariableName(value: string);
  131149. /** Gets or sets the type of animation applied to the input */
  131150. get animationType(): AnimatedInputBlockTypes;
  131151. set animationType(value: AnimatedInputBlockTypes);
  131152. /**
  131153. * Gets a boolean indicating that this connection point not defined yet
  131154. */
  131155. get isUndefined(): boolean;
  131156. /**
  131157. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131158. * In this case the connection point name must be the name of the uniform to use.
  131159. * Can only be set on inputs
  131160. */
  131161. get isUniform(): boolean;
  131162. set isUniform(value: boolean);
  131163. /**
  131164. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131165. * In this case the connection point name must be the name of the attribute to use
  131166. * Can only be set on inputs
  131167. */
  131168. get isAttribute(): boolean;
  131169. set isAttribute(value: boolean);
  131170. /**
  131171. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131172. * Can only be set on exit points
  131173. */
  131174. get isVarying(): boolean;
  131175. set isVarying(value: boolean);
  131176. /**
  131177. * Gets a boolean indicating that the current connection point is a system value
  131178. */
  131179. get isSystemValue(): boolean;
  131180. /**
  131181. * Gets or sets the current well known value or null if not defined as a system value
  131182. */
  131183. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131184. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131185. /**
  131186. * Gets the current class name
  131187. * @returns the class name
  131188. */
  131189. getClassName(): string;
  131190. /**
  131191. * Animate the input if animationType !== None
  131192. * @param scene defines the rendering scene
  131193. */
  131194. animate(scene: Scene): void;
  131195. private _emitDefine;
  131196. initialize(state: NodeMaterialBuildState): void;
  131197. /**
  131198. * Set the input block to its default value (based on its type)
  131199. */
  131200. setDefaultValue(): void;
  131201. private _emitConstant;
  131202. private _emit;
  131203. /** @hidden */
  131204. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131205. /** @hidden */
  131206. _transmit(effect: Effect, scene: Scene): void;
  131207. protected _buildBlock(state: NodeMaterialBuildState): void;
  131208. protected _dumpPropertiesCode(): string;
  131209. dispose(): void;
  131210. serialize(): any;
  131211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131212. }
  131213. }
  131214. declare module BABYLON {
  131215. /**
  131216. * Enum used to define the compatibility state between two connection points
  131217. */
  131218. export enum NodeMaterialConnectionPointCompatibilityStates {
  131219. /** Points are compatibles */
  131220. Compatible = 0,
  131221. /** Points are incompatible because of their types */
  131222. TypeIncompatible = 1,
  131223. /** Points are incompatible because of their targets (vertex vs fragment) */
  131224. TargetIncompatible = 2
  131225. }
  131226. /**
  131227. * Defines the direction of a connection point
  131228. */
  131229. export enum NodeMaterialConnectionPointDirection {
  131230. /** Input */
  131231. Input = 0,
  131232. /** Output */
  131233. Output = 1
  131234. }
  131235. /**
  131236. * Defines a connection point for a block
  131237. */
  131238. export class NodeMaterialConnectionPoint {
  131239. /** @hidden */
  131240. _ownerBlock: NodeMaterialBlock;
  131241. /** @hidden */
  131242. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131243. private _endpoints;
  131244. private _associatedVariableName;
  131245. private _direction;
  131246. /** @hidden */
  131247. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131248. /** @hidden */
  131249. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131250. private _type;
  131251. /** @hidden */
  131252. _enforceAssociatedVariableName: boolean;
  131253. /** Gets the direction of the point */
  131254. get direction(): NodeMaterialConnectionPointDirection;
  131255. /**
  131256. * Gets or sets the additional types supported by this connection point
  131257. */
  131258. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131259. /**
  131260. * Gets or sets the additional types excluded by this connection point
  131261. */
  131262. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131263. /**
  131264. * Observable triggered when this point is connected
  131265. */
  131266. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131267. /**
  131268. * Gets or sets the associated variable name in the shader
  131269. */
  131270. get associatedVariableName(): string;
  131271. set associatedVariableName(value: string);
  131272. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131273. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131274. /**
  131275. * Gets or sets the connection point type (default is float)
  131276. */
  131277. get type(): NodeMaterialBlockConnectionPointTypes;
  131278. set type(value: NodeMaterialBlockConnectionPointTypes);
  131279. /**
  131280. * Gets or sets the connection point name
  131281. */
  131282. name: string;
  131283. /**
  131284. * Gets or sets a boolean indicating that this connection point can be omitted
  131285. */
  131286. isOptional: boolean;
  131287. /**
  131288. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131289. */
  131290. define: string;
  131291. /** @hidden */
  131292. _prioritizeVertex: boolean;
  131293. private _target;
  131294. /** Gets or sets the target of that connection point */
  131295. get target(): NodeMaterialBlockTargets;
  131296. set target(value: NodeMaterialBlockTargets);
  131297. /**
  131298. * Gets a boolean indicating that the current point is connected
  131299. */
  131300. get isConnected(): boolean;
  131301. /**
  131302. * Gets a boolean indicating that the current point is connected to an input block
  131303. */
  131304. get isConnectedToInputBlock(): boolean;
  131305. /**
  131306. * Gets a the connected input block (if any)
  131307. */
  131308. get connectInputBlock(): Nullable<InputBlock>;
  131309. /** Get the other side of the connection (if any) */
  131310. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131311. /** Get the block that owns this connection point */
  131312. get ownerBlock(): NodeMaterialBlock;
  131313. /** Get the block connected on the other side of this connection (if any) */
  131314. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131315. /** Get the block connected on the endpoints of this connection (if any) */
  131316. get connectedBlocks(): Array<NodeMaterialBlock>;
  131317. /** Gets the list of connected endpoints */
  131318. get endpoints(): NodeMaterialConnectionPoint[];
  131319. /** Gets a boolean indicating if that output point is connected to at least one input */
  131320. get hasEndpoints(): boolean;
  131321. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131322. get isConnectedInVertexShader(): boolean;
  131323. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131324. get isConnectedInFragmentShader(): boolean;
  131325. /**
  131326. * Creates a new connection point
  131327. * @param name defines the connection point name
  131328. * @param ownerBlock defines the block hosting this connection point
  131329. * @param direction defines the direction of the connection point
  131330. */
  131331. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131332. /**
  131333. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131334. * @returns the class name
  131335. */
  131336. getClassName(): string;
  131337. /**
  131338. * Gets a boolean indicating if the current point can be connected to another point
  131339. * @param connectionPoint defines the other connection point
  131340. * @returns a boolean
  131341. */
  131342. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131343. /**
  131344. * Gets a number indicating if the current point can be connected to another point
  131345. * @param connectionPoint defines the other connection point
  131346. * @returns a number defining the compatibility state
  131347. */
  131348. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131349. /**
  131350. * Connect this point to another connection point
  131351. * @param connectionPoint defines the other connection point
  131352. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131353. * @returns the current connection point
  131354. */
  131355. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131356. /**
  131357. * Disconnect this point from one of his endpoint
  131358. * @param endpoint defines the other connection point
  131359. * @returns the current connection point
  131360. */
  131361. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131362. /**
  131363. * Serializes this point in a JSON representation
  131364. * @returns the serialized point object
  131365. */
  131366. serialize(): any;
  131367. /**
  131368. * Release resources
  131369. */
  131370. dispose(): void;
  131371. }
  131372. }
  131373. declare module BABYLON {
  131374. /**
  131375. * Block used to add support for vertex skinning (bones)
  131376. */
  131377. export class BonesBlock extends NodeMaterialBlock {
  131378. /**
  131379. * Creates a new BonesBlock
  131380. * @param name defines the block name
  131381. */
  131382. constructor(name: string);
  131383. /**
  131384. * Initialize the block and prepare the context for build
  131385. * @param state defines the state that will be used for the build
  131386. */
  131387. initialize(state: NodeMaterialBuildState): void;
  131388. /**
  131389. * Gets the current class name
  131390. * @returns the class name
  131391. */
  131392. getClassName(): string;
  131393. /**
  131394. * Gets the matrix indices input component
  131395. */
  131396. get matricesIndices(): NodeMaterialConnectionPoint;
  131397. /**
  131398. * Gets the matrix weights input component
  131399. */
  131400. get matricesWeights(): NodeMaterialConnectionPoint;
  131401. /**
  131402. * Gets the extra matrix indices input component
  131403. */
  131404. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131405. /**
  131406. * Gets the extra matrix weights input component
  131407. */
  131408. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131409. /**
  131410. * Gets the world input component
  131411. */
  131412. get world(): NodeMaterialConnectionPoint;
  131413. /**
  131414. * Gets the output component
  131415. */
  131416. get output(): NodeMaterialConnectionPoint;
  131417. autoConfigure(material: NodeMaterial): void;
  131418. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131421. protected _buildBlock(state: NodeMaterialBuildState): this;
  131422. }
  131423. }
  131424. declare module BABYLON {
  131425. /**
  131426. * Block used to add support for instances
  131427. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131428. */
  131429. export class InstancesBlock extends NodeMaterialBlock {
  131430. /**
  131431. * Creates a new InstancesBlock
  131432. * @param name defines the block name
  131433. */
  131434. constructor(name: string);
  131435. /**
  131436. * Gets the current class name
  131437. * @returns the class name
  131438. */
  131439. getClassName(): string;
  131440. /**
  131441. * Gets the first world row input component
  131442. */
  131443. get world0(): NodeMaterialConnectionPoint;
  131444. /**
  131445. * Gets the second world row input component
  131446. */
  131447. get world1(): NodeMaterialConnectionPoint;
  131448. /**
  131449. * Gets the third world row input component
  131450. */
  131451. get world2(): NodeMaterialConnectionPoint;
  131452. /**
  131453. * Gets the forth world row input component
  131454. */
  131455. get world3(): NodeMaterialConnectionPoint;
  131456. /**
  131457. * Gets the world input component
  131458. */
  131459. get world(): NodeMaterialConnectionPoint;
  131460. /**
  131461. * Gets the output component
  131462. */
  131463. get output(): NodeMaterialConnectionPoint;
  131464. /**
  131465. * Gets the isntanceID component
  131466. */
  131467. get instanceID(): NodeMaterialConnectionPoint;
  131468. autoConfigure(material: NodeMaterial): void;
  131469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131470. protected _buildBlock(state: NodeMaterialBuildState): this;
  131471. }
  131472. }
  131473. declare module BABYLON {
  131474. /**
  131475. * Block used to add morph targets support to vertex shader
  131476. */
  131477. export class MorphTargetsBlock extends NodeMaterialBlock {
  131478. private _repeatableContentAnchor;
  131479. /**
  131480. * Create a new MorphTargetsBlock
  131481. * @param name defines the block name
  131482. */
  131483. constructor(name: string);
  131484. /**
  131485. * Gets the current class name
  131486. * @returns the class name
  131487. */
  131488. getClassName(): string;
  131489. /**
  131490. * Gets the position input component
  131491. */
  131492. get position(): NodeMaterialConnectionPoint;
  131493. /**
  131494. * Gets the normal input component
  131495. */
  131496. get normal(): NodeMaterialConnectionPoint;
  131497. /**
  131498. * Gets the tangent input component
  131499. */
  131500. get tangent(): NodeMaterialConnectionPoint;
  131501. /**
  131502. * Gets the tangent input component
  131503. */
  131504. get uv(): NodeMaterialConnectionPoint;
  131505. /**
  131506. * Gets the position output component
  131507. */
  131508. get positionOutput(): NodeMaterialConnectionPoint;
  131509. /**
  131510. * Gets the normal output component
  131511. */
  131512. get normalOutput(): NodeMaterialConnectionPoint;
  131513. /**
  131514. * Gets the tangent output component
  131515. */
  131516. get tangentOutput(): NodeMaterialConnectionPoint;
  131517. /**
  131518. * Gets the tangent output component
  131519. */
  131520. get uvOutput(): NodeMaterialConnectionPoint;
  131521. initialize(state: NodeMaterialBuildState): void;
  131522. autoConfigure(material: NodeMaterial): void;
  131523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131525. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131526. protected _buildBlock(state: NodeMaterialBuildState): this;
  131527. }
  131528. }
  131529. declare module BABYLON {
  131530. /**
  131531. * Block used to get data information from a light
  131532. */
  131533. export class LightInformationBlock extends NodeMaterialBlock {
  131534. private _lightDataUniformName;
  131535. private _lightColorUniformName;
  131536. private _lightTypeDefineName;
  131537. /**
  131538. * Gets or sets the light associated with this block
  131539. */
  131540. light: Nullable<Light>;
  131541. /**
  131542. * Creates a new LightInformationBlock
  131543. * @param name defines the block name
  131544. */
  131545. constructor(name: string);
  131546. /**
  131547. * Gets the current class name
  131548. * @returns the class name
  131549. */
  131550. getClassName(): string;
  131551. /**
  131552. * Gets the world position input component
  131553. */
  131554. get worldPosition(): NodeMaterialConnectionPoint;
  131555. /**
  131556. * Gets the direction output component
  131557. */
  131558. get direction(): NodeMaterialConnectionPoint;
  131559. /**
  131560. * Gets the direction output component
  131561. */
  131562. get color(): NodeMaterialConnectionPoint;
  131563. /**
  131564. * Gets the direction output component
  131565. */
  131566. get intensity(): NodeMaterialConnectionPoint;
  131567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131569. protected _buildBlock(state: NodeMaterialBuildState): this;
  131570. serialize(): any;
  131571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131572. }
  131573. }
  131574. declare module BABYLON {
  131575. /**
  131576. * Block used to add image processing support to fragment shader
  131577. */
  131578. export class ImageProcessingBlock extends NodeMaterialBlock {
  131579. /**
  131580. * Create a new ImageProcessingBlock
  131581. * @param name defines the block name
  131582. */
  131583. constructor(name: string);
  131584. /**
  131585. * Gets the current class name
  131586. * @returns the class name
  131587. */
  131588. getClassName(): string;
  131589. /**
  131590. * Gets the color input component
  131591. */
  131592. get color(): NodeMaterialConnectionPoint;
  131593. /**
  131594. * Gets the output component
  131595. */
  131596. get output(): NodeMaterialConnectionPoint;
  131597. /**
  131598. * Initialize the block and prepare the context for build
  131599. * @param state defines the state that will be used for the build
  131600. */
  131601. initialize(state: NodeMaterialBuildState): void;
  131602. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131605. protected _buildBlock(state: NodeMaterialBuildState): this;
  131606. }
  131607. }
  131608. declare module BABYLON {
  131609. /**
  131610. * Block used to pertub normals based on a normal map
  131611. */
  131612. export class PerturbNormalBlock extends NodeMaterialBlock {
  131613. private _tangentSpaceParameterName;
  131614. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131615. invertX: boolean;
  131616. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131617. invertY: boolean;
  131618. /**
  131619. * Create a new PerturbNormalBlock
  131620. * @param name defines the block name
  131621. */
  131622. constructor(name: string);
  131623. /**
  131624. * Gets the current class name
  131625. * @returns the class name
  131626. */
  131627. getClassName(): string;
  131628. /**
  131629. * Gets the world position input component
  131630. */
  131631. get worldPosition(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the world normal input component
  131634. */
  131635. get worldNormal(): NodeMaterialConnectionPoint;
  131636. /**
  131637. * Gets the world tangent input component
  131638. */
  131639. get worldTangent(): NodeMaterialConnectionPoint;
  131640. /**
  131641. * Gets the uv input component
  131642. */
  131643. get uv(): NodeMaterialConnectionPoint;
  131644. /**
  131645. * Gets the normal map color input component
  131646. */
  131647. get normalMapColor(): NodeMaterialConnectionPoint;
  131648. /**
  131649. * Gets the strength input component
  131650. */
  131651. get strength(): NodeMaterialConnectionPoint;
  131652. /**
  131653. * Gets the output component
  131654. */
  131655. get output(): NodeMaterialConnectionPoint;
  131656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131658. autoConfigure(material: NodeMaterial): void;
  131659. protected _buildBlock(state: NodeMaterialBuildState): this;
  131660. protected _dumpPropertiesCode(): string;
  131661. serialize(): any;
  131662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131663. }
  131664. }
  131665. declare module BABYLON {
  131666. /**
  131667. * Block used to discard a pixel if a value is smaller than a cutoff
  131668. */
  131669. export class DiscardBlock extends NodeMaterialBlock {
  131670. /**
  131671. * Create a new DiscardBlock
  131672. * @param name defines the block name
  131673. */
  131674. constructor(name: string);
  131675. /**
  131676. * Gets the current class name
  131677. * @returns the class name
  131678. */
  131679. getClassName(): string;
  131680. /**
  131681. * Gets the color input component
  131682. */
  131683. get value(): NodeMaterialConnectionPoint;
  131684. /**
  131685. * Gets the cutoff input component
  131686. */
  131687. get cutoff(): NodeMaterialConnectionPoint;
  131688. protected _buildBlock(state: NodeMaterialBuildState): this;
  131689. }
  131690. }
  131691. declare module BABYLON {
  131692. /**
  131693. * Block used to test if the fragment shader is front facing
  131694. */
  131695. export class FrontFacingBlock extends NodeMaterialBlock {
  131696. /**
  131697. * Creates a new FrontFacingBlock
  131698. * @param name defines the block name
  131699. */
  131700. constructor(name: string);
  131701. /**
  131702. * Gets the current class name
  131703. * @returns the class name
  131704. */
  131705. getClassName(): string;
  131706. /**
  131707. * Gets the output component
  131708. */
  131709. get output(): NodeMaterialConnectionPoint;
  131710. protected _buildBlock(state: NodeMaterialBuildState): this;
  131711. }
  131712. }
  131713. declare module BABYLON {
  131714. /**
  131715. * Block used to get the derivative value on x and y of a given input
  131716. */
  131717. export class DerivativeBlock extends NodeMaterialBlock {
  131718. /**
  131719. * Create a new DerivativeBlock
  131720. * @param name defines the block name
  131721. */
  131722. constructor(name: string);
  131723. /**
  131724. * Gets the current class name
  131725. * @returns the class name
  131726. */
  131727. getClassName(): string;
  131728. /**
  131729. * Gets the input component
  131730. */
  131731. get input(): NodeMaterialConnectionPoint;
  131732. /**
  131733. * Gets the derivative output on x
  131734. */
  131735. get dx(): NodeMaterialConnectionPoint;
  131736. /**
  131737. * Gets the derivative output on y
  131738. */
  131739. get dy(): NodeMaterialConnectionPoint;
  131740. protected _buildBlock(state: NodeMaterialBuildState): this;
  131741. }
  131742. }
  131743. declare module BABYLON {
  131744. /**
  131745. * Block used to add support for scene fog
  131746. */
  131747. export class FogBlock extends NodeMaterialBlock {
  131748. private _fogDistanceName;
  131749. private _fogParameters;
  131750. /**
  131751. * Create a new FogBlock
  131752. * @param name defines the block name
  131753. */
  131754. constructor(name: string);
  131755. /**
  131756. * Gets the current class name
  131757. * @returns the class name
  131758. */
  131759. getClassName(): string;
  131760. /**
  131761. * Gets the world position input component
  131762. */
  131763. get worldPosition(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the view input component
  131766. */
  131767. get view(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the color input component
  131770. */
  131771. get input(): NodeMaterialConnectionPoint;
  131772. /**
  131773. * Gets the fog color input component
  131774. */
  131775. get fogColor(): NodeMaterialConnectionPoint;
  131776. /**
  131777. * Gets the output component
  131778. */
  131779. get output(): NodeMaterialConnectionPoint;
  131780. autoConfigure(material: NodeMaterial): void;
  131781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131783. protected _buildBlock(state: NodeMaterialBuildState): this;
  131784. }
  131785. }
  131786. declare module BABYLON {
  131787. /**
  131788. * Block used to add light in the fragment shader
  131789. */
  131790. export class LightBlock extends NodeMaterialBlock {
  131791. private _lightId;
  131792. /**
  131793. * Gets or sets the light associated with this block
  131794. */
  131795. light: Nullable<Light>;
  131796. /**
  131797. * Create a new LightBlock
  131798. * @param name defines the block name
  131799. */
  131800. constructor(name: string);
  131801. /**
  131802. * Gets the current class name
  131803. * @returns the class name
  131804. */
  131805. getClassName(): string;
  131806. /**
  131807. * Gets the world position input component
  131808. */
  131809. get worldPosition(): NodeMaterialConnectionPoint;
  131810. /**
  131811. * Gets the world normal input component
  131812. */
  131813. get worldNormal(): NodeMaterialConnectionPoint;
  131814. /**
  131815. * Gets the camera (or eye) position component
  131816. */
  131817. get cameraPosition(): NodeMaterialConnectionPoint;
  131818. /**
  131819. * Gets the glossiness component
  131820. */
  131821. get glossiness(): NodeMaterialConnectionPoint;
  131822. /**
  131823. * Gets the glossinness power component
  131824. */
  131825. get glossPower(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the diffuse color component
  131828. */
  131829. get diffuseColor(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the specular color component
  131832. */
  131833. get specularColor(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the diffuse output component
  131836. */
  131837. get diffuseOutput(): NodeMaterialConnectionPoint;
  131838. /**
  131839. * Gets the specular output component
  131840. */
  131841. get specularOutput(): NodeMaterialConnectionPoint;
  131842. /**
  131843. * Gets the shadow output component
  131844. */
  131845. get shadow(): NodeMaterialConnectionPoint;
  131846. autoConfigure(material: NodeMaterial): void;
  131847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131848. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131850. private _injectVertexCode;
  131851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131852. serialize(): any;
  131853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131854. }
  131855. }
  131856. declare module BABYLON {
  131857. /**
  131858. * Block used to multiply 2 values
  131859. */
  131860. export class MultiplyBlock extends NodeMaterialBlock {
  131861. /**
  131862. * Creates a new MultiplyBlock
  131863. * @param name defines the block name
  131864. */
  131865. constructor(name: string);
  131866. /**
  131867. * Gets the current class name
  131868. * @returns the class name
  131869. */
  131870. getClassName(): string;
  131871. /**
  131872. * Gets the left operand input component
  131873. */
  131874. get left(): NodeMaterialConnectionPoint;
  131875. /**
  131876. * Gets the right operand input component
  131877. */
  131878. get right(): NodeMaterialConnectionPoint;
  131879. /**
  131880. * Gets the output component
  131881. */
  131882. get output(): NodeMaterialConnectionPoint;
  131883. protected _buildBlock(state: NodeMaterialBuildState): this;
  131884. }
  131885. }
  131886. declare module BABYLON {
  131887. /**
  131888. * Block used to add 2 vectors
  131889. */
  131890. export class AddBlock extends NodeMaterialBlock {
  131891. /**
  131892. * Creates a new AddBlock
  131893. * @param name defines the block name
  131894. */
  131895. constructor(name: string);
  131896. /**
  131897. * Gets the current class name
  131898. * @returns the class name
  131899. */
  131900. getClassName(): string;
  131901. /**
  131902. * Gets the left operand input component
  131903. */
  131904. get left(): NodeMaterialConnectionPoint;
  131905. /**
  131906. * Gets the right operand input component
  131907. */
  131908. get right(): NodeMaterialConnectionPoint;
  131909. /**
  131910. * Gets the output component
  131911. */
  131912. get output(): NodeMaterialConnectionPoint;
  131913. protected _buildBlock(state: NodeMaterialBuildState): this;
  131914. }
  131915. }
  131916. declare module BABYLON {
  131917. /**
  131918. * Block used to scale a vector by a float
  131919. */
  131920. export class ScaleBlock extends NodeMaterialBlock {
  131921. /**
  131922. * Creates a new ScaleBlock
  131923. * @param name defines the block name
  131924. */
  131925. constructor(name: string);
  131926. /**
  131927. * Gets the current class name
  131928. * @returns the class name
  131929. */
  131930. getClassName(): string;
  131931. /**
  131932. * Gets the input component
  131933. */
  131934. get input(): NodeMaterialConnectionPoint;
  131935. /**
  131936. * Gets the factor input component
  131937. */
  131938. get factor(): NodeMaterialConnectionPoint;
  131939. /**
  131940. * Gets the output component
  131941. */
  131942. get output(): NodeMaterialConnectionPoint;
  131943. protected _buildBlock(state: NodeMaterialBuildState): this;
  131944. }
  131945. }
  131946. declare module BABYLON {
  131947. /**
  131948. * Block used to clamp a float
  131949. */
  131950. export class ClampBlock extends NodeMaterialBlock {
  131951. /** Gets or sets the minimum range */
  131952. minimum: number;
  131953. /** Gets or sets the maximum range */
  131954. maximum: number;
  131955. /**
  131956. * Creates a new ClampBlock
  131957. * @param name defines the block name
  131958. */
  131959. constructor(name: string);
  131960. /**
  131961. * Gets the current class name
  131962. * @returns the class name
  131963. */
  131964. getClassName(): string;
  131965. /**
  131966. * Gets the value input component
  131967. */
  131968. get value(): NodeMaterialConnectionPoint;
  131969. /**
  131970. * Gets the output component
  131971. */
  131972. get output(): NodeMaterialConnectionPoint;
  131973. protected _buildBlock(state: NodeMaterialBuildState): this;
  131974. protected _dumpPropertiesCode(): string;
  131975. serialize(): any;
  131976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131977. }
  131978. }
  131979. declare module BABYLON {
  131980. /**
  131981. * Block used to apply a cross product between 2 vectors
  131982. */
  131983. export class CrossBlock extends NodeMaterialBlock {
  131984. /**
  131985. * Creates a new CrossBlock
  131986. * @param name defines the block name
  131987. */
  131988. constructor(name: string);
  131989. /**
  131990. * Gets the current class name
  131991. * @returns the class name
  131992. */
  131993. getClassName(): string;
  131994. /**
  131995. * Gets the left operand input component
  131996. */
  131997. get left(): NodeMaterialConnectionPoint;
  131998. /**
  131999. * Gets the right operand input component
  132000. */
  132001. get right(): NodeMaterialConnectionPoint;
  132002. /**
  132003. * Gets the output component
  132004. */
  132005. get output(): NodeMaterialConnectionPoint;
  132006. protected _buildBlock(state: NodeMaterialBuildState): this;
  132007. }
  132008. }
  132009. declare module BABYLON {
  132010. /**
  132011. * Block used to apply a dot product between 2 vectors
  132012. */
  132013. export class DotBlock extends NodeMaterialBlock {
  132014. /**
  132015. * Creates a new DotBlock
  132016. * @param name defines the block name
  132017. */
  132018. constructor(name: string);
  132019. /**
  132020. * Gets the current class name
  132021. * @returns the class name
  132022. */
  132023. getClassName(): string;
  132024. /**
  132025. * Gets the left operand input component
  132026. */
  132027. get left(): NodeMaterialConnectionPoint;
  132028. /**
  132029. * Gets the right operand input component
  132030. */
  132031. get right(): NodeMaterialConnectionPoint;
  132032. /**
  132033. * Gets the output component
  132034. */
  132035. get output(): NodeMaterialConnectionPoint;
  132036. protected _buildBlock(state: NodeMaterialBuildState): this;
  132037. }
  132038. }
  132039. declare module BABYLON {
  132040. /**
  132041. * Block used to remap a float from a range to a new one
  132042. */
  132043. export class RemapBlock extends NodeMaterialBlock {
  132044. /**
  132045. * Gets or sets the source range
  132046. */
  132047. sourceRange: Vector2;
  132048. /**
  132049. * Gets or sets the target range
  132050. */
  132051. targetRange: Vector2;
  132052. /**
  132053. * Creates a new RemapBlock
  132054. * @param name defines the block name
  132055. */
  132056. constructor(name: string);
  132057. /**
  132058. * Gets the current class name
  132059. * @returns the class name
  132060. */
  132061. getClassName(): string;
  132062. /**
  132063. * Gets the input component
  132064. */
  132065. get input(): NodeMaterialConnectionPoint;
  132066. /**
  132067. * Gets the source min input component
  132068. */
  132069. get sourceMin(): NodeMaterialConnectionPoint;
  132070. /**
  132071. * Gets the source max input component
  132072. */
  132073. get sourceMax(): NodeMaterialConnectionPoint;
  132074. /**
  132075. * Gets the target min input component
  132076. */
  132077. get targetMin(): NodeMaterialConnectionPoint;
  132078. /**
  132079. * Gets the target max input component
  132080. */
  132081. get targetMax(): NodeMaterialConnectionPoint;
  132082. /**
  132083. * Gets the output component
  132084. */
  132085. get output(): NodeMaterialConnectionPoint;
  132086. protected _buildBlock(state: NodeMaterialBuildState): this;
  132087. protected _dumpPropertiesCode(): string;
  132088. serialize(): any;
  132089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132090. }
  132091. }
  132092. declare module BABYLON {
  132093. /**
  132094. * Block used to normalize a vector
  132095. */
  132096. export class NormalizeBlock extends NodeMaterialBlock {
  132097. /**
  132098. * Creates a new NormalizeBlock
  132099. * @param name defines the block name
  132100. */
  132101. constructor(name: string);
  132102. /**
  132103. * Gets the current class name
  132104. * @returns the class name
  132105. */
  132106. getClassName(): string;
  132107. /**
  132108. * Gets the input component
  132109. */
  132110. get input(): NodeMaterialConnectionPoint;
  132111. /**
  132112. * Gets the output component
  132113. */
  132114. get output(): NodeMaterialConnectionPoint;
  132115. protected _buildBlock(state: NodeMaterialBuildState): this;
  132116. }
  132117. }
  132118. declare module BABYLON {
  132119. /**
  132120. * Operations supported by the Trigonometry block
  132121. */
  132122. export enum TrigonometryBlockOperations {
  132123. /** Cos */
  132124. Cos = 0,
  132125. /** Sin */
  132126. Sin = 1,
  132127. /** Abs */
  132128. Abs = 2,
  132129. /** Exp */
  132130. Exp = 3,
  132131. /** Exp2 */
  132132. Exp2 = 4,
  132133. /** Round */
  132134. Round = 5,
  132135. /** Floor */
  132136. Floor = 6,
  132137. /** Ceiling */
  132138. Ceiling = 7,
  132139. /** Square root */
  132140. Sqrt = 8,
  132141. /** Log */
  132142. Log = 9,
  132143. /** Tangent */
  132144. Tan = 10,
  132145. /** Arc tangent */
  132146. ArcTan = 11,
  132147. /** Arc cosinus */
  132148. ArcCos = 12,
  132149. /** Arc sinus */
  132150. ArcSin = 13,
  132151. /** Fraction */
  132152. Fract = 14,
  132153. /** Sign */
  132154. Sign = 15,
  132155. /** To radians (from degrees) */
  132156. Radians = 16,
  132157. /** To degrees (from radians) */
  132158. Degrees = 17
  132159. }
  132160. /**
  132161. * Block used to apply trigonometry operation to floats
  132162. */
  132163. export class TrigonometryBlock extends NodeMaterialBlock {
  132164. /**
  132165. * Gets or sets the operation applied by the block
  132166. */
  132167. operation: TrigonometryBlockOperations;
  132168. /**
  132169. * Creates a new TrigonometryBlock
  132170. * @param name defines the block name
  132171. */
  132172. constructor(name: string);
  132173. /**
  132174. * Gets the current class name
  132175. * @returns the class name
  132176. */
  132177. getClassName(): string;
  132178. /**
  132179. * Gets the input component
  132180. */
  132181. get input(): NodeMaterialConnectionPoint;
  132182. /**
  132183. * Gets the output component
  132184. */
  132185. get output(): NodeMaterialConnectionPoint;
  132186. protected _buildBlock(state: NodeMaterialBuildState): this;
  132187. serialize(): any;
  132188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132189. protected _dumpPropertiesCode(): string;
  132190. }
  132191. }
  132192. declare module BABYLON {
  132193. /**
  132194. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132195. */
  132196. export class ColorMergerBlock extends NodeMaterialBlock {
  132197. /**
  132198. * Create a new ColorMergerBlock
  132199. * @param name defines the block name
  132200. */
  132201. constructor(name: string);
  132202. /**
  132203. * Gets the current class name
  132204. * @returns the class name
  132205. */
  132206. getClassName(): string;
  132207. /**
  132208. * Gets the rgb component (input)
  132209. */
  132210. get rgbIn(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the r component (input)
  132213. */
  132214. get r(): NodeMaterialConnectionPoint;
  132215. /**
  132216. * Gets the g component (input)
  132217. */
  132218. get g(): NodeMaterialConnectionPoint;
  132219. /**
  132220. * Gets the b component (input)
  132221. */
  132222. get b(): NodeMaterialConnectionPoint;
  132223. /**
  132224. * Gets the a component (input)
  132225. */
  132226. get a(): NodeMaterialConnectionPoint;
  132227. /**
  132228. * Gets the rgba component (output)
  132229. */
  132230. get rgba(): NodeMaterialConnectionPoint;
  132231. /**
  132232. * Gets the rgb component (output)
  132233. */
  132234. get rgbOut(): NodeMaterialConnectionPoint;
  132235. /**
  132236. * Gets the rgb component (output)
  132237. * @deprecated Please use rgbOut instead.
  132238. */
  132239. get rgb(): NodeMaterialConnectionPoint;
  132240. protected _buildBlock(state: NodeMaterialBuildState): this;
  132241. }
  132242. }
  132243. declare module BABYLON {
  132244. /**
  132245. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132246. */
  132247. export class VectorMergerBlock extends NodeMaterialBlock {
  132248. /**
  132249. * Create a new VectorMergerBlock
  132250. * @param name defines the block name
  132251. */
  132252. constructor(name: string);
  132253. /**
  132254. * Gets the current class name
  132255. * @returns the class name
  132256. */
  132257. getClassName(): string;
  132258. /**
  132259. * Gets the xyz component (input)
  132260. */
  132261. get xyzIn(): NodeMaterialConnectionPoint;
  132262. /**
  132263. * Gets the xy component (input)
  132264. */
  132265. get xyIn(): NodeMaterialConnectionPoint;
  132266. /**
  132267. * Gets the x component (input)
  132268. */
  132269. get x(): NodeMaterialConnectionPoint;
  132270. /**
  132271. * Gets the y component (input)
  132272. */
  132273. get y(): NodeMaterialConnectionPoint;
  132274. /**
  132275. * Gets the z component (input)
  132276. */
  132277. get z(): NodeMaterialConnectionPoint;
  132278. /**
  132279. * Gets the w component (input)
  132280. */
  132281. get w(): NodeMaterialConnectionPoint;
  132282. /**
  132283. * Gets the xyzw component (output)
  132284. */
  132285. get xyzw(): NodeMaterialConnectionPoint;
  132286. /**
  132287. * Gets the xyz component (output)
  132288. */
  132289. get xyzOut(): NodeMaterialConnectionPoint;
  132290. /**
  132291. * Gets the xy component (output)
  132292. */
  132293. get xyOut(): NodeMaterialConnectionPoint;
  132294. /**
  132295. * Gets the xy component (output)
  132296. * @deprecated Please use xyOut instead.
  132297. */
  132298. get xy(): NodeMaterialConnectionPoint;
  132299. /**
  132300. * Gets the xyz component (output)
  132301. * @deprecated Please use xyzOut instead.
  132302. */
  132303. get xyz(): NodeMaterialConnectionPoint;
  132304. protected _buildBlock(state: NodeMaterialBuildState): this;
  132305. }
  132306. }
  132307. declare module BABYLON {
  132308. /**
  132309. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132310. */
  132311. export class ColorSplitterBlock extends NodeMaterialBlock {
  132312. /**
  132313. * Create a new ColorSplitterBlock
  132314. * @param name defines the block name
  132315. */
  132316. constructor(name: string);
  132317. /**
  132318. * Gets the current class name
  132319. * @returns the class name
  132320. */
  132321. getClassName(): string;
  132322. /**
  132323. * Gets the rgba component (input)
  132324. */
  132325. get rgba(): NodeMaterialConnectionPoint;
  132326. /**
  132327. * Gets the rgb component (input)
  132328. */
  132329. get rgbIn(): NodeMaterialConnectionPoint;
  132330. /**
  132331. * Gets the rgb component (output)
  132332. */
  132333. get rgbOut(): NodeMaterialConnectionPoint;
  132334. /**
  132335. * Gets the r component (output)
  132336. */
  132337. get r(): NodeMaterialConnectionPoint;
  132338. /**
  132339. * Gets the g component (output)
  132340. */
  132341. get g(): NodeMaterialConnectionPoint;
  132342. /**
  132343. * Gets the b component (output)
  132344. */
  132345. get b(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the a component (output)
  132348. */
  132349. get a(): NodeMaterialConnectionPoint;
  132350. protected _inputRename(name: string): string;
  132351. protected _outputRename(name: string): string;
  132352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132353. }
  132354. }
  132355. declare module BABYLON {
  132356. /**
  132357. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132358. */
  132359. export class VectorSplitterBlock extends NodeMaterialBlock {
  132360. /**
  132361. * Create a new VectorSplitterBlock
  132362. * @param name defines the block name
  132363. */
  132364. constructor(name: string);
  132365. /**
  132366. * Gets the current class name
  132367. * @returns the class name
  132368. */
  132369. getClassName(): string;
  132370. /**
  132371. * Gets the xyzw component (input)
  132372. */
  132373. get xyzw(): NodeMaterialConnectionPoint;
  132374. /**
  132375. * Gets the xyz component (input)
  132376. */
  132377. get xyzIn(): NodeMaterialConnectionPoint;
  132378. /**
  132379. * Gets the xy component (input)
  132380. */
  132381. get xyIn(): NodeMaterialConnectionPoint;
  132382. /**
  132383. * Gets the xyz component (output)
  132384. */
  132385. get xyzOut(): NodeMaterialConnectionPoint;
  132386. /**
  132387. * Gets the xy component (output)
  132388. */
  132389. get xyOut(): NodeMaterialConnectionPoint;
  132390. /**
  132391. * Gets the x component (output)
  132392. */
  132393. get x(): NodeMaterialConnectionPoint;
  132394. /**
  132395. * Gets the y component (output)
  132396. */
  132397. get y(): NodeMaterialConnectionPoint;
  132398. /**
  132399. * Gets the z component (output)
  132400. */
  132401. get z(): NodeMaterialConnectionPoint;
  132402. /**
  132403. * Gets the w component (output)
  132404. */
  132405. get w(): NodeMaterialConnectionPoint;
  132406. protected _inputRename(name: string): string;
  132407. protected _outputRename(name: string): string;
  132408. protected _buildBlock(state: NodeMaterialBuildState): this;
  132409. }
  132410. }
  132411. declare module BABYLON {
  132412. /**
  132413. * Block used to lerp between 2 values
  132414. */
  132415. export class LerpBlock extends NodeMaterialBlock {
  132416. /**
  132417. * Creates a new LerpBlock
  132418. * @param name defines the block name
  132419. */
  132420. constructor(name: string);
  132421. /**
  132422. * Gets the current class name
  132423. * @returns the class name
  132424. */
  132425. getClassName(): string;
  132426. /**
  132427. * Gets the left operand input component
  132428. */
  132429. get left(): NodeMaterialConnectionPoint;
  132430. /**
  132431. * Gets the right operand input component
  132432. */
  132433. get right(): NodeMaterialConnectionPoint;
  132434. /**
  132435. * Gets the gradient operand input component
  132436. */
  132437. get gradient(): NodeMaterialConnectionPoint;
  132438. /**
  132439. * Gets the output component
  132440. */
  132441. get output(): NodeMaterialConnectionPoint;
  132442. protected _buildBlock(state: NodeMaterialBuildState): this;
  132443. }
  132444. }
  132445. declare module BABYLON {
  132446. /**
  132447. * Block used to divide 2 vectors
  132448. */
  132449. export class DivideBlock extends NodeMaterialBlock {
  132450. /**
  132451. * Creates a new DivideBlock
  132452. * @param name defines the block name
  132453. */
  132454. constructor(name: string);
  132455. /**
  132456. * Gets the current class name
  132457. * @returns the class name
  132458. */
  132459. getClassName(): string;
  132460. /**
  132461. * Gets the left operand input component
  132462. */
  132463. get left(): NodeMaterialConnectionPoint;
  132464. /**
  132465. * Gets the right operand input component
  132466. */
  132467. get right(): NodeMaterialConnectionPoint;
  132468. /**
  132469. * Gets the output component
  132470. */
  132471. get output(): NodeMaterialConnectionPoint;
  132472. protected _buildBlock(state: NodeMaterialBuildState): this;
  132473. }
  132474. }
  132475. declare module BABYLON {
  132476. /**
  132477. * Block used to subtract 2 vectors
  132478. */
  132479. export class SubtractBlock extends NodeMaterialBlock {
  132480. /**
  132481. * Creates a new SubtractBlock
  132482. * @param name defines the block name
  132483. */
  132484. constructor(name: string);
  132485. /**
  132486. * Gets the current class name
  132487. * @returns the class name
  132488. */
  132489. getClassName(): string;
  132490. /**
  132491. * Gets the left operand input component
  132492. */
  132493. get left(): NodeMaterialConnectionPoint;
  132494. /**
  132495. * Gets the right operand input component
  132496. */
  132497. get right(): NodeMaterialConnectionPoint;
  132498. /**
  132499. * Gets the output component
  132500. */
  132501. get output(): NodeMaterialConnectionPoint;
  132502. protected _buildBlock(state: NodeMaterialBuildState): this;
  132503. }
  132504. }
  132505. declare module BABYLON {
  132506. /**
  132507. * Block used to step a value
  132508. */
  132509. export class StepBlock extends NodeMaterialBlock {
  132510. /**
  132511. * Creates a new StepBlock
  132512. * @param name defines the block name
  132513. */
  132514. constructor(name: string);
  132515. /**
  132516. * Gets the current class name
  132517. * @returns the class name
  132518. */
  132519. getClassName(): string;
  132520. /**
  132521. * Gets the value operand input component
  132522. */
  132523. get value(): NodeMaterialConnectionPoint;
  132524. /**
  132525. * Gets the edge operand input component
  132526. */
  132527. get edge(): NodeMaterialConnectionPoint;
  132528. /**
  132529. * Gets the output component
  132530. */
  132531. get output(): NodeMaterialConnectionPoint;
  132532. protected _buildBlock(state: NodeMaterialBuildState): this;
  132533. }
  132534. }
  132535. declare module BABYLON {
  132536. /**
  132537. * Block used to get the opposite (1 - x) of a value
  132538. */
  132539. export class OneMinusBlock extends NodeMaterialBlock {
  132540. /**
  132541. * Creates a new OneMinusBlock
  132542. * @param name defines the block name
  132543. */
  132544. constructor(name: string);
  132545. /**
  132546. * Gets the current class name
  132547. * @returns the class name
  132548. */
  132549. getClassName(): string;
  132550. /**
  132551. * Gets the input component
  132552. */
  132553. get input(): NodeMaterialConnectionPoint;
  132554. /**
  132555. * Gets the output component
  132556. */
  132557. get output(): NodeMaterialConnectionPoint;
  132558. protected _buildBlock(state: NodeMaterialBuildState): this;
  132559. }
  132560. }
  132561. declare module BABYLON {
  132562. /**
  132563. * Block used to get the view direction
  132564. */
  132565. export class ViewDirectionBlock extends NodeMaterialBlock {
  132566. /**
  132567. * Creates a new ViewDirectionBlock
  132568. * @param name defines the block name
  132569. */
  132570. constructor(name: string);
  132571. /**
  132572. * Gets the current class name
  132573. * @returns the class name
  132574. */
  132575. getClassName(): string;
  132576. /**
  132577. * Gets the world position component
  132578. */
  132579. get worldPosition(): NodeMaterialConnectionPoint;
  132580. /**
  132581. * Gets the camera position component
  132582. */
  132583. get cameraPosition(): NodeMaterialConnectionPoint;
  132584. /**
  132585. * Gets the output component
  132586. */
  132587. get output(): NodeMaterialConnectionPoint;
  132588. autoConfigure(material: NodeMaterial): void;
  132589. protected _buildBlock(state: NodeMaterialBuildState): this;
  132590. }
  132591. }
  132592. declare module BABYLON {
  132593. /**
  132594. * Block used to compute fresnel value
  132595. */
  132596. export class FresnelBlock extends NodeMaterialBlock {
  132597. /**
  132598. * Create a new FresnelBlock
  132599. * @param name defines the block name
  132600. */
  132601. constructor(name: string);
  132602. /**
  132603. * Gets the current class name
  132604. * @returns the class name
  132605. */
  132606. getClassName(): string;
  132607. /**
  132608. * Gets the world normal input component
  132609. */
  132610. get worldNormal(): NodeMaterialConnectionPoint;
  132611. /**
  132612. * Gets the view direction input component
  132613. */
  132614. get viewDirection(): NodeMaterialConnectionPoint;
  132615. /**
  132616. * Gets the bias input component
  132617. */
  132618. get bias(): NodeMaterialConnectionPoint;
  132619. /**
  132620. * Gets the camera (or eye) position component
  132621. */
  132622. get power(): NodeMaterialConnectionPoint;
  132623. /**
  132624. * Gets the fresnel output component
  132625. */
  132626. get fresnel(): NodeMaterialConnectionPoint;
  132627. autoConfigure(material: NodeMaterial): void;
  132628. protected _buildBlock(state: NodeMaterialBuildState): this;
  132629. }
  132630. }
  132631. declare module BABYLON {
  132632. /**
  132633. * Block used to get the max of 2 values
  132634. */
  132635. export class MaxBlock extends NodeMaterialBlock {
  132636. /**
  132637. * Creates a new MaxBlock
  132638. * @param name defines the block name
  132639. */
  132640. constructor(name: string);
  132641. /**
  132642. * Gets the current class name
  132643. * @returns the class name
  132644. */
  132645. getClassName(): string;
  132646. /**
  132647. * Gets the left operand input component
  132648. */
  132649. get left(): NodeMaterialConnectionPoint;
  132650. /**
  132651. * Gets the right operand input component
  132652. */
  132653. get right(): NodeMaterialConnectionPoint;
  132654. /**
  132655. * Gets the output component
  132656. */
  132657. get output(): NodeMaterialConnectionPoint;
  132658. protected _buildBlock(state: NodeMaterialBuildState): this;
  132659. }
  132660. }
  132661. declare module BABYLON {
  132662. /**
  132663. * Block used to get the min of 2 values
  132664. */
  132665. export class MinBlock extends NodeMaterialBlock {
  132666. /**
  132667. * Creates a new MinBlock
  132668. * @param name defines the block name
  132669. */
  132670. constructor(name: string);
  132671. /**
  132672. * Gets the current class name
  132673. * @returns the class name
  132674. */
  132675. getClassName(): string;
  132676. /**
  132677. * Gets the left operand input component
  132678. */
  132679. get left(): NodeMaterialConnectionPoint;
  132680. /**
  132681. * Gets the right operand input component
  132682. */
  132683. get right(): NodeMaterialConnectionPoint;
  132684. /**
  132685. * Gets the output component
  132686. */
  132687. get output(): NodeMaterialConnectionPoint;
  132688. protected _buildBlock(state: NodeMaterialBuildState): this;
  132689. }
  132690. }
  132691. declare module BABYLON {
  132692. /**
  132693. * Block used to get the distance between 2 values
  132694. */
  132695. export class DistanceBlock extends NodeMaterialBlock {
  132696. /**
  132697. * Creates a new DistanceBlock
  132698. * @param name defines the block name
  132699. */
  132700. constructor(name: string);
  132701. /**
  132702. * Gets the current class name
  132703. * @returns the class name
  132704. */
  132705. getClassName(): string;
  132706. /**
  132707. * Gets the left operand input component
  132708. */
  132709. get left(): NodeMaterialConnectionPoint;
  132710. /**
  132711. * Gets the right operand input component
  132712. */
  132713. get right(): NodeMaterialConnectionPoint;
  132714. /**
  132715. * Gets the output component
  132716. */
  132717. get output(): NodeMaterialConnectionPoint;
  132718. protected _buildBlock(state: NodeMaterialBuildState): this;
  132719. }
  132720. }
  132721. declare module BABYLON {
  132722. /**
  132723. * Block used to get the length of a vector
  132724. */
  132725. export class LengthBlock extends NodeMaterialBlock {
  132726. /**
  132727. * Creates a new LengthBlock
  132728. * @param name defines the block name
  132729. */
  132730. constructor(name: string);
  132731. /**
  132732. * Gets the current class name
  132733. * @returns the class name
  132734. */
  132735. getClassName(): string;
  132736. /**
  132737. * Gets the value input component
  132738. */
  132739. get value(): NodeMaterialConnectionPoint;
  132740. /**
  132741. * Gets the output component
  132742. */
  132743. get output(): NodeMaterialConnectionPoint;
  132744. protected _buildBlock(state: NodeMaterialBuildState): this;
  132745. }
  132746. }
  132747. declare module BABYLON {
  132748. /**
  132749. * Block used to get negative version of a value (i.e. x * -1)
  132750. */
  132751. export class NegateBlock extends NodeMaterialBlock {
  132752. /**
  132753. * Creates a new NegateBlock
  132754. * @param name defines the block name
  132755. */
  132756. constructor(name: string);
  132757. /**
  132758. * Gets the current class name
  132759. * @returns the class name
  132760. */
  132761. getClassName(): string;
  132762. /**
  132763. * Gets the value input component
  132764. */
  132765. get value(): NodeMaterialConnectionPoint;
  132766. /**
  132767. * Gets the output component
  132768. */
  132769. get output(): NodeMaterialConnectionPoint;
  132770. protected _buildBlock(state: NodeMaterialBuildState): this;
  132771. }
  132772. }
  132773. declare module BABYLON {
  132774. /**
  132775. * Block used to get the value of the first parameter raised to the power of the second
  132776. */
  132777. export class PowBlock extends NodeMaterialBlock {
  132778. /**
  132779. * Creates a new PowBlock
  132780. * @param name defines the block name
  132781. */
  132782. constructor(name: string);
  132783. /**
  132784. * Gets the current class name
  132785. * @returns the class name
  132786. */
  132787. getClassName(): string;
  132788. /**
  132789. * Gets the value operand input component
  132790. */
  132791. get value(): NodeMaterialConnectionPoint;
  132792. /**
  132793. * Gets the power operand input component
  132794. */
  132795. get power(): NodeMaterialConnectionPoint;
  132796. /**
  132797. * Gets the output component
  132798. */
  132799. get output(): NodeMaterialConnectionPoint;
  132800. protected _buildBlock(state: NodeMaterialBuildState): this;
  132801. }
  132802. }
  132803. declare module BABYLON {
  132804. /**
  132805. * Block used to get a random number
  132806. */
  132807. export class RandomNumberBlock extends NodeMaterialBlock {
  132808. /**
  132809. * Creates a new RandomNumberBlock
  132810. * @param name defines the block name
  132811. */
  132812. constructor(name: string);
  132813. /**
  132814. * Gets the current class name
  132815. * @returns the class name
  132816. */
  132817. getClassName(): string;
  132818. /**
  132819. * Gets the seed input component
  132820. */
  132821. get seed(): NodeMaterialConnectionPoint;
  132822. /**
  132823. * Gets the output component
  132824. */
  132825. get output(): NodeMaterialConnectionPoint;
  132826. protected _buildBlock(state: NodeMaterialBuildState): this;
  132827. }
  132828. }
  132829. declare module BABYLON {
  132830. /**
  132831. * Block used to compute arc tangent of 2 values
  132832. */
  132833. export class ArcTan2Block extends NodeMaterialBlock {
  132834. /**
  132835. * Creates a new ArcTan2Block
  132836. * @param name defines the block name
  132837. */
  132838. constructor(name: string);
  132839. /**
  132840. * Gets the current class name
  132841. * @returns the class name
  132842. */
  132843. getClassName(): string;
  132844. /**
  132845. * Gets the x operand input component
  132846. */
  132847. get x(): NodeMaterialConnectionPoint;
  132848. /**
  132849. * Gets the y operand input component
  132850. */
  132851. get y(): NodeMaterialConnectionPoint;
  132852. /**
  132853. * Gets the output component
  132854. */
  132855. get output(): NodeMaterialConnectionPoint;
  132856. protected _buildBlock(state: NodeMaterialBuildState): this;
  132857. }
  132858. }
  132859. declare module BABYLON {
  132860. /**
  132861. * Block used to smooth step a value
  132862. */
  132863. export class SmoothStepBlock extends NodeMaterialBlock {
  132864. /**
  132865. * Creates a new SmoothStepBlock
  132866. * @param name defines the block name
  132867. */
  132868. constructor(name: string);
  132869. /**
  132870. * Gets the current class name
  132871. * @returns the class name
  132872. */
  132873. getClassName(): string;
  132874. /**
  132875. * Gets the value operand input component
  132876. */
  132877. get value(): NodeMaterialConnectionPoint;
  132878. /**
  132879. * Gets the first edge operand input component
  132880. */
  132881. get edge0(): NodeMaterialConnectionPoint;
  132882. /**
  132883. * Gets the second edge operand input component
  132884. */
  132885. get edge1(): NodeMaterialConnectionPoint;
  132886. /**
  132887. * Gets the output component
  132888. */
  132889. get output(): NodeMaterialConnectionPoint;
  132890. protected _buildBlock(state: NodeMaterialBuildState): this;
  132891. }
  132892. }
  132893. declare module BABYLON {
  132894. /**
  132895. * Block used to get the reciprocal (1 / x) of a value
  132896. */
  132897. export class ReciprocalBlock extends NodeMaterialBlock {
  132898. /**
  132899. * Creates a new ReciprocalBlock
  132900. * @param name defines the block name
  132901. */
  132902. constructor(name: string);
  132903. /**
  132904. * Gets the current class name
  132905. * @returns the class name
  132906. */
  132907. getClassName(): string;
  132908. /**
  132909. * Gets the input component
  132910. */
  132911. get input(): NodeMaterialConnectionPoint;
  132912. /**
  132913. * Gets the output component
  132914. */
  132915. get output(): NodeMaterialConnectionPoint;
  132916. protected _buildBlock(state: NodeMaterialBuildState): this;
  132917. }
  132918. }
  132919. declare module BABYLON {
  132920. /**
  132921. * Block used to replace a color by another one
  132922. */
  132923. export class ReplaceColorBlock extends NodeMaterialBlock {
  132924. /**
  132925. * Creates a new ReplaceColorBlock
  132926. * @param name defines the block name
  132927. */
  132928. constructor(name: string);
  132929. /**
  132930. * Gets the current class name
  132931. * @returns the class name
  132932. */
  132933. getClassName(): string;
  132934. /**
  132935. * Gets the value input component
  132936. */
  132937. get value(): NodeMaterialConnectionPoint;
  132938. /**
  132939. * Gets the reference input component
  132940. */
  132941. get reference(): NodeMaterialConnectionPoint;
  132942. /**
  132943. * Gets the distance input component
  132944. */
  132945. get distance(): NodeMaterialConnectionPoint;
  132946. /**
  132947. * Gets the replacement input component
  132948. */
  132949. get replacement(): NodeMaterialConnectionPoint;
  132950. /**
  132951. * Gets the output component
  132952. */
  132953. get output(): NodeMaterialConnectionPoint;
  132954. protected _buildBlock(state: NodeMaterialBuildState): this;
  132955. }
  132956. }
  132957. declare module BABYLON {
  132958. /**
  132959. * Block used to posterize a value
  132960. * @see https://en.wikipedia.org/wiki/Posterization
  132961. */
  132962. export class PosterizeBlock extends NodeMaterialBlock {
  132963. /**
  132964. * Creates a new PosterizeBlock
  132965. * @param name defines the block name
  132966. */
  132967. constructor(name: string);
  132968. /**
  132969. * Gets the current class name
  132970. * @returns the class name
  132971. */
  132972. getClassName(): string;
  132973. /**
  132974. * Gets the value input component
  132975. */
  132976. get value(): NodeMaterialConnectionPoint;
  132977. /**
  132978. * Gets the steps input component
  132979. */
  132980. get steps(): NodeMaterialConnectionPoint;
  132981. /**
  132982. * Gets the output component
  132983. */
  132984. get output(): NodeMaterialConnectionPoint;
  132985. protected _buildBlock(state: NodeMaterialBuildState): this;
  132986. }
  132987. }
  132988. declare module BABYLON {
  132989. /**
  132990. * Operations supported by the Wave block
  132991. */
  132992. export enum WaveBlockKind {
  132993. /** SawTooth */
  132994. SawTooth = 0,
  132995. /** Square */
  132996. Square = 1,
  132997. /** Triangle */
  132998. Triangle = 2
  132999. }
  133000. /**
  133001. * Block used to apply wave operation to floats
  133002. */
  133003. export class WaveBlock extends NodeMaterialBlock {
  133004. /**
  133005. * Gets or sets the kibnd of wave to be applied by the block
  133006. */
  133007. kind: WaveBlockKind;
  133008. /**
  133009. * Creates a new WaveBlock
  133010. * @param name defines the block name
  133011. */
  133012. constructor(name: string);
  133013. /**
  133014. * Gets the current class name
  133015. * @returns the class name
  133016. */
  133017. getClassName(): string;
  133018. /**
  133019. * Gets the input component
  133020. */
  133021. get input(): NodeMaterialConnectionPoint;
  133022. /**
  133023. * Gets the output component
  133024. */
  133025. get output(): NodeMaterialConnectionPoint;
  133026. protected _buildBlock(state: NodeMaterialBuildState): this;
  133027. serialize(): any;
  133028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133029. }
  133030. }
  133031. declare module BABYLON {
  133032. /**
  133033. * Class used to store a color step for the GradientBlock
  133034. */
  133035. export class GradientBlockColorStep {
  133036. /**
  133037. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133038. */
  133039. step: number;
  133040. /**
  133041. * Gets or sets the color associated with this step
  133042. */
  133043. color: Color3;
  133044. /**
  133045. * Creates a new GradientBlockColorStep
  133046. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133047. * @param color defines the color associated with this step
  133048. */
  133049. constructor(
  133050. /**
  133051. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133052. */
  133053. step: number,
  133054. /**
  133055. * Gets or sets the color associated with this step
  133056. */
  133057. color: Color3);
  133058. }
  133059. /**
  133060. * Block used to return a color from a gradient based on an input value between 0 and 1
  133061. */
  133062. export class GradientBlock extends NodeMaterialBlock {
  133063. /**
  133064. * Gets or sets the list of color steps
  133065. */
  133066. colorSteps: GradientBlockColorStep[];
  133067. /**
  133068. * Creates a new GradientBlock
  133069. * @param name defines the block name
  133070. */
  133071. constructor(name: string);
  133072. /**
  133073. * Gets the current class name
  133074. * @returns the class name
  133075. */
  133076. getClassName(): string;
  133077. /**
  133078. * Gets the gradient input component
  133079. */
  133080. get gradient(): NodeMaterialConnectionPoint;
  133081. /**
  133082. * Gets the output component
  133083. */
  133084. get output(): NodeMaterialConnectionPoint;
  133085. private _writeColorConstant;
  133086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133087. serialize(): any;
  133088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133089. protected _dumpPropertiesCode(): string;
  133090. }
  133091. }
  133092. declare module BABYLON {
  133093. /**
  133094. * Block used to normalize lerp between 2 values
  133095. */
  133096. export class NLerpBlock extends NodeMaterialBlock {
  133097. /**
  133098. * Creates a new NLerpBlock
  133099. * @param name defines the block name
  133100. */
  133101. constructor(name: string);
  133102. /**
  133103. * Gets the current class name
  133104. * @returns the class name
  133105. */
  133106. getClassName(): string;
  133107. /**
  133108. * Gets the left operand input component
  133109. */
  133110. get left(): NodeMaterialConnectionPoint;
  133111. /**
  133112. * Gets the right operand input component
  133113. */
  133114. get right(): NodeMaterialConnectionPoint;
  133115. /**
  133116. * Gets the gradient operand input component
  133117. */
  133118. get gradient(): NodeMaterialConnectionPoint;
  133119. /**
  133120. * Gets the output component
  133121. */
  133122. get output(): NodeMaterialConnectionPoint;
  133123. protected _buildBlock(state: NodeMaterialBuildState): this;
  133124. }
  133125. }
  133126. declare module BABYLON {
  133127. /**
  133128. * block used to Generate a Worley Noise 3D Noise Pattern
  133129. */
  133130. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133131. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133132. manhattanDistance: boolean;
  133133. /**
  133134. * Creates a new WorleyNoise3DBlock
  133135. * @param name defines the block name
  133136. */
  133137. constructor(name: string);
  133138. /**
  133139. * Gets the current class name
  133140. * @returns the class name
  133141. */
  133142. getClassName(): string;
  133143. /**
  133144. * Gets the seed input component
  133145. */
  133146. get seed(): NodeMaterialConnectionPoint;
  133147. /**
  133148. * Gets the jitter input component
  133149. */
  133150. get jitter(): NodeMaterialConnectionPoint;
  133151. /**
  133152. * Gets the output component
  133153. */
  133154. get output(): NodeMaterialConnectionPoint;
  133155. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133156. /**
  133157. * Exposes the properties to the UI?
  133158. */
  133159. protected _dumpPropertiesCode(): string;
  133160. /**
  133161. * Exposes the properties to the Seralize?
  133162. */
  133163. serialize(): any;
  133164. /**
  133165. * Exposes the properties to the deseralize?
  133166. */
  133167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133168. }
  133169. }
  133170. declare module BABYLON {
  133171. /**
  133172. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133173. */
  133174. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133175. /**
  133176. * Creates a new SimplexPerlin3DBlock
  133177. * @param name defines the block name
  133178. */
  133179. constructor(name: string);
  133180. /**
  133181. * Gets the current class name
  133182. * @returns the class name
  133183. */
  133184. getClassName(): string;
  133185. /**
  133186. * Gets the seed operand input component
  133187. */
  133188. get seed(): NodeMaterialConnectionPoint;
  133189. /**
  133190. * Gets the output component
  133191. */
  133192. get output(): NodeMaterialConnectionPoint;
  133193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133194. }
  133195. }
  133196. declare module BABYLON {
  133197. /**
  133198. * Block used to blend normals
  133199. */
  133200. export class NormalBlendBlock extends NodeMaterialBlock {
  133201. /**
  133202. * Creates a new NormalBlendBlock
  133203. * @param name defines the block name
  133204. */
  133205. constructor(name: string);
  133206. /**
  133207. * Gets the current class name
  133208. * @returns the class name
  133209. */
  133210. getClassName(): string;
  133211. /**
  133212. * Gets the first input component
  133213. */
  133214. get normalMap0(): NodeMaterialConnectionPoint;
  133215. /**
  133216. * Gets the second input component
  133217. */
  133218. get normalMap1(): NodeMaterialConnectionPoint;
  133219. /**
  133220. * Gets the output component
  133221. */
  133222. get output(): NodeMaterialConnectionPoint;
  133223. protected _buildBlock(state: NodeMaterialBuildState): this;
  133224. }
  133225. }
  133226. declare module BABYLON {
  133227. /**
  133228. * Block used to rotate a 2d vector by a given angle
  133229. */
  133230. export class Rotate2dBlock extends NodeMaterialBlock {
  133231. /**
  133232. * Creates a new Rotate2dBlock
  133233. * @param name defines the block name
  133234. */
  133235. constructor(name: string);
  133236. /**
  133237. * Gets the current class name
  133238. * @returns the class name
  133239. */
  133240. getClassName(): string;
  133241. /**
  133242. * Gets the input vector
  133243. */
  133244. get input(): NodeMaterialConnectionPoint;
  133245. /**
  133246. * Gets the input angle
  133247. */
  133248. get angle(): NodeMaterialConnectionPoint;
  133249. /**
  133250. * Gets the output component
  133251. */
  133252. get output(): NodeMaterialConnectionPoint;
  133253. autoConfigure(material: NodeMaterial): void;
  133254. protected _buildBlock(state: NodeMaterialBuildState): this;
  133255. }
  133256. }
  133257. declare module BABYLON {
  133258. /**
  133259. * Block used to get the reflected vector from a direction and a normal
  133260. */
  133261. export class ReflectBlock extends NodeMaterialBlock {
  133262. /**
  133263. * Creates a new ReflectBlock
  133264. * @param name defines the block name
  133265. */
  133266. constructor(name: string);
  133267. /**
  133268. * Gets the current class name
  133269. * @returns the class name
  133270. */
  133271. getClassName(): string;
  133272. /**
  133273. * Gets the incident component
  133274. */
  133275. get incident(): NodeMaterialConnectionPoint;
  133276. /**
  133277. * Gets the normal component
  133278. */
  133279. get normal(): NodeMaterialConnectionPoint;
  133280. /**
  133281. * Gets the output component
  133282. */
  133283. get output(): NodeMaterialConnectionPoint;
  133284. protected _buildBlock(state: NodeMaterialBuildState): this;
  133285. }
  133286. }
  133287. declare module BABYLON {
  133288. /**
  133289. * Block used to get the refracted vector from a direction and a normal
  133290. */
  133291. export class RefractBlock extends NodeMaterialBlock {
  133292. /**
  133293. * Creates a new RefractBlock
  133294. * @param name defines the block name
  133295. */
  133296. constructor(name: string);
  133297. /**
  133298. * Gets the current class name
  133299. * @returns the class name
  133300. */
  133301. getClassName(): string;
  133302. /**
  133303. * Gets the incident component
  133304. */
  133305. get incident(): NodeMaterialConnectionPoint;
  133306. /**
  133307. * Gets the normal component
  133308. */
  133309. get normal(): NodeMaterialConnectionPoint;
  133310. /**
  133311. * Gets the index of refraction component
  133312. */
  133313. get ior(): NodeMaterialConnectionPoint;
  133314. /**
  133315. * Gets the output component
  133316. */
  133317. get output(): NodeMaterialConnectionPoint;
  133318. protected _buildBlock(state: NodeMaterialBuildState): this;
  133319. }
  133320. }
  133321. declare module BABYLON {
  133322. /**
  133323. * Block used to desaturate a color
  133324. */
  133325. export class DesaturateBlock extends NodeMaterialBlock {
  133326. /**
  133327. * Creates a new DesaturateBlock
  133328. * @param name defines the block name
  133329. */
  133330. constructor(name: string);
  133331. /**
  133332. * Gets the current class name
  133333. * @returns the class name
  133334. */
  133335. getClassName(): string;
  133336. /**
  133337. * Gets the color operand input component
  133338. */
  133339. get color(): NodeMaterialConnectionPoint;
  133340. /**
  133341. * Gets the level operand input component
  133342. */
  133343. get level(): NodeMaterialConnectionPoint;
  133344. /**
  133345. * Gets the output component
  133346. */
  133347. get output(): NodeMaterialConnectionPoint;
  133348. protected _buildBlock(state: NodeMaterialBuildState): this;
  133349. }
  133350. }
  133351. declare module BABYLON {
  133352. /**
  133353. * Effect Render Options
  133354. */
  133355. export interface IEffectRendererOptions {
  133356. /**
  133357. * Defines the vertices positions.
  133358. */
  133359. positions?: number[];
  133360. /**
  133361. * Defines the indices.
  133362. */
  133363. indices?: number[];
  133364. }
  133365. /**
  133366. * Helper class to render one or more effects
  133367. */
  133368. export class EffectRenderer {
  133369. private engine;
  133370. private static _DefaultOptions;
  133371. private _vertexBuffers;
  133372. private _indexBuffer;
  133373. private _ringBufferIndex;
  133374. private _ringScreenBuffer;
  133375. private _fullscreenViewport;
  133376. private _getNextFrameBuffer;
  133377. /**
  133378. * Creates an effect renderer
  133379. * @param engine the engine to use for rendering
  133380. * @param options defines the options of the effect renderer
  133381. */
  133382. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133383. /**
  133384. * Sets the current viewport in normalized coordinates 0-1
  133385. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133386. */
  133387. setViewport(viewport?: Viewport): void;
  133388. /**
  133389. * Binds the embedded attributes buffer to the effect.
  133390. * @param effect Defines the effect to bind the attributes for
  133391. */
  133392. bindBuffers(effect: Effect): void;
  133393. /**
  133394. * Sets the current effect wrapper to use during draw.
  133395. * The effect needs to be ready before calling this api.
  133396. * This also sets the default full screen position attribute.
  133397. * @param effectWrapper Defines the effect to draw with
  133398. */
  133399. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133400. /**
  133401. * Draws a full screen quad.
  133402. */
  133403. draw(): void;
  133404. /**
  133405. * renders one or more effects to a specified texture
  133406. * @param effectWrappers list of effects to renderer
  133407. * @param outputTexture texture to draw to, if null it will render to the screen
  133408. */
  133409. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133410. /**
  133411. * Disposes of the effect renderer
  133412. */
  133413. dispose(): void;
  133414. }
  133415. /**
  133416. * Options to create an EffectWrapper
  133417. */
  133418. interface EffectWrapperCreationOptions {
  133419. /**
  133420. * Engine to use to create the effect
  133421. */
  133422. engine: ThinEngine;
  133423. /**
  133424. * Fragment shader for the effect
  133425. */
  133426. fragmentShader: string;
  133427. /**
  133428. * Vertex shader for the effect
  133429. */
  133430. vertexShader?: string;
  133431. /**
  133432. * Attributes to use in the shader
  133433. */
  133434. attributeNames?: Array<string>;
  133435. /**
  133436. * Uniforms to use in the shader
  133437. */
  133438. uniformNames?: Array<string>;
  133439. /**
  133440. * Texture sampler names to use in the shader
  133441. */
  133442. samplerNames?: Array<string>;
  133443. /**
  133444. * The friendly name of the effect displayed in Spector.
  133445. */
  133446. name?: string;
  133447. }
  133448. /**
  133449. * Wraps an effect to be used for rendering
  133450. */
  133451. export class EffectWrapper {
  133452. /**
  133453. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133454. */
  133455. onApplyObservable: Observable<{}>;
  133456. /**
  133457. * The underlying effect
  133458. */
  133459. effect: Effect;
  133460. /**
  133461. * Creates an effect to be renderer
  133462. * @param creationOptions options to create the effect
  133463. */
  133464. constructor(creationOptions: EffectWrapperCreationOptions);
  133465. /**
  133466. * Disposes of the effect wrapper
  133467. */
  133468. dispose(): void;
  133469. }
  133470. }
  133471. declare module BABYLON {
  133472. /**
  133473. * Helper class to push actions to a pool of workers.
  133474. */
  133475. export class WorkerPool implements IDisposable {
  133476. private _workerInfos;
  133477. private _pendingActions;
  133478. /**
  133479. * Constructor
  133480. * @param workers Array of workers to use for actions
  133481. */
  133482. constructor(workers: Array<Worker>);
  133483. /**
  133484. * Terminates all workers and clears any pending actions.
  133485. */
  133486. dispose(): void;
  133487. /**
  133488. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133489. * pended until a worker has completed its action.
  133490. * @param action The action to perform. Call onComplete when the action is complete.
  133491. */
  133492. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133493. private _execute;
  133494. }
  133495. }
  133496. declare module BABYLON {
  133497. /**
  133498. * Configuration for Draco compression
  133499. */
  133500. export interface IDracoCompressionConfiguration {
  133501. /**
  133502. * Configuration for the decoder.
  133503. */
  133504. decoder: {
  133505. /**
  133506. * The url to the WebAssembly module.
  133507. */
  133508. wasmUrl?: string;
  133509. /**
  133510. * The url to the WebAssembly binary.
  133511. */
  133512. wasmBinaryUrl?: string;
  133513. /**
  133514. * The url to the fallback JavaScript module.
  133515. */
  133516. fallbackUrl?: string;
  133517. };
  133518. }
  133519. /**
  133520. * Draco compression (https://google.github.io/draco/)
  133521. *
  133522. * This class wraps the Draco module.
  133523. *
  133524. * **Encoder**
  133525. *
  133526. * The encoder is not currently implemented.
  133527. *
  133528. * **Decoder**
  133529. *
  133530. * 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.
  133531. *
  133532. * To update the configuration, use the following code:
  133533. * ```javascript
  133534. * DracoCompression.Configuration = {
  133535. * decoder: {
  133536. * wasmUrl: "<url to the WebAssembly library>",
  133537. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133538. * fallbackUrl: "<url to the fallback JavaScript library>",
  133539. * }
  133540. * };
  133541. * ```
  133542. *
  133543. * 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.
  133544. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133545. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133546. *
  133547. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133548. * ```javascript
  133549. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133550. * ```
  133551. *
  133552. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133553. */
  133554. export class DracoCompression implements IDisposable {
  133555. private _workerPoolPromise?;
  133556. private _decoderModulePromise?;
  133557. /**
  133558. * The configuration. Defaults to the following urls:
  133559. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133560. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133561. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133562. */
  133563. static Configuration: IDracoCompressionConfiguration;
  133564. /**
  133565. * Returns true if the decoder configuration is available.
  133566. */
  133567. static get DecoderAvailable(): boolean;
  133568. /**
  133569. * Default number of workers to create when creating the draco compression object.
  133570. */
  133571. static DefaultNumWorkers: number;
  133572. private static GetDefaultNumWorkers;
  133573. private static _Default;
  133574. /**
  133575. * Default instance for the draco compression object.
  133576. */
  133577. static get Default(): DracoCompression;
  133578. /**
  133579. * Constructor
  133580. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133581. */
  133582. constructor(numWorkers?: number);
  133583. /**
  133584. * Stop all async operations and release resources.
  133585. */
  133586. dispose(): void;
  133587. /**
  133588. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133589. * @returns a promise that resolves when ready
  133590. */
  133591. whenReadyAsync(): Promise<void>;
  133592. /**
  133593. * Decode Draco compressed mesh data to vertex data.
  133594. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133595. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133596. * @returns A promise that resolves with the decoded vertex data
  133597. */
  133598. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133599. [kind: string]: number;
  133600. }): Promise<VertexData>;
  133601. }
  133602. }
  133603. declare module BABYLON {
  133604. /**
  133605. * Class for building Constructive Solid Geometry
  133606. */
  133607. export class CSG {
  133608. private polygons;
  133609. /**
  133610. * The world matrix
  133611. */
  133612. matrix: Matrix;
  133613. /**
  133614. * Stores the position
  133615. */
  133616. position: Vector3;
  133617. /**
  133618. * Stores the rotation
  133619. */
  133620. rotation: Vector3;
  133621. /**
  133622. * Stores the rotation quaternion
  133623. */
  133624. rotationQuaternion: Nullable<Quaternion>;
  133625. /**
  133626. * Stores the scaling vector
  133627. */
  133628. scaling: Vector3;
  133629. /**
  133630. * Convert the Mesh to CSG
  133631. * @param mesh The Mesh to convert to CSG
  133632. * @returns A new CSG from the Mesh
  133633. */
  133634. static FromMesh(mesh: Mesh): CSG;
  133635. /**
  133636. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133637. * @param polygons Polygons used to construct a CSG solid
  133638. */
  133639. private static FromPolygons;
  133640. /**
  133641. * Clones, or makes a deep copy, of the CSG
  133642. * @returns A new CSG
  133643. */
  133644. clone(): CSG;
  133645. /**
  133646. * Unions this CSG with another CSG
  133647. * @param csg The CSG to union against this CSG
  133648. * @returns The unioned CSG
  133649. */
  133650. union(csg: CSG): CSG;
  133651. /**
  133652. * Unions this CSG with another CSG in place
  133653. * @param csg The CSG to union against this CSG
  133654. */
  133655. unionInPlace(csg: CSG): void;
  133656. /**
  133657. * Subtracts this CSG with another CSG
  133658. * @param csg The CSG to subtract against this CSG
  133659. * @returns A new CSG
  133660. */
  133661. subtract(csg: CSG): CSG;
  133662. /**
  133663. * Subtracts this CSG with another CSG in place
  133664. * @param csg The CSG to subtact against this CSG
  133665. */
  133666. subtractInPlace(csg: CSG): void;
  133667. /**
  133668. * Intersect this CSG with another CSG
  133669. * @param csg The CSG to intersect against this CSG
  133670. * @returns A new CSG
  133671. */
  133672. intersect(csg: CSG): CSG;
  133673. /**
  133674. * Intersects this CSG with another CSG in place
  133675. * @param csg The CSG to intersect against this CSG
  133676. */
  133677. intersectInPlace(csg: CSG): void;
  133678. /**
  133679. * Return a new CSG solid with solid and empty space switched. This solid is
  133680. * not modified.
  133681. * @returns A new CSG solid with solid and empty space switched
  133682. */
  133683. inverse(): CSG;
  133684. /**
  133685. * Inverses the CSG in place
  133686. */
  133687. inverseInPlace(): void;
  133688. /**
  133689. * This is used to keep meshes transformations so they can be restored
  133690. * when we build back a Babylon Mesh
  133691. * NB : All CSG operations are performed in world coordinates
  133692. * @param csg The CSG to copy the transform attributes from
  133693. * @returns This CSG
  133694. */
  133695. copyTransformAttributes(csg: CSG): CSG;
  133696. /**
  133697. * Build Raw mesh from CSG
  133698. * Coordinates here are in world space
  133699. * @param name The name of the mesh geometry
  133700. * @param scene The Scene
  133701. * @param keepSubMeshes Specifies if the submeshes should be kept
  133702. * @returns A new Mesh
  133703. */
  133704. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133705. /**
  133706. * Build Mesh from CSG taking material and transforms into account
  133707. * @param name The name of the Mesh
  133708. * @param material The material of the Mesh
  133709. * @param scene The Scene
  133710. * @param keepSubMeshes Specifies if submeshes should be kept
  133711. * @returns The new Mesh
  133712. */
  133713. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133714. }
  133715. }
  133716. declare module BABYLON {
  133717. /**
  133718. * Class used to create a trail following a mesh
  133719. */
  133720. export class TrailMesh extends Mesh {
  133721. private _generator;
  133722. private _autoStart;
  133723. private _running;
  133724. private _diameter;
  133725. private _length;
  133726. private _sectionPolygonPointsCount;
  133727. private _sectionVectors;
  133728. private _sectionNormalVectors;
  133729. private _beforeRenderObserver;
  133730. /**
  133731. * @constructor
  133732. * @param name The value used by scene.getMeshByName() to do a lookup.
  133733. * @param generator The mesh or transform node to generate a trail.
  133734. * @param scene The scene to add this mesh to.
  133735. * @param diameter Diameter of trailing mesh. Default is 1.
  133736. * @param length Length of trailing mesh. Default is 60.
  133737. * @param autoStart Automatically start trailing mesh. Default true.
  133738. */
  133739. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133740. /**
  133741. * "TrailMesh"
  133742. * @returns "TrailMesh"
  133743. */
  133744. getClassName(): string;
  133745. private _createMesh;
  133746. /**
  133747. * Start trailing mesh.
  133748. */
  133749. start(): void;
  133750. /**
  133751. * Stop trailing mesh.
  133752. */
  133753. stop(): void;
  133754. /**
  133755. * Update trailing mesh geometry.
  133756. */
  133757. update(): void;
  133758. /**
  133759. * Returns a new TrailMesh object.
  133760. * @param name is a string, the name given to the new mesh
  133761. * @param newGenerator use new generator object for cloned trail mesh
  133762. * @returns a new mesh
  133763. */
  133764. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133765. /**
  133766. * Serializes this trail mesh
  133767. * @param serializationObject object to write serialization to
  133768. */
  133769. serialize(serializationObject: any): void;
  133770. /**
  133771. * Parses a serialized trail mesh
  133772. * @param parsedMesh the serialized mesh
  133773. * @param scene the scene to create the trail mesh in
  133774. * @returns the created trail mesh
  133775. */
  133776. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133777. }
  133778. }
  133779. declare module BABYLON {
  133780. /**
  133781. * Class containing static functions to help procedurally build meshes
  133782. */
  133783. export class TiledBoxBuilder {
  133784. /**
  133785. * Creates a box mesh
  133786. * 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)
  133787. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133791. * @param name defines the name of the mesh
  133792. * @param options defines the options used to create the mesh
  133793. * @param scene defines the hosting scene
  133794. * @returns the box mesh
  133795. */
  133796. static CreateTiledBox(name: string, options: {
  133797. pattern?: number;
  133798. width?: number;
  133799. height?: number;
  133800. depth?: number;
  133801. tileSize?: number;
  133802. tileWidth?: number;
  133803. tileHeight?: number;
  133804. alignHorizontal?: number;
  133805. alignVertical?: number;
  133806. faceUV?: Vector4[];
  133807. faceColors?: Color4[];
  133808. sideOrientation?: number;
  133809. updatable?: boolean;
  133810. }, scene?: Nullable<Scene>): Mesh;
  133811. }
  133812. }
  133813. declare module BABYLON {
  133814. /**
  133815. * Class containing static functions to help procedurally build meshes
  133816. */
  133817. export class TorusKnotBuilder {
  133818. /**
  133819. * Creates a torus knot mesh
  133820. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133821. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133822. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133823. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133827. * @param name defines the name of the mesh
  133828. * @param options defines the options used to create the mesh
  133829. * @param scene defines the hosting scene
  133830. * @returns the torus knot mesh
  133831. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133832. */
  133833. static CreateTorusKnot(name: string, options: {
  133834. radius?: number;
  133835. tube?: number;
  133836. radialSegments?: number;
  133837. tubularSegments?: number;
  133838. p?: number;
  133839. q?: number;
  133840. updatable?: boolean;
  133841. sideOrientation?: number;
  133842. frontUVs?: Vector4;
  133843. backUVs?: Vector4;
  133844. }, scene: any): Mesh;
  133845. }
  133846. }
  133847. declare module BABYLON {
  133848. /**
  133849. * Polygon
  133850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133851. */
  133852. export class Polygon {
  133853. /**
  133854. * Creates a rectangle
  133855. * @param xmin bottom X coord
  133856. * @param ymin bottom Y coord
  133857. * @param xmax top X coord
  133858. * @param ymax top Y coord
  133859. * @returns points that make the resulting rectation
  133860. */
  133861. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133862. /**
  133863. * Creates a circle
  133864. * @param radius radius of circle
  133865. * @param cx scale in x
  133866. * @param cy scale in y
  133867. * @param numberOfSides number of sides that make up the circle
  133868. * @returns points that make the resulting circle
  133869. */
  133870. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133871. /**
  133872. * Creates a polygon from input string
  133873. * @param input Input polygon data
  133874. * @returns the parsed points
  133875. */
  133876. static Parse(input: string): Vector2[];
  133877. /**
  133878. * Starts building a polygon from x and y coordinates
  133879. * @param x x coordinate
  133880. * @param y y coordinate
  133881. * @returns the started path2
  133882. */
  133883. static StartingAt(x: number, y: number): Path2;
  133884. }
  133885. /**
  133886. * Builds a polygon
  133887. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133888. */
  133889. export class PolygonMeshBuilder {
  133890. private _points;
  133891. private _outlinepoints;
  133892. private _holes;
  133893. private _name;
  133894. private _scene;
  133895. private _epoints;
  133896. private _eholes;
  133897. private _addToepoint;
  133898. /**
  133899. * Babylon reference to the earcut plugin.
  133900. */
  133901. bjsEarcut: any;
  133902. /**
  133903. * Creates a PolygonMeshBuilder
  133904. * @param name name of the builder
  133905. * @param contours Path of the polygon
  133906. * @param scene scene to add to when creating the mesh
  133907. * @param earcutInjection can be used to inject your own earcut reference
  133908. */
  133909. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133910. /**
  133911. * Adds a whole within the polygon
  133912. * @param hole Array of points defining the hole
  133913. * @returns this
  133914. */
  133915. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133916. /**
  133917. * Creates the polygon
  133918. * @param updatable If the mesh should be updatable
  133919. * @param depth The depth of the mesh created
  133920. * @returns the created mesh
  133921. */
  133922. build(updatable?: boolean, depth?: number): Mesh;
  133923. /**
  133924. * Creates the polygon
  133925. * @param depth The depth of the mesh created
  133926. * @returns the created VertexData
  133927. */
  133928. buildVertexData(depth?: number): VertexData;
  133929. /**
  133930. * Adds a side to the polygon
  133931. * @param positions points that make the polygon
  133932. * @param normals normals of the polygon
  133933. * @param uvs uvs of the polygon
  133934. * @param indices indices of the polygon
  133935. * @param bounds bounds of the polygon
  133936. * @param points points of the polygon
  133937. * @param depth depth of the polygon
  133938. * @param flip flip of the polygon
  133939. */
  133940. private addSide;
  133941. }
  133942. }
  133943. declare module BABYLON {
  133944. /**
  133945. * Class containing static functions to help procedurally build meshes
  133946. */
  133947. export class PolygonBuilder {
  133948. /**
  133949. * Creates a polygon mesh
  133950. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133951. * * 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
  133952. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133955. * * Remember you can only change the shape positions, not their number when updating a polygon
  133956. * @param name defines the name of the mesh
  133957. * @param options defines the options used to create the mesh
  133958. * @param scene defines the hosting scene
  133959. * @param earcutInjection can be used to inject your own earcut reference
  133960. * @returns the polygon mesh
  133961. */
  133962. static CreatePolygon(name: string, options: {
  133963. shape: Vector3[];
  133964. holes?: Vector3[][];
  133965. depth?: number;
  133966. faceUV?: Vector4[];
  133967. faceColors?: Color4[];
  133968. updatable?: boolean;
  133969. sideOrientation?: number;
  133970. frontUVs?: Vector4;
  133971. backUVs?: Vector4;
  133972. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133973. /**
  133974. * Creates an extruded polygon mesh, with depth in the Y direction.
  133975. * * 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)
  133976. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133977. * @param name defines the name of the mesh
  133978. * @param options defines the options used to create the mesh
  133979. * @param scene defines the hosting scene
  133980. * @param earcutInjection can be used to inject your own earcut reference
  133981. * @returns the polygon mesh
  133982. */
  133983. static ExtrudePolygon(name: string, options: {
  133984. shape: Vector3[];
  133985. holes?: Vector3[][];
  133986. depth?: number;
  133987. faceUV?: Vector4[];
  133988. faceColors?: Color4[];
  133989. updatable?: boolean;
  133990. sideOrientation?: number;
  133991. frontUVs?: Vector4;
  133992. backUVs?: Vector4;
  133993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133994. }
  133995. }
  133996. declare module BABYLON {
  133997. /**
  133998. * Class containing static functions to help procedurally build meshes
  133999. */
  134000. export class LatheBuilder {
  134001. /**
  134002. * Creates lathe mesh.
  134003. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134004. * * 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
  134005. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134006. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134007. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134008. * * 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
  134009. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134010. * * 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
  134011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134015. * @param name defines the name of the mesh
  134016. * @param options defines the options used to create the mesh
  134017. * @param scene defines the hosting scene
  134018. * @returns the lathe mesh
  134019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134020. */
  134021. static CreateLathe(name: string, options: {
  134022. shape: Vector3[];
  134023. radius?: number;
  134024. tessellation?: number;
  134025. clip?: number;
  134026. arc?: number;
  134027. closed?: boolean;
  134028. updatable?: boolean;
  134029. sideOrientation?: number;
  134030. frontUVs?: Vector4;
  134031. backUVs?: Vector4;
  134032. cap?: number;
  134033. invertUV?: boolean;
  134034. }, scene?: Nullable<Scene>): Mesh;
  134035. }
  134036. }
  134037. declare module BABYLON {
  134038. /**
  134039. * Class containing static functions to help procedurally build meshes
  134040. */
  134041. export class TiledPlaneBuilder {
  134042. /**
  134043. * Creates a tiled plane mesh
  134044. * * The parameter `pattern` will, depending on value, do nothing or
  134045. * * * flip (reflect about central vertical) alternate tiles across and up
  134046. * * * flip every tile on alternate rows
  134047. * * * rotate (180 degs) alternate tiles across and up
  134048. * * * rotate every tile on alternate rows
  134049. * * * flip and rotate alternate tiles across and up
  134050. * * * flip and rotate every tile on alternate rows
  134051. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134052. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134055. * * 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)
  134056. * * 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)
  134057. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134058. * @param name defines the name of the mesh
  134059. * @param options defines the options used to create the mesh
  134060. * @param scene defines the hosting scene
  134061. * @returns the box mesh
  134062. */
  134063. static CreateTiledPlane(name: string, options: {
  134064. pattern?: number;
  134065. tileSize?: number;
  134066. tileWidth?: number;
  134067. tileHeight?: number;
  134068. size?: number;
  134069. width?: number;
  134070. height?: number;
  134071. alignHorizontal?: number;
  134072. alignVertical?: number;
  134073. sideOrientation?: number;
  134074. frontUVs?: Vector4;
  134075. backUVs?: Vector4;
  134076. updatable?: boolean;
  134077. }, scene?: Nullable<Scene>): Mesh;
  134078. }
  134079. }
  134080. declare module BABYLON {
  134081. /**
  134082. * Class containing static functions to help procedurally build meshes
  134083. */
  134084. export class TubeBuilder {
  134085. /**
  134086. * Creates a tube mesh.
  134087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134092. * * 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)
  134093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134094. * * 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
  134095. * * 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
  134096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134100. * @param name defines the name of the mesh
  134101. * @param options defines the options used to create the mesh
  134102. * @param scene defines the hosting scene
  134103. * @returns the tube mesh
  134104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134106. */
  134107. static CreateTube(name: string, options: {
  134108. path: Vector3[];
  134109. radius?: number;
  134110. tessellation?: number;
  134111. radiusFunction?: {
  134112. (i: number, distance: number): number;
  134113. };
  134114. cap?: number;
  134115. arc?: number;
  134116. updatable?: boolean;
  134117. sideOrientation?: number;
  134118. frontUVs?: Vector4;
  134119. backUVs?: Vector4;
  134120. instance?: Mesh;
  134121. invertUV?: boolean;
  134122. }, scene?: Nullable<Scene>): Mesh;
  134123. }
  134124. }
  134125. declare module BABYLON {
  134126. /**
  134127. * Class containing static functions to help procedurally build meshes
  134128. */
  134129. export class IcoSphereBuilder {
  134130. /**
  134131. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134132. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134133. * * 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`)
  134134. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134135. * * 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
  134136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134139. * @param name defines the name of the mesh
  134140. * @param options defines the options used to create the mesh
  134141. * @param scene defines the hosting scene
  134142. * @returns the icosahedron mesh
  134143. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134144. */
  134145. static CreateIcoSphere(name: string, options: {
  134146. radius?: number;
  134147. radiusX?: number;
  134148. radiusY?: number;
  134149. radiusZ?: number;
  134150. flat?: boolean;
  134151. subdivisions?: number;
  134152. sideOrientation?: number;
  134153. frontUVs?: Vector4;
  134154. backUVs?: Vector4;
  134155. updatable?: boolean;
  134156. }, scene?: Nullable<Scene>): Mesh;
  134157. }
  134158. }
  134159. declare module BABYLON {
  134160. /**
  134161. * Class containing static functions to help procedurally build meshes
  134162. */
  134163. export class DecalBuilder {
  134164. /**
  134165. * Creates a decal mesh.
  134166. * 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
  134167. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134168. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134169. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134170. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134171. * @param name defines the name of the mesh
  134172. * @param sourceMesh defines the mesh where the decal must be applied
  134173. * @param options defines the options used to create the mesh
  134174. * @param scene defines the hosting scene
  134175. * @returns the decal mesh
  134176. * @see https://doc.babylonjs.com/how_to/decals
  134177. */
  134178. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134179. position?: Vector3;
  134180. normal?: Vector3;
  134181. size?: Vector3;
  134182. angle?: number;
  134183. }): Mesh;
  134184. }
  134185. }
  134186. declare module BABYLON {
  134187. /**
  134188. * Class containing static functions to help procedurally build meshes
  134189. */
  134190. export class MeshBuilder {
  134191. /**
  134192. * Creates a box mesh
  134193. * * The parameter `size` sets the size (float) of each box side (default 1)
  134194. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134195. * * 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)
  134196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134200. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134201. * @param name defines the name of the mesh
  134202. * @param options defines the options used to create the mesh
  134203. * @param scene defines the hosting scene
  134204. * @returns the box mesh
  134205. */
  134206. static CreateBox(name: string, options: {
  134207. size?: number;
  134208. width?: number;
  134209. height?: number;
  134210. depth?: number;
  134211. faceUV?: Vector4[];
  134212. faceColors?: Color4[];
  134213. sideOrientation?: number;
  134214. frontUVs?: Vector4;
  134215. backUVs?: Vector4;
  134216. updatable?: boolean;
  134217. }, scene?: Nullable<Scene>): Mesh;
  134218. /**
  134219. * Creates a tiled box mesh
  134220. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134222. * @param name defines the name of the mesh
  134223. * @param options defines the options used to create the mesh
  134224. * @param scene defines the hosting scene
  134225. * @returns the tiled box mesh
  134226. */
  134227. static CreateTiledBox(name: string, options: {
  134228. pattern?: number;
  134229. size?: number;
  134230. width?: number;
  134231. height?: number;
  134232. depth: number;
  134233. tileSize?: number;
  134234. tileWidth?: number;
  134235. tileHeight?: number;
  134236. faceUV?: Vector4[];
  134237. faceColors?: Color4[];
  134238. alignHorizontal?: number;
  134239. alignVertical?: number;
  134240. sideOrientation?: number;
  134241. updatable?: boolean;
  134242. }, scene?: Nullable<Scene>): Mesh;
  134243. /**
  134244. * Creates a sphere mesh
  134245. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134246. * * 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`)
  134247. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134248. * * 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
  134249. * * 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)
  134250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134253. * @param name defines the name of the mesh
  134254. * @param options defines the options used to create the mesh
  134255. * @param scene defines the hosting scene
  134256. * @returns the sphere mesh
  134257. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134258. */
  134259. static CreateSphere(name: string, options: {
  134260. segments?: number;
  134261. diameter?: number;
  134262. diameterX?: number;
  134263. diameterY?: number;
  134264. diameterZ?: number;
  134265. arc?: number;
  134266. slice?: number;
  134267. sideOrientation?: number;
  134268. frontUVs?: Vector4;
  134269. backUVs?: Vector4;
  134270. updatable?: boolean;
  134271. }, scene?: Nullable<Scene>): Mesh;
  134272. /**
  134273. * Creates a plane polygonal mesh. By default, this is a disc
  134274. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134275. * * 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
  134276. * * 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
  134277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134280. * @param name defines the name of the mesh
  134281. * @param options defines the options used to create the mesh
  134282. * @param scene defines the hosting scene
  134283. * @returns the plane polygonal mesh
  134284. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134285. */
  134286. static CreateDisc(name: string, options: {
  134287. radius?: number;
  134288. tessellation?: number;
  134289. arc?: number;
  134290. updatable?: boolean;
  134291. sideOrientation?: number;
  134292. frontUVs?: Vector4;
  134293. backUVs?: Vector4;
  134294. }, scene?: Nullable<Scene>): Mesh;
  134295. /**
  134296. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134297. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134298. * * 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`)
  134299. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134300. * * 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
  134301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134304. * @param name defines the name of the mesh
  134305. * @param options defines the options used to create the mesh
  134306. * @param scene defines the hosting scene
  134307. * @returns the icosahedron mesh
  134308. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134309. */
  134310. static CreateIcoSphere(name: string, options: {
  134311. radius?: number;
  134312. radiusX?: number;
  134313. radiusY?: number;
  134314. radiusZ?: number;
  134315. flat?: boolean;
  134316. subdivisions?: number;
  134317. sideOrientation?: number;
  134318. frontUVs?: Vector4;
  134319. backUVs?: Vector4;
  134320. updatable?: boolean;
  134321. }, scene?: Nullable<Scene>): Mesh;
  134322. /**
  134323. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134324. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134325. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134326. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134327. * * 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
  134328. * * 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
  134329. * * 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
  134330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134333. * * 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
  134334. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134335. * * 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
  134336. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134338. * @param name defines the name of the mesh
  134339. * @param options defines the options used to create the mesh
  134340. * @param scene defines the hosting scene
  134341. * @returns the ribbon mesh
  134342. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134344. */
  134345. static CreateRibbon(name: string, options: {
  134346. pathArray: Vector3[][];
  134347. closeArray?: boolean;
  134348. closePath?: boolean;
  134349. offset?: number;
  134350. updatable?: boolean;
  134351. sideOrientation?: number;
  134352. frontUVs?: Vector4;
  134353. backUVs?: Vector4;
  134354. instance?: Mesh;
  134355. invertUV?: boolean;
  134356. uvs?: Vector2[];
  134357. colors?: Color4[];
  134358. }, scene?: Nullable<Scene>): Mesh;
  134359. /**
  134360. * Creates a cylinder or a cone mesh
  134361. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134362. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134363. * * 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.
  134364. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134365. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134366. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134367. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134368. * * 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).
  134369. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134370. * * 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).
  134371. * * 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
  134372. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134373. * * 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
  134374. * * 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.
  134375. * * If `enclose` is false, a ring surface is one element.
  134376. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134377. * * 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
  134378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134381. * @param name defines the name of the mesh
  134382. * @param options defines the options used to create the mesh
  134383. * @param scene defines the hosting scene
  134384. * @returns the cylinder mesh
  134385. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134386. */
  134387. static CreateCylinder(name: string, options: {
  134388. height?: number;
  134389. diameterTop?: number;
  134390. diameterBottom?: number;
  134391. diameter?: number;
  134392. tessellation?: number;
  134393. subdivisions?: number;
  134394. arc?: number;
  134395. faceColors?: Color4[];
  134396. faceUV?: Vector4[];
  134397. updatable?: boolean;
  134398. hasRings?: boolean;
  134399. enclose?: boolean;
  134400. cap?: number;
  134401. sideOrientation?: number;
  134402. frontUVs?: Vector4;
  134403. backUVs?: Vector4;
  134404. }, scene?: Nullable<Scene>): Mesh;
  134405. /**
  134406. * Creates a torus mesh
  134407. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134408. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134409. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134413. * @param name defines the name of the mesh
  134414. * @param options defines the options used to create the mesh
  134415. * @param scene defines the hosting scene
  134416. * @returns the torus mesh
  134417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134418. */
  134419. static CreateTorus(name: string, options: {
  134420. diameter?: number;
  134421. thickness?: number;
  134422. tessellation?: number;
  134423. updatable?: boolean;
  134424. sideOrientation?: number;
  134425. frontUVs?: Vector4;
  134426. backUVs?: Vector4;
  134427. }, scene?: Nullable<Scene>): Mesh;
  134428. /**
  134429. * Creates a torus knot mesh
  134430. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134431. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134432. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134433. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134437. * @param name defines the name of the mesh
  134438. * @param options defines the options used to create the mesh
  134439. * @param scene defines the hosting scene
  134440. * @returns the torus knot mesh
  134441. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134442. */
  134443. static CreateTorusKnot(name: string, options: {
  134444. radius?: number;
  134445. tube?: number;
  134446. radialSegments?: number;
  134447. tubularSegments?: number;
  134448. p?: number;
  134449. q?: number;
  134450. updatable?: boolean;
  134451. sideOrientation?: number;
  134452. frontUVs?: Vector4;
  134453. backUVs?: Vector4;
  134454. }, scene?: Nullable<Scene>): Mesh;
  134455. /**
  134456. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134457. * * 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
  134458. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134459. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134460. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134461. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134462. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134463. * * 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
  134464. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134467. * @param name defines the name of the new line system
  134468. * @param options defines the options used to create the line system
  134469. * @param scene defines the hosting scene
  134470. * @returns a new line system mesh
  134471. */
  134472. static CreateLineSystem(name: string, options: {
  134473. lines: Vector3[][];
  134474. updatable?: boolean;
  134475. instance?: Nullable<LinesMesh>;
  134476. colors?: Nullable<Color4[][]>;
  134477. useVertexAlpha?: boolean;
  134478. }, scene: Nullable<Scene>): LinesMesh;
  134479. /**
  134480. * Creates a line mesh
  134481. * 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
  134482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134483. * * The parameter `points` is an array successive Vector3
  134484. * * 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
  134485. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134486. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134487. * * When updating an instance, remember that only point positions can change, not the number of points
  134488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134490. * @param name defines the name of the new line system
  134491. * @param options defines the options used to create the line system
  134492. * @param scene defines the hosting scene
  134493. * @returns a new line mesh
  134494. */
  134495. static CreateLines(name: string, options: {
  134496. points: Vector3[];
  134497. updatable?: boolean;
  134498. instance?: Nullable<LinesMesh>;
  134499. colors?: Color4[];
  134500. useVertexAlpha?: boolean;
  134501. }, scene?: Nullable<Scene>): LinesMesh;
  134502. /**
  134503. * Creates a dashed line mesh
  134504. * * 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
  134505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134506. * * The parameter `points` is an array successive Vector3
  134507. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134508. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134509. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134510. * * 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
  134511. * * When updating an instance, remember that only point positions can change, not the number of points
  134512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134513. * @param name defines the name of the mesh
  134514. * @param options defines the options used to create the mesh
  134515. * @param scene defines the hosting scene
  134516. * @returns the dashed line mesh
  134517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134518. */
  134519. static CreateDashedLines(name: string, options: {
  134520. points: Vector3[];
  134521. dashSize?: number;
  134522. gapSize?: number;
  134523. dashNb?: number;
  134524. updatable?: boolean;
  134525. instance?: LinesMesh;
  134526. }, scene?: Nullable<Scene>): LinesMesh;
  134527. /**
  134528. * 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.
  134529. * * 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.
  134530. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134531. * * 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.
  134532. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134533. * * 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
  134534. * * 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
  134535. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134540. * @param name defines the name of the mesh
  134541. * @param options defines the options used to create the mesh
  134542. * @param scene defines the hosting scene
  134543. * @returns the extruded shape mesh
  134544. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134546. */
  134547. static ExtrudeShape(name: string, options: {
  134548. shape: Vector3[];
  134549. path: Vector3[];
  134550. scale?: number;
  134551. rotation?: number;
  134552. cap?: number;
  134553. updatable?: boolean;
  134554. sideOrientation?: number;
  134555. frontUVs?: Vector4;
  134556. backUVs?: Vector4;
  134557. instance?: Mesh;
  134558. invertUV?: boolean;
  134559. }, scene?: Nullable<Scene>): Mesh;
  134560. /**
  134561. * Creates an custom extruded shape mesh.
  134562. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134563. * * 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.
  134564. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134565. * * 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
  134566. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134567. * * 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
  134568. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134569. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134570. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134571. * * 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
  134572. * * 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
  134573. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134578. * @param name defines the name of the mesh
  134579. * @param options defines the options used to create the mesh
  134580. * @param scene defines the hosting scene
  134581. * @returns the custom extruded shape mesh
  134582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134585. */
  134586. static ExtrudeShapeCustom(name: string, options: {
  134587. shape: Vector3[];
  134588. path: Vector3[];
  134589. scaleFunction?: any;
  134590. rotationFunction?: any;
  134591. ribbonCloseArray?: boolean;
  134592. ribbonClosePath?: boolean;
  134593. cap?: number;
  134594. updatable?: boolean;
  134595. sideOrientation?: number;
  134596. frontUVs?: Vector4;
  134597. backUVs?: Vector4;
  134598. instance?: Mesh;
  134599. invertUV?: boolean;
  134600. }, scene?: Nullable<Scene>): Mesh;
  134601. /**
  134602. * Creates lathe mesh.
  134603. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134604. * * 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
  134605. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134606. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134607. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134608. * * 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
  134609. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134610. * * 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
  134611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134615. * @param name defines the name of the mesh
  134616. * @param options defines the options used to create the mesh
  134617. * @param scene defines the hosting scene
  134618. * @returns the lathe mesh
  134619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134620. */
  134621. static CreateLathe(name: string, options: {
  134622. shape: Vector3[];
  134623. radius?: number;
  134624. tessellation?: number;
  134625. clip?: number;
  134626. arc?: number;
  134627. closed?: boolean;
  134628. updatable?: boolean;
  134629. sideOrientation?: number;
  134630. frontUVs?: Vector4;
  134631. backUVs?: Vector4;
  134632. cap?: number;
  134633. invertUV?: boolean;
  134634. }, scene?: Nullable<Scene>): Mesh;
  134635. /**
  134636. * Creates a tiled plane mesh
  134637. * * You can set a limited pattern arrangement with the tiles
  134638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134641. * @param name defines the name of the mesh
  134642. * @param options defines the options used to create the mesh
  134643. * @param scene defines the hosting scene
  134644. * @returns the plane mesh
  134645. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134646. */
  134647. static CreateTiledPlane(name: string, options: {
  134648. pattern?: number;
  134649. tileSize?: number;
  134650. tileWidth?: number;
  134651. tileHeight?: number;
  134652. size?: number;
  134653. width?: number;
  134654. height?: number;
  134655. alignHorizontal?: number;
  134656. alignVertical?: number;
  134657. sideOrientation?: number;
  134658. frontUVs?: Vector4;
  134659. backUVs?: Vector4;
  134660. updatable?: boolean;
  134661. }, scene?: Nullable<Scene>): Mesh;
  134662. /**
  134663. * Creates a plane mesh
  134664. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134665. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134666. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134670. * @param name defines the name of the mesh
  134671. * @param options defines the options used to create the mesh
  134672. * @param scene defines the hosting scene
  134673. * @returns the plane mesh
  134674. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134675. */
  134676. static CreatePlane(name: string, options: {
  134677. size?: number;
  134678. width?: number;
  134679. height?: number;
  134680. sideOrientation?: number;
  134681. frontUVs?: Vector4;
  134682. backUVs?: Vector4;
  134683. updatable?: boolean;
  134684. sourcePlane?: Plane;
  134685. }, scene?: Nullable<Scene>): Mesh;
  134686. /**
  134687. * Creates a ground mesh
  134688. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134689. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134691. * @param name defines the name of the mesh
  134692. * @param options defines the options used to create the mesh
  134693. * @param scene defines the hosting scene
  134694. * @returns the ground mesh
  134695. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134696. */
  134697. static CreateGround(name: string, options: {
  134698. width?: number;
  134699. height?: number;
  134700. subdivisions?: number;
  134701. subdivisionsX?: number;
  134702. subdivisionsY?: number;
  134703. updatable?: boolean;
  134704. }, scene?: Nullable<Scene>): Mesh;
  134705. /**
  134706. * Creates a tiled ground mesh
  134707. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134708. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134709. * * 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
  134710. * * 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
  134711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134712. * @param name defines the name of the mesh
  134713. * @param options defines the options used to create the mesh
  134714. * @param scene defines the hosting scene
  134715. * @returns the tiled ground mesh
  134716. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134717. */
  134718. static CreateTiledGround(name: string, options: {
  134719. xmin: number;
  134720. zmin: number;
  134721. xmax: number;
  134722. zmax: number;
  134723. subdivisions?: {
  134724. w: number;
  134725. h: number;
  134726. };
  134727. precision?: {
  134728. w: number;
  134729. h: number;
  134730. };
  134731. updatable?: boolean;
  134732. }, scene?: Nullable<Scene>): Mesh;
  134733. /**
  134734. * Creates a ground mesh from a height map
  134735. * * The parameter `url` sets the URL of the height map image resource.
  134736. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134737. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134738. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134739. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134740. * * 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.
  134741. * * 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).
  134742. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134744. * @param name defines the name of the mesh
  134745. * @param url defines the url to the height map
  134746. * @param options defines the options used to create the mesh
  134747. * @param scene defines the hosting scene
  134748. * @returns the ground mesh
  134749. * @see https://doc.babylonjs.com/babylon101/height_map
  134750. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134751. */
  134752. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134753. width?: number;
  134754. height?: number;
  134755. subdivisions?: number;
  134756. minHeight?: number;
  134757. maxHeight?: number;
  134758. colorFilter?: Color3;
  134759. alphaFilter?: number;
  134760. updatable?: boolean;
  134761. onReady?: (mesh: GroundMesh) => void;
  134762. }, scene?: Nullable<Scene>): GroundMesh;
  134763. /**
  134764. * Creates a polygon mesh
  134765. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134766. * * 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
  134767. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134770. * * Remember you can only change the shape positions, not their number when updating a polygon
  134771. * @param name defines the name of the mesh
  134772. * @param options defines the options used to create the mesh
  134773. * @param scene defines the hosting scene
  134774. * @param earcutInjection can be used to inject your own earcut reference
  134775. * @returns the polygon mesh
  134776. */
  134777. static CreatePolygon(name: string, options: {
  134778. shape: Vector3[];
  134779. holes?: Vector3[][];
  134780. depth?: number;
  134781. faceUV?: Vector4[];
  134782. faceColors?: Color4[];
  134783. updatable?: boolean;
  134784. sideOrientation?: number;
  134785. frontUVs?: Vector4;
  134786. backUVs?: Vector4;
  134787. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134788. /**
  134789. * Creates an extruded polygon mesh, with depth in the Y direction.
  134790. * * 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)
  134791. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134792. * @param name defines the name of the mesh
  134793. * @param options defines the options used to create the mesh
  134794. * @param scene defines the hosting scene
  134795. * @param earcutInjection can be used to inject your own earcut reference
  134796. * @returns the polygon mesh
  134797. */
  134798. static ExtrudePolygon(name: string, options: {
  134799. shape: Vector3[];
  134800. holes?: Vector3[][];
  134801. depth?: number;
  134802. faceUV?: Vector4[];
  134803. faceColors?: Color4[];
  134804. updatable?: boolean;
  134805. sideOrientation?: number;
  134806. frontUVs?: Vector4;
  134807. backUVs?: Vector4;
  134808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134809. /**
  134810. * Creates a tube mesh.
  134811. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134812. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134813. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134814. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134815. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134816. * * 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)
  134817. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134818. * * 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
  134819. * * 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
  134820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134824. * @param name defines the name of the mesh
  134825. * @param options defines the options used to create the mesh
  134826. * @param scene defines the hosting scene
  134827. * @returns the tube mesh
  134828. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134829. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134830. */
  134831. static CreateTube(name: string, options: {
  134832. path: Vector3[];
  134833. radius?: number;
  134834. tessellation?: number;
  134835. radiusFunction?: {
  134836. (i: number, distance: number): number;
  134837. };
  134838. cap?: number;
  134839. arc?: number;
  134840. updatable?: boolean;
  134841. sideOrientation?: number;
  134842. frontUVs?: Vector4;
  134843. backUVs?: Vector4;
  134844. instance?: Mesh;
  134845. invertUV?: boolean;
  134846. }, scene?: Nullable<Scene>): Mesh;
  134847. /**
  134848. * Creates a polyhedron mesh
  134849. * * 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
  134850. * * The parameter `size` (positive float, default 1) sets the polygon size
  134851. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134852. * * 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`
  134853. * * 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
  134854. * * 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)`)
  134855. * * 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
  134856. * * 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
  134857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134860. * @param name defines the name of the mesh
  134861. * @param options defines the options used to create the mesh
  134862. * @param scene defines the hosting scene
  134863. * @returns the polyhedron mesh
  134864. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134865. */
  134866. static CreatePolyhedron(name: string, options: {
  134867. type?: number;
  134868. size?: number;
  134869. sizeX?: number;
  134870. sizeY?: number;
  134871. sizeZ?: number;
  134872. custom?: any;
  134873. faceUV?: Vector4[];
  134874. faceColors?: Color4[];
  134875. flat?: boolean;
  134876. updatable?: boolean;
  134877. sideOrientation?: number;
  134878. frontUVs?: Vector4;
  134879. backUVs?: Vector4;
  134880. }, scene?: Nullable<Scene>): Mesh;
  134881. /**
  134882. * Creates a decal mesh.
  134883. * 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
  134884. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134885. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134886. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134887. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134888. * @param name defines the name of the mesh
  134889. * @param sourceMesh defines the mesh where the decal must be applied
  134890. * @param options defines the options used to create the mesh
  134891. * @param scene defines the hosting scene
  134892. * @returns the decal mesh
  134893. * @see https://doc.babylonjs.com/how_to/decals
  134894. */
  134895. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134896. position?: Vector3;
  134897. normal?: Vector3;
  134898. size?: Vector3;
  134899. angle?: number;
  134900. }): Mesh;
  134901. }
  134902. }
  134903. declare module BABYLON {
  134904. /**
  134905. * A simplifier interface for future simplification implementations
  134906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134907. */
  134908. export interface ISimplifier {
  134909. /**
  134910. * Simplification of a given mesh according to the given settings.
  134911. * Since this requires computation, it is assumed that the function runs async.
  134912. * @param settings The settings of the simplification, including quality and distance
  134913. * @param successCallback A callback that will be called after the mesh was simplified.
  134914. * @param errorCallback in case of an error, this callback will be called. optional.
  134915. */
  134916. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134917. }
  134918. /**
  134919. * Expected simplification settings.
  134920. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134922. */
  134923. export interface ISimplificationSettings {
  134924. /**
  134925. * Gets or sets the expected quality
  134926. */
  134927. quality: number;
  134928. /**
  134929. * Gets or sets the distance when this optimized version should be used
  134930. */
  134931. distance: number;
  134932. /**
  134933. * Gets an already optimized mesh
  134934. */
  134935. optimizeMesh?: boolean;
  134936. }
  134937. /**
  134938. * Class used to specify simplification options
  134939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134940. */
  134941. export class SimplificationSettings implements ISimplificationSettings {
  134942. /** expected quality */
  134943. quality: number;
  134944. /** distance when this optimized version should be used */
  134945. distance: number;
  134946. /** already optimized mesh */
  134947. optimizeMesh?: boolean | undefined;
  134948. /**
  134949. * Creates a SimplificationSettings
  134950. * @param quality expected quality
  134951. * @param distance distance when this optimized version should be used
  134952. * @param optimizeMesh already optimized mesh
  134953. */
  134954. constructor(
  134955. /** expected quality */
  134956. quality: number,
  134957. /** distance when this optimized version should be used */
  134958. distance: number,
  134959. /** already optimized mesh */
  134960. optimizeMesh?: boolean | undefined);
  134961. }
  134962. /**
  134963. * Interface used to define a simplification task
  134964. */
  134965. export interface ISimplificationTask {
  134966. /**
  134967. * Array of settings
  134968. */
  134969. settings: Array<ISimplificationSettings>;
  134970. /**
  134971. * Simplification type
  134972. */
  134973. simplificationType: SimplificationType;
  134974. /**
  134975. * Mesh to simplify
  134976. */
  134977. mesh: Mesh;
  134978. /**
  134979. * Callback called on success
  134980. */
  134981. successCallback?: () => void;
  134982. /**
  134983. * Defines if parallel processing can be used
  134984. */
  134985. parallelProcessing: boolean;
  134986. }
  134987. /**
  134988. * Queue used to order the simplification tasks
  134989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134990. */
  134991. export class SimplificationQueue {
  134992. private _simplificationArray;
  134993. /**
  134994. * Gets a boolean indicating that the process is still running
  134995. */
  134996. running: boolean;
  134997. /**
  134998. * Creates a new queue
  134999. */
  135000. constructor();
  135001. /**
  135002. * Adds a new simplification task
  135003. * @param task defines a task to add
  135004. */
  135005. addTask(task: ISimplificationTask): void;
  135006. /**
  135007. * Execute next task
  135008. */
  135009. executeNext(): void;
  135010. /**
  135011. * Execute a simplification task
  135012. * @param task defines the task to run
  135013. */
  135014. runSimplification(task: ISimplificationTask): void;
  135015. private getSimplifier;
  135016. }
  135017. /**
  135018. * The implemented types of simplification
  135019. * At the moment only Quadratic Error Decimation is implemented
  135020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135021. */
  135022. export enum SimplificationType {
  135023. /** Quadratic error decimation */
  135024. QUADRATIC = 0
  135025. }
  135026. }
  135027. declare module BABYLON {
  135028. interface Scene {
  135029. /** @hidden (Backing field) */
  135030. _simplificationQueue: SimplificationQueue;
  135031. /**
  135032. * Gets or sets the simplification queue attached to the scene
  135033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135034. */
  135035. simplificationQueue: SimplificationQueue;
  135036. }
  135037. interface Mesh {
  135038. /**
  135039. * Simplify the mesh according to the given array of settings.
  135040. * Function will return immediately and will simplify async
  135041. * @param settings a collection of simplification settings
  135042. * @param parallelProcessing should all levels calculate parallel or one after the other
  135043. * @param simplificationType the type of simplification to run
  135044. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135045. * @returns the current mesh
  135046. */
  135047. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135048. }
  135049. /**
  135050. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135051. * created in a scene
  135052. */
  135053. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135054. /**
  135055. * The component name helpfull to identify the component in the list of scene components.
  135056. */
  135057. readonly name: string;
  135058. /**
  135059. * The scene the component belongs to.
  135060. */
  135061. scene: Scene;
  135062. /**
  135063. * Creates a new instance of the component for the given scene
  135064. * @param scene Defines the scene to register the component in
  135065. */
  135066. constructor(scene: Scene);
  135067. /**
  135068. * Registers the component in a given scene
  135069. */
  135070. register(): void;
  135071. /**
  135072. * Rebuilds the elements related to this component in case of
  135073. * context lost for instance.
  135074. */
  135075. rebuild(): void;
  135076. /**
  135077. * Disposes the component and the associated ressources
  135078. */
  135079. dispose(): void;
  135080. private _beforeCameraUpdate;
  135081. }
  135082. }
  135083. declare module BABYLON {
  135084. /**
  135085. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135086. */
  135087. export interface INavigationEnginePlugin {
  135088. /**
  135089. * plugin name
  135090. */
  135091. name: string;
  135092. /**
  135093. * Creates a navigation mesh
  135094. * @param meshes array of all the geometry used to compute the navigatio mesh
  135095. * @param parameters bunch of parameters used to filter geometry
  135096. */
  135097. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135098. /**
  135099. * Create a navigation mesh debug mesh
  135100. * @param scene is where the mesh will be added
  135101. * @returns debug display mesh
  135102. */
  135103. createDebugNavMesh(scene: Scene): Mesh;
  135104. /**
  135105. * Get a navigation mesh constrained position, closest to the parameter position
  135106. * @param position world position
  135107. * @returns the closest point to position constrained by the navigation mesh
  135108. */
  135109. getClosestPoint(position: Vector3): Vector3;
  135110. /**
  135111. * Get a navigation mesh constrained position, within a particular radius
  135112. * @param position world position
  135113. * @param maxRadius the maximum distance to the constrained world position
  135114. * @returns the closest point to position constrained by the navigation mesh
  135115. */
  135116. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135117. /**
  135118. * Compute the final position from a segment made of destination-position
  135119. * @param position world position
  135120. * @param destination world position
  135121. * @returns the resulting point along the navmesh
  135122. */
  135123. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135124. /**
  135125. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135126. * @param start world position
  135127. * @param end world position
  135128. * @returns array containing world position composing the path
  135129. */
  135130. computePath(start: Vector3, end: Vector3): Vector3[];
  135131. /**
  135132. * If this plugin is supported
  135133. * @returns true if plugin is supported
  135134. */
  135135. isSupported(): boolean;
  135136. /**
  135137. * Create a new Crowd so you can add agents
  135138. * @param maxAgents the maximum agent count in the crowd
  135139. * @param maxAgentRadius the maximum radius an agent can have
  135140. * @param scene to attach the crowd to
  135141. * @returns the crowd you can add agents to
  135142. */
  135143. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135144. /**
  135145. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135146. * The queries will try to find a solution within those bounds
  135147. * default is (1,1,1)
  135148. * @param extent x,y,z value that define the extent around the queries point of reference
  135149. */
  135150. setDefaultQueryExtent(extent: Vector3): void;
  135151. /**
  135152. * Get the Bounding box extent specified by setDefaultQueryExtent
  135153. * @returns the box extent values
  135154. */
  135155. getDefaultQueryExtent(): Vector3;
  135156. /**
  135157. * Release all resources
  135158. */
  135159. dispose(): void;
  135160. }
  135161. /**
  135162. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135163. */
  135164. export interface ICrowd {
  135165. /**
  135166. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135167. * You can attach anything to that node. The node position is updated in the scene update tick.
  135168. * @param pos world position that will be constrained by the navigation mesh
  135169. * @param parameters agent parameters
  135170. * @param transform hooked to the agent that will be update by the scene
  135171. * @returns agent index
  135172. */
  135173. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135174. /**
  135175. * Returns the agent position in world space
  135176. * @param index agent index returned by addAgent
  135177. * @returns world space position
  135178. */
  135179. getAgentPosition(index: number): Vector3;
  135180. /**
  135181. * Gets the agent velocity in world space
  135182. * @param index agent index returned by addAgent
  135183. * @returns world space velocity
  135184. */
  135185. getAgentVelocity(index: number): Vector3;
  135186. /**
  135187. * remove a particular agent previously created
  135188. * @param index agent index returned by addAgent
  135189. */
  135190. removeAgent(index: number): void;
  135191. /**
  135192. * get the list of all agents attached to this crowd
  135193. * @returns list of agent indices
  135194. */
  135195. getAgents(): number[];
  135196. /**
  135197. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135198. * @param deltaTime in seconds
  135199. */
  135200. update(deltaTime: number): void;
  135201. /**
  135202. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135203. * @param index agent index returned by addAgent
  135204. * @param destination targeted world position
  135205. */
  135206. agentGoto(index: number, destination: Vector3): void;
  135207. /**
  135208. * Teleport the agent to a new position
  135209. * @param index agent index returned by addAgent
  135210. * @param destination targeted world position
  135211. */
  135212. agentTeleport(index: number, destination: Vector3): void;
  135213. /**
  135214. * Update agent parameters
  135215. * @param index agent index returned by addAgent
  135216. * @param parameters agent parameters
  135217. */
  135218. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135219. /**
  135220. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135221. * The queries will try to find a solution within those bounds
  135222. * default is (1,1,1)
  135223. * @param extent x,y,z value that define the extent around the queries point of reference
  135224. */
  135225. setDefaultQueryExtent(extent: Vector3): void;
  135226. /**
  135227. * Get the Bounding box extent specified by setDefaultQueryExtent
  135228. * @returns the box extent values
  135229. */
  135230. getDefaultQueryExtent(): Vector3;
  135231. /**
  135232. * Release all resources
  135233. */
  135234. dispose(): void;
  135235. }
  135236. /**
  135237. * Configures an agent
  135238. */
  135239. export interface IAgentParameters {
  135240. /**
  135241. * Agent radius. [Limit: >= 0]
  135242. */
  135243. radius: number;
  135244. /**
  135245. * Agent height. [Limit: > 0]
  135246. */
  135247. height: number;
  135248. /**
  135249. * Maximum allowed acceleration. [Limit: >= 0]
  135250. */
  135251. maxAcceleration: number;
  135252. /**
  135253. * Maximum allowed speed. [Limit: >= 0]
  135254. */
  135255. maxSpeed: number;
  135256. /**
  135257. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135258. */
  135259. collisionQueryRange: number;
  135260. /**
  135261. * The path visibility optimization range. [Limit: > 0]
  135262. */
  135263. pathOptimizationRange: number;
  135264. /**
  135265. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135266. */
  135267. separationWeight: number;
  135268. }
  135269. /**
  135270. * Configures the navigation mesh creation
  135271. */
  135272. export interface INavMeshParameters {
  135273. /**
  135274. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135275. */
  135276. cs: number;
  135277. /**
  135278. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135279. */
  135280. ch: number;
  135281. /**
  135282. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135283. */
  135284. walkableSlopeAngle: number;
  135285. /**
  135286. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135287. * be considered walkable. [Limit: >= 3] [Units: vx]
  135288. */
  135289. walkableHeight: number;
  135290. /**
  135291. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135292. */
  135293. walkableClimb: number;
  135294. /**
  135295. * The distance to erode/shrink the walkable area of the heightfield away from
  135296. * obstructions. [Limit: >=0] [Units: vx]
  135297. */
  135298. walkableRadius: number;
  135299. /**
  135300. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135301. */
  135302. maxEdgeLen: number;
  135303. /**
  135304. * The maximum distance a simplfied contour's border edges should deviate
  135305. * the original raw contour. [Limit: >=0] [Units: vx]
  135306. */
  135307. maxSimplificationError: number;
  135308. /**
  135309. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135310. */
  135311. minRegionArea: number;
  135312. /**
  135313. * Any regions with a span count smaller than this value will, if possible,
  135314. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135315. */
  135316. mergeRegionArea: number;
  135317. /**
  135318. * The maximum number of vertices allowed for polygons generated during the
  135319. * contour to polygon conversion process. [Limit: >= 3]
  135320. */
  135321. maxVertsPerPoly: number;
  135322. /**
  135323. * Sets the sampling distance to use when generating the detail mesh.
  135324. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135325. */
  135326. detailSampleDist: number;
  135327. /**
  135328. * The maximum distance the detail mesh surface should deviate from heightfield
  135329. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135330. */
  135331. detailSampleMaxError: number;
  135332. }
  135333. }
  135334. declare module BABYLON {
  135335. /**
  135336. * RecastJS navigation plugin
  135337. */
  135338. export class RecastJSPlugin implements INavigationEnginePlugin {
  135339. /**
  135340. * Reference to the Recast library
  135341. */
  135342. bjsRECAST: any;
  135343. /**
  135344. * plugin name
  135345. */
  135346. name: string;
  135347. /**
  135348. * the first navmesh created. We might extend this to support multiple navmeshes
  135349. */
  135350. navMesh: any;
  135351. /**
  135352. * Initializes the recastJS plugin
  135353. * @param recastInjection can be used to inject your own recast reference
  135354. */
  135355. constructor(recastInjection?: any);
  135356. /**
  135357. * Creates a navigation mesh
  135358. * @param meshes array of all the geometry used to compute the navigatio mesh
  135359. * @param parameters bunch of parameters used to filter geometry
  135360. */
  135361. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135362. /**
  135363. * Create a navigation mesh debug mesh
  135364. * @param scene is where the mesh will be added
  135365. * @returns debug display mesh
  135366. */
  135367. createDebugNavMesh(scene: Scene): Mesh;
  135368. /**
  135369. * Get a navigation mesh constrained position, closest to the parameter position
  135370. * @param position world position
  135371. * @returns the closest point to position constrained by the navigation mesh
  135372. */
  135373. getClosestPoint(position: Vector3): Vector3;
  135374. /**
  135375. * Get a navigation mesh constrained position, within a particular radius
  135376. * @param position world position
  135377. * @param maxRadius the maximum distance to the constrained world position
  135378. * @returns the closest point to position constrained by the navigation mesh
  135379. */
  135380. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135381. /**
  135382. * Compute the final position from a segment made of destination-position
  135383. * @param position world position
  135384. * @param destination world position
  135385. * @returns the resulting point along the navmesh
  135386. */
  135387. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135388. /**
  135389. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135390. * @param start world position
  135391. * @param end world position
  135392. * @returns array containing world position composing the path
  135393. */
  135394. computePath(start: Vector3, end: Vector3): Vector3[];
  135395. /**
  135396. * Create a new Crowd so you can add agents
  135397. * @param maxAgents the maximum agent count in the crowd
  135398. * @param maxAgentRadius the maximum radius an agent can have
  135399. * @param scene to attach the crowd to
  135400. * @returns the crowd you can add agents to
  135401. */
  135402. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135403. /**
  135404. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135405. * The queries will try to find a solution within those bounds
  135406. * default is (1,1,1)
  135407. * @param extent x,y,z value that define the extent around the queries point of reference
  135408. */
  135409. setDefaultQueryExtent(extent: Vector3): void;
  135410. /**
  135411. * Get the Bounding box extent specified by setDefaultQueryExtent
  135412. * @returns the box extent values
  135413. */
  135414. getDefaultQueryExtent(): Vector3;
  135415. /**
  135416. * Disposes
  135417. */
  135418. dispose(): void;
  135419. /**
  135420. * If this plugin is supported
  135421. * @returns true if plugin is supported
  135422. */
  135423. isSupported(): boolean;
  135424. }
  135425. /**
  135426. * Recast detour crowd implementation
  135427. */
  135428. export class RecastJSCrowd implements ICrowd {
  135429. /**
  135430. * Recast/detour plugin
  135431. */
  135432. bjsRECASTPlugin: RecastJSPlugin;
  135433. /**
  135434. * Link to the detour crowd
  135435. */
  135436. recastCrowd: any;
  135437. /**
  135438. * One transform per agent
  135439. */
  135440. transforms: TransformNode[];
  135441. /**
  135442. * All agents created
  135443. */
  135444. agents: number[];
  135445. /**
  135446. * Link to the scene is kept to unregister the crowd from the scene
  135447. */
  135448. private _scene;
  135449. /**
  135450. * Observer for crowd updates
  135451. */
  135452. private _onBeforeAnimationsObserver;
  135453. /**
  135454. * Constructor
  135455. * @param plugin recastJS plugin
  135456. * @param maxAgents the maximum agent count in the crowd
  135457. * @param maxAgentRadius the maximum radius an agent can have
  135458. * @param scene to attach the crowd to
  135459. * @returns the crowd you can add agents to
  135460. */
  135461. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135462. /**
  135463. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135464. * You can attach anything to that node. The node position is updated in the scene update tick.
  135465. * @param pos world position that will be constrained by the navigation mesh
  135466. * @param parameters agent parameters
  135467. * @param transform hooked to the agent that will be update by the scene
  135468. * @returns agent index
  135469. */
  135470. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135471. /**
  135472. * Returns the agent position in world space
  135473. * @param index agent index returned by addAgent
  135474. * @returns world space position
  135475. */
  135476. getAgentPosition(index: number): Vector3;
  135477. /**
  135478. * Returns the agent velocity in world space
  135479. * @param index agent index returned by addAgent
  135480. * @returns world space velocity
  135481. */
  135482. getAgentVelocity(index: number): Vector3;
  135483. /**
  135484. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135485. * @param index agent index returned by addAgent
  135486. * @param destination targeted world position
  135487. */
  135488. agentGoto(index: number, destination: Vector3): void;
  135489. /**
  135490. * Teleport the agent to a new position
  135491. * @param index agent index returned by addAgent
  135492. * @param destination targeted world position
  135493. */
  135494. agentTeleport(index: number, destination: Vector3): void;
  135495. /**
  135496. * Update agent parameters
  135497. * @param index agent index returned by addAgent
  135498. * @param parameters agent parameters
  135499. */
  135500. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135501. /**
  135502. * remove a particular agent previously created
  135503. * @param index agent index returned by addAgent
  135504. */
  135505. removeAgent(index: number): void;
  135506. /**
  135507. * get the list of all agents attached to this crowd
  135508. * @returns list of agent indices
  135509. */
  135510. getAgents(): number[];
  135511. /**
  135512. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135513. * @param deltaTime in seconds
  135514. */
  135515. update(deltaTime: number): void;
  135516. /**
  135517. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135518. * The queries will try to find a solution within those bounds
  135519. * default is (1,1,1)
  135520. * @param extent x,y,z value that define the extent around the queries point of reference
  135521. */
  135522. setDefaultQueryExtent(extent: Vector3): void;
  135523. /**
  135524. * Get the Bounding box extent specified by setDefaultQueryExtent
  135525. * @returns the box extent values
  135526. */
  135527. getDefaultQueryExtent(): Vector3;
  135528. /**
  135529. * Release all resources
  135530. */
  135531. dispose(): void;
  135532. }
  135533. }
  135534. declare module BABYLON {
  135535. /**
  135536. * Class used to enable access to IndexedDB
  135537. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135538. */
  135539. export class Database implements IOfflineProvider {
  135540. private _callbackManifestChecked;
  135541. private _currentSceneUrl;
  135542. private _db;
  135543. private _enableSceneOffline;
  135544. private _enableTexturesOffline;
  135545. private _manifestVersionFound;
  135546. private _mustUpdateRessources;
  135547. private _hasReachedQuota;
  135548. private _isSupported;
  135549. private _idbFactory;
  135550. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135551. private static IsUASupportingBlobStorage;
  135552. /**
  135553. * Gets a boolean indicating if Database storate is enabled (off by default)
  135554. */
  135555. static IDBStorageEnabled: boolean;
  135556. /**
  135557. * Gets a boolean indicating if scene must be saved in the database
  135558. */
  135559. get enableSceneOffline(): boolean;
  135560. /**
  135561. * Gets a boolean indicating if textures must be saved in the database
  135562. */
  135563. get enableTexturesOffline(): boolean;
  135564. /**
  135565. * Creates a new Database
  135566. * @param urlToScene defines the url to load the scene
  135567. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135568. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135569. */
  135570. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135571. private static _ParseURL;
  135572. private static _ReturnFullUrlLocation;
  135573. private _checkManifestFile;
  135574. /**
  135575. * Open the database and make it available
  135576. * @param successCallback defines the callback to call on success
  135577. * @param errorCallback defines the callback to call on error
  135578. */
  135579. open(successCallback: () => void, errorCallback: () => void): void;
  135580. /**
  135581. * Loads an image from the database
  135582. * @param url defines the url to load from
  135583. * @param image defines the target DOM image
  135584. */
  135585. loadImage(url: string, image: HTMLImageElement): void;
  135586. private _loadImageFromDBAsync;
  135587. private _saveImageIntoDBAsync;
  135588. private _checkVersionFromDB;
  135589. private _loadVersionFromDBAsync;
  135590. private _saveVersionIntoDBAsync;
  135591. /**
  135592. * Loads a file from database
  135593. * @param url defines the URL to load from
  135594. * @param sceneLoaded defines a callback to call on success
  135595. * @param progressCallBack defines a callback to call when progress changed
  135596. * @param errorCallback defines a callback to call on error
  135597. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135598. */
  135599. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135600. private _loadFileAsync;
  135601. private _saveFileAsync;
  135602. /**
  135603. * Validates if xhr data is correct
  135604. * @param xhr defines the request to validate
  135605. * @param dataType defines the expected data type
  135606. * @returns true if data is correct
  135607. */
  135608. private static _ValidateXHRData;
  135609. }
  135610. }
  135611. declare module BABYLON {
  135612. /** @hidden */
  135613. export var gpuUpdateParticlesPixelShader: {
  135614. name: string;
  135615. shader: string;
  135616. };
  135617. }
  135618. declare module BABYLON {
  135619. /** @hidden */
  135620. export var gpuUpdateParticlesVertexShader: {
  135621. name: string;
  135622. shader: string;
  135623. };
  135624. }
  135625. declare module BABYLON {
  135626. /** @hidden */
  135627. export var clipPlaneFragmentDeclaration2: {
  135628. name: string;
  135629. shader: string;
  135630. };
  135631. }
  135632. declare module BABYLON {
  135633. /** @hidden */
  135634. export var gpuRenderParticlesPixelShader: {
  135635. name: string;
  135636. shader: string;
  135637. };
  135638. }
  135639. declare module BABYLON {
  135640. /** @hidden */
  135641. export var clipPlaneVertexDeclaration2: {
  135642. name: string;
  135643. shader: string;
  135644. };
  135645. }
  135646. declare module BABYLON {
  135647. /** @hidden */
  135648. export var gpuRenderParticlesVertexShader: {
  135649. name: string;
  135650. shader: string;
  135651. };
  135652. }
  135653. declare module BABYLON {
  135654. /**
  135655. * This represents a GPU particle system in Babylon
  135656. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135657. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135658. */
  135659. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135660. /**
  135661. * The layer mask we are rendering the particles through.
  135662. */
  135663. layerMask: number;
  135664. private _capacity;
  135665. private _activeCount;
  135666. private _currentActiveCount;
  135667. private _accumulatedCount;
  135668. private _renderEffect;
  135669. private _updateEffect;
  135670. private _buffer0;
  135671. private _buffer1;
  135672. private _spriteBuffer;
  135673. private _updateVAO;
  135674. private _renderVAO;
  135675. private _targetIndex;
  135676. private _sourceBuffer;
  135677. private _targetBuffer;
  135678. private _engine;
  135679. private _currentRenderId;
  135680. private _started;
  135681. private _stopped;
  135682. private _timeDelta;
  135683. private _randomTexture;
  135684. private _randomTexture2;
  135685. private _attributesStrideSize;
  135686. private _updateEffectOptions;
  135687. private _randomTextureSize;
  135688. private _actualFrame;
  135689. private readonly _rawTextureWidth;
  135690. /**
  135691. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135692. */
  135693. static get IsSupported(): boolean;
  135694. /**
  135695. * An event triggered when the system is disposed.
  135696. */
  135697. onDisposeObservable: Observable<GPUParticleSystem>;
  135698. /**
  135699. * Gets the maximum number of particles active at the same time.
  135700. * @returns The max number of active particles.
  135701. */
  135702. getCapacity(): number;
  135703. /**
  135704. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135705. * to override the particles.
  135706. */
  135707. forceDepthWrite: boolean;
  135708. /**
  135709. * Gets or set the number of active particles
  135710. */
  135711. get activeParticleCount(): number;
  135712. set activeParticleCount(value: number);
  135713. private _preWarmDone;
  135714. /**
  135715. * Specifies if the particles are updated in emitter local space or world space.
  135716. * This is always false for GPU particles
  135717. */
  135718. get isLocal(): boolean;
  135719. set isLocal(value: boolean);
  135720. /**
  135721. * Is this system ready to be used/rendered
  135722. * @return true if the system is ready
  135723. */
  135724. isReady(): boolean;
  135725. /**
  135726. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135727. * @returns True if it has been started, otherwise false.
  135728. */
  135729. isStarted(): boolean;
  135730. /**
  135731. * Starts the particle system and begins to emit
  135732. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135733. */
  135734. start(delay?: number): void;
  135735. /**
  135736. * Stops the particle system.
  135737. */
  135738. stop(): void;
  135739. /**
  135740. * Remove all active particles
  135741. */
  135742. reset(): void;
  135743. /**
  135744. * Returns the string "GPUParticleSystem"
  135745. * @returns a string containing the class name
  135746. */
  135747. getClassName(): string;
  135748. private _colorGradientsTexture;
  135749. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135750. /**
  135751. * Adds a new color gradient
  135752. * @param gradient defines the gradient to use (between 0 and 1)
  135753. * @param color1 defines the color to affect to the specified gradient
  135754. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135755. * @returns the current particle system
  135756. */
  135757. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135758. /**
  135759. * Remove a specific color gradient
  135760. * @param gradient defines the gradient to remove
  135761. * @returns the current particle system
  135762. */
  135763. removeColorGradient(gradient: number): GPUParticleSystem;
  135764. private _angularSpeedGradientsTexture;
  135765. private _sizeGradientsTexture;
  135766. private _velocityGradientsTexture;
  135767. private _limitVelocityGradientsTexture;
  135768. private _dragGradientsTexture;
  135769. private _addFactorGradient;
  135770. /**
  135771. * Adds a new size gradient
  135772. * @param gradient defines the gradient to use (between 0 and 1)
  135773. * @param factor defines the size factor to affect to the specified gradient
  135774. * @returns the current particle system
  135775. */
  135776. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135777. /**
  135778. * Remove a specific size gradient
  135779. * @param gradient defines the gradient to remove
  135780. * @returns the current particle system
  135781. */
  135782. removeSizeGradient(gradient: number): GPUParticleSystem;
  135783. /**
  135784. * Adds a new angular speed gradient
  135785. * @param gradient defines the gradient to use (between 0 and 1)
  135786. * @param factor defines the angular speed to affect to the specified gradient
  135787. * @returns the current particle system
  135788. */
  135789. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135790. /**
  135791. * Remove a specific angular speed gradient
  135792. * @param gradient defines the gradient to remove
  135793. * @returns the current particle system
  135794. */
  135795. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135796. /**
  135797. * Adds a new velocity gradient
  135798. * @param gradient defines the gradient to use (between 0 and 1)
  135799. * @param factor defines the velocity to affect to the specified gradient
  135800. * @returns the current particle system
  135801. */
  135802. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135803. /**
  135804. * Remove a specific velocity gradient
  135805. * @param gradient defines the gradient to remove
  135806. * @returns the current particle system
  135807. */
  135808. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135809. /**
  135810. * Adds a new limit velocity gradient
  135811. * @param gradient defines the gradient to use (between 0 and 1)
  135812. * @param factor defines the limit velocity value to affect to the specified gradient
  135813. * @returns the current particle system
  135814. */
  135815. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135816. /**
  135817. * Remove a specific limit velocity gradient
  135818. * @param gradient defines the gradient to remove
  135819. * @returns the current particle system
  135820. */
  135821. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135822. /**
  135823. * Adds a new drag gradient
  135824. * @param gradient defines the gradient to use (between 0 and 1)
  135825. * @param factor defines the drag value to affect to the specified gradient
  135826. * @returns the current particle system
  135827. */
  135828. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135829. /**
  135830. * Remove a specific drag gradient
  135831. * @param gradient defines the gradient to remove
  135832. * @returns the current particle system
  135833. */
  135834. removeDragGradient(gradient: number): GPUParticleSystem;
  135835. /**
  135836. * Not supported by GPUParticleSystem
  135837. * @param gradient defines the gradient to use (between 0 and 1)
  135838. * @param factor defines the emit rate value to affect to the specified gradient
  135839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135840. * @returns the current particle system
  135841. */
  135842. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135843. /**
  135844. * Not supported by GPUParticleSystem
  135845. * @param gradient defines the gradient to remove
  135846. * @returns the current particle system
  135847. */
  135848. removeEmitRateGradient(gradient: number): IParticleSystem;
  135849. /**
  135850. * Not supported by GPUParticleSystem
  135851. * @param gradient defines the gradient to use (between 0 and 1)
  135852. * @param factor defines the start size value to affect to the specified gradient
  135853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135854. * @returns the current particle system
  135855. */
  135856. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135857. /**
  135858. * Not supported by GPUParticleSystem
  135859. * @param gradient defines the gradient to remove
  135860. * @returns the current particle system
  135861. */
  135862. removeStartSizeGradient(gradient: number): IParticleSystem;
  135863. /**
  135864. * Not supported by GPUParticleSystem
  135865. * @param gradient defines the gradient to use (between 0 and 1)
  135866. * @param min defines the color remap minimal range
  135867. * @param max defines the color remap maximal range
  135868. * @returns the current particle system
  135869. */
  135870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135871. /**
  135872. * Not supported by GPUParticleSystem
  135873. * @param gradient defines the gradient to remove
  135874. * @returns the current particle system
  135875. */
  135876. removeColorRemapGradient(): IParticleSystem;
  135877. /**
  135878. * Not supported by GPUParticleSystem
  135879. * @param gradient defines the gradient to use (between 0 and 1)
  135880. * @param min defines the alpha remap minimal range
  135881. * @param max defines the alpha remap maximal range
  135882. * @returns the current particle system
  135883. */
  135884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135885. /**
  135886. * Not supported by GPUParticleSystem
  135887. * @param gradient defines the gradient to remove
  135888. * @returns the current particle system
  135889. */
  135890. removeAlphaRemapGradient(): IParticleSystem;
  135891. /**
  135892. * Not supported by GPUParticleSystem
  135893. * @param gradient defines the gradient to use (between 0 and 1)
  135894. * @param color defines the color to affect to the specified gradient
  135895. * @returns the current particle system
  135896. */
  135897. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135898. /**
  135899. * Not supported by GPUParticleSystem
  135900. * @param gradient defines the gradient to remove
  135901. * @returns the current particle system
  135902. */
  135903. removeRampGradient(): IParticleSystem;
  135904. /**
  135905. * Not supported by GPUParticleSystem
  135906. * @returns the list of ramp gradients
  135907. */
  135908. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135909. /**
  135910. * Not supported by GPUParticleSystem
  135911. * Gets or sets a boolean indicating that ramp gradients must be used
  135912. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135913. */
  135914. get useRampGradients(): boolean;
  135915. set useRampGradients(value: boolean);
  135916. /**
  135917. * Not supported by GPUParticleSystem
  135918. * @param gradient defines the gradient to use (between 0 and 1)
  135919. * @param factor defines the life time factor to affect to the specified gradient
  135920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135921. * @returns the current particle system
  135922. */
  135923. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135924. /**
  135925. * Not supported by GPUParticleSystem
  135926. * @param gradient defines the gradient to remove
  135927. * @returns the current particle system
  135928. */
  135929. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135930. /**
  135931. * Instantiates a GPU particle system.
  135932. * 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.
  135933. * @param name The name of the particle system
  135934. * @param options The options used to create the system
  135935. * @param scene The scene the particle system belongs to
  135936. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135937. */
  135938. constructor(name: string, options: Partial<{
  135939. capacity: number;
  135940. randomTextureSize: number;
  135941. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135942. protected _reset(): void;
  135943. private _createUpdateVAO;
  135944. private _createRenderVAO;
  135945. private _initialize;
  135946. /** @hidden */
  135947. _recreateUpdateEffect(): void;
  135948. /** @hidden */
  135949. _recreateRenderEffect(): void;
  135950. /**
  135951. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135952. * @param preWarm defines if we are in the pre-warmimg phase
  135953. */
  135954. animate(preWarm?: boolean): void;
  135955. private _createFactorGradientTexture;
  135956. private _createSizeGradientTexture;
  135957. private _createAngularSpeedGradientTexture;
  135958. private _createVelocityGradientTexture;
  135959. private _createLimitVelocityGradientTexture;
  135960. private _createDragGradientTexture;
  135961. private _createColorGradientTexture;
  135962. /**
  135963. * Renders the particle system in its current state
  135964. * @param preWarm defines if the system should only update the particles but not render them
  135965. * @returns the current number of particles
  135966. */
  135967. render(preWarm?: boolean): number;
  135968. /**
  135969. * Rebuilds the particle system
  135970. */
  135971. rebuild(): void;
  135972. private _releaseBuffers;
  135973. private _releaseVAOs;
  135974. /**
  135975. * Disposes the particle system and free the associated resources
  135976. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135977. */
  135978. dispose(disposeTexture?: boolean): void;
  135979. /**
  135980. * Clones the particle system.
  135981. * @param name The name of the cloned object
  135982. * @param newEmitter The new emitter to use
  135983. * @returns the cloned particle system
  135984. */
  135985. clone(name: string, newEmitter: any): GPUParticleSystem;
  135986. /**
  135987. * Serializes the particle system to a JSON object.
  135988. * @returns the JSON object
  135989. */
  135990. serialize(): any;
  135991. /**
  135992. * Parses a JSON object to create a GPU particle system.
  135993. * @param parsedParticleSystem The JSON object to parse
  135994. * @param scene The scene to create the particle system in
  135995. * @param rootUrl The root url to use to load external dependencies like texture
  135996. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135997. * @returns the parsed GPU particle system
  135998. */
  135999. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136000. }
  136001. }
  136002. declare module BABYLON {
  136003. /**
  136004. * Represents a set of particle systems working together to create a specific effect
  136005. */
  136006. export class ParticleSystemSet implements IDisposable {
  136007. /**
  136008. * Gets or sets base Assets URL
  136009. */
  136010. static BaseAssetsUrl: string;
  136011. private _emitterCreationOptions;
  136012. private _emitterNode;
  136013. /**
  136014. * Gets the particle system list
  136015. */
  136016. systems: IParticleSystem[];
  136017. /**
  136018. * Gets the emitter node used with this set
  136019. */
  136020. get emitterNode(): Nullable<TransformNode>;
  136021. /**
  136022. * Creates a new emitter mesh as a sphere
  136023. * @param options defines the options used to create the sphere
  136024. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136025. * @param scene defines the hosting scene
  136026. */
  136027. setEmitterAsSphere(options: {
  136028. diameter: number;
  136029. segments: number;
  136030. color: Color3;
  136031. }, renderingGroupId: number, scene: Scene): void;
  136032. /**
  136033. * Starts all particle systems of the set
  136034. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136035. */
  136036. start(emitter?: AbstractMesh): void;
  136037. /**
  136038. * Release all associated resources
  136039. */
  136040. dispose(): void;
  136041. /**
  136042. * Serialize the set into a JSON compatible object
  136043. * @returns a JSON compatible representation of the set
  136044. */
  136045. serialize(): any;
  136046. /**
  136047. * Parse a new ParticleSystemSet from a serialized source
  136048. * @param data defines a JSON compatible representation of the set
  136049. * @param scene defines the hosting scene
  136050. * @param gpu defines if we want GPU particles or CPU particles
  136051. * @returns a new ParticleSystemSet
  136052. */
  136053. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136054. }
  136055. }
  136056. declare module BABYLON {
  136057. /**
  136058. * This class is made for on one-liner static method to help creating particle system set.
  136059. */
  136060. export class ParticleHelper {
  136061. /**
  136062. * Gets or sets base Assets URL
  136063. */
  136064. static BaseAssetsUrl: string;
  136065. /**
  136066. * Create a default particle system that you can tweak
  136067. * @param emitter defines the emitter to use
  136068. * @param capacity defines the system capacity (default is 500 particles)
  136069. * @param scene defines the hosting scene
  136070. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136071. * @returns the new Particle system
  136072. */
  136073. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136074. /**
  136075. * This is the main static method (one-liner) of this helper to create different particle systems
  136076. * @param type This string represents the type to the particle system to create
  136077. * @param scene The scene where the particle system should live
  136078. * @param gpu If the system will use gpu
  136079. * @returns the ParticleSystemSet created
  136080. */
  136081. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136082. /**
  136083. * Static function used to export a particle system to a ParticleSystemSet variable.
  136084. * Please note that the emitter shape is not exported
  136085. * @param systems defines the particle systems to export
  136086. * @returns the created particle system set
  136087. */
  136088. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136089. }
  136090. }
  136091. declare module BABYLON {
  136092. interface Engine {
  136093. /**
  136094. * Create an effect to use with particle systems.
  136095. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136096. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136097. * @param uniformsNames defines a list of attribute names
  136098. * @param samplers defines an array of string used to represent textures
  136099. * @param defines defines the string containing the defines to use to compile the shaders
  136100. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136101. * @param onCompiled defines a function to call when the effect creation is successful
  136102. * @param onError defines a function to call when the effect creation has failed
  136103. * @returns the new Effect
  136104. */
  136105. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136106. }
  136107. interface Mesh {
  136108. /**
  136109. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136110. * @returns an array of IParticleSystem
  136111. */
  136112. getEmittedParticleSystems(): IParticleSystem[];
  136113. /**
  136114. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136115. * @returns an array of IParticleSystem
  136116. */
  136117. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136118. }
  136119. /**
  136120. * @hidden
  136121. */
  136122. export var _IDoNeedToBeInTheBuild: number;
  136123. }
  136124. declare module BABYLON {
  136125. /** Defines the 4 color options */
  136126. export enum PointColor {
  136127. /** color value */
  136128. Color = 2,
  136129. /** uv value */
  136130. UV = 1,
  136131. /** random value */
  136132. Random = 0,
  136133. /** stated value */
  136134. Stated = 3
  136135. }
  136136. /**
  136137. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136138. * 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.
  136139. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136140. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136141. *
  136142. * Full documentation here : TO BE ENTERED
  136143. */
  136144. export class PointsCloudSystem implements IDisposable {
  136145. /**
  136146. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136147. * Example : var p = SPS.particles[i];
  136148. */
  136149. particles: CloudPoint[];
  136150. /**
  136151. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136152. */
  136153. nbParticles: number;
  136154. /**
  136155. * This a counter for your own usage. It's not set by any SPS functions.
  136156. */
  136157. counter: number;
  136158. /**
  136159. * The PCS name. This name is also given to the underlying mesh.
  136160. */
  136161. name: string;
  136162. /**
  136163. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136164. */
  136165. mesh: Mesh;
  136166. /**
  136167. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136168. * Please read :
  136169. */
  136170. vars: any;
  136171. /**
  136172. * @hidden
  136173. */
  136174. _size: number;
  136175. private _scene;
  136176. private _promises;
  136177. private _positions;
  136178. private _indices;
  136179. private _normals;
  136180. private _colors;
  136181. private _uvs;
  136182. private _indices32;
  136183. private _positions32;
  136184. private _colors32;
  136185. private _uvs32;
  136186. private _updatable;
  136187. private _isVisibilityBoxLocked;
  136188. private _alwaysVisible;
  136189. private _groups;
  136190. private _groupCounter;
  136191. private _computeParticleColor;
  136192. private _computeParticleTexture;
  136193. private _computeParticleRotation;
  136194. private _computeBoundingBox;
  136195. private _isReady;
  136196. /**
  136197. * Creates a PCS (Points Cloud System) object
  136198. * @param name (String) is the PCS name, this will be the underlying mesh name
  136199. * @param pointSize (number) is the size for each point
  136200. * @param scene (Scene) is the scene in which the PCS is added
  136201. * @param options defines the options of the PCS e.g.
  136202. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136203. */
  136204. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136205. updatable?: boolean;
  136206. });
  136207. /**
  136208. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136209. * If no points were added to the PCS, the returned mesh is just a single point.
  136210. * @returns a promise for the created mesh
  136211. */
  136212. buildMeshAsync(): Promise<Mesh>;
  136213. /**
  136214. * @hidden
  136215. */
  136216. private _buildMesh;
  136217. private _addParticle;
  136218. private _randomUnitVector;
  136219. private _getColorIndicesForCoord;
  136220. private _setPointsColorOrUV;
  136221. private _colorFromTexture;
  136222. private _calculateDensity;
  136223. /**
  136224. * Adds points to the PCS in random positions within a unit sphere
  136225. * @param nb (positive integer) the number of particles to be created from this model
  136226. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136227. * @returns the number of groups in the system
  136228. */
  136229. addPoints(nb: number, pointFunction?: any): number;
  136230. /**
  136231. * Adds points to the PCS from the surface of the model shape
  136232. * @param mesh is any Mesh object that will be used as a surface model for the points
  136233. * @param nb (positive integer) the number of particles to be created from this model
  136234. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136235. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136236. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136237. * @returns the number of groups in the system
  136238. */
  136239. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136240. /**
  136241. * Adds points to the PCS inside the model shape
  136242. * @param mesh is any Mesh object that will be used as a surface model for the points
  136243. * @param nb (positive integer) the number of particles to be created from this model
  136244. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136245. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136246. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136247. * @returns the number of groups in the system
  136248. */
  136249. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136250. /**
  136251. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136252. * This method calls `updateParticle()` for each particle of the SPS.
  136253. * For an animated SPS, it is usually called within the render loop.
  136254. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136255. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136256. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136257. * @returns the PCS.
  136258. */
  136259. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136260. /**
  136261. * Disposes the PCS.
  136262. */
  136263. dispose(): void;
  136264. /**
  136265. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136266. * doc :
  136267. * @returns the PCS.
  136268. */
  136269. refreshVisibleSize(): PointsCloudSystem;
  136270. /**
  136271. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136272. * @param size the size (float) of the visibility box
  136273. * note : this doesn't lock the PCS mesh bounding box.
  136274. * doc :
  136275. */
  136276. setVisibilityBox(size: number): void;
  136277. /**
  136278. * Gets whether the PCS is always visible or not
  136279. * doc :
  136280. */
  136281. get isAlwaysVisible(): boolean;
  136282. /**
  136283. * Sets the PCS as always visible or not
  136284. * doc :
  136285. */
  136286. set isAlwaysVisible(val: boolean);
  136287. /**
  136288. * Tells to `setParticles()` to compute the particle rotations or not
  136289. * Default value : false. The PCS is faster when it's set to false
  136290. * Note : particle rotations are only applied to parent particles
  136291. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136292. */
  136293. set computeParticleRotation(val: boolean);
  136294. /**
  136295. * Tells to `setParticles()` to compute the particle colors or not.
  136296. * Default value : true. The PCS is faster when it's set to false.
  136297. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136298. */
  136299. set computeParticleColor(val: boolean);
  136300. set computeParticleTexture(val: boolean);
  136301. /**
  136302. * Gets if `setParticles()` computes the particle colors or not.
  136303. * Default value : false. The PCS is faster when it's set to false.
  136304. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136305. */
  136306. get computeParticleColor(): boolean;
  136307. /**
  136308. * Gets if `setParticles()` computes the particle textures or not.
  136309. * Default value : false. The PCS is faster when it's set to false.
  136310. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136311. */
  136312. get computeParticleTexture(): boolean;
  136313. /**
  136314. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136315. */
  136316. set computeBoundingBox(val: boolean);
  136317. /**
  136318. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136319. */
  136320. get computeBoundingBox(): boolean;
  136321. /**
  136322. * This function does nothing. It may be overwritten to set all the particle first values.
  136323. * The PCS doesn't call this function, you may have to call it by your own.
  136324. * doc :
  136325. */
  136326. initParticles(): void;
  136327. /**
  136328. * This function does nothing. It may be overwritten to recycle a particle
  136329. * The PCS doesn't call this function, you can to call it
  136330. * doc :
  136331. * @param particle The particle to recycle
  136332. * @returns the recycled particle
  136333. */
  136334. recycleParticle(particle: CloudPoint): CloudPoint;
  136335. /**
  136336. * Updates a particle : this function should be overwritten by the user.
  136337. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136338. * doc :
  136339. * @example : just set a particle position or velocity and recycle conditions
  136340. * @param particle The particle to update
  136341. * @returns the updated particle
  136342. */
  136343. updateParticle(particle: CloudPoint): CloudPoint;
  136344. /**
  136345. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136346. * This does nothing and may be overwritten by the user.
  136347. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136348. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136349. * @param update the boolean update value actually passed to setParticles()
  136350. */
  136351. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136352. /**
  136353. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136354. * This will be passed three parameters.
  136355. * This does nothing and may be overwritten by the user.
  136356. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136357. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136358. * @param update the boolean update value actually passed to setParticles()
  136359. */
  136360. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136361. }
  136362. }
  136363. declare module BABYLON {
  136364. /**
  136365. * Represents one particle of a points cloud system.
  136366. */
  136367. export class CloudPoint {
  136368. /**
  136369. * particle global index
  136370. */
  136371. idx: number;
  136372. /**
  136373. * The color of the particle
  136374. */
  136375. color: Nullable<Color4>;
  136376. /**
  136377. * The world space position of the particle.
  136378. */
  136379. position: Vector3;
  136380. /**
  136381. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136382. */
  136383. rotation: Vector3;
  136384. /**
  136385. * The world space rotation quaternion of the particle.
  136386. */
  136387. rotationQuaternion: Nullable<Quaternion>;
  136388. /**
  136389. * The uv of the particle.
  136390. */
  136391. uv: Nullable<Vector2>;
  136392. /**
  136393. * The current speed of the particle.
  136394. */
  136395. velocity: Vector3;
  136396. /**
  136397. * The pivot point in the particle local space.
  136398. */
  136399. pivot: Vector3;
  136400. /**
  136401. * Must the particle be translated from its pivot point in its local space ?
  136402. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136403. * Default : false
  136404. */
  136405. translateFromPivot: boolean;
  136406. /**
  136407. * Index of this particle in the global "positions" array (Internal use)
  136408. * @hidden
  136409. */
  136410. _pos: number;
  136411. /**
  136412. * @hidden Index of this particle in the global "indices" array (Internal use)
  136413. */
  136414. _ind: number;
  136415. /**
  136416. * Group this particle belongs to
  136417. */
  136418. _group: PointsGroup;
  136419. /**
  136420. * Group id of this particle
  136421. */
  136422. groupId: number;
  136423. /**
  136424. * Index of the particle in its group id (Internal use)
  136425. */
  136426. idxInGroup: number;
  136427. /**
  136428. * @hidden Particle BoundingInfo object (Internal use)
  136429. */
  136430. _boundingInfo: BoundingInfo;
  136431. /**
  136432. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136433. */
  136434. _pcs: PointsCloudSystem;
  136435. /**
  136436. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136437. */
  136438. _stillInvisible: boolean;
  136439. /**
  136440. * @hidden Last computed particle rotation matrix
  136441. */
  136442. _rotationMatrix: number[];
  136443. /**
  136444. * Parent particle Id, if any.
  136445. * Default null.
  136446. */
  136447. parentId: Nullable<number>;
  136448. /**
  136449. * @hidden Internal global position in the PCS.
  136450. */
  136451. _globalPosition: Vector3;
  136452. /**
  136453. * Creates a Point Cloud object.
  136454. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136455. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136456. * @param group (PointsGroup) is the group the particle belongs to
  136457. * @param groupId (integer) is the group identifier in the PCS.
  136458. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136459. * @param pcs defines the PCS it is associated to
  136460. */
  136461. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136462. /**
  136463. * get point size
  136464. */
  136465. get size(): Vector3;
  136466. /**
  136467. * Set point size
  136468. */
  136469. set size(scale: Vector3);
  136470. /**
  136471. * Legacy support, changed quaternion to rotationQuaternion
  136472. */
  136473. get quaternion(): Nullable<Quaternion>;
  136474. /**
  136475. * Legacy support, changed quaternion to rotationQuaternion
  136476. */
  136477. set quaternion(q: Nullable<Quaternion>);
  136478. /**
  136479. * Returns a boolean. True if the particle intersects a mesh, else false
  136480. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136481. * @param target is the object (point or mesh) what the intersection is computed against
  136482. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136483. * @returns true if it intersects
  136484. */
  136485. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136486. /**
  136487. * get the rotation matrix of the particle
  136488. * @hidden
  136489. */
  136490. getRotationMatrix(m: Matrix): void;
  136491. }
  136492. /**
  136493. * Represents a group of points in a points cloud system
  136494. * * PCS internal tool, don't use it manually.
  136495. */
  136496. export class PointsGroup {
  136497. /**
  136498. * The group id
  136499. * @hidden
  136500. */
  136501. groupID: number;
  136502. /**
  136503. * image data for group (internal use)
  136504. * @hidden
  136505. */
  136506. _groupImageData: Nullable<ArrayBufferView>;
  136507. /**
  136508. * Image Width (internal use)
  136509. * @hidden
  136510. */
  136511. _groupImgWidth: number;
  136512. /**
  136513. * Image Height (internal use)
  136514. * @hidden
  136515. */
  136516. _groupImgHeight: number;
  136517. /**
  136518. * Custom position function (internal use)
  136519. * @hidden
  136520. */
  136521. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136522. /**
  136523. * density per facet for surface points
  136524. * @hidden
  136525. */
  136526. _groupDensity: number[];
  136527. /**
  136528. * Only when points are colored by texture carries pointer to texture list array
  136529. * @hidden
  136530. */
  136531. _textureNb: number;
  136532. /**
  136533. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136534. * PCS internal tool, don't use it manually.
  136535. * @hidden
  136536. */
  136537. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136538. }
  136539. }
  136540. declare module BABYLON {
  136541. interface Scene {
  136542. /** @hidden (Backing field) */
  136543. _physicsEngine: Nullable<IPhysicsEngine>;
  136544. /** @hidden */
  136545. _physicsTimeAccumulator: number;
  136546. /**
  136547. * Gets the current physics engine
  136548. * @returns a IPhysicsEngine or null if none attached
  136549. */
  136550. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136551. /**
  136552. * Enables physics to the current scene
  136553. * @param gravity defines the scene's gravity for the physics engine
  136554. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136555. * @return a boolean indicating if the physics engine was initialized
  136556. */
  136557. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136558. /**
  136559. * Disables and disposes the physics engine associated with the scene
  136560. */
  136561. disablePhysicsEngine(): void;
  136562. /**
  136563. * Gets a boolean indicating if there is an active physics engine
  136564. * @returns a boolean indicating if there is an active physics engine
  136565. */
  136566. isPhysicsEnabled(): boolean;
  136567. /**
  136568. * Deletes a physics compound impostor
  136569. * @param compound defines the compound to delete
  136570. */
  136571. deleteCompoundImpostor(compound: any): void;
  136572. /**
  136573. * An event triggered when physic simulation is about to be run
  136574. */
  136575. onBeforePhysicsObservable: Observable<Scene>;
  136576. /**
  136577. * An event triggered when physic simulation has been done
  136578. */
  136579. onAfterPhysicsObservable: Observable<Scene>;
  136580. }
  136581. interface AbstractMesh {
  136582. /** @hidden */
  136583. _physicsImpostor: Nullable<PhysicsImpostor>;
  136584. /**
  136585. * Gets or sets impostor used for physic simulation
  136586. * @see http://doc.babylonjs.com/features/physics_engine
  136587. */
  136588. physicsImpostor: Nullable<PhysicsImpostor>;
  136589. /**
  136590. * Gets the current physics impostor
  136591. * @see http://doc.babylonjs.com/features/physics_engine
  136592. * @returns a physics impostor or null
  136593. */
  136594. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136595. /** Apply a physic impulse to the mesh
  136596. * @param force defines the force to apply
  136597. * @param contactPoint defines where to apply the force
  136598. * @returns the current mesh
  136599. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136600. */
  136601. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136602. /**
  136603. * Creates a physic joint between two meshes
  136604. * @param otherMesh defines the other mesh to use
  136605. * @param pivot1 defines the pivot to use on this mesh
  136606. * @param pivot2 defines the pivot to use on the other mesh
  136607. * @param options defines additional options (can be plugin dependent)
  136608. * @returns the current mesh
  136609. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136610. */
  136611. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136612. /** @hidden */
  136613. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136614. }
  136615. /**
  136616. * Defines the physics engine scene component responsible to manage a physics engine
  136617. */
  136618. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136619. /**
  136620. * The component name helpful to identify the component in the list of scene components.
  136621. */
  136622. readonly name: string;
  136623. /**
  136624. * The scene the component belongs to.
  136625. */
  136626. scene: Scene;
  136627. /**
  136628. * Creates a new instance of the component for the given scene
  136629. * @param scene Defines the scene to register the component in
  136630. */
  136631. constructor(scene: Scene);
  136632. /**
  136633. * Registers the component in a given scene
  136634. */
  136635. register(): void;
  136636. /**
  136637. * Rebuilds the elements related to this component in case of
  136638. * context lost for instance.
  136639. */
  136640. rebuild(): void;
  136641. /**
  136642. * Disposes the component and the associated ressources
  136643. */
  136644. dispose(): void;
  136645. }
  136646. }
  136647. declare module BABYLON {
  136648. /**
  136649. * A helper for physics simulations
  136650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136651. */
  136652. export class PhysicsHelper {
  136653. private _scene;
  136654. private _physicsEngine;
  136655. /**
  136656. * Initializes the Physics helper
  136657. * @param scene Babylon.js scene
  136658. */
  136659. constructor(scene: Scene);
  136660. /**
  136661. * Applies a radial explosion impulse
  136662. * @param origin the origin of the explosion
  136663. * @param radiusOrEventOptions the radius or the options of radial explosion
  136664. * @param strength the explosion strength
  136665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136666. * @returns A physics radial explosion event, or null
  136667. */
  136668. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136669. /**
  136670. * Applies a radial explosion force
  136671. * @param origin the origin of the explosion
  136672. * @param radiusOrEventOptions the radius or the options of radial explosion
  136673. * @param strength the explosion strength
  136674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136675. * @returns A physics radial explosion event, or null
  136676. */
  136677. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136678. /**
  136679. * Creates a gravitational field
  136680. * @param origin the origin of the explosion
  136681. * @param radiusOrEventOptions the radius or the options of radial explosion
  136682. * @param strength the explosion strength
  136683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136684. * @returns A physics gravitational field event, or null
  136685. */
  136686. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136687. /**
  136688. * Creates a physics updraft event
  136689. * @param origin the origin of the updraft
  136690. * @param radiusOrEventOptions the radius or the options of the updraft
  136691. * @param strength the strength of the updraft
  136692. * @param height the height of the updraft
  136693. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136694. * @returns A physics updraft event, or null
  136695. */
  136696. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136697. /**
  136698. * Creates a physics vortex event
  136699. * @param origin the of the vortex
  136700. * @param radiusOrEventOptions the radius or the options of the vortex
  136701. * @param strength the strength of the vortex
  136702. * @param height the height of the vortex
  136703. * @returns a Physics vortex event, or null
  136704. * A physics vortex event or null
  136705. */
  136706. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136707. }
  136708. /**
  136709. * Represents a physics radial explosion event
  136710. */
  136711. class PhysicsRadialExplosionEvent {
  136712. private _scene;
  136713. private _options;
  136714. private _sphere;
  136715. private _dataFetched;
  136716. /**
  136717. * Initializes a radial explosioin event
  136718. * @param _scene BabylonJS scene
  136719. * @param _options The options for the vortex event
  136720. */
  136721. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136722. /**
  136723. * Returns the data related to the radial explosion event (sphere).
  136724. * @returns The radial explosion event data
  136725. */
  136726. getData(): PhysicsRadialExplosionEventData;
  136727. /**
  136728. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136729. * @param impostor A physics imposter
  136730. * @param origin the origin of the explosion
  136731. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136732. */
  136733. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136734. /**
  136735. * Triggers affecterd impostors callbacks
  136736. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136737. */
  136738. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136739. /**
  136740. * Disposes the sphere.
  136741. * @param force Specifies if the sphere should be disposed by force
  136742. */
  136743. dispose(force?: boolean): void;
  136744. /*** Helpers ***/
  136745. private _prepareSphere;
  136746. private _intersectsWithSphere;
  136747. }
  136748. /**
  136749. * Represents a gravitational field event
  136750. */
  136751. class PhysicsGravitationalFieldEvent {
  136752. private _physicsHelper;
  136753. private _scene;
  136754. private _origin;
  136755. private _options;
  136756. private _tickCallback;
  136757. private _sphere;
  136758. private _dataFetched;
  136759. /**
  136760. * Initializes the physics gravitational field event
  136761. * @param _physicsHelper A physics helper
  136762. * @param _scene BabylonJS scene
  136763. * @param _origin The origin position of the gravitational field event
  136764. * @param _options The options for the vortex event
  136765. */
  136766. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136767. /**
  136768. * Returns the data related to the gravitational field event (sphere).
  136769. * @returns A gravitational field event
  136770. */
  136771. getData(): PhysicsGravitationalFieldEventData;
  136772. /**
  136773. * Enables the gravitational field.
  136774. */
  136775. enable(): void;
  136776. /**
  136777. * Disables the gravitational field.
  136778. */
  136779. disable(): void;
  136780. /**
  136781. * Disposes the sphere.
  136782. * @param force The force to dispose from the gravitational field event
  136783. */
  136784. dispose(force?: boolean): void;
  136785. private _tick;
  136786. }
  136787. /**
  136788. * Represents a physics updraft event
  136789. */
  136790. class PhysicsUpdraftEvent {
  136791. private _scene;
  136792. private _origin;
  136793. private _options;
  136794. private _physicsEngine;
  136795. private _originTop;
  136796. private _originDirection;
  136797. private _tickCallback;
  136798. private _cylinder;
  136799. private _cylinderPosition;
  136800. private _dataFetched;
  136801. /**
  136802. * Initializes the physics updraft event
  136803. * @param _scene BabylonJS scene
  136804. * @param _origin The origin position of the updraft
  136805. * @param _options The options for the updraft event
  136806. */
  136807. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136808. /**
  136809. * Returns the data related to the updraft event (cylinder).
  136810. * @returns A physics updraft event
  136811. */
  136812. getData(): PhysicsUpdraftEventData;
  136813. /**
  136814. * Enables the updraft.
  136815. */
  136816. enable(): void;
  136817. /**
  136818. * Disables the updraft.
  136819. */
  136820. disable(): void;
  136821. /**
  136822. * Disposes the cylinder.
  136823. * @param force Specifies if the updraft should be disposed by force
  136824. */
  136825. dispose(force?: boolean): void;
  136826. private getImpostorHitData;
  136827. private _tick;
  136828. /*** Helpers ***/
  136829. private _prepareCylinder;
  136830. private _intersectsWithCylinder;
  136831. }
  136832. /**
  136833. * Represents a physics vortex event
  136834. */
  136835. class PhysicsVortexEvent {
  136836. private _scene;
  136837. private _origin;
  136838. private _options;
  136839. private _physicsEngine;
  136840. private _originTop;
  136841. private _tickCallback;
  136842. private _cylinder;
  136843. private _cylinderPosition;
  136844. private _dataFetched;
  136845. /**
  136846. * Initializes the physics vortex event
  136847. * @param _scene The BabylonJS scene
  136848. * @param _origin The origin position of the vortex
  136849. * @param _options The options for the vortex event
  136850. */
  136851. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136852. /**
  136853. * Returns the data related to the vortex event (cylinder).
  136854. * @returns The physics vortex event data
  136855. */
  136856. getData(): PhysicsVortexEventData;
  136857. /**
  136858. * Enables the vortex.
  136859. */
  136860. enable(): void;
  136861. /**
  136862. * Disables the cortex.
  136863. */
  136864. disable(): void;
  136865. /**
  136866. * Disposes the sphere.
  136867. * @param force
  136868. */
  136869. dispose(force?: boolean): void;
  136870. private getImpostorHitData;
  136871. private _tick;
  136872. /*** Helpers ***/
  136873. private _prepareCylinder;
  136874. private _intersectsWithCylinder;
  136875. }
  136876. /**
  136877. * Options fot the radial explosion event
  136878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136879. */
  136880. export class PhysicsRadialExplosionEventOptions {
  136881. /**
  136882. * The radius of the sphere for the radial explosion.
  136883. */
  136884. radius: number;
  136885. /**
  136886. * The strenth of the explosion.
  136887. */
  136888. strength: number;
  136889. /**
  136890. * The strenght of the force in correspondence to the distance of the affected object
  136891. */
  136892. falloff: PhysicsRadialImpulseFalloff;
  136893. /**
  136894. * Sphere options for the radial explosion.
  136895. */
  136896. sphere: {
  136897. segments: number;
  136898. diameter: number;
  136899. };
  136900. /**
  136901. * Sphere options for the radial explosion.
  136902. */
  136903. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136904. }
  136905. /**
  136906. * Options fot the updraft event
  136907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136908. */
  136909. export class PhysicsUpdraftEventOptions {
  136910. /**
  136911. * The radius of the cylinder for the vortex
  136912. */
  136913. radius: number;
  136914. /**
  136915. * The strenth of the updraft.
  136916. */
  136917. strength: number;
  136918. /**
  136919. * The height of the cylinder for the updraft.
  136920. */
  136921. height: number;
  136922. /**
  136923. * The mode for the the updraft.
  136924. */
  136925. updraftMode: PhysicsUpdraftMode;
  136926. }
  136927. /**
  136928. * Options fot the vortex event
  136929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136930. */
  136931. export class PhysicsVortexEventOptions {
  136932. /**
  136933. * The radius of the cylinder for the vortex
  136934. */
  136935. radius: number;
  136936. /**
  136937. * The strenth of the vortex.
  136938. */
  136939. strength: number;
  136940. /**
  136941. * The height of the cylinder for the vortex.
  136942. */
  136943. height: number;
  136944. /**
  136945. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136946. */
  136947. centripetalForceThreshold: number;
  136948. /**
  136949. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136950. */
  136951. centripetalForceMultiplier: number;
  136952. /**
  136953. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136954. */
  136955. centrifugalForceMultiplier: number;
  136956. /**
  136957. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136958. */
  136959. updraftForceMultiplier: number;
  136960. }
  136961. /**
  136962. * The strenght of the force in correspondence to the distance of the affected object
  136963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136964. */
  136965. export enum PhysicsRadialImpulseFalloff {
  136966. /** Defines that impulse is constant in strength across it's whole radius */
  136967. Constant = 0,
  136968. /** Defines that impulse gets weaker if it's further from the origin */
  136969. Linear = 1
  136970. }
  136971. /**
  136972. * The strength of the force in correspondence to the distance of the affected object
  136973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136974. */
  136975. export enum PhysicsUpdraftMode {
  136976. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136977. Center = 0,
  136978. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136979. Perpendicular = 1
  136980. }
  136981. /**
  136982. * Interface for a physics hit data
  136983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136984. */
  136985. export interface PhysicsHitData {
  136986. /**
  136987. * The force applied at the contact point
  136988. */
  136989. force: Vector3;
  136990. /**
  136991. * The contact point
  136992. */
  136993. contactPoint: Vector3;
  136994. /**
  136995. * The distance from the origin to the contact point
  136996. */
  136997. distanceFromOrigin: number;
  136998. }
  136999. /**
  137000. * Interface for radial explosion event data
  137001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137002. */
  137003. export interface PhysicsRadialExplosionEventData {
  137004. /**
  137005. * A sphere used for the radial explosion event
  137006. */
  137007. sphere: Mesh;
  137008. }
  137009. /**
  137010. * Interface for gravitational field event data
  137011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137012. */
  137013. export interface PhysicsGravitationalFieldEventData {
  137014. /**
  137015. * A sphere mesh used for the gravitational field event
  137016. */
  137017. sphere: Mesh;
  137018. }
  137019. /**
  137020. * Interface for updraft event data
  137021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137022. */
  137023. export interface PhysicsUpdraftEventData {
  137024. /**
  137025. * A cylinder used for the updraft event
  137026. */
  137027. cylinder: Mesh;
  137028. }
  137029. /**
  137030. * Interface for vortex event data
  137031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137032. */
  137033. export interface PhysicsVortexEventData {
  137034. /**
  137035. * A cylinder used for the vortex event
  137036. */
  137037. cylinder: Mesh;
  137038. }
  137039. /**
  137040. * Interface for an affected physics impostor
  137041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137042. */
  137043. export interface PhysicsAffectedImpostorWithData {
  137044. /**
  137045. * The impostor affected by the effect
  137046. */
  137047. impostor: PhysicsImpostor;
  137048. /**
  137049. * The data about the hit/horce from the explosion
  137050. */
  137051. hitData: PhysicsHitData;
  137052. }
  137053. }
  137054. declare module BABYLON {
  137055. /** @hidden */
  137056. export var blackAndWhitePixelShader: {
  137057. name: string;
  137058. shader: string;
  137059. };
  137060. }
  137061. declare module BABYLON {
  137062. /**
  137063. * Post process used to render in black and white
  137064. */
  137065. export class BlackAndWhitePostProcess extends PostProcess {
  137066. /**
  137067. * Linear about to convert he result to black and white (default: 1)
  137068. */
  137069. degree: number;
  137070. /**
  137071. * Creates a black and white post process
  137072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137073. * @param name The name of the effect.
  137074. * @param options The required width/height ratio to downsize to before computing the render pass.
  137075. * @param camera The camera to apply the render pass to.
  137076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137077. * @param engine The engine which the post process will be applied. (default: current engine)
  137078. * @param reusable If the post process can be reused on the same frame. (default: false)
  137079. */
  137080. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137081. }
  137082. }
  137083. declare module BABYLON {
  137084. /**
  137085. * This represents a set of one or more post processes in Babylon.
  137086. * A post process can be used to apply a shader to a texture after it is rendered.
  137087. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137088. */
  137089. export class PostProcessRenderEffect {
  137090. private _postProcesses;
  137091. private _getPostProcesses;
  137092. private _singleInstance;
  137093. private _cameras;
  137094. private _indicesForCamera;
  137095. /**
  137096. * Name of the effect
  137097. * @hidden
  137098. */
  137099. _name: string;
  137100. /**
  137101. * Instantiates a post process render effect.
  137102. * A post process can be used to apply a shader to a texture after it is rendered.
  137103. * @param engine The engine the effect is tied to
  137104. * @param name The name of the effect
  137105. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137106. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137107. */
  137108. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137109. /**
  137110. * Checks if all the post processes in the effect are supported.
  137111. */
  137112. get isSupported(): boolean;
  137113. /**
  137114. * Updates the current state of the effect
  137115. * @hidden
  137116. */
  137117. _update(): void;
  137118. /**
  137119. * Attaches the effect on cameras
  137120. * @param cameras The camera to attach to.
  137121. * @hidden
  137122. */
  137123. _attachCameras(cameras: Camera): void;
  137124. /**
  137125. * Attaches the effect on cameras
  137126. * @param cameras The camera to attach to.
  137127. * @hidden
  137128. */
  137129. _attachCameras(cameras: Camera[]): void;
  137130. /**
  137131. * Detaches the effect on cameras
  137132. * @param cameras The camera to detatch from.
  137133. * @hidden
  137134. */
  137135. _detachCameras(cameras: Camera): void;
  137136. /**
  137137. * Detatches the effect on cameras
  137138. * @param cameras The camera to detatch from.
  137139. * @hidden
  137140. */
  137141. _detachCameras(cameras: Camera[]): void;
  137142. /**
  137143. * Enables the effect on given cameras
  137144. * @param cameras The camera to enable.
  137145. * @hidden
  137146. */
  137147. _enable(cameras: Camera): void;
  137148. /**
  137149. * Enables the effect on given cameras
  137150. * @param cameras The camera to enable.
  137151. * @hidden
  137152. */
  137153. _enable(cameras: Nullable<Camera[]>): void;
  137154. /**
  137155. * Disables the effect on the given cameras
  137156. * @param cameras The camera to disable.
  137157. * @hidden
  137158. */
  137159. _disable(cameras: Camera): void;
  137160. /**
  137161. * Disables the effect on the given cameras
  137162. * @param cameras The camera to disable.
  137163. * @hidden
  137164. */
  137165. _disable(cameras: Nullable<Camera[]>): void;
  137166. /**
  137167. * Gets a list of the post processes contained in the effect.
  137168. * @param camera The camera to get the post processes on.
  137169. * @returns The list of the post processes in the effect.
  137170. */
  137171. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137172. }
  137173. }
  137174. declare module BABYLON {
  137175. /** @hidden */
  137176. export var extractHighlightsPixelShader: {
  137177. name: string;
  137178. shader: string;
  137179. };
  137180. }
  137181. declare module BABYLON {
  137182. /**
  137183. * 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.
  137184. */
  137185. export class ExtractHighlightsPostProcess extends PostProcess {
  137186. /**
  137187. * The luminance threshold, pixels below this value will be set to black.
  137188. */
  137189. threshold: number;
  137190. /** @hidden */
  137191. _exposure: number;
  137192. /**
  137193. * Post process which has the input texture to be used when performing highlight extraction
  137194. * @hidden
  137195. */
  137196. _inputPostProcess: Nullable<PostProcess>;
  137197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137198. }
  137199. }
  137200. declare module BABYLON {
  137201. /** @hidden */
  137202. export var bloomMergePixelShader: {
  137203. name: string;
  137204. shader: string;
  137205. };
  137206. }
  137207. declare module BABYLON {
  137208. /**
  137209. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137210. */
  137211. export class BloomMergePostProcess extends PostProcess {
  137212. /** Weight of the bloom to be added to the original input. */
  137213. weight: number;
  137214. /**
  137215. * Creates a new instance of @see BloomMergePostProcess
  137216. * @param name The name of the effect.
  137217. * @param originalFromInput Post process which's input will be used for the merge.
  137218. * @param blurred Blurred highlights post process which's output will be used.
  137219. * @param weight Weight of the bloom to be added to the original input.
  137220. * @param options The required width/height ratio to downsize to before computing the render pass.
  137221. * @param camera The camera to apply the render pass to.
  137222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137223. * @param engine The engine which the post process will be applied. (default: current engine)
  137224. * @param reusable If the post process can be reused on the same frame. (default: false)
  137225. * @param textureType Type of textures used when performing the post process. (default: 0)
  137226. * @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)
  137227. */
  137228. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137229. /** Weight of the bloom to be added to the original input. */
  137230. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137231. }
  137232. }
  137233. declare module BABYLON {
  137234. /**
  137235. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137236. */
  137237. export class BloomEffect extends PostProcessRenderEffect {
  137238. private bloomScale;
  137239. /**
  137240. * @hidden Internal
  137241. */
  137242. _effects: Array<PostProcess>;
  137243. /**
  137244. * @hidden Internal
  137245. */
  137246. _downscale: ExtractHighlightsPostProcess;
  137247. private _blurX;
  137248. private _blurY;
  137249. private _merge;
  137250. /**
  137251. * The luminance threshold to find bright areas of the image to bloom.
  137252. */
  137253. get threshold(): number;
  137254. set threshold(value: number);
  137255. /**
  137256. * The strength of the bloom.
  137257. */
  137258. get weight(): number;
  137259. set weight(value: number);
  137260. /**
  137261. * Specifies the size of the bloom blur kernel, relative to the final output size
  137262. */
  137263. get kernel(): number;
  137264. set kernel(value: number);
  137265. /**
  137266. * Creates a new instance of @see BloomEffect
  137267. * @param scene The scene the effect belongs to.
  137268. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137269. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137270. * @param bloomWeight The the strength of bloom.
  137271. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137272. * @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)
  137273. */
  137274. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137275. /**
  137276. * Disposes each of the internal effects for a given camera.
  137277. * @param camera The camera to dispose the effect on.
  137278. */
  137279. disposeEffects(camera: Camera): void;
  137280. /**
  137281. * @hidden Internal
  137282. */
  137283. _updateEffects(): void;
  137284. /**
  137285. * Internal
  137286. * @returns if all the contained post processes are ready.
  137287. * @hidden
  137288. */
  137289. _isReady(): boolean;
  137290. }
  137291. }
  137292. declare module BABYLON {
  137293. /** @hidden */
  137294. export var chromaticAberrationPixelShader: {
  137295. name: string;
  137296. shader: string;
  137297. };
  137298. }
  137299. declare module BABYLON {
  137300. /**
  137301. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137302. */
  137303. export class ChromaticAberrationPostProcess extends PostProcess {
  137304. /**
  137305. * The amount of seperation of rgb channels (default: 30)
  137306. */
  137307. aberrationAmount: number;
  137308. /**
  137309. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137310. */
  137311. radialIntensity: number;
  137312. /**
  137313. * 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))
  137314. */
  137315. direction: Vector2;
  137316. /**
  137317. * 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))
  137318. */
  137319. centerPosition: Vector2;
  137320. /**
  137321. * Creates a new instance ChromaticAberrationPostProcess
  137322. * @param name The name of the effect.
  137323. * @param screenWidth The width of the screen to apply the effect on.
  137324. * @param screenHeight The height of the screen to apply the effect on.
  137325. * @param options The required width/height ratio to downsize to before computing the render pass.
  137326. * @param camera The camera to apply the render pass to.
  137327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137328. * @param engine The engine which the post process will be applied. (default: current engine)
  137329. * @param reusable If the post process can be reused on the same frame. (default: false)
  137330. * @param textureType Type of textures used when performing the post process. (default: 0)
  137331. * @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)
  137332. */
  137333. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137334. }
  137335. }
  137336. declare module BABYLON {
  137337. /** @hidden */
  137338. export var circleOfConfusionPixelShader: {
  137339. name: string;
  137340. shader: string;
  137341. };
  137342. }
  137343. declare module BABYLON {
  137344. /**
  137345. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137346. */
  137347. export class CircleOfConfusionPostProcess extends PostProcess {
  137348. /**
  137349. * 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.
  137350. */
  137351. lensSize: number;
  137352. /**
  137353. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137354. */
  137355. fStop: number;
  137356. /**
  137357. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137358. */
  137359. focusDistance: number;
  137360. /**
  137361. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137362. */
  137363. focalLength: number;
  137364. private _depthTexture;
  137365. /**
  137366. * Creates a new instance CircleOfConfusionPostProcess
  137367. * @param name The name of the effect.
  137368. * @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.
  137369. * @param options The required width/height ratio to downsize to before computing the render pass.
  137370. * @param camera The camera to apply the render pass to.
  137371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137372. * @param engine The engine which the post process will be applied. (default: current engine)
  137373. * @param reusable If the post process can be reused on the same frame. (default: false)
  137374. * @param textureType Type of textures used when performing the post process. (default: 0)
  137375. * @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)
  137376. */
  137377. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137378. /**
  137379. * 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.
  137380. */
  137381. set depthTexture(value: RenderTargetTexture);
  137382. }
  137383. }
  137384. declare module BABYLON {
  137385. /** @hidden */
  137386. export var colorCorrectionPixelShader: {
  137387. name: string;
  137388. shader: string;
  137389. };
  137390. }
  137391. declare module BABYLON {
  137392. /**
  137393. *
  137394. * This post-process allows the modification of rendered colors by using
  137395. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137396. *
  137397. * The object needs to be provided an url to a texture containing the color
  137398. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137399. * Use an image editing software to tweak the LUT to match your needs.
  137400. *
  137401. * For an example of a color LUT, see here:
  137402. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137403. * For explanations on color grading, see here:
  137404. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137405. *
  137406. */
  137407. export class ColorCorrectionPostProcess extends PostProcess {
  137408. private _colorTableTexture;
  137409. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137410. }
  137411. }
  137412. declare module BABYLON {
  137413. /** @hidden */
  137414. export var convolutionPixelShader: {
  137415. name: string;
  137416. shader: string;
  137417. };
  137418. }
  137419. declare module BABYLON {
  137420. /**
  137421. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137422. * input texture to perform effects such as edge detection or sharpening
  137423. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137424. */
  137425. export class ConvolutionPostProcess extends PostProcess {
  137426. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137427. kernel: number[];
  137428. /**
  137429. * Creates a new instance ConvolutionPostProcess
  137430. * @param name The name of the effect.
  137431. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137432. * @param options The required width/height ratio to downsize to before computing the render pass.
  137433. * @param camera The camera to apply the render pass to.
  137434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137435. * @param engine The engine which the post process will be applied. (default: current engine)
  137436. * @param reusable If the post process can be reused on the same frame. (default: false)
  137437. * @param textureType Type of textures used when performing the post process. (default: 0)
  137438. */
  137439. constructor(name: string,
  137440. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137441. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137442. /**
  137443. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137444. */
  137445. static EdgeDetect0Kernel: number[];
  137446. /**
  137447. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137448. */
  137449. static EdgeDetect1Kernel: number[];
  137450. /**
  137451. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137452. */
  137453. static EdgeDetect2Kernel: number[];
  137454. /**
  137455. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137456. */
  137457. static SharpenKernel: number[];
  137458. /**
  137459. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137460. */
  137461. static EmbossKernel: number[];
  137462. /**
  137463. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137464. */
  137465. static GaussianKernel: number[];
  137466. }
  137467. }
  137468. declare module BABYLON {
  137469. /**
  137470. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137471. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137472. * based on samples that have a large difference in distance than the center pixel.
  137473. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137474. */
  137475. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137476. direction: Vector2;
  137477. /**
  137478. * Creates a new instance CircleOfConfusionPostProcess
  137479. * @param name The name of the effect.
  137480. * @param scene The scene the effect belongs to.
  137481. * @param direction The direction the blur should be applied.
  137482. * @param kernel The size of the kernel used to blur.
  137483. * @param options The required width/height ratio to downsize to before computing the render pass.
  137484. * @param camera The camera to apply the render pass to.
  137485. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137486. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137488. * @param engine The engine which the post process will be applied. (default: current engine)
  137489. * @param reusable If the post process can be reused on the same frame. (default: false)
  137490. * @param textureType Type of textures used when performing the post process. (default: 0)
  137491. * @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)
  137492. */
  137493. 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);
  137494. }
  137495. }
  137496. declare module BABYLON {
  137497. /** @hidden */
  137498. export var depthOfFieldMergePixelShader: {
  137499. name: string;
  137500. shader: string;
  137501. };
  137502. }
  137503. declare module BABYLON {
  137504. /**
  137505. * Options to be set when merging outputs from the default pipeline.
  137506. */
  137507. export class DepthOfFieldMergePostProcessOptions {
  137508. /**
  137509. * The original image to merge on top of
  137510. */
  137511. originalFromInput: PostProcess;
  137512. /**
  137513. * Parameters to perform the merge of the depth of field effect
  137514. */
  137515. depthOfField?: {
  137516. circleOfConfusion: PostProcess;
  137517. blurSteps: Array<PostProcess>;
  137518. };
  137519. /**
  137520. * Parameters to perform the merge of bloom effect
  137521. */
  137522. bloom?: {
  137523. blurred: PostProcess;
  137524. weight: number;
  137525. };
  137526. }
  137527. /**
  137528. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137529. */
  137530. export class DepthOfFieldMergePostProcess extends PostProcess {
  137531. private blurSteps;
  137532. /**
  137533. * Creates a new instance of DepthOfFieldMergePostProcess
  137534. * @param name The name of the effect.
  137535. * @param originalFromInput Post process which's input will be used for the merge.
  137536. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137537. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137538. * @param options The required width/height ratio to downsize to before computing the render pass.
  137539. * @param camera The camera to apply the render pass to.
  137540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137541. * @param engine The engine which the post process will be applied. (default: current engine)
  137542. * @param reusable If the post process can be reused on the same frame. (default: false)
  137543. * @param textureType Type of textures used when performing the post process. (default: 0)
  137544. * @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)
  137545. */
  137546. 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);
  137547. /**
  137548. * Updates the effect with the current post process compile time values and recompiles the shader.
  137549. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137550. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137551. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137552. * @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
  137553. * @param onCompiled Called when the shader has been compiled.
  137554. * @param onError Called if there is an error when compiling a shader.
  137555. */
  137556. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137557. }
  137558. }
  137559. declare module BABYLON {
  137560. /**
  137561. * Specifies the level of max blur that should be applied when using the depth of field effect
  137562. */
  137563. export enum DepthOfFieldEffectBlurLevel {
  137564. /**
  137565. * Subtle blur
  137566. */
  137567. Low = 0,
  137568. /**
  137569. * Medium blur
  137570. */
  137571. Medium = 1,
  137572. /**
  137573. * Large blur
  137574. */
  137575. High = 2
  137576. }
  137577. /**
  137578. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137579. */
  137580. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137581. private _circleOfConfusion;
  137582. /**
  137583. * @hidden Internal, blurs from high to low
  137584. */
  137585. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137586. private _depthOfFieldBlurY;
  137587. private _dofMerge;
  137588. /**
  137589. * @hidden Internal post processes in depth of field effect
  137590. */
  137591. _effects: Array<PostProcess>;
  137592. /**
  137593. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137594. */
  137595. set focalLength(value: number);
  137596. get focalLength(): number;
  137597. /**
  137598. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137599. */
  137600. set fStop(value: number);
  137601. get fStop(): number;
  137602. /**
  137603. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137604. */
  137605. set focusDistance(value: number);
  137606. get focusDistance(): number;
  137607. /**
  137608. * 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.
  137609. */
  137610. set lensSize(value: number);
  137611. get lensSize(): number;
  137612. /**
  137613. * Creates a new instance DepthOfFieldEffect
  137614. * @param scene The scene the effect belongs to.
  137615. * @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.
  137616. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137617. * @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)
  137618. */
  137619. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137620. /**
  137621. * Get the current class name of the current effet
  137622. * @returns "DepthOfFieldEffect"
  137623. */
  137624. getClassName(): string;
  137625. /**
  137626. * 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.
  137627. */
  137628. set depthTexture(value: RenderTargetTexture);
  137629. /**
  137630. * Disposes each of the internal effects for a given camera.
  137631. * @param camera The camera to dispose the effect on.
  137632. */
  137633. disposeEffects(camera: Camera): void;
  137634. /**
  137635. * @hidden Internal
  137636. */
  137637. _updateEffects(): void;
  137638. /**
  137639. * Internal
  137640. * @returns if all the contained post processes are ready.
  137641. * @hidden
  137642. */
  137643. _isReady(): boolean;
  137644. }
  137645. }
  137646. declare module BABYLON {
  137647. /** @hidden */
  137648. export var displayPassPixelShader: {
  137649. name: string;
  137650. shader: string;
  137651. };
  137652. }
  137653. declare module BABYLON {
  137654. /**
  137655. * DisplayPassPostProcess which produces an output the same as it's input
  137656. */
  137657. export class DisplayPassPostProcess extends PostProcess {
  137658. /**
  137659. * Creates the DisplayPassPostProcess
  137660. * @param name The name of the effect.
  137661. * @param options The required width/height ratio to downsize to before computing the render pass.
  137662. * @param camera The camera to apply the render pass to.
  137663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137664. * @param engine The engine which the post process will be applied. (default: current engine)
  137665. * @param reusable If the post process can be reused on the same frame. (default: false)
  137666. */
  137667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137668. }
  137669. }
  137670. declare module BABYLON {
  137671. /** @hidden */
  137672. export var filterPixelShader: {
  137673. name: string;
  137674. shader: string;
  137675. };
  137676. }
  137677. declare module BABYLON {
  137678. /**
  137679. * Applies a kernel filter to the image
  137680. */
  137681. export class FilterPostProcess extends PostProcess {
  137682. /** The matrix to be applied to the image */
  137683. kernelMatrix: Matrix;
  137684. /**
  137685. *
  137686. * @param name The name of the effect.
  137687. * @param kernelMatrix The matrix to be applied to the image
  137688. * @param options The required width/height ratio to downsize to before computing the render pass.
  137689. * @param camera The camera to apply the render pass to.
  137690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137691. * @param engine The engine which the post process will be applied. (default: current engine)
  137692. * @param reusable If the post process can be reused on the same frame. (default: false)
  137693. */
  137694. constructor(name: string,
  137695. /** The matrix to be applied to the image */
  137696. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137697. }
  137698. }
  137699. declare module BABYLON {
  137700. /** @hidden */
  137701. export var fxaaPixelShader: {
  137702. name: string;
  137703. shader: string;
  137704. };
  137705. }
  137706. declare module BABYLON {
  137707. /** @hidden */
  137708. export var fxaaVertexShader: {
  137709. name: string;
  137710. shader: string;
  137711. };
  137712. }
  137713. declare module BABYLON {
  137714. /**
  137715. * Fxaa post process
  137716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137717. */
  137718. export class FxaaPostProcess extends PostProcess {
  137719. /** @hidden */
  137720. texelWidth: number;
  137721. /** @hidden */
  137722. texelHeight: number;
  137723. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137724. private _getDefines;
  137725. }
  137726. }
  137727. declare module BABYLON {
  137728. /** @hidden */
  137729. export var grainPixelShader: {
  137730. name: string;
  137731. shader: string;
  137732. };
  137733. }
  137734. declare module BABYLON {
  137735. /**
  137736. * The GrainPostProcess adds noise to the image at mid luminance levels
  137737. */
  137738. export class GrainPostProcess extends PostProcess {
  137739. /**
  137740. * The intensity of the grain added (default: 30)
  137741. */
  137742. intensity: number;
  137743. /**
  137744. * If the grain should be randomized on every frame
  137745. */
  137746. animated: boolean;
  137747. /**
  137748. * Creates a new instance of @see GrainPostProcess
  137749. * @param name The name of the effect.
  137750. * @param options The required width/height ratio to downsize to before computing the render pass.
  137751. * @param camera The camera to apply the render pass to.
  137752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137753. * @param engine The engine which the post process will be applied. (default: current engine)
  137754. * @param reusable If the post process can be reused on the same frame. (default: false)
  137755. * @param textureType Type of textures used when performing the post process. (default: 0)
  137756. * @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)
  137757. */
  137758. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137759. }
  137760. }
  137761. declare module BABYLON {
  137762. /** @hidden */
  137763. export var highlightsPixelShader: {
  137764. name: string;
  137765. shader: string;
  137766. };
  137767. }
  137768. declare module BABYLON {
  137769. /**
  137770. * Extracts highlights from the image
  137771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137772. */
  137773. export class HighlightsPostProcess extends PostProcess {
  137774. /**
  137775. * Extracts highlights from the image
  137776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137777. * @param name The name of the effect.
  137778. * @param options The required width/height ratio to downsize to before computing the render pass.
  137779. * @param camera The camera to apply the render pass to.
  137780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137781. * @param engine The engine which the post process will be applied. (default: current engine)
  137782. * @param reusable If the post process can be reused on the same frame. (default: false)
  137783. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137784. */
  137785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137786. }
  137787. }
  137788. declare module BABYLON {
  137789. /** @hidden */
  137790. export var mrtFragmentDeclaration: {
  137791. name: string;
  137792. shader: string;
  137793. };
  137794. }
  137795. declare module BABYLON {
  137796. /** @hidden */
  137797. export var geometryPixelShader: {
  137798. name: string;
  137799. shader: string;
  137800. };
  137801. }
  137802. declare module BABYLON {
  137803. /** @hidden */
  137804. export var geometryVertexShader: {
  137805. name: string;
  137806. shader: string;
  137807. };
  137808. }
  137809. declare module BABYLON {
  137810. /** @hidden */
  137811. interface ISavedTransformationMatrix {
  137812. world: Matrix;
  137813. viewProjection: Matrix;
  137814. }
  137815. /**
  137816. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137817. */
  137818. export class GeometryBufferRenderer {
  137819. /**
  137820. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137821. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137822. */
  137823. static readonly POSITION_TEXTURE_TYPE: number;
  137824. /**
  137825. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137826. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137827. */
  137828. static readonly VELOCITY_TEXTURE_TYPE: number;
  137829. /**
  137830. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137831. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137832. */
  137833. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137834. /**
  137835. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137836. * in order to compute objects velocities when enableVelocity is set to "true"
  137837. * @hidden
  137838. */
  137839. _previousTransformationMatrices: {
  137840. [index: number]: ISavedTransformationMatrix;
  137841. };
  137842. /**
  137843. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137844. * in order to compute objects velocities when enableVelocity is set to "true"
  137845. * @hidden
  137846. */
  137847. _previousBonesTransformationMatrices: {
  137848. [index: number]: Float32Array;
  137849. };
  137850. /**
  137851. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137852. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137853. */
  137854. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137855. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137856. renderTransparentMeshes: boolean;
  137857. private _scene;
  137858. private _multiRenderTarget;
  137859. private _ratio;
  137860. private _enablePosition;
  137861. private _enableVelocity;
  137862. private _enableReflectivity;
  137863. private _positionIndex;
  137864. private _velocityIndex;
  137865. private _reflectivityIndex;
  137866. protected _effect: Effect;
  137867. protected _cachedDefines: string;
  137868. /**
  137869. * Set the render list (meshes to be rendered) used in the G buffer.
  137870. */
  137871. set renderList(meshes: Mesh[]);
  137872. /**
  137873. * Gets wether or not G buffer are supported by the running hardware.
  137874. * This requires draw buffer supports
  137875. */
  137876. get isSupported(): boolean;
  137877. /**
  137878. * Returns the index of the given texture type in the G-Buffer textures array
  137879. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137880. * @returns the index of the given texture type in the G-Buffer textures array
  137881. */
  137882. getTextureIndex(textureType: number): number;
  137883. /**
  137884. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137885. */
  137886. get enablePosition(): boolean;
  137887. /**
  137888. * Sets whether or not objects positions are enabled for the G buffer.
  137889. */
  137890. set enablePosition(enable: boolean);
  137891. /**
  137892. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137893. */
  137894. get enableVelocity(): boolean;
  137895. /**
  137896. * Sets wether or not objects velocities are enabled for the G buffer.
  137897. */
  137898. set enableVelocity(enable: boolean);
  137899. /**
  137900. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137901. */
  137902. get enableReflectivity(): boolean;
  137903. /**
  137904. * Sets wether or not objects roughness are enabled for the G buffer.
  137905. */
  137906. set enableReflectivity(enable: boolean);
  137907. /**
  137908. * Gets the scene associated with the buffer.
  137909. */
  137910. get scene(): Scene;
  137911. /**
  137912. * Gets the ratio used by the buffer during its creation.
  137913. * How big is the buffer related to the main canvas.
  137914. */
  137915. get ratio(): number;
  137916. /** @hidden */
  137917. static _SceneComponentInitialization: (scene: Scene) => void;
  137918. /**
  137919. * Creates a new G Buffer for the scene
  137920. * @param scene The scene the buffer belongs to
  137921. * @param ratio How big is the buffer related to the main canvas.
  137922. */
  137923. constructor(scene: Scene, ratio?: number);
  137924. /**
  137925. * Checks wether everything is ready to render a submesh to the G buffer.
  137926. * @param subMesh the submesh to check readiness for
  137927. * @param useInstances is the mesh drawn using instance or not
  137928. * @returns true if ready otherwise false
  137929. */
  137930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137931. /**
  137932. * Gets the current underlying G Buffer.
  137933. * @returns the buffer
  137934. */
  137935. getGBuffer(): MultiRenderTarget;
  137936. /**
  137937. * Gets the number of samples used to render the buffer (anti aliasing).
  137938. */
  137939. get samples(): number;
  137940. /**
  137941. * Sets the number of samples used to render the buffer (anti aliasing).
  137942. */
  137943. set samples(value: number);
  137944. /**
  137945. * Disposes the renderer and frees up associated resources.
  137946. */
  137947. dispose(): void;
  137948. protected _createRenderTargets(): void;
  137949. private _copyBonesTransformationMatrices;
  137950. }
  137951. }
  137952. declare module BABYLON {
  137953. interface Scene {
  137954. /** @hidden (Backing field) */
  137955. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137956. /**
  137957. * Gets or Sets the current geometry buffer associated to the scene.
  137958. */
  137959. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137960. /**
  137961. * Enables a GeometryBufferRender and associates it with the scene
  137962. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137963. * @returns the GeometryBufferRenderer
  137964. */
  137965. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137966. /**
  137967. * Disables the GeometryBufferRender associated with the scene
  137968. */
  137969. disableGeometryBufferRenderer(): void;
  137970. }
  137971. /**
  137972. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137973. * in several rendering techniques.
  137974. */
  137975. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137976. /**
  137977. * The component name helpful to identify the component in the list of scene components.
  137978. */
  137979. readonly name: string;
  137980. /**
  137981. * The scene the component belongs to.
  137982. */
  137983. scene: Scene;
  137984. /**
  137985. * Creates a new instance of the component for the given scene
  137986. * @param scene Defines the scene to register the component in
  137987. */
  137988. constructor(scene: Scene);
  137989. /**
  137990. * Registers the component in a given scene
  137991. */
  137992. register(): void;
  137993. /**
  137994. * Rebuilds the elements related to this component in case of
  137995. * context lost for instance.
  137996. */
  137997. rebuild(): void;
  137998. /**
  137999. * Disposes the component and the associated ressources
  138000. */
  138001. dispose(): void;
  138002. private _gatherRenderTargets;
  138003. }
  138004. }
  138005. declare module BABYLON {
  138006. /** @hidden */
  138007. export var motionBlurPixelShader: {
  138008. name: string;
  138009. shader: string;
  138010. };
  138011. }
  138012. declare module BABYLON {
  138013. /**
  138014. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138015. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138016. * As an example, all you have to do is to create the post-process:
  138017. * var mb = new BABYLON.MotionBlurPostProcess(
  138018. * 'mb', // The name of the effect.
  138019. * scene, // The scene containing the objects to blur according to their velocity.
  138020. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138021. * camera // The camera to apply the render pass to.
  138022. * );
  138023. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138024. */
  138025. export class MotionBlurPostProcess extends PostProcess {
  138026. /**
  138027. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138028. */
  138029. motionStrength: number;
  138030. /**
  138031. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138032. */
  138033. get motionBlurSamples(): number;
  138034. /**
  138035. * Sets the number of iterations to be used for motion blur quality
  138036. */
  138037. set motionBlurSamples(samples: number);
  138038. private _motionBlurSamples;
  138039. private _geometryBufferRenderer;
  138040. /**
  138041. * Creates a new instance MotionBlurPostProcess
  138042. * @param name The name of the effect.
  138043. * @param scene The scene containing the objects to blur according to their velocity.
  138044. * @param options The required width/height ratio to downsize to before computing the render pass.
  138045. * @param camera The camera to apply the render pass to.
  138046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138047. * @param engine The engine which the post process will be applied. (default: current engine)
  138048. * @param reusable If the post process can be reused on the same frame. (default: false)
  138049. * @param textureType Type of textures used when performing the post process. (default: 0)
  138050. * @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)
  138051. */
  138052. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138053. /**
  138054. * Excludes the given skinned mesh from computing bones velocities.
  138055. * 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.
  138056. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138057. */
  138058. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138059. /**
  138060. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138061. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138062. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138063. */
  138064. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138065. /**
  138066. * Disposes the post process.
  138067. * @param camera The camera to dispose the post process on.
  138068. */
  138069. dispose(camera?: Camera): void;
  138070. }
  138071. }
  138072. declare module BABYLON {
  138073. /** @hidden */
  138074. export var refractionPixelShader: {
  138075. name: string;
  138076. shader: string;
  138077. };
  138078. }
  138079. declare module BABYLON {
  138080. /**
  138081. * Post process which applies a refractin texture
  138082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138083. */
  138084. export class RefractionPostProcess extends PostProcess {
  138085. /** the base color of the refraction (used to taint the rendering) */
  138086. color: Color3;
  138087. /** simulated refraction depth */
  138088. depth: number;
  138089. /** the coefficient of the base color (0 to remove base color tainting) */
  138090. colorLevel: number;
  138091. private _refTexture;
  138092. private _ownRefractionTexture;
  138093. /**
  138094. * Gets or sets the refraction texture
  138095. * Please note that you are responsible for disposing the texture if you set it manually
  138096. */
  138097. get refractionTexture(): Texture;
  138098. set refractionTexture(value: Texture);
  138099. /**
  138100. * Initializes the RefractionPostProcess
  138101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138102. * @param name The name of the effect.
  138103. * @param refractionTextureUrl Url of the refraction texture to use
  138104. * @param color the base color of the refraction (used to taint the rendering)
  138105. * @param depth simulated refraction depth
  138106. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138107. * @param camera The camera to apply the render pass to.
  138108. * @param options The required width/height ratio to downsize to before computing the render pass.
  138109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138110. * @param engine The engine which the post process will be applied. (default: current engine)
  138111. * @param reusable If the post process can be reused on the same frame. (default: false)
  138112. */
  138113. constructor(name: string, refractionTextureUrl: string,
  138114. /** the base color of the refraction (used to taint the rendering) */
  138115. color: Color3,
  138116. /** simulated refraction depth */
  138117. depth: number,
  138118. /** the coefficient of the base color (0 to remove base color tainting) */
  138119. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138120. /**
  138121. * Disposes of the post process
  138122. * @param camera Camera to dispose post process on
  138123. */
  138124. dispose(camera: Camera): void;
  138125. }
  138126. }
  138127. declare module BABYLON {
  138128. /** @hidden */
  138129. export var sharpenPixelShader: {
  138130. name: string;
  138131. shader: string;
  138132. };
  138133. }
  138134. declare module BABYLON {
  138135. /**
  138136. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138137. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138138. */
  138139. export class SharpenPostProcess extends PostProcess {
  138140. /**
  138141. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138142. */
  138143. colorAmount: number;
  138144. /**
  138145. * How much sharpness should be applied (default: 0.3)
  138146. */
  138147. edgeAmount: number;
  138148. /**
  138149. * Creates a new instance ConvolutionPostProcess
  138150. * @param name The name of the effect.
  138151. * @param options The required width/height ratio to downsize to before computing the render pass.
  138152. * @param camera The camera to apply the render pass to.
  138153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138154. * @param engine The engine which the post process will be applied. (default: current engine)
  138155. * @param reusable If the post process can be reused on the same frame. (default: false)
  138156. * @param textureType Type of textures used when performing the post process. (default: 0)
  138157. * @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)
  138158. */
  138159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138160. }
  138161. }
  138162. declare module BABYLON {
  138163. /**
  138164. * PostProcessRenderPipeline
  138165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138166. */
  138167. export class PostProcessRenderPipeline {
  138168. private engine;
  138169. private _renderEffects;
  138170. private _renderEffectsForIsolatedPass;
  138171. /**
  138172. * List of inspectable custom properties (used by the Inspector)
  138173. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138174. */
  138175. inspectableCustomProperties: IInspectable[];
  138176. /**
  138177. * @hidden
  138178. */
  138179. protected _cameras: Camera[];
  138180. /** @hidden */
  138181. _name: string;
  138182. /**
  138183. * Gets pipeline name
  138184. */
  138185. get name(): string;
  138186. /** Gets the list of attached cameras */
  138187. get cameras(): Camera[];
  138188. /**
  138189. * Initializes a PostProcessRenderPipeline
  138190. * @param engine engine to add the pipeline to
  138191. * @param name name of the pipeline
  138192. */
  138193. constructor(engine: Engine, name: string);
  138194. /**
  138195. * Gets the class name
  138196. * @returns "PostProcessRenderPipeline"
  138197. */
  138198. getClassName(): string;
  138199. /**
  138200. * If all the render effects in the pipeline are supported
  138201. */
  138202. get isSupported(): boolean;
  138203. /**
  138204. * Adds an effect to the pipeline
  138205. * @param renderEffect the effect to add
  138206. */
  138207. addEffect(renderEffect: PostProcessRenderEffect): void;
  138208. /** @hidden */
  138209. _rebuild(): void;
  138210. /** @hidden */
  138211. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138212. /** @hidden */
  138213. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138214. /** @hidden */
  138215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138216. /** @hidden */
  138217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138218. /** @hidden */
  138219. _attachCameras(cameras: Camera, unique: boolean): void;
  138220. /** @hidden */
  138221. _attachCameras(cameras: Camera[], unique: boolean): void;
  138222. /** @hidden */
  138223. _detachCameras(cameras: Camera): void;
  138224. /** @hidden */
  138225. _detachCameras(cameras: Nullable<Camera[]>): void;
  138226. /** @hidden */
  138227. _update(): void;
  138228. /** @hidden */
  138229. _reset(): void;
  138230. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138231. /**
  138232. * Disposes of the pipeline
  138233. */
  138234. dispose(): void;
  138235. }
  138236. }
  138237. declare module BABYLON {
  138238. /**
  138239. * PostProcessRenderPipelineManager class
  138240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138241. */
  138242. export class PostProcessRenderPipelineManager {
  138243. private _renderPipelines;
  138244. /**
  138245. * Initializes a PostProcessRenderPipelineManager
  138246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138247. */
  138248. constructor();
  138249. /**
  138250. * Gets the list of supported render pipelines
  138251. */
  138252. get supportedPipelines(): PostProcessRenderPipeline[];
  138253. /**
  138254. * Adds a pipeline to the manager
  138255. * @param renderPipeline The pipeline to add
  138256. */
  138257. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138258. /**
  138259. * Attaches a camera to the pipeline
  138260. * @param renderPipelineName The name of the pipeline to attach to
  138261. * @param cameras the camera to attach
  138262. * @param unique if the camera can be attached multiple times to the pipeline
  138263. */
  138264. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138265. /**
  138266. * Detaches a camera from the pipeline
  138267. * @param renderPipelineName The name of the pipeline to detach from
  138268. * @param cameras the camera to detach
  138269. */
  138270. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138271. /**
  138272. * Enables an effect by name on a pipeline
  138273. * @param renderPipelineName the name of the pipeline to enable the effect in
  138274. * @param renderEffectName the name of the effect to enable
  138275. * @param cameras the cameras that the effect should be enabled on
  138276. */
  138277. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138278. /**
  138279. * Disables an effect by name on a pipeline
  138280. * @param renderPipelineName the name of the pipeline to disable the effect in
  138281. * @param renderEffectName the name of the effect to disable
  138282. * @param cameras the cameras that the effect should be disabled on
  138283. */
  138284. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138285. /**
  138286. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138287. */
  138288. update(): void;
  138289. /** @hidden */
  138290. _rebuild(): void;
  138291. /**
  138292. * Disposes of the manager and pipelines
  138293. */
  138294. dispose(): void;
  138295. }
  138296. }
  138297. declare module BABYLON {
  138298. interface Scene {
  138299. /** @hidden (Backing field) */
  138300. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138301. /**
  138302. * Gets the postprocess render pipeline manager
  138303. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138304. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138305. */
  138306. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138307. }
  138308. /**
  138309. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138310. */
  138311. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138312. /**
  138313. * The component name helpfull to identify the component in the list of scene components.
  138314. */
  138315. readonly name: string;
  138316. /**
  138317. * The scene the component belongs to.
  138318. */
  138319. scene: Scene;
  138320. /**
  138321. * Creates a new instance of the component for the given scene
  138322. * @param scene Defines the scene to register the component in
  138323. */
  138324. constructor(scene: Scene);
  138325. /**
  138326. * Registers the component in a given scene
  138327. */
  138328. register(): void;
  138329. /**
  138330. * Rebuilds the elements related to this component in case of
  138331. * context lost for instance.
  138332. */
  138333. rebuild(): void;
  138334. /**
  138335. * Disposes the component and the associated ressources
  138336. */
  138337. dispose(): void;
  138338. private _gatherRenderTargets;
  138339. }
  138340. }
  138341. declare module BABYLON {
  138342. /**
  138343. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138344. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138345. */
  138346. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138347. private _scene;
  138348. private _camerasToBeAttached;
  138349. /**
  138350. * ID of the sharpen post process,
  138351. */
  138352. private readonly SharpenPostProcessId;
  138353. /**
  138354. * @ignore
  138355. * ID of the image processing post process;
  138356. */
  138357. readonly ImageProcessingPostProcessId: string;
  138358. /**
  138359. * @ignore
  138360. * ID of the Fast Approximate Anti-Aliasing post process;
  138361. */
  138362. readonly FxaaPostProcessId: string;
  138363. /**
  138364. * ID of the chromatic aberration post process,
  138365. */
  138366. private readonly ChromaticAberrationPostProcessId;
  138367. /**
  138368. * ID of the grain post process
  138369. */
  138370. private readonly GrainPostProcessId;
  138371. /**
  138372. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138373. */
  138374. sharpen: SharpenPostProcess;
  138375. private _sharpenEffect;
  138376. private bloom;
  138377. /**
  138378. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138379. */
  138380. depthOfField: DepthOfFieldEffect;
  138381. /**
  138382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138383. */
  138384. fxaa: FxaaPostProcess;
  138385. /**
  138386. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138387. */
  138388. imageProcessing: ImageProcessingPostProcess;
  138389. /**
  138390. * Chromatic aberration post process which will shift rgb colors in the image
  138391. */
  138392. chromaticAberration: ChromaticAberrationPostProcess;
  138393. private _chromaticAberrationEffect;
  138394. /**
  138395. * Grain post process which add noise to the image
  138396. */
  138397. grain: GrainPostProcess;
  138398. private _grainEffect;
  138399. /**
  138400. * Glow post process which adds a glow to emissive areas of the image
  138401. */
  138402. private _glowLayer;
  138403. /**
  138404. * Animations which can be used to tweak settings over a period of time
  138405. */
  138406. animations: Animation[];
  138407. private _imageProcessingConfigurationObserver;
  138408. private _sharpenEnabled;
  138409. private _bloomEnabled;
  138410. private _depthOfFieldEnabled;
  138411. private _depthOfFieldBlurLevel;
  138412. private _fxaaEnabled;
  138413. private _imageProcessingEnabled;
  138414. private _defaultPipelineTextureType;
  138415. private _bloomScale;
  138416. private _chromaticAberrationEnabled;
  138417. private _grainEnabled;
  138418. private _buildAllowed;
  138419. /**
  138420. * Gets active scene
  138421. */
  138422. get scene(): Scene;
  138423. /**
  138424. * Enable or disable the sharpen process from the pipeline
  138425. */
  138426. set sharpenEnabled(enabled: boolean);
  138427. get sharpenEnabled(): boolean;
  138428. private _resizeObserver;
  138429. private _hardwareScaleLevel;
  138430. private _bloomKernel;
  138431. /**
  138432. * Specifies the size of the bloom blur kernel, relative to the final output size
  138433. */
  138434. get bloomKernel(): number;
  138435. set bloomKernel(value: number);
  138436. /**
  138437. * Specifies the weight of the bloom in the final rendering
  138438. */
  138439. private _bloomWeight;
  138440. /**
  138441. * Specifies the luma threshold for the area that will be blurred by the bloom
  138442. */
  138443. private _bloomThreshold;
  138444. private _hdr;
  138445. /**
  138446. * The strength of the bloom.
  138447. */
  138448. set bloomWeight(value: number);
  138449. get bloomWeight(): number;
  138450. /**
  138451. * The strength of the bloom.
  138452. */
  138453. set bloomThreshold(value: number);
  138454. get bloomThreshold(): number;
  138455. /**
  138456. * The scale of the bloom, lower value will provide better performance.
  138457. */
  138458. set bloomScale(value: number);
  138459. get bloomScale(): number;
  138460. /**
  138461. * Enable or disable the bloom from the pipeline
  138462. */
  138463. set bloomEnabled(enabled: boolean);
  138464. get bloomEnabled(): boolean;
  138465. private _rebuildBloom;
  138466. /**
  138467. * If the depth of field is enabled.
  138468. */
  138469. get depthOfFieldEnabled(): boolean;
  138470. set depthOfFieldEnabled(enabled: boolean);
  138471. /**
  138472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138473. */
  138474. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138475. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138476. /**
  138477. * If the anti aliasing is enabled.
  138478. */
  138479. set fxaaEnabled(enabled: boolean);
  138480. get fxaaEnabled(): boolean;
  138481. private _samples;
  138482. /**
  138483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138484. */
  138485. set samples(sampleCount: number);
  138486. get samples(): number;
  138487. /**
  138488. * If image processing is enabled.
  138489. */
  138490. set imageProcessingEnabled(enabled: boolean);
  138491. get imageProcessingEnabled(): boolean;
  138492. /**
  138493. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138494. */
  138495. set glowLayerEnabled(enabled: boolean);
  138496. get glowLayerEnabled(): boolean;
  138497. /**
  138498. * Gets the glow layer (or null if not defined)
  138499. */
  138500. get glowLayer(): Nullable<GlowLayer>;
  138501. /**
  138502. * Enable or disable the chromaticAberration process from the pipeline
  138503. */
  138504. set chromaticAberrationEnabled(enabled: boolean);
  138505. get chromaticAberrationEnabled(): boolean;
  138506. /**
  138507. * Enable or disable the grain process from the pipeline
  138508. */
  138509. set grainEnabled(enabled: boolean);
  138510. get grainEnabled(): boolean;
  138511. /**
  138512. * @constructor
  138513. * @param name - The rendering pipeline name (default: "")
  138514. * @param hdr - If high dynamic range textures should be used (default: true)
  138515. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138516. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138517. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138518. */
  138519. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138520. /**
  138521. * Get the class name
  138522. * @returns "DefaultRenderingPipeline"
  138523. */
  138524. getClassName(): string;
  138525. /**
  138526. * Force the compilation of the entire pipeline.
  138527. */
  138528. prepare(): void;
  138529. private _hasCleared;
  138530. private _prevPostProcess;
  138531. private _prevPrevPostProcess;
  138532. private _setAutoClearAndTextureSharing;
  138533. private _depthOfFieldSceneObserver;
  138534. private _buildPipeline;
  138535. private _disposePostProcesses;
  138536. /**
  138537. * Adds a camera to the pipeline
  138538. * @param camera the camera to be added
  138539. */
  138540. addCamera(camera: Camera): void;
  138541. /**
  138542. * Removes a camera from the pipeline
  138543. * @param camera the camera to remove
  138544. */
  138545. removeCamera(camera: Camera): void;
  138546. /**
  138547. * Dispose of the pipeline and stop all post processes
  138548. */
  138549. dispose(): void;
  138550. /**
  138551. * Serialize the rendering pipeline (Used when exporting)
  138552. * @returns the serialized object
  138553. */
  138554. serialize(): any;
  138555. /**
  138556. * Parse the serialized pipeline
  138557. * @param source Source pipeline.
  138558. * @param scene The scene to load the pipeline to.
  138559. * @param rootUrl The URL of the serialized pipeline.
  138560. * @returns An instantiated pipeline from the serialized object.
  138561. */
  138562. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138563. }
  138564. }
  138565. declare module BABYLON {
  138566. /** @hidden */
  138567. export var lensHighlightsPixelShader: {
  138568. name: string;
  138569. shader: string;
  138570. };
  138571. }
  138572. declare module BABYLON {
  138573. /** @hidden */
  138574. export var depthOfFieldPixelShader: {
  138575. name: string;
  138576. shader: string;
  138577. };
  138578. }
  138579. declare module BABYLON {
  138580. /**
  138581. * BABYLON.JS Chromatic Aberration GLSL Shader
  138582. * Author: Olivier Guyot
  138583. * Separates very slightly R, G and B colors on the edges of the screen
  138584. * Inspired by Francois Tarlier & Martins Upitis
  138585. */
  138586. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138587. /**
  138588. * @ignore
  138589. * The chromatic aberration PostProcess id in the pipeline
  138590. */
  138591. LensChromaticAberrationEffect: string;
  138592. /**
  138593. * @ignore
  138594. * The highlights enhancing PostProcess id in the pipeline
  138595. */
  138596. HighlightsEnhancingEffect: string;
  138597. /**
  138598. * @ignore
  138599. * The depth-of-field PostProcess id in the pipeline
  138600. */
  138601. LensDepthOfFieldEffect: string;
  138602. private _scene;
  138603. private _depthTexture;
  138604. private _grainTexture;
  138605. private _chromaticAberrationPostProcess;
  138606. private _highlightsPostProcess;
  138607. private _depthOfFieldPostProcess;
  138608. private _edgeBlur;
  138609. private _grainAmount;
  138610. private _chromaticAberration;
  138611. private _distortion;
  138612. private _highlightsGain;
  138613. private _highlightsThreshold;
  138614. private _dofDistance;
  138615. private _dofAperture;
  138616. private _dofDarken;
  138617. private _dofPentagon;
  138618. private _blurNoise;
  138619. /**
  138620. * @constructor
  138621. *
  138622. * Effect parameters are as follow:
  138623. * {
  138624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138625. * edge_blur: number; // from 0 to x (1 for realism)
  138626. * distortion: number; // from 0 to x (1 for realism)
  138627. * grain_amount: number; // from 0 to 1
  138628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138636. * }
  138637. * Note: if an effect parameter is unset, effect is disabled
  138638. *
  138639. * @param name The rendering pipeline name
  138640. * @param parameters - An object containing all parameters (see above)
  138641. * @param scene The scene linked to this pipeline
  138642. * @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)
  138643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138644. */
  138645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138646. /**
  138647. * Get the class name
  138648. * @returns "LensRenderingPipeline"
  138649. */
  138650. getClassName(): string;
  138651. /**
  138652. * Gets associated scene
  138653. */
  138654. get scene(): Scene;
  138655. /**
  138656. * Gets or sets the edge blur
  138657. */
  138658. get edgeBlur(): number;
  138659. set edgeBlur(value: number);
  138660. /**
  138661. * Gets or sets the grain amount
  138662. */
  138663. get grainAmount(): number;
  138664. set grainAmount(value: number);
  138665. /**
  138666. * Gets or sets the chromatic aberration amount
  138667. */
  138668. get chromaticAberration(): number;
  138669. set chromaticAberration(value: number);
  138670. /**
  138671. * Gets or sets the depth of field aperture
  138672. */
  138673. get dofAperture(): number;
  138674. set dofAperture(value: number);
  138675. /**
  138676. * Gets or sets the edge distortion
  138677. */
  138678. get edgeDistortion(): number;
  138679. set edgeDistortion(value: number);
  138680. /**
  138681. * Gets or sets the depth of field distortion
  138682. */
  138683. get dofDistortion(): number;
  138684. set dofDistortion(value: number);
  138685. /**
  138686. * Gets or sets the darken out of focus amount
  138687. */
  138688. get darkenOutOfFocus(): number;
  138689. set darkenOutOfFocus(value: number);
  138690. /**
  138691. * Gets or sets a boolean indicating if blur noise is enabled
  138692. */
  138693. get blurNoise(): boolean;
  138694. set blurNoise(value: boolean);
  138695. /**
  138696. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138697. */
  138698. get pentagonBokeh(): boolean;
  138699. set pentagonBokeh(value: boolean);
  138700. /**
  138701. * Gets or sets the highlight grain amount
  138702. */
  138703. get highlightsGain(): number;
  138704. set highlightsGain(value: number);
  138705. /**
  138706. * Gets or sets the highlight threshold
  138707. */
  138708. get highlightsThreshold(): number;
  138709. set highlightsThreshold(value: number);
  138710. /**
  138711. * Sets the amount of blur at the edges
  138712. * @param amount blur amount
  138713. */
  138714. setEdgeBlur(amount: number): void;
  138715. /**
  138716. * Sets edge blur to 0
  138717. */
  138718. disableEdgeBlur(): void;
  138719. /**
  138720. * Sets the amout of grain
  138721. * @param amount Amount of grain
  138722. */
  138723. setGrainAmount(amount: number): void;
  138724. /**
  138725. * Set grain amount to 0
  138726. */
  138727. disableGrain(): void;
  138728. /**
  138729. * Sets the chromatic aberration amount
  138730. * @param amount amount of chromatic aberration
  138731. */
  138732. setChromaticAberration(amount: number): void;
  138733. /**
  138734. * Sets chromatic aberration amount to 0
  138735. */
  138736. disableChromaticAberration(): void;
  138737. /**
  138738. * Sets the EdgeDistortion amount
  138739. * @param amount amount of EdgeDistortion
  138740. */
  138741. setEdgeDistortion(amount: number): void;
  138742. /**
  138743. * Sets edge distortion to 0
  138744. */
  138745. disableEdgeDistortion(): void;
  138746. /**
  138747. * Sets the FocusDistance amount
  138748. * @param amount amount of FocusDistance
  138749. */
  138750. setFocusDistance(amount: number): void;
  138751. /**
  138752. * Disables depth of field
  138753. */
  138754. disableDepthOfField(): void;
  138755. /**
  138756. * Sets the Aperture amount
  138757. * @param amount amount of Aperture
  138758. */
  138759. setAperture(amount: number): void;
  138760. /**
  138761. * Sets the DarkenOutOfFocus amount
  138762. * @param amount amount of DarkenOutOfFocus
  138763. */
  138764. setDarkenOutOfFocus(amount: number): void;
  138765. private _pentagonBokehIsEnabled;
  138766. /**
  138767. * Creates a pentagon bokeh effect
  138768. */
  138769. enablePentagonBokeh(): void;
  138770. /**
  138771. * Disables the pentagon bokeh effect
  138772. */
  138773. disablePentagonBokeh(): void;
  138774. /**
  138775. * Enables noise blur
  138776. */
  138777. enableNoiseBlur(): void;
  138778. /**
  138779. * Disables noise blur
  138780. */
  138781. disableNoiseBlur(): void;
  138782. /**
  138783. * Sets the HighlightsGain amount
  138784. * @param amount amount of HighlightsGain
  138785. */
  138786. setHighlightsGain(amount: number): void;
  138787. /**
  138788. * Sets the HighlightsThreshold amount
  138789. * @param amount amount of HighlightsThreshold
  138790. */
  138791. setHighlightsThreshold(amount: number): void;
  138792. /**
  138793. * Disables highlights
  138794. */
  138795. disableHighlights(): void;
  138796. /**
  138797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138799. */
  138800. dispose(disableDepthRender?: boolean): void;
  138801. private _createChromaticAberrationPostProcess;
  138802. private _createHighlightsPostProcess;
  138803. private _createDepthOfFieldPostProcess;
  138804. private _createGrainTexture;
  138805. }
  138806. }
  138807. declare module BABYLON {
  138808. /** @hidden */
  138809. export var ssao2PixelShader: {
  138810. name: string;
  138811. shader: string;
  138812. };
  138813. }
  138814. declare module BABYLON {
  138815. /** @hidden */
  138816. export var ssaoCombinePixelShader: {
  138817. name: string;
  138818. shader: string;
  138819. };
  138820. }
  138821. declare module BABYLON {
  138822. /**
  138823. * Render pipeline to produce ssao effect
  138824. */
  138825. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138826. /**
  138827. * @ignore
  138828. * The PassPostProcess id in the pipeline that contains the original scene color
  138829. */
  138830. SSAOOriginalSceneColorEffect: string;
  138831. /**
  138832. * @ignore
  138833. * The SSAO PostProcess id in the pipeline
  138834. */
  138835. SSAORenderEffect: string;
  138836. /**
  138837. * @ignore
  138838. * The horizontal blur PostProcess id in the pipeline
  138839. */
  138840. SSAOBlurHRenderEffect: string;
  138841. /**
  138842. * @ignore
  138843. * The vertical blur PostProcess id in the pipeline
  138844. */
  138845. SSAOBlurVRenderEffect: string;
  138846. /**
  138847. * @ignore
  138848. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138849. */
  138850. SSAOCombineRenderEffect: string;
  138851. /**
  138852. * The output strength of the SSAO post-process. Default value is 1.0.
  138853. */
  138854. totalStrength: number;
  138855. /**
  138856. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138857. */
  138858. maxZ: number;
  138859. /**
  138860. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138861. */
  138862. minZAspect: number;
  138863. private _samples;
  138864. /**
  138865. * Number of samples used for the SSAO calculations. Default value is 8
  138866. */
  138867. set samples(n: number);
  138868. get samples(): number;
  138869. private _textureSamples;
  138870. /**
  138871. * Number of samples to use for antialiasing
  138872. */
  138873. set textureSamples(n: number);
  138874. get textureSamples(): number;
  138875. /**
  138876. * Ratio object used for SSAO ratio and blur ratio
  138877. */
  138878. private _ratio;
  138879. /**
  138880. * Dynamically generated sphere sampler.
  138881. */
  138882. private _sampleSphere;
  138883. /**
  138884. * Blur filter offsets
  138885. */
  138886. private _samplerOffsets;
  138887. private _expensiveBlur;
  138888. /**
  138889. * If bilateral blur should be used
  138890. */
  138891. set expensiveBlur(b: boolean);
  138892. get expensiveBlur(): boolean;
  138893. /**
  138894. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138895. */
  138896. radius: number;
  138897. /**
  138898. * The base color of the SSAO post-process
  138899. * The final result is "base + ssao" between [0, 1]
  138900. */
  138901. base: number;
  138902. /**
  138903. * Support test.
  138904. */
  138905. static get IsSupported(): boolean;
  138906. private _scene;
  138907. private _depthTexture;
  138908. private _normalTexture;
  138909. private _randomTexture;
  138910. private _originalColorPostProcess;
  138911. private _ssaoPostProcess;
  138912. private _blurHPostProcess;
  138913. private _blurVPostProcess;
  138914. private _ssaoCombinePostProcess;
  138915. /**
  138916. * Gets active scene
  138917. */
  138918. get scene(): Scene;
  138919. /**
  138920. * @constructor
  138921. * @param name The rendering pipeline name
  138922. * @param scene The scene linked to this pipeline
  138923. * @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 }
  138924. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138925. */
  138926. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138927. /**
  138928. * Get the class name
  138929. * @returns "SSAO2RenderingPipeline"
  138930. */
  138931. getClassName(): string;
  138932. /**
  138933. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138934. */
  138935. dispose(disableGeometryBufferRenderer?: boolean): void;
  138936. private _createBlurPostProcess;
  138937. /** @hidden */
  138938. _rebuild(): void;
  138939. private _bits;
  138940. private _radicalInverse_VdC;
  138941. private _hammersley;
  138942. private _hemisphereSample_uniform;
  138943. private _generateHemisphere;
  138944. private _createSSAOPostProcess;
  138945. private _createSSAOCombinePostProcess;
  138946. private _createRandomTexture;
  138947. /**
  138948. * Serialize the rendering pipeline (Used when exporting)
  138949. * @returns the serialized object
  138950. */
  138951. serialize(): any;
  138952. /**
  138953. * Parse the serialized pipeline
  138954. * @param source Source pipeline.
  138955. * @param scene The scene to load the pipeline to.
  138956. * @param rootUrl The URL of the serialized pipeline.
  138957. * @returns An instantiated pipeline from the serialized object.
  138958. */
  138959. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138960. }
  138961. }
  138962. declare module BABYLON {
  138963. /** @hidden */
  138964. export var ssaoPixelShader: {
  138965. name: string;
  138966. shader: string;
  138967. };
  138968. }
  138969. declare module BABYLON {
  138970. /**
  138971. * Render pipeline to produce ssao effect
  138972. */
  138973. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138974. /**
  138975. * @ignore
  138976. * The PassPostProcess id in the pipeline that contains the original scene color
  138977. */
  138978. SSAOOriginalSceneColorEffect: string;
  138979. /**
  138980. * @ignore
  138981. * The SSAO PostProcess id in the pipeline
  138982. */
  138983. SSAORenderEffect: string;
  138984. /**
  138985. * @ignore
  138986. * The horizontal blur PostProcess id in the pipeline
  138987. */
  138988. SSAOBlurHRenderEffect: string;
  138989. /**
  138990. * @ignore
  138991. * The vertical blur PostProcess id in the pipeline
  138992. */
  138993. SSAOBlurVRenderEffect: string;
  138994. /**
  138995. * @ignore
  138996. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138997. */
  138998. SSAOCombineRenderEffect: string;
  138999. /**
  139000. * The output strength of the SSAO post-process. Default value is 1.0.
  139001. */
  139002. totalStrength: number;
  139003. /**
  139004. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139005. */
  139006. radius: number;
  139007. /**
  139008. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139009. * Must not be equal to fallOff and superior to fallOff.
  139010. * Default value is 0.0075
  139011. */
  139012. area: number;
  139013. /**
  139014. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139015. * Must not be equal to area and inferior to area.
  139016. * Default value is 0.000001
  139017. */
  139018. fallOff: number;
  139019. /**
  139020. * The base color of the SSAO post-process
  139021. * The final result is "base + ssao" between [0, 1]
  139022. */
  139023. base: number;
  139024. private _scene;
  139025. private _depthTexture;
  139026. private _randomTexture;
  139027. private _originalColorPostProcess;
  139028. private _ssaoPostProcess;
  139029. private _blurHPostProcess;
  139030. private _blurVPostProcess;
  139031. private _ssaoCombinePostProcess;
  139032. private _firstUpdate;
  139033. /**
  139034. * Gets active scene
  139035. */
  139036. get scene(): Scene;
  139037. /**
  139038. * @constructor
  139039. * @param name - The rendering pipeline name
  139040. * @param scene - The scene linked to this pipeline
  139041. * @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 }
  139042. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139043. */
  139044. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139045. /**
  139046. * Get the class name
  139047. * @returns "SSAORenderingPipeline"
  139048. */
  139049. getClassName(): string;
  139050. /**
  139051. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139052. */
  139053. dispose(disableDepthRender?: boolean): void;
  139054. private _createBlurPostProcess;
  139055. /** @hidden */
  139056. _rebuild(): void;
  139057. private _createSSAOPostProcess;
  139058. private _createSSAOCombinePostProcess;
  139059. private _createRandomTexture;
  139060. }
  139061. }
  139062. declare module BABYLON {
  139063. /** @hidden */
  139064. export var screenSpaceReflectionPixelShader: {
  139065. name: string;
  139066. shader: string;
  139067. };
  139068. }
  139069. declare module BABYLON {
  139070. /**
  139071. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139072. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139073. */
  139074. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139075. /**
  139076. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139077. */
  139078. threshold: number;
  139079. /**
  139080. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139081. */
  139082. strength: number;
  139083. /**
  139084. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139085. */
  139086. reflectionSpecularFalloffExponent: number;
  139087. /**
  139088. * 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]
  139089. */
  139090. step: number;
  139091. /**
  139092. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139093. */
  139094. roughnessFactor: number;
  139095. private _geometryBufferRenderer;
  139096. private _enableSmoothReflections;
  139097. private _reflectionSamples;
  139098. private _smoothSteps;
  139099. /**
  139100. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139101. * @param name The name of the effect.
  139102. * @param scene The scene containing the objects to calculate reflections.
  139103. * @param options The required width/height ratio to downsize to before computing the render pass.
  139104. * @param camera The camera to apply the render pass to.
  139105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139106. * @param engine The engine which the post process will be applied. (default: current engine)
  139107. * @param reusable If the post process can be reused on the same frame. (default: false)
  139108. * @param textureType Type of textures used when performing the post process. (default: 0)
  139109. * @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)
  139110. */
  139111. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139112. /**
  139113. * Gets wether or not smoothing reflections is enabled.
  139114. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139115. */
  139116. get enableSmoothReflections(): boolean;
  139117. /**
  139118. * Sets wether or not smoothing reflections is enabled.
  139119. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139120. */
  139121. set enableSmoothReflections(enabled: boolean);
  139122. /**
  139123. * Gets the number of samples taken while computing reflections. More samples count is high,
  139124. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139125. */
  139126. get reflectionSamples(): number;
  139127. /**
  139128. * Sets the number of samples taken while computing reflections. More samples count is high,
  139129. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139130. */
  139131. set reflectionSamples(samples: number);
  139132. /**
  139133. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139134. * more the post-process will require GPU power and can generate a drop in FPS.
  139135. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139136. */
  139137. get smoothSteps(): number;
  139138. set smoothSteps(steps: number);
  139139. private _updateEffectDefines;
  139140. }
  139141. }
  139142. declare module BABYLON {
  139143. /** @hidden */
  139144. export var standardPixelShader: {
  139145. name: string;
  139146. shader: string;
  139147. };
  139148. }
  139149. declare module BABYLON {
  139150. /**
  139151. * Standard rendering pipeline
  139152. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139153. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139154. */
  139155. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139156. /**
  139157. * Public members
  139158. */
  139159. /**
  139160. * Post-process which contains the original scene color before the pipeline applies all the effects
  139161. */
  139162. originalPostProcess: Nullable<PostProcess>;
  139163. /**
  139164. * Post-process used to down scale an image x4
  139165. */
  139166. downSampleX4PostProcess: Nullable<PostProcess>;
  139167. /**
  139168. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139169. */
  139170. brightPassPostProcess: Nullable<PostProcess>;
  139171. /**
  139172. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139173. */
  139174. blurHPostProcesses: PostProcess[];
  139175. /**
  139176. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139177. */
  139178. blurVPostProcesses: PostProcess[];
  139179. /**
  139180. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139181. */
  139182. textureAdderPostProcess: Nullable<PostProcess>;
  139183. /**
  139184. * Post-process used to create volumetric lighting effect
  139185. */
  139186. volumetricLightPostProcess: Nullable<PostProcess>;
  139187. /**
  139188. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139189. */
  139190. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139191. /**
  139192. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139193. */
  139194. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139195. /**
  139196. * Post-process used to merge the volumetric light effect and the real scene color
  139197. */
  139198. volumetricLightMergePostProces: Nullable<PostProcess>;
  139199. /**
  139200. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139201. */
  139202. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139203. /**
  139204. * Base post-process used to calculate the average luminance of the final image for HDR
  139205. */
  139206. luminancePostProcess: Nullable<PostProcess>;
  139207. /**
  139208. * Post-processes used to create down sample post-processes in order to get
  139209. * the average luminance of the final image for HDR
  139210. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139211. */
  139212. luminanceDownSamplePostProcesses: PostProcess[];
  139213. /**
  139214. * Post-process used to create a HDR effect (light adaptation)
  139215. */
  139216. hdrPostProcess: Nullable<PostProcess>;
  139217. /**
  139218. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139219. */
  139220. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139221. /**
  139222. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139223. */
  139224. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139225. /**
  139226. * Post-process used to merge the final HDR post-process and the real scene color
  139227. */
  139228. hdrFinalPostProcess: Nullable<PostProcess>;
  139229. /**
  139230. * Post-process used to create a lens flare effect
  139231. */
  139232. lensFlarePostProcess: Nullable<PostProcess>;
  139233. /**
  139234. * Post-process that merges the result of the lens flare post-process and the real scene color
  139235. */
  139236. lensFlareComposePostProcess: Nullable<PostProcess>;
  139237. /**
  139238. * Post-process used to create a motion blur effect
  139239. */
  139240. motionBlurPostProcess: Nullable<PostProcess>;
  139241. /**
  139242. * Post-process used to create a depth of field effect
  139243. */
  139244. depthOfFieldPostProcess: Nullable<PostProcess>;
  139245. /**
  139246. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139247. */
  139248. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139249. /**
  139250. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139251. */
  139252. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139253. /**
  139254. * Represents the brightness threshold in order to configure the illuminated surfaces
  139255. */
  139256. brightThreshold: number;
  139257. /**
  139258. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139259. */
  139260. blurWidth: number;
  139261. /**
  139262. * Sets if the blur for highlighted surfaces must be only horizontal
  139263. */
  139264. horizontalBlur: boolean;
  139265. /**
  139266. * Gets the overall exposure used by the pipeline
  139267. */
  139268. get exposure(): number;
  139269. /**
  139270. * Sets the overall exposure used by the pipeline
  139271. */
  139272. set exposure(value: number);
  139273. /**
  139274. * Texture used typically to simulate "dirty" on camera lens
  139275. */
  139276. lensTexture: Nullable<Texture>;
  139277. /**
  139278. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139279. */
  139280. volumetricLightCoefficient: number;
  139281. /**
  139282. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139283. */
  139284. volumetricLightPower: number;
  139285. /**
  139286. * Used the set the blur intensity to smooth the volumetric lights
  139287. */
  139288. volumetricLightBlurScale: number;
  139289. /**
  139290. * Light (spot or directional) used to generate the volumetric lights rays
  139291. * The source light must have a shadow generate so the pipeline can get its
  139292. * depth map
  139293. */
  139294. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139295. /**
  139296. * For eye adaptation, represents the minimum luminance the eye can see
  139297. */
  139298. hdrMinimumLuminance: number;
  139299. /**
  139300. * For eye adaptation, represents the decrease luminance speed
  139301. */
  139302. hdrDecreaseRate: number;
  139303. /**
  139304. * For eye adaptation, represents the increase luminance speed
  139305. */
  139306. hdrIncreaseRate: number;
  139307. /**
  139308. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139309. */
  139310. get hdrAutoExposure(): boolean;
  139311. /**
  139312. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139313. */
  139314. set hdrAutoExposure(value: boolean);
  139315. /**
  139316. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139317. */
  139318. lensColorTexture: Nullable<Texture>;
  139319. /**
  139320. * The overall strengh for the lens flare effect
  139321. */
  139322. lensFlareStrength: number;
  139323. /**
  139324. * Dispersion coefficient for lens flare ghosts
  139325. */
  139326. lensFlareGhostDispersal: number;
  139327. /**
  139328. * Main lens flare halo width
  139329. */
  139330. lensFlareHaloWidth: number;
  139331. /**
  139332. * Based on the lens distortion effect, defines how much the lens flare result
  139333. * is distorted
  139334. */
  139335. lensFlareDistortionStrength: number;
  139336. /**
  139337. * Configures the blur intensity used for for lens flare (halo)
  139338. */
  139339. lensFlareBlurWidth: number;
  139340. /**
  139341. * Lens star texture must be used to simulate rays on the flares and is available
  139342. * in the documentation
  139343. */
  139344. lensStarTexture: Nullable<Texture>;
  139345. /**
  139346. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139347. * flare effect by taking account of the dirt texture
  139348. */
  139349. lensFlareDirtTexture: Nullable<Texture>;
  139350. /**
  139351. * Represents the focal length for the depth of field effect
  139352. */
  139353. depthOfFieldDistance: number;
  139354. /**
  139355. * Represents the blur intensity for the blurred part of the depth of field effect
  139356. */
  139357. depthOfFieldBlurWidth: number;
  139358. /**
  139359. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139360. */
  139361. get motionStrength(): number;
  139362. /**
  139363. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139364. */
  139365. set motionStrength(strength: number);
  139366. /**
  139367. * Gets wether or not the motion blur post-process is object based or screen based.
  139368. */
  139369. get objectBasedMotionBlur(): boolean;
  139370. /**
  139371. * Sets wether or not the motion blur post-process should be object based or screen based
  139372. */
  139373. set objectBasedMotionBlur(value: boolean);
  139374. /**
  139375. * List of animations for the pipeline (IAnimatable implementation)
  139376. */
  139377. animations: Animation[];
  139378. /**
  139379. * Private members
  139380. */
  139381. private _scene;
  139382. private _currentDepthOfFieldSource;
  139383. private _basePostProcess;
  139384. private _fixedExposure;
  139385. private _currentExposure;
  139386. private _hdrAutoExposure;
  139387. private _hdrCurrentLuminance;
  139388. private _motionStrength;
  139389. private _isObjectBasedMotionBlur;
  139390. private _floatTextureType;
  139391. private _camerasToBeAttached;
  139392. private _ratio;
  139393. private _bloomEnabled;
  139394. private _depthOfFieldEnabled;
  139395. private _vlsEnabled;
  139396. private _lensFlareEnabled;
  139397. private _hdrEnabled;
  139398. private _motionBlurEnabled;
  139399. private _fxaaEnabled;
  139400. private _screenSpaceReflectionsEnabled;
  139401. private _motionBlurSamples;
  139402. private _volumetricLightStepsCount;
  139403. private _samples;
  139404. /**
  139405. * @ignore
  139406. * Specifies if the bloom pipeline is enabled
  139407. */
  139408. get BloomEnabled(): boolean;
  139409. set BloomEnabled(enabled: boolean);
  139410. /**
  139411. * @ignore
  139412. * Specifies if the depth of field pipeline is enabed
  139413. */
  139414. get DepthOfFieldEnabled(): boolean;
  139415. set DepthOfFieldEnabled(enabled: boolean);
  139416. /**
  139417. * @ignore
  139418. * Specifies if the lens flare pipeline is enabed
  139419. */
  139420. get LensFlareEnabled(): boolean;
  139421. set LensFlareEnabled(enabled: boolean);
  139422. /**
  139423. * @ignore
  139424. * Specifies if the HDR pipeline is enabled
  139425. */
  139426. get HDREnabled(): boolean;
  139427. set HDREnabled(enabled: boolean);
  139428. /**
  139429. * @ignore
  139430. * Specifies if the volumetric lights scattering effect is enabled
  139431. */
  139432. get VLSEnabled(): boolean;
  139433. set VLSEnabled(enabled: boolean);
  139434. /**
  139435. * @ignore
  139436. * Specifies if the motion blur effect is enabled
  139437. */
  139438. get MotionBlurEnabled(): boolean;
  139439. set MotionBlurEnabled(enabled: boolean);
  139440. /**
  139441. * Specifies if anti-aliasing is enabled
  139442. */
  139443. get fxaaEnabled(): boolean;
  139444. set fxaaEnabled(enabled: boolean);
  139445. /**
  139446. * Specifies if screen space reflections are enabled.
  139447. */
  139448. get screenSpaceReflectionsEnabled(): boolean;
  139449. set screenSpaceReflectionsEnabled(enabled: boolean);
  139450. /**
  139451. * Specifies the number of steps used to calculate the volumetric lights
  139452. * Typically in interval [50, 200]
  139453. */
  139454. get volumetricLightStepsCount(): number;
  139455. set volumetricLightStepsCount(count: number);
  139456. /**
  139457. * Specifies the number of samples used for the motion blur effect
  139458. * Typically in interval [16, 64]
  139459. */
  139460. get motionBlurSamples(): number;
  139461. set motionBlurSamples(samples: number);
  139462. /**
  139463. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139464. */
  139465. get samples(): number;
  139466. set samples(sampleCount: number);
  139467. /**
  139468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139469. * @constructor
  139470. * @param name The rendering pipeline name
  139471. * @param scene The scene linked to this pipeline
  139472. * @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)
  139473. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139474. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139475. */
  139476. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139477. private _buildPipeline;
  139478. private _createDownSampleX4PostProcess;
  139479. private _createBrightPassPostProcess;
  139480. private _createBlurPostProcesses;
  139481. private _createTextureAdderPostProcess;
  139482. private _createVolumetricLightPostProcess;
  139483. private _createLuminancePostProcesses;
  139484. private _createHdrPostProcess;
  139485. private _createLensFlarePostProcess;
  139486. private _createDepthOfFieldPostProcess;
  139487. private _createMotionBlurPostProcess;
  139488. private _getDepthTexture;
  139489. private _disposePostProcesses;
  139490. /**
  139491. * Dispose of the pipeline and stop all post processes
  139492. */
  139493. dispose(): void;
  139494. /**
  139495. * Serialize the rendering pipeline (Used when exporting)
  139496. * @returns the serialized object
  139497. */
  139498. serialize(): any;
  139499. /**
  139500. * Parse the serialized pipeline
  139501. * @param source Source pipeline.
  139502. * @param scene The scene to load the pipeline to.
  139503. * @param rootUrl The URL of the serialized pipeline.
  139504. * @returns An instantiated pipeline from the serialized object.
  139505. */
  139506. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139507. /**
  139508. * Luminance steps
  139509. */
  139510. static LuminanceSteps: number;
  139511. }
  139512. }
  139513. declare module BABYLON {
  139514. /** @hidden */
  139515. export var tonemapPixelShader: {
  139516. name: string;
  139517. shader: string;
  139518. };
  139519. }
  139520. declare module BABYLON {
  139521. /** Defines operator used for tonemapping */
  139522. export enum TonemappingOperator {
  139523. /** Hable */
  139524. Hable = 0,
  139525. /** Reinhard */
  139526. Reinhard = 1,
  139527. /** HejiDawson */
  139528. HejiDawson = 2,
  139529. /** Photographic */
  139530. Photographic = 3
  139531. }
  139532. /**
  139533. * Defines a post process to apply tone mapping
  139534. */
  139535. export class TonemapPostProcess extends PostProcess {
  139536. private _operator;
  139537. /** Defines the required exposure adjustement */
  139538. exposureAdjustment: number;
  139539. /**
  139540. * Creates a new TonemapPostProcess
  139541. * @param name defines the name of the postprocess
  139542. * @param _operator defines the operator to use
  139543. * @param exposureAdjustment defines the required exposure adjustement
  139544. * @param camera defines the camera to use (can be null)
  139545. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139546. * @param engine defines the hosting engine (can be ignore if camera is set)
  139547. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139548. */
  139549. constructor(name: string, _operator: TonemappingOperator,
  139550. /** Defines the required exposure adjustement */
  139551. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139552. }
  139553. }
  139554. declare module BABYLON {
  139555. /** @hidden */
  139556. export var volumetricLightScatteringPixelShader: {
  139557. name: string;
  139558. shader: string;
  139559. };
  139560. }
  139561. declare module BABYLON {
  139562. /** @hidden */
  139563. export var volumetricLightScatteringPassVertexShader: {
  139564. name: string;
  139565. shader: string;
  139566. };
  139567. }
  139568. declare module BABYLON {
  139569. /** @hidden */
  139570. export var volumetricLightScatteringPassPixelShader: {
  139571. name: string;
  139572. shader: string;
  139573. };
  139574. }
  139575. declare module BABYLON {
  139576. /**
  139577. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139578. */
  139579. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139580. private _volumetricLightScatteringPass;
  139581. private _volumetricLightScatteringRTT;
  139582. private _viewPort;
  139583. private _screenCoordinates;
  139584. private _cachedDefines;
  139585. /**
  139586. * If not undefined, the mesh position is computed from the attached node position
  139587. */
  139588. attachedNode: {
  139589. position: Vector3;
  139590. };
  139591. /**
  139592. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139593. */
  139594. customMeshPosition: Vector3;
  139595. /**
  139596. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139597. */
  139598. useCustomMeshPosition: boolean;
  139599. /**
  139600. * If the post-process should inverse the light scattering direction
  139601. */
  139602. invert: boolean;
  139603. /**
  139604. * The internal mesh used by the post-process
  139605. */
  139606. mesh: Mesh;
  139607. /**
  139608. * @hidden
  139609. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139610. */
  139611. get useDiffuseColor(): boolean;
  139612. set useDiffuseColor(useDiffuseColor: boolean);
  139613. /**
  139614. * Array containing the excluded meshes not rendered in the internal pass
  139615. */
  139616. excludedMeshes: AbstractMesh[];
  139617. /**
  139618. * Controls the overall intensity of the post-process
  139619. */
  139620. exposure: number;
  139621. /**
  139622. * Dissipates each sample's contribution in range [0, 1]
  139623. */
  139624. decay: number;
  139625. /**
  139626. * Controls the overall intensity of each sample
  139627. */
  139628. weight: number;
  139629. /**
  139630. * Controls the density of each sample
  139631. */
  139632. density: number;
  139633. /**
  139634. * @constructor
  139635. * @param name The post-process name
  139636. * @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)
  139637. * @param camera The camera that the post-process will be attached to
  139638. * @param mesh The mesh used to create the light scattering
  139639. * @param samples The post-process quality, default 100
  139640. * @param samplingModeThe post-process filtering mode
  139641. * @param engine The babylon engine
  139642. * @param reusable If the post-process is reusable
  139643. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139644. */
  139645. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139646. /**
  139647. * Returns the string "VolumetricLightScatteringPostProcess"
  139648. * @returns "VolumetricLightScatteringPostProcess"
  139649. */
  139650. getClassName(): string;
  139651. private _isReady;
  139652. /**
  139653. * Sets the new light position for light scattering effect
  139654. * @param position The new custom light position
  139655. */
  139656. setCustomMeshPosition(position: Vector3): void;
  139657. /**
  139658. * Returns the light position for light scattering effect
  139659. * @return Vector3 The custom light position
  139660. */
  139661. getCustomMeshPosition(): Vector3;
  139662. /**
  139663. * Disposes the internal assets and detaches the post-process from the camera
  139664. */
  139665. dispose(camera: Camera): void;
  139666. /**
  139667. * Returns the render target texture used by the post-process
  139668. * @return the render target texture used by the post-process
  139669. */
  139670. getPass(): RenderTargetTexture;
  139671. private _meshExcluded;
  139672. private _createPass;
  139673. private _updateMeshScreenCoordinates;
  139674. /**
  139675. * Creates a default mesh for the Volumeric Light Scattering post-process
  139676. * @param name The mesh name
  139677. * @param scene The scene where to create the mesh
  139678. * @return the default mesh
  139679. */
  139680. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139681. }
  139682. }
  139683. declare module BABYLON {
  139684. interface Scene {
  139685. /** @hidden (Backing field) */
  139686. _boundingBoxRenderer: BoundingBoxRenderer;
  139687. /** @hidden (Backing field) */
  139688. _forceShowBoundingBoxes: boolean;
  139689. /**
  139690. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139691. */
  139692. forceShowBoundingBoxes: boolean;
  139693. /**
  139694. * Gets the bounding box renderer associated with the scene
  139695. * @returns a BoundingBoxRenderer
  139696. */
  139697. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139698. }
  139699. interface AbstractMesh {
  139700. /** @hidden (Backing field) */
  139701. _showBoundingBox: boolean;
  139702. /**
  139703. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139704. */
  139705. showBoundingBox: boolean;
  139706. }
  139707. /**
  139708. * Component responsible of rendering the bounding box of the meshes in a scene.
  139709. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139710. */
  139711. export class BoundingBoxRenderer implements ISceneComponent {
  139712. /**
  139713. * The component name helpfull to identify the component in the list of scene components.
  139714. */
  139715. readonly name: string;
  139716. /**
  139717. * The scene the component belongs to.
  139718. */
  139719. scene: Scene;
  139720. /**
  139721. * Color of the bounding box lines placed in front of an object
  139722. */
  139723. frontColor: Color3;
  139724. /**
  139725. * Color of the bounding box lines placed behind an object
  139726. */
  139727. backColor: Color3;
  139728. /**
  139729. * Defines if the renderer should show the back lines or not
  139730. */
  139731. showBackLines: boolean;
  139732. /**
  139733. * @hidden
  139734. */
  139735. renderList: SmartArray<BoundingBox>;
  139736. private _colorShader;
  139737. private _vertexBuffers;
  139738. private _indexBuffer;
  139739. private _fillIndexBuffer;
  139740. private _fillIndexData;
  139741. /**
  139742. * Instantiates a new bounding box renderer in a scene.
  139743. * @param scene the scene the renderer renders in
  139744. */
  139745. constructor(scene: Scene);
  139746. /**
  139747. * Registers the component in a given scene
  139748. */
  139749. register(): void;
  139750. private _evaluateSubMesh;
  139751. private _activeMesh;
  139752. private _prepareRessources;
  139753. private _createIndexBuffer;
  139754. /**
  139755. * Rebuilds the elements related to this component in case of
  139756. * context lost for instance.
  139757. */
  139758. rebuild(): void;
  139759. /**
  139760. * @hidden
  139761. */
  139762. reset(): void;
  139763. /**
  139764. * Render the bounding boxes of a specific rendering group
  139765. * @param renderingGroupId defines the rendering group to render
  139766. */
  139767. render(renderingGroupId: number): void;
  139768. /**
  139769. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139770. * @param mesh Define the mesh to render the occlusion bounding box for
  139771. */
  139772. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139773. /**
  139774. * Dispose and release the resources attached to this renderer.
  139775. */
  139776. dispose(): void;
  139777. }
  139778. }
  139779. declare module BABYLON {
  139780. interface Scene {
  139781. /** @hidden (Backing field) */
  139782. _depthRenderer: {
  139783. [id: string]: DepthRenderer;
  139784. };
  139785. /**
  139786. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139787. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139788. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139789. * @returns the created depth renderer
  139790. */
  139791. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139792. /**
  139793. * Disables a depth renderer for a given camera
  139794. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139795. */
  139796. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139797. }
  139798. /**
  139799. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139800. * in several rendering techniques.
  139801. */
  139802. export class DepthRendererSceneComponent implements ISceneComponent {
  139803. /**
  139804. * The component name helpfull to identify the component in the list of scene components.
  139805. */
  139806. readonly name: string;
  139807. /**
  139808. * The scene the component belongs to.
  139809. */
  139810. scene: Scene;
  139811. /**
  139812. * Creates a new instance of the component for the given scene
  139813. * @param scene Defines the scene to register the component in
  139814. */
  139815. constructor(scene: Scene);
  139816. /**
  139817. * Registers the component in a given scene
  139818. */
  139819. register(): void;
  139820. /**
  139821. * Rebuilds the elements related to this component in case of
  139822. * context lost for instance.
  139823. */
  139824. rebuild(): void;
  139825. /**
  139826. * Disposes the component and the associated ressources
  139827. */
  139828. dispose(): void;
  139829. private _gatherRenderTargets;
  139830. private _gatherActiveCameraRenderTargets;
  139831. }
  139832. }
  139833. declare module BABYLON {
  139834. /** @hidden */
  139835. export var outlinePixelShader: {
  139836. name: string;
  139837. shader: string;
  139838. };
  139839. }
  139840. declare module BABYLON {
  139841. /** @hidden */
  139842. export var outlineVertexShader: {
  139843. name: string;
  139844. shader: string;
  139845. };
  139846. }
  139847. declare module BABYLON {
  139848. interface Scene {
  139849. /** @hidden */
  139850. _outlineRenderer: OutlineRenderer;
  139851. /**
  139852. * Gets the outline renderer associated with the scene
  139853. * @returns a OutlineRenderer
  139854. */
  139855. getOutlineRenderer(): OutlineRenderer;
  139856. }
  139857. interface AbstractMesh {
  139858. /** @hidden (Backing field) */
  139859. _renderOutline: boolean;
  139860. /**
  139861. * Gets or sets a boolean indicating if the outline must be rendered as well
  139862. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139863. */
  139864. renderOutline: boolean;
  139865. /** @hidden (Backing field) */
  139866. _renderOverlay: boolean;
  139867. /**
  139868. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139869. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139870. */
  139871. renderOverlay: boolean;
  139872. }
  139873. /**
  139874. * This class is responsible to draw bothe outline/overlay of meshes.
  139875. * It should not be used directly but through the available method on mesh.
  139876. */
  139877. export class OutlineRenderer implements ISceneComponent {
  139878. /**
  139879. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139880. */
  139881. private static _StencilReference;
  139882. /**
  139883. * The name of the component. Each component must have a unique name.
  139884. */
  139885. name: string;
  139886. /**
  139887. * The scene the component belongs to.
  139888. */
  139889. scene: Scene;
  139890. /**
  139891. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139892. */
  139893. zOffset: number;
  139894. private _engine;
  139895. private _effect;
  139896. private _cachedDefines;
  139897. private _savedDepthWrite;
  139898. /**
  139899. * Instantiates a new outline renderer. (There could be only one per scene).
  139900. * @param scene Defines the scene it belongs to
  139901. */
  139902. constructor(scene: Scene);
  139903. /**
  139904. * Register the component to one instance of a scene.
  139905. */
  139906. register(): void;
  139907. /**
  139908. * Rebuilds the elements related to this component in case of
  139909. * context lost for instance.
  139910. */
  139911. rebuild(): void;
  139912. /**
  139913. * Disposes the component and the associated ressources.
  139914. */
  139915. dispose(): void;
  139916. /**
  139917. * Renders the outline in the canvas.
  139918. * @param subMesh Defines the sumesh to render
  139919. * @param batch Defines the batch of meshes in case of instances
  139920. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139921. */
  139922. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139923. /**
  139924. * Returns whether or not the outline renderer is ready for a given submesh.
  139925. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139926. * @param subMesh Defines the submesh to check readyness for
  139927. * @param useInstances Defines wheter wee are trying to render instances or not
  139928. * @returns true if ready otherwise false
  139929. */
  139930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139931. private _beforeRenderingMesh;
  139932. private _afterRenderingMesh;
  139933. }
  139934. }
  139935. declare module BABYLON {
  139936. /**
  139937. * Defines the basic options interface of a Sprite Frame Source Size.
  139938. */
  139939. export interface ISpriteJSONSpriteSourceSize {
  139940. /**
  139941. * number of the original width of the Frame
  139942. */
  139943. w: number;
  139944. /**
  139945. * number of the original height of the Frame
  139946. */
  139947. h: number;
  139948. }
  139949. /**
  139950. * Defines the basic options interface of a Sprite Frame Data.
  139951. */
  139952. export interface ISpriteJSONSpriteFrameData {
  139953. /**
  139954. * number of the x offset of the Frame
  139955. */
  139956. x: number;
  139957. /**
  139958. * number of the y offset of the Frame
  139959. */
  139960. y: number;
  139961. /**
  139962. * number of the width of the Frame
  139963. */
  139964. w: number;
  139965. /**
  139966. * number of the height of the Frame
  139967. */
  139968. h: number;
  139969. }
  139970. /**
  139971. * Defines the basic options interface of a JSON Sprite.
  139972. */
  139973. export interface ISpriteJSONSprite {
  139974. /**
  139975. * string name of the Frame
  139976. */
  139977. filename: string;
  139978. /**
  139979. * ISpriteJSONSpriteFrame basic object of the frame data
  139980. */
  139981. frame: ISpriteJSONSpriteFrameData;
  139982. /**
  139983. * boolean to flag is the frame was rotated.
  139984. */
  139985. rotated: boolean;
  139986. /**
  139987. * boolean to flag is the frame was trimmed.
  139988. */
  139989. trimmed: boolean;
  139990. /**
  139991. * ISpriteJSONSpriteFrame basic object of the source data
  139992. */
  139993. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139994. /**
  139995. * ISpriteJSONSpriteFrame basic object of the source data
  139996. */
  139997. sourceSize: ISpriteJSONSpriteSourceSize;
  139998. }
  139999. /**
  140000. * Defines the basic options interface of a JSON atlas.
  140001. */
  140002. export interface ISpriteJSONAtlas {
  140003. /**
  140004. * Array of objects that contain the frame data.
  140005. */
  140006. frames: Array<ISpriteJSONSprite>;
  140007. /**
  140008. * object basic object containing the sprite meta data.
  140009. */
  140010. meta?: object;
  140011. }
  140012. }
  140013. declare module BABYLON {
  140014. /** @hidden */
  140015. export var spriteMapPixelShader: {
  140016. name: string;
  140017. shader: string;
  140018. };
  140019. }
  140020. declare module BABYLON {
  140021. /** @hidden */
  140022. export var spriteMapVertexShader: {
  140023. name: string;
  140024. shader: string;
  140025. };
  140026. }
  140027. declare module BABYLON {
  140028. /**
  140029. * Defines the basic options interface of a SpriteMap
  140030. */
  140031. export interface ISpriteMapOptions {
  140032. /**
  140033. * Vector2 of the number of cells in the grid.
  140034. */
  140035. stageSize?: Vector2;
  140036. /**
  140037. * Vector2 of the size of the output plane in World Units.
  140038. */
  140039. outputSize?: Vector2;
  140040. /**
  140041. * Vector3 of the position of the output plane in World Units.
  140042. */
  140043. outputPosition?: Vector3;
  140044. /**
  140045. * Vector3 of the rotation of the output plane.
  140046. */
  140047. outputRotation?: Vector3;
  140048. /**
  140049. * number of layers that the system will reserve in resources.
  140050. */
  140051. layerCount?: number;
  140052. /**
  140053. * number of max animation frames a single cell will reserve in resources.
  140054. */
  140055. maxAnimationFrames?: number;
  140056. /**
  140057. * number cell index of the base tile when the system compiles.
  140058. */
  140059. baseTile?: number;
  140060. /**
  140061. * boolean flip the sprite after its been repositioned by the framing data.
  140062. */
  140063. flipU?: boolean;
  140064. /**
  140065. * Vector3 scalar of the global RGB values of the SpriteMap.
  140066. */
  140067. colorMultiply?: Vector3;
  140068. }
  140069. /**
  140070. * Defines the IDisposable interface in order to be cleanable from resources.
  140071. */
  140072. export interface ISpriteMap extends IDisposable {
  140073. /**
  140074. * String name of the SpriteMap.
  140075. */
  140076. name: string;
  140077. /**
  140078. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140079. */
  140080. atlasJSON: ISpriteJSONAtlas;
  140081. /**
  140082. * Texture of the SpriteMap.
  140083. */
  140084. spriteSheet: Texture;
  140085. /**
  140086. * The parameters to initialize the SpriteMap with.
  140087. */
  140088. options: ISpriteMapOptions;
  140089. }
  140090. /**
  140091. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140092. */
  140093. export class SpriteMap implements ISpriteMap {
  140094. /** The Name of the spriteMap */
  140095. name: string;
  140096. /** The JSON file with the frame and meta data */
  140097. atlasJSON: ISpriteJSONAtlas;
  140098. /** The systems Sprite Sheet Texture */
  140099. spriteSheet: Texture;
  140100. /** Arguments passed with the Constructor */
  140101. options: ISpriteMapOptions;
  140102. /** Public Sprite Storage array, parsed from atlasJSON */
  140103. sprites: Array<ISpriteJSONSprite>;
  140104. /** Returns the Number of Sprites in the System */
  140105. get spriteCount(): number;
  140106. /** Returns the Position of Output Plane*/
  140107. get position(): Vector3;
  140108. /** Returns the Position of Output Plane*/
  140109. set position(v: Vector3);
  140110. /** Returns the Rotation of Output Plane*/
  140111. get rotation(): Vector3;
  140112. /** Returns the Rotation of Output Plane*/
  140113. set rotation(v: Vector3);
  140114. /** Sets the AnimationMap*/
  140115. get animationMap(): RawTexture;
  140116. /** Sets the AnimationMap*/
  140117. set animationMap(v: RawTexture);
  140118. /** Scene that the SpriteMap was created in */
  140119. private _scene;
  140120. /** Texture Buffer of Float32 that holds tile frame data*/
  140121. private _frameMap;
  140122. /** Texture Buffers of Float32 that holds tileMap data*/
  140123. private _tileMaps;
  140124. /** Texture Buffer of Float32 that holds Animation Data*/
  140125. private _animationMap;
  140126. /** Custom ShaderMaterial Central to the System*/
  140127. private _material;
  140128. /** Custom ShaderMaterial Central to the System*/
  140129. private _output;
  140130. /** Systems Time Ticker*/
  140131. private _time;
  140132. /**
  140133. * Creates a new SpriteMap
  140134. * @param name defines the SpriteMaps Name
  140135. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140136. * @param spriteSheet is the Texture that the Sprites are on.
  140137. * @param options a basic deployment configuration
  140138. * @param scene The Scene that the map is deployed on
  140139. */
  140140. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140141. /**
  140142. * Returns tileID location
  140143. * @returns Vector2 the cell position ID
  140144. */
  140145. getTileID(): Vector2;
  140146. /**
  140147. * Gets the UV location of the mouse over the SpriteMap.
  140148. * @returns Vector2 the UV position of the mouse interaction
  140149. */
  140150. getMousePosition(): Vector2;
  140151. /**
  140152. * Creates the "frame" texture Buffer
  140153. * -------------------------------------
  140154. * Structure of frames
  140155. * "filename": "Falling-Water-2.png",
  140156. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140157. * "rotated": true,
  140158. * "trimmed": true,
  140159. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140160. * "sourceSize": {"w":32,"h":32}
  140161. * @returns RawTexture of the frameMap
  140162. */
  140163. private _createFrameBuffer;
  140164. /**
  140165. * Creates the tileMap texture Buffer
  140166. * @param buffer normally and array of numbers, or a false to generate from scratch
  140167. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140168. * @returns RawTexture of the tileMap
  140169. */
  140170. private _createTileBuffer;
  140171. /**
  140172. * Modifies the data of the tileMaps
  140173. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140174. * @param pos is the iVector2 Coordinates of the Tile
  140175. * @param tile The SpriteIndex of the new Tile
  140176. */
  140177. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140178. /**
  140179. * Creates the animationMap texture Buffer
  140180. * @param buffer normally and array of numbers, or a false to generate from scratch
  140181. * @returns RawTexture of the animationMap
  140182. */
  140183. private _createTileAnimationBuffer;
  140184. /**
  140185. * Modifies the data of the animationMap
  140186. * @param cellID is the Index of the Sprite
  140187. * @param _frame is the target Animation frame
  140188. * @param toCell is the Target Index of the next frame of the animation
  140189. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140190. * @param speed is a global scalar of the time variable on the map.
  140191. */
  140192. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140193. /**
  140194. * Exports the .tilemaps file
  140195. */
  140196. saveTileMaps(): void;
  140197. /**
  140198. * Imports the .tilemaps file
  140199. * @param url of the .tilemaps file
  140200. */
  140201. loadTileMaps(url: string): void;
  140202. /**
  140203. * Release associated resources
  140204. */
  140205. dispose(): void;
  140206. }
  140207. }
  140208. declare module BABYLON {
  140209. /**
  140210. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140211. * @see http://doc.babylonjs.com/babylon101/sprites
  140212. */
  140213. export class SpritePackedManager extends SpriteManager {
  140214. /** defines the packed manager's name */
  140215. name: string;
  140216. /**
  140217. * Creates a new sprite manager from a packed sprite sheet
  140218. * @param name defines the manager's name
  140219. * @param imgUrl defines the sprite sheet url
  140220. * @param capacity defines the maximum allowed number of sprites
  140221. * @param scene defines the hosting scene
  140222. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140223. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140224. * @param samplingMode defines the smapling mode to use with spritesheet
  140225. * @param fromPacked set to true; do not alter
  140226. */
  140227. constructor(
  140228. /** defines the packed manager's name */
  140229. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140230. }
  140231. }
  140232. declare module BABYLON {
  140233. /**
  140234. * Defines the list of states available for a task inside a AssetsManager
  140235. */
  140236. export enum AssetTaskState {
  140237. /**
  140238. * Initialization
  140239. */
  140240. INIT = 0,
  140241. /**
  140242. * Running
  140243. */
  140244. RUNNING = 1,
  140245. /**
  140246. * Done
  140247. */
  140248. DONE = 2,
  140249. /**
  140250. * Error
  140251. */
  140252. ERROR = 3
  140253. }
  140254. /**
  140255. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140256. */
  140257. export abstract class AbstractAssetTask {
  140258. /**
  140259. * Task name
  140260. */ name: string;
  140261. /**
  140262. * Callback called when the task is successful
  140263. */
  140264. onSuccess: (task: any) => void;
  140265. /**
  140266. * Callback called when the task is not successful
  140267. */
  140268. onError: (task: any, message?: string, exception?: any) => void;
  140269. /**
  140270. * Creates a new AssetsManager
  140271. * @param name defines the name of the task
  140272. */
  140273. constructor(
  140274. /**
  140275. * Task name
  140276. */ name: string);
  140277. private _isCompleted;
  140278. private _taskState;
  140279. private _errorObject;
  140280. /**
  140281. * Get if the task is completed
  140282. */
  140283. get isCompleted(): boolean;
  140284. /**
  140285. * Gets the current state of the task
  140286. */
  140287. get taskState(): AssetTaskState;
  140288. /**
  140289. * Gets the current error object (if task is in error)
  140290. */
  140291. get errorObject(): {
  140292. message?: string;
  140293. exception?: any;
  140294. };
  140295. /**
  140296. * Internal only
  140297. * @hidden
  140298. */
  140299. _setErrorObject(message?: string, exception?: any): void;
  140300. /**
  140301. * Execute the current task
  140302. * @param scene defines the scene where you want your assets to be loaded
  140303. * @param onSuccess is a callback called when the task is successfully executed
  140304. * @param onError is a callback called if an error occurs
  140305. */
  140306. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140307. /**
  140308. * Execute the current task
  140309. * @param scene defines the scene where you want your assets to be loaded
  140310. * @param onSuccess is a callback called when the task is successfully executed
  140311. * @param onError is a callback called if an error occurs
  140312. */
  140313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140314. /**
  140315. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140316. * This can be used with failed tasks that have the reason for failure fixed.
  140317. */
  140318. reset(): void;
  140319. private onErrorCallback;
  140320. private onDoneCallback;
  140321. }
  140322. /**
  140323. * Define the interface used by progress events raised during assets loading
  140324. */
  140325. export interface IAssetsProgressEvent {
  140326. /**
  140327. * Defines the number of remaining tasks to process
  140328. */
  140329. remainingCount: number;
  140330. /**
  140331. * Defines the total number of tasks
  140332. */
  140333. totalCount: number;
  140334. /**
  140335. * Defines the task that was just processed
  140336. */
  140337. task: AbstractAssetTask;
  140338. }
  140339. /**
  140340. * Class used to share progress information about assets loading
  140341. */
  140342. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140343. /**
  140344. * Defines the number of remaining tasks to process
  140345. */
  140346. remainingCount: number;
  140347. /**
  140348. * Defines the total number of tasks
  140349. */
  140350. totalCount: number;
  140351. /**
  140352. * Defines the task that was just processed
  140353. */
  140354. task: AbstractAssetTask;
  140355. /**
  140356. * Creates a AssetsProgressEvent
  140357. * @param remainingCount defines the number of remaining tasks to process
  140358. * @param totalCount defines the total number of tasks
  140359. * @param task defines the task that was just processed
  140360. */
  140361. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140362. }
  140363. /**
  140364. * Define a task used by AssetsManager to load meshes
  140365. */
  140366. export class MeshAssetTask extends AbstractAssetTask {
  140367. /**
  140368. * Defines the name of the task
  140369. */
  140370. name: string;
  140371. /**
  140372. * Defines the list of mesh's names you want to load
  140373. */
  140374. meshesNames: any;
  140375. /**
  140376. * Defines the root url to use as a base to load your meshes and associated resources
  140377. */
  140378. rootUrl: string;
  140379. /**
  140380. * Defines the filename of the scene to load from
  140381. */
  140382. sceneFilename: string;
  140383. /**
  140384. * Gets the list of loaded meshes
  140385. */
  140386. loadedMeshes: Array<AbstractMesh>;
  140387. /**
  140388. * Gets the list of loaded particle systems
  140389. */
  140390. loadedParticleSystems: Array<IParticleSystem>;
  140391. /**
  140392. * Gets the list of loaded skeletons
  140393. */
  140394. loadedSkeletons: Array<Skeleton>;
  140395. /**
  140396. * Gets the list of loaded animation groups
  140397. */
  140398. loadedAnimationGroups: Array<AnimationGroup>;
  140399. /**
  140400. * Callback called when the task is successful
  140401. */
  140402. onSuccess: (task: MeshAssetTask) => void;
  140403. /**
  140404. * Callback called when the task is successful
  140405. */
  140406. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140407. /**
  140408. * Creates a new MeshAssetTask
  140409. * @param name defines the name of the task
  140410. * @param meshesNames defines the list of mesh's names you want to load
  140411. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140412. * @param sceneFilename defines the filename of the scene to load from
  140413. */
  140414. constructor(
  140415. /**
  140416. * Defines the name of the task
  140417. */
  140418. name: string,
  140419. /**
  140420. * Defines the list of mesh's names you want to load
  140421. */
  140422. meshesNames: any,
  140423. /**
  140424. * Defines the root url to use as a base to load your meshes and associated resources
  140425. */
  140426. rootUrl: string,
  140427. /**
  140428. * Defines the filename of the scene to load from
  140429. */
  140430. sceneFilename: string);
  140431. /**
  140432. * Execute the current task
  140433. * @param scene defines the scene where you want your assets to be loaded
  140434. * @param onSuccess is a callback called when the task is successfully executed
  140435. * @param onError is a callback called if an error occurs
  140436. */
  140437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140438. }
  140439. /**
  140440. * Define a task used by AssetsManager to load text content
  140441. */
  140442. export class TextFileAssetTask extends AbstractAssetTask {
  140443. /**
  140444. * Defines the name of the task
  140445. */
  140446. name: string;
  140447. /**
  140448. * Defines the location of the file to load
  140449. */
  140450. url: string;
  140451. /**
  140452. * Gets the loaded text string
  140453. */
  140454. text: string;
  140455. /**
  140456. * Callback called when the task is successful
  140457. */
  140458. onSuccess: (task: TextFileAssetTask) => void;
  140459. /**
  140460. * Callback called when the task is successful
  140461. */
  140462. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140463. /**
  140464. * Creates a new TextFileAssetTask object
  140465. * @param name defines the name of the task
  140466. * @param url defines the location of the file to load
  140467. */
  140468. constructor(
  140469. /**
  140470. * Defines the name of the task
  140471. */
  140472. name: string,
  140473. /**
  140474. * Defines the location of the file to load
  140475. */
  140476. url: string);
  140477. /**
  140478. * Execute the current task
  140479. * @param scene defines the scene where you want your assets to be loaded
  140480. * @param onSuccess is a callback called when the task is successfully executed
  140481. * @param onError is a callback called if an error occurs
  140482. */
  140483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140484. }
  140485. /**
  140486. * Define a task used by AssetsManager to load binary data
  140487. */
  140488. export class BinaryFileAssetTask extends AbstractAssetTask {
  140489. /**
  140490. * Defines the name of the task
  140491. */
  140492. name: string;
  140493. /**
  140494. * Defines the location of the file to load
  140495. */
  140496. url: string;
  140497. /**
  140498. * Gets the lodaded data (as an array buffer)
  140499. */
  140500. data: ArrayBuffer;
  140501. /**
  140502. * Callback called when the task is successful
  140503. */
  140504. onSuccess: (task: BinaryFileAssetTask) => void;
  140505. /**
  140506. * Callback called when the task is successful
  140507. */
  140508. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140509. /**
  140510. * Creates a new BinaryFileAssetTask object
  140511. * @param name defines the name of the new task
  140512. * @param url defines the location of the file to load
  140513. */
  140514. constructor(
  140515. /**
  140516. * Defines the name of the task
  140517. */
  140518. name: string,
  140519. /**
  140520. * Defines the location of the file to load
  140521. */
  140522. url: string);
  140523. /**
  140524. * Execute the current task
  140525. * @param scene defines the scene where you want your assets to be loaded
  140526. * @param onSuccess is a callback called when the task is successfully executed
  140527. * @param onError is a callback called if an error occurs
  140528. */
  140529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140530. }
  140531. /**
  140532. * Define a task used by AssetsManager to load images
  140533. */
  140534. export class ImageAssetTask extends AbstractAssetTask {
  140535. /**
  140536. * Defines the name of the task
  140537. */
  140538. name: string;
  140539. /**
  140540. * Defines the location of the image to load
  140541. */
  140542. url: string;
  140543. /**
  140544. * Gets the loaded images
  140545. */
  140546. image: HTMLImageElement;
  140547. /**
  140548. * Callback called when the task is successful
  140549. */
  140550. onSuccess: (task: ImageAssetTask) => void;
  140551. /**
  140552. * Callback called when the task is successful
  140553. */
  140554. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140555. /**
  140556. * Creates a new ImageAssetTask
  140557. * @param name defines the name of the task
  140558. * @param url defines the location of the image to load
  140559. */
  140560. constructor(
  140561. /**
  140562. * Defines the name of the task
  140563. */
  140564. name: string,
  140565. /**
  140566. * Defines the location of the image to load
  140567. */
  140568. url: string);
  140569. /**
  140570. * Execute the current task
  140571. * @param scene defines the scene where you want your assets to be loaded
  140572. * @param onSuccess is a callback called when the task is successfully executed
  140573. * @param onError is a callback called if an error occurs
  140574. */
  140575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140576. }
  140577. /**
  140578. * Defines the interface used by texture loading tasks
  140579. */
  140580. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140581. /**
  140582. * Gets the loaded texture
  140583. */
  140584. texture: TEX;
  140585. }
  140586. /**
  140587. * Define a task used by AssetsManager to load 2D textures
  140588. */
  140589. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140590. /**
  140591. * Defines the name of the task
  140592. */
  140593. name: string;
  140594. /**
  140595. * Defines the location of the file to load
  140596. */
  140597. url: string;
  140598. /**
  140599. * Defines if mipmap should not be generated (default is false)
  140600. */
  140601. noMipmap?: boolean | undefined;
  140602. /**
  140603. * Defines if texture must be inverted on Y axis (default is false)
  140604. */
  140605. invertY?: boolean | undefined;
  140606. /**
  140607. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140608. */
  140609. samplingMode: number;
  140610. /**
  140611. * Gets the loaded texture
  140612. */
  140613. texture: Texture;
  140614. /**
  140615. * Callback called when the task is successful
  140616. */
  140617. onSuccess: (task: TextureAssetTask) => void;
  140618. /**
  140619. * Callback called when the task is successful
  140620. */
  140621. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140622. /**
  140623. * Creates a new TextureAssetTask object
  140624. * @param name defines the name of the task
  140625. * @param url defines the location of the file to load
  140626. * @param noMipmap defines if mipmap should not be generated (default is false)
  140627. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140628. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140629. */
  140630. constructor(
  140631. /**
  140632. * Defines the name of the task
  140633. */
  140634. name: string,
  140635. /**
  140636. * Defines the location of the file to load
  140637. */
  140638. url: string,
  140639. /**
  140640. * Defines if mipmap should not be generated (default is false)
  140641. */
  140642. noMipmap?: boolean | undefined,
  140643. /**
  140644. * Defines if texture must be inverted on Y axis (default is false)
  140645. */
  140646. invertY?: boolean | undefined,
  140647. /**
  140648. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140649. */
  140650. samplingMode?: number);
  140651. /**
  140652. * Execute the current task
  140653. * @param scene defines the scene where you want your assets to be loaded
  140654. * @param onSuccess is a callback called when the task is successfully executed
  140655. * @param onError is a callback called if an error occurs
  140656. */
  140657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140658. }
  140659. /**
  140660. * Define a task used by AssetsManager to load cube textures
  140661. */
  140662. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140663. /**
  140664. * Defines the name of the task
  140665. */
  140666. name: string;
  140667. /**
  140668. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140669. */
  140670. url: string;
  140671. /**
  140672. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140673. */
  140674. extensions?: string[] | undefined;
  140675. /**
  140676. * Defines if mipmaps should not be generated (default is false)
  140677. */
  140678. noMipmap?: boolean | undefined;
  140679. /**
  140680. * Defines the explicit list of files (undefined by default)
  140681. */
  140682. files?: string[] | undefined;
  140683. /**
  140684. * Gets the loaded texture
  140685. */
  140686. texture: CubeTexture;
  140687. /**
  140688. * Callback called when the task is successful
  140689. */
  140690. onSuccess: (task: CubeTextureAssetTask) => void;
  140691. /**
  140692. * Callback called when the task is successful
  140693. */
  140694. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140695. /**
  140696. * Creates a new CubeTextureAssetTask
  140697. * @param name defines the name of the task
  140698. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140699. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140700. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140701. * @param files defines the explicit list of files (undefined by default)
  140702. */
  140703. constructor(
  140704. /**
  140705. * Defines the name of the task
  140706. */
  140707. name: string,
  140708. /**
  140709. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140710. */
  140711. url: string,
  140712. /**
  140713. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140714. */
  140715. extensions?: string[] | undefined,
  140716. /**
  140717. * Defines if mipmaps should not be generated (default is false)
  140718. */
  140719. noMipmap?: boolean | undefined,
  140720. /**
  140721. * Defines the explicit list of files (undefined by default)
  140722. */
  140723. files?: string[] | undefined);
  140724. /**
  140725. * Execute the current task
  140726. * @param scene defines the scene where you want your assets to be loaded
  140727. * @param onSuccess is a callback called when the task is successfully executed
  140728. * @param onError is a callback called if an error occurs
  140729. */
  140730. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140731. }
  140732. /**
  140733. * Define a task used by AssetsManager to load HDR cube textures
  140734. */
  140735. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140736. /**
  140737. * Defines the name of the task
  140738. */
  140739. name: string;
  140740. /**
  140741. * Defines the location of the file to load
  140742. */
  140743. url: string;
  140744. /**
  140745. * Defines the desired size (the more it increases the longer the generation will be)
  140746. */
  140747. size: number;
  140748. /**
  140749. * Defines if mipmaps should not be generated (default is false)
  140750. */
  140751. noMipmap: boolean;
  140752. /**
  140753. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140754. */
  140755. generateHarmonics: boolean;
  140756. /**
  140757. * 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)
  140758. */
  140759. gammaSpace: boolean;
  140760. /**
  140761. * Internal Use Only
  140762. */
  140763. reserved: boolean;
  140764. /**
  140765. * Gets the loaded texture
  140766. */
  140767. texture: HDRCubeTexture;
  140768. /**
  140769. * Callback called when the task is successful
  140770. */
  140771. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140772. /**
  140773. * Callback called when the task is successful
  140774. */
  140775. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140776. /**
  140777. * Creates a new HDRCubeTextureAssetTask object
  140778. * @param name defines the name of the task
  140779. * @param url defines the location of the file to load
  140780. * @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.
  140781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140782. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140783. * @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)
  140784. * @param reserved Internal use only
  140785. */
  140786. constructor(
  140787. /**
  140788. * Defines the name of the task
  140789. */
  140790. name: string,
  140791. /**
  140792. * Defines the location of the file to load
  140793. */
  140794. url: string,
  140795. /**
  140796. * Defines the desired size (the more it increases the longer the generation will be)
  140797. */
  140798. size: number,
  140799. /**
  140800. * Defines if mipmaps should not be generated (default is false)
  140801. */
  140802. noMipmap?: boolean,
  140803. /**
  140804. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140805. */
  140806. generateHarmonics?: boolean,
  140807. /**
  140808. * 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)
  140809. */
  140810. gammaSpace?: boolean,
  140811. /**
  140812. * Internal Use Only
  140813. */
  140814. reserved?: boolean);
  140815. /**
  140816. * Execute the current task
  140817. * @param scene defines the scene where you want your assets to be loaded
  140818. * @param onSuccess is a callback called when the task is successfully executed
  140819. * @param onError is a callback called if an error occurs
  140820. */
  140821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140822. }
  140823. /**
  140824. * Define a task used by AssetsManager to load Equirectangular cube textures
  140825. */
  140826. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140827. /**
  140828. * Defines the name of the task
  140829. */
  140830. name: string;
  140831. /**
  140832. * Defines the location of the file to load
  140833. */
  140834. url: string;
  140835. /**
  140836. * Defines the desired size (the more it increases the longer the generation will be)
  140837. */
  140838. size: number;
  140839. /**
  140840. * Defines if mipmaps should not be generated (default is false)
  140841. */
  140842. noMipmap: boolean;
  140843. /**
  140844. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140845. * but the standard material would require them in Gamma space) (default is true)
  140846. */
  140847. gammaSpace: boolean;
  140848. /**
  140849. * Gets the loaded texture
  140850. */
  140851. texture: EquiRectangularCubeTexture;
  140852. /**
  140853. * Callback called when the task is successful
  140854. */
  140855. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140856. /**
  140857. * Callback called when the task is successful
  140858. */
  140859. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140860. /**
  140861. * Creates a new EquiRectangularCubeTextureAssetTask object
  140862. * @param name defines the name of the task
  140863. * @param url defines the location of the file to load
  140864. * @param size defines the desired size (the more it increases the longer the generation will be)
  140865. * If the size is omitted this implies you are using a preprocessed cubemap.
  140866. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140867. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140868. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140869. * (default is true)
  140870. */
  140871. constructor(
  140872. /**
  140873. * Defines the name of the task
  140874. */
  140875. name: string,
  140876. /**
  140877. * Defines the location of the file to load
  140878. */
  140879. url: string,
  140880. /**
  140881. * Defines the desired size (the more it increases the longer the generation will be)
  140882. */
  140883. size: number,
  140884. /**
  140885. * Defines if mipmaps should not be generated (default is false)
  140886. */
  140887. noMipmap?: boolean,
  140888. /**
  140889. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140890. * but the standard material would require them in Gamma space) (default is true)
  140891. */
  140892. gammaSpace?: boolean);
  140893. /**
  140894. * Execute the current task
  140895. * @param scene defines the scene where you want your assets to be loaded
  140896. * @param onSuccess is a callback called when the task is successfully executed
  140897. * @param onError is a callback called if an error occurs
  140898. */
  140899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140900. }
  140901. /**
  140902. * This class can be used to easily import assets into a scene
  140903. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140904. */
  140905. export class AssetsManager {
  140906. private _scene;
  140907. private _isLoading;
  140908. protected _tasks: AbstractAssetTask[];
  140909. protected _waitingTasksCount: number;
  140910. protected _totalTasksCount: number;
  140911. /**
  140912. * Callback called when all tasks are processed
  140913. */
  140914. onFinish: (tasks: AbstractAssetTask[]) => void;
  140915. /**
  140916. * Callback called when a task is successful
  140917. */
  140918. onTaskSuccess: (task: AbstractAssetTask) => void;
  140919. /**
  140920. * Callback called when a task had an error
  140921. */
  140922. onTaskError: (task: AbstractAssetTask) => void;
  140923. /**
  140924. * Callback called when a task is done (whatever the result is)
  140925. */
  140926. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140927. /**
  140928. * Observable called when all tasks are processed
  140929. */
  140930. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140931. /**
  140932. * Observable called when a task had an error
  140933. */
  140934. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140935. /**
  140936. * Observable called when all tasks were executed
  140937. */
  140938. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140939. /**
  140940. * Observable called when a task is done (whatever the result is)
  140941. */
  140942. onProgressObservable: Observable<IAssetsProgressEvent>;
  140943. /**
  140944. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140945. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140946. */
  140947. useDefaultLoadingScreen: boolean;
  140948. /**
  140949. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140950. * when all assets have been downloaded.
  140951. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140952. */
  140953. autoHideLoadingUI: boolean;
  140954. /**
  140955. * Creates a new AssetsManager
  140956. * @param scene defines the scene to work on
  140957. */
  140958. constructor(scene: Scene);
  140959. /**
  140960. * Add a MeshAssetTask to the list of active tasks
  140961. * @param taskName defines the name of the new task
  140962. * @param meshesNames defines the name of meshes to load
  140963. * @param rootUrl defines the root url to use to locate files
  140964. * @param sceneFilename defines the filename of the scene file
  140965. * @returns a new MeshAssetTask object
  140966. */
  140967. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140968. /**
  140969. * Add a TextFileAssetTask to the list of active tasks
  140970. * @param taskName defines the name of the new task
  140971. * @param url defines the url of the file to load
  140972. * @returns a new TextFileAssetTask object
  140973. */
  140974. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140975. /**
  140976. * Add a BinaryFileAssetTask to the list of active tasks
  140977. * @param taskName defines the name of the new task
  140978. * @param url defines the url of the file to load
  140979. * @returns a new BinaryFileAssetTask object
  140980. */
  140981. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140982. /**
  140983. * Add a ImageAssetTask to the list of active tasks
  140984. * @param taskName defines the name of the new task
  140985. * @param url defines the url of the file to load
  140986. * @returns a new ImageAssetTask object
  140987. */
  140988. addImageTask(taskName: string, url: string): ImageAssetTask;
  140989. /**
  140990. * Add a TextureAssetTask to the list of active tasks
  140991. * @param taskName defines the name of the new task
  140992. * @param url defines the url of the file to load
  140993. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140994. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140995. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140996. * @returns a new TextureAssetTask object
  140997. */
  140998. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140999. /**
  141000. * Add a CubeTextureAssetTask to the list of active tasks
  141001. * @param taskName defines the name of the new task
  141002. * @param url defines the url of the file to load
  141003. * @param extensions defines the extension to use to load the cube map (can be null)
  141004. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141005. * @param files defines the list of files to load (can be null)
  141006. * @returns a new CubeTextureAssetTask object
  141007. */
  141008. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141009. /**
  141010. *
  141011. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141012. * @param taskName defines the name of the new task
  141013. * @param url defines the url of the file to load
  141014. * @param size defines the size you want for the cubemap (can be null)
  141015. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141016. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141017. * @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)
  141018. * @param reserved Internal use only
  141019. * @returns a new HDRCubeTextureAssetTask object
  141020. */
  141021. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141022. /**
  141023. *
  141024. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141025. * @param taskName defines the name of the new task
  141026. * @param url defines the url of the file to load
  141027. * @param size defines the size you want for the cubemap (can be null)
  141028. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141029. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141030. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141031. * @returns a new EquiRectangularCubeTextureAssetTask object
  141032. */
  141033. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141034. /**
  141035. * Remove a task from the assets manager.
  141036. * @param task the task to remove
  141037. */
  141038. removeTask(task: AbstractAssetTask): void;
  141039. private _decreaseWaitingTasksCount;
  141040. private _runTask;
  141041. /**
  141042. * Reset the AssetsManager and remove all tasks
  141043. * @return the current instance of the AssetsManager
  141044. */
  141045. reset(): AssetsManager;
  141046. /**
  141047. * Start the loading process
  141048. * @return the current instance of the AssetsManager
  141049. */
  141050. load(): AssetsManager;
  141051. /**
  141052. * Start the loading process as an async operation
  141053. * @return a promise returning the list of failed tasks
  141054. */
  141055. loadAsync(): Promise<void>;
  141056. }
  141057. }
  141058. declare module BABYLON {
  141059. /**
  141060. * Wrapper class for promise with external resolve and reject.
  141061. */
  141062. export class Deferred<T> {
  141063. /**
  141064. * The promise associated with this deferred object.
  141065. */
  141066. readonly promise: Promise<T>;
  141067. private _resolve;
  141068. private _reject;
  141069. /**
  141070. * The resolve method of the promise associated with this deferred object.
  141071. */
  141072. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141073. /**
  141074. * The reject method of the promise associated with this deferred object.
  141075. */
  141076. get reject(): (reason?: any) => void;
  141077. /**
  141078. * Constructor for this deferred object.
  141079. */
  141080. constructor();
  141081. }
  141082. }
  141083. declare module BABYLON {
  141084. /**
  141085. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141086. */
  141087. export class MeshExploder {
  141088. private _centerMesh;
  141089. private _meshes;
  141090. private _meshesOrigins;
  141091. private _toCenterVectors;
  141092. private _scaledDirection;
  141093. private _newPosition;
  141094. private _centerPosition;
  141095. /**
  141096. * Explodes meshes from a center mesh.
  141097. * @param meshes The meshes to explode.
  141098. * @param centerMesh The mesh to be center of explosion.
  141099. */
  141100. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141101. private _setCenterMesh;
  141102. /**
  141103. * Get class name
  141104. * @returns "MeshExploder"
  141105. */
  141106. getClassName(): string;
  141107. /**
  141108. * "Exploded meshes"
  141109. * @returns Array of meshes with the centerMesh at index 0.
  141110. */
  141111. getMeshes(): Array<Mesh>;
  141112. /**
  141113. * Explodes meshes giving a specific direction
  141114. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141115. */
  141116. explode(direction?: number): void;
  141117. }
  141118. }
  141119. declare module BABYLON {
  141120. /**
  141121. * Class used to help managing file picking and drag'n'drop
  141122. */
  141123. export class FilesInput {
  141124. /**
  141125. * List of files ready to be loaded
  141126. */
  141127. static get FilesToLoad(): {
  141128. [key: string]: File;
  141129. };
  141130. /**
  141131. * Callback called when a file is processed
  141132. */
  141133. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141134. private _engine;
  141135. private _currentScene;
  141136. private _sceneLoadedCallback;
  141137. private _progressCallback;
  141138. private _additionalRenderLoopLogicCallback;
  141139. private _textureLoadingCallback;
  141140. private _startingProcessingFilesCallback;
  141141. private _onReloadCallback;
  141142. private _errorCallback;
  141143. private _elementToMonitor;
  141144. private _sceneFileToLoad;
  141145. private _filesToLoad;
  141146. /**
  141147. * Creates a new FilesInput
  141148. * @param engine defines the rendering engine
  141149. * @param scene defines the hosting scene
  141150. * @param sceneLoadedCallback callback called when scene is loaded
  141151. * @param progressCallback callback called to track progress
  141152. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141153. * @param textureLoadingCallback callback called when a texture is loading
  141154. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141155. * @param onReloadCallback callback called when a reload is requested
  141156. * @param errorCallback callback call if an error occurs
  141157. */
  141158. 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);
  141159. private _dragEnterHandler;
  141160. private _dragOverHandler;
  141161. private _dropHandler;
  141162. /**
  141163. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141164. * @param elementToMonitor defines the DOM element to track
  141165. */
  141166. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141167. /**
  141168. * Release all associated resources
  141169. */
  141170. dispose(): void;
  141171. private renderFunction;
  141172. private drag;
  141173. private drop;
  141174. private _traverseFolder;
  141175. private _processFiles;
  141176. /**
  141177. * Load files from a drop event
  141178. * @param event defines the drop event to use as source
  141179. */
  141180. loadFiles(event: any): void;
  141181. private _processReload;
  141182. /**
  141183. * Reload the current scene from the loaded files
  141184. */
  141185. reload(): void;
  141186. }
  141187. }
  141188. declare module BABYLON {
  141189. /**
  141190. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141192. */
  141193. export class SceneOptimization {
  141194. /**
  141195. * Defines the priority of this optimization (0 by default which means first in the list)
  141196. */
  141197. priority: number;
  141198. /**
  141199. * Gets a string describing the action executed by the current optimization
  141200. * @returns description string
  141201. */
  141202. getDescription(): string;
  141203. /**
  141204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141205. * @param scene defines the current scene where to apply this optimization
  141206. * @param optimizer defines the current optimizer
  141207. * @returns true if everything that can be done was applied
  141208. */
  141209. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141210. /**
  141211. * Creates the SceneOptimization object
  141212. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141213. * @param desc defines the description associated with the optimization
  141214. */
  141215. constructor(
  141216. /**
  141217. * Defines the priority of this optimization (0 by default which means first in the list)
  141218. */
  141219. priority?: number);
  141220. }
  141221. /**
  141222. * Defines an optimization used to reduce the size of render target textures
  141223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141224. */
  141225. export class TextureOptimization extends SceneOptimization {
  141226. /**
  141227. * Defines the priority of this optimization (0 by default which means first in the list)
  141228. */
  141229. priority: number;
  141230. /**
  141231. * 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
  141232. */
  141233. maximumSize: number;
  141234. /**
  141235. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141236. */
  141237. step: number;
  141238. /**
  141239. * Gets a string describing the action executed by the current optimization
  141240. * @returns description string
  141241. */
  141242. getDescription(): string;
  141243. /**
  141244. * Creates the TextureOptimization object
  141245. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141246. * @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
  141247. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141248. */
  141249. constructor(
  141250. /**
  141251. * Defines the priority of this optimization (0 by default which means first in the list)
  141252. */
  141253. priority?: number,
  141254. /**
  141255. * 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
  141256. */
  141257. maximumSize?: number,
  141258. /**
  141259. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141260. */
  141261. step?: number);
  141262. /**
  141263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141264. * @param scene defines the current scene where to apply this optimization
  141265. * @param optimizer defines the current optimizer
  141266. * @returns true if everything that can be done was applied
  141267. */
  141268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141269. }
  141270. /**
  141271. * Defines an optimization used to increase or decrease the rendering resolution
  141272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141273. */
  141274. export class HardwareScalingOptimization extends SceneOptimization {
  141275. /**
  141276. * Defines the priority of this optimization (0 by default which means first in the list)
  141277. */
  141278. priority: number;
  141279. /**
  141280. * Defines the maximum scale to use (2 by default)
  141281. */
  141282. maximumScale: number;
  141283. /**
  141284. * Defines the step to use between two passes (0.5 by default)
  141285. */
  141286. step: number;
  141287. private _currentScale;
  141288. private _directionOffset;
  141289. /**
  141290. * Gets a string describing the action executed by the current optimization
  141291. * @return description string
  141292. */
  141293. getDescription(): string;
  141294. /**
  141295. * Creates the HardwareScalingOptimization object
  141296. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141297. * @param maximumScale defines the maximum scale to use (2 by default)
  141298. * @param step defines the step to use between two passes (0.5 by default)
  141299. */
  141300. constructor(
  141301. /**
  141302. * Defines the priority of this optimization (0 by default which means first in the list)
  141303. */
  141304. priority?: number,
  141305. /**
  141306. * Defines the maximum scale to use (2 by default)
  141307. */
  141308. maximumScale?: number,
  141309. /**
  141310. * Defines the step to use between two passes (0.5 by default)
  141311. */
  141312. step?: number);
  141313. /**
  141314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141315. * @param scene defines the current scene where to apply this optimization
  141316. * @param optimizer defines the current optimizer
  141317. * @returns true if everything that can be done was applied
  141318. */
  141319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141320. }
  141321. /**
  141322. * Defines an optimization used to remove shadows
  141323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141324. */
  141325. export class ShadowsOptimization extends SceneOptimization {
  141326. /**
  141327. * Gets a string describing the action executed by the current optimization
  141328. * @return description string
  141329. */
  141330. getDescription(): string;
  141331. /**
  141332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141333. * @param scene defines the current scene where to apply this optimization
  141334. * @param optimizer defines the current optimizer
  141335. * @returns true if everything that can be done was applied
  141336. */
  141337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141338. }
  141339. /**
  141340. * Defines an optimization used to turn post-processes off
  141341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141342. */
  141343. export class PostProcessesOptimization extends SceneOptimization {
  141344. /**
  141345. * Gets a string describing the action executed by the current optimization
  141346. * @return description string
  141347. */
  141348. getDescription(): string;
  141349. /**
  141350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141351. * @param scene defines the current scene where to apply this optimization
  141352. * @param optimizer defines the current optimizer
  141353. * @returns true if everything that can be done was applied
  141354. */
  141355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141356. }
  141357. /**
  141358. * Defines an optimization used to turn lens flares off
  141359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141360. */
  141361. export class LensFlaresOptimization extends SceneOptimization {
  141362. /**
  141363. * Gets a string describing the action executed by the current optimization
  141364. * @return description string
  141365. */
  141366. getDescription(): string;
  141367. /**
  141368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141369. * @param scene defines the current scene where to apply this optimization
  141370. * @param optimizer defines the current optimizer
  141371. * @returns true if everything that can be done was applied
  141372. */
  141373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141374. }
  141375. /**
  141376. * Defines an optimization based on user defined callback.
  141377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141378. */
  141379. export class CustomOptimization extends SceneOptimization {
  141380. /**
  141381. * Callback called to apply the custom optimization.
  141382. */
  141383. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141384. /**
  141385. * Callback called to get custom description
  141386. */
  141387. onGetDescription: () => string;
  141388. /**
  141389. * Gets a string describing the action executed by the current optimization
  141390. * @returns description string
  141391. */
  141392. getDescription(): string;
  141393. /**
  141394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141395. * @param scene defines the current scene where to apply this optimization
  141396. * @param optimizer defines the current optimizer
  141397. * @returns true if everything that can be done was applied
  141398. */
  141399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141400. }
  141401. /**
  141402. * Defines an optimization used to turn particles off
  141403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141404. */
  141405. export class ParticlesOptimization extends SceneOptimization {
  141406. /**
  141407. * Gets a string describing the action executed by the current optimization
  141408. * @return description string
  141409. */
  141410. getDescription(): string;
  141411. /**
  141412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141413. * @param scene defines the current scene where to apply this optimization
  141414. * @param optimizer defines the current optimizer
  141415. * @returns true if everything that can be done was applied
  141416. */
  141417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141418. }
  141419. /**
  141420. * Defines an optimization used to turn render targets off
  141421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141422. */
  141423. export class RenderTargetsOptimization extends SceneOptimization {
  141424. /**
  141425. * Gets a string describing the action executed by the current optimization
  141426. * @return description string
  141427. */
  141428. getDescription(): string;
  141429. /**
  141430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141431. * @param scene defines the current scene where to apply this optimization
  141432. * @param optimizer defines the current optimizer
  141433. * @returns true if everything that can be done was applied
  141434. */
  141435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141436. }
  141437. /**
  141438. * Defines an optimization used to merge meshes with compatible materials
  141439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141440. */
  141441. export class MergeMeshesOptimization extends SceneOptimization {
  141442. private static _UpdateSelectionTree;
  141443. /**
  141444. * Gets or sets a boolean which defines if optimization octree has to be updated
  141445. */
  141446. static get UpdateSelectionTree(): boolean;
  141447. /**
  141448. * Gets or sets a boolean which defines if optimization octree has to be updated
  141449. */
  141450. static set UpdateSelectionTree(value: boolean);
  141451. /**
  141452. * Gets a string describing the action executed by the current optimization
  141453. * @return description string
  141454. */
  141455. getDescription(): string;
  141456. private _canBeMerged;
  141457. /**
  141458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141459. * @param scene defines the current scene where to apply this optimization
  141460. * @param optimizer defines the current optimizer
  141461. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141462. * @returns true if everything that can be done was applied
  141463. */
  141464. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141465. }
  141466. /**
  141467. * Defines a list of options used by SceneOptimizer
  141468. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141469. */
  141470. export class SceneOptimizerOptions {
  141471. /**
  141472. * Defines the target frame rate to reach (60 by default)
  141473. */
  141474. targetFrameRate: number;
  141475. /**
  141476. * Defines the interval between two checkes (2000ms by default)
  141477. */
  141478. trackerDuration: number;
  141479. /**
  141480. * Gets the list of optimizations to apply
  141481. */
  141482. optimizations: SceneOptimization[];
  141483. /**
  141484. * Creates a new list of options used by SceneOptimizer
  141485. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141486. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141487. */
  141488. constructor(
  141489. /**
  141490. * Defines the target frame rate to reach (60 by default)
  141491. */
  141492. targetFrameRate?: number,
  141493. /**
  141494. * Defines the interval between two checkes (2000ms by default)
  141495. */
  141496. trackerDuration?: number);
  141497. /**
  141498. * Add a new optimization
  141499. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141500. * @returns the current SceneOptimizerOptions
  141501. */
  141502. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141503. /**
  141504. * Add a new custom optimization
  141505. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141506. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141507. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141508. * @returns the current SceneOptimizerOptions
  141509. */
  141510. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141511. /**
  141512. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141513. * @param targetFrameRate defines the target frame rate (60 by default)
  141514. * @returns a SceneOptimizerOptions object
  141515. */
  141516. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141517. /**
  141518. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141519. * @param targetFrameRate defines the target frame rate (60 by default)
  141520. * @returns a SceneOptimizerOptions object
  141521. */
  141522. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141523. /**
  141524. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141525. * @param targetFrameRate defines the target frame rate (60 by default)
  141526. * @returns a SceneOptimizerOptions object
  141527. */
  141528. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141529. }
  141530. /**
  141531. * Class used to run optimizations in order to reach a target frame rate
  141532. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141533. */
  141534. export class SceneOptimizer implements IDisposable {
  141535. private _isRunning;
  141536. private _options;
  141537. private _scene;
  141538. private _currentPriorityLevel;
  141539. private _targetFrameRate;
  141540. private _trackerDuration;
  141541. private _currentFrameRate;
  141542. private _sceneDisposeObserver;
  141543. private _improvementMode;
  141544. /**
  141545. * Defines an observable called when the optimizer reaches the target frame rate
  141546. */
  141547. onSuccessObservable: Observable<SceneOptimizer>;
  141548. /**
  141549. * Defines an observable called when the optimizer enables an optimization
  141550. */
  141551. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141552. /**
  141553. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141554. */
  141555. onFailureObservable: Observable<SceneOptimizer>;
  141556. /**
  141557. * Gets a boolean indicating if the optimizer is in improvement mode
  141558. */
  141559. get isInImprovementMode(): boolean;
  141560. /**
  141561. * Gets the current priority level (0 at start)
  141562. */
  141563. get currentPriorityLevel(): number;
  141564. /**
  141565. * Gets the current frame rate checked by the SceneOptimizer
  141566. */
  141567. get currentFrameRate(): number;
  141568. /**
  141569. * Gets or sets the current target frame rate (60 by default)
  141570. */
  141571. get targetFrameRate(): number;
  141572. /**
  141573. * Gets or sets the current target frame rate (60 by default)
  141574. */
  141575. set targetFrameRate(value: number);
  141576. /**
  141577. * Gets or sets the current interval between two checks (every 2000ms by default)
  141578. */
  141579. get trackerDuration(): number;
  141580. /**
  141581. * Gets or sets the current interval between two checks (every 2000ms by default)
  141582. */
  141583. set trackerDuration(value: number);
  141584. /**
  141585. * Gets the list of active optimizations
  141586. */
  141587. get optimizations(): SceneOptimization[];
  141588. /**
  141589. * Creates a new SceneOptimizer
  141590. * @param scene defines the scene to work on
  141591. * @param options defines the options to use with the SceneOptimizer
  141592. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141593. * @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)
  141594. */
  141595. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141596. /**
  141597. * Stops the current optimizer
  141598. */
  141599. stop(): void;
  141600. /**
  141601. * Reset the optimizer to initial step (current priority level = 0)
  141602. */
  141603. reset(): void;
  141604. /**
  141605. * Start the optimizer. By default it will try to reach a specific framerate
  141606. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141607. */
  141608. start(): void;
  141609. private _checkCurrentState;
  141610. /**
  141611. * Release all resources
  141612. */
  141613. dispose(): void;
  141614. /**
  141615. * Helper function to create a SceneOptimizer with one single line of code
  141616. * @param scene defines the scene to work on
  141617. * @param options defines the options to use with the SceneOptimizer
  141618. * @param onSuccess defines a callback to call on success
  141619. * @param onFailure defines a callback to call on failure
  141620. * @returns the new SceneOptimizer object
  141621. */
  141622. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141623. }
  141624. }
  141625. declare module BABYLON {
  141626. /**
  141627. * Class used to serialize a scene into a string
  141628. */
  141629. export class SceneSerializer {
  141630. /**
  141631. * Clear cache used by a previous serialization
  141632. */
  141633. static ClearCache(): void;
  141634. /**
  141635. * Serialize a scene into a JSON compatible object
  141636. * @param scene defines the scene to serialize
  141637. * @returns a JSON compatible object
  141638. */
  141639. static Serialize(scene: Scene): any;
  141640. /**
  141641. * Serialize a mesh into a JSON compatible object
  141642. * @param toSerialize defines the mesh to serialize
  141643. * @param withParents defines if parents must be serialized as well
  141644. * @param withChildren defines if children must be serialized as well
  141645. * @returns a JSON compatible object
  141646. */
  141647. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141648. }
  141649. }
  141650. declare module BABYLON {
  141651. /**
  141652. * Class used to host texture specific utilities
  141653. */
  141654. export class TextureTools {
  141655. /**
  141656. * Uses the GPU to create a copy texture rescaled at a given size
  141657. * @param texture Texture to copy from
  141658. * @param width defines the desired width
  141659. * @param height defines the desired height
  141660. * @param useBilinearMode defines if bilinear mode has to be used
  141661. * @return the generated texture
  141662. */
  141663. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141664. }
  141665. }
  141666. declare module BABYLON {
  141667. /**
  141668. * This represents the different options available for the video capture.
  141669. */
  141670. export interface VideoRecorderOptions {
  141671. /** Defines the mime type of the video. */
  141672. mimeType: string;
  141673. /** Defines the FPS the video should be recorded at. */
  141674. fps: number;
  141675. /** Defines the chunk size for the recording data. */
  141676. recordChunckSize: number;
  141677. /** The audio tracks to attach to the recording. */
  141678. audioTracks?: MediaStreamTrack[];
  141679. }
  141680. /**
  141681. * This can help with recording videos from BabylonJS.
  141682. * This is based on the available WebRTC functionalities of the browser.
  141683. *
  141684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141685. */
  141686. export class VideoRecorder {
  141687. private static readonly _defaultOptions;
  141688. /**
  141689. * Returns whether or not the VideoRecorder is available in your browser.
  141690. * @param engine Defines the Babylon Engine.
  141691. * @returns true if supported otherwise false.
  141692. */
  141693. static IsSupported(engine: Engine): boolean;
  141694. private readonly _options;
  141695. private _canvas;
  141696. private _mediaRecorder;
  141697. private _recordedChunks;
  141698. private _fileName;
  141699. private _resolve;
  141700. private _reject;
  141701. /**
  141702. * True when a recording is already in progress.
  141703. */
  141704. get isRecording(): boolean;
  141705. /**
  141706. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141707. * @param engine Defines the BabylonJS Engine you wish to record.
  141708. * @param options Defines options that can be used to customize the capture.
  141709. */
  141710. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141711. /**
  141712. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141713. */
  141714. stopRecording(): void;
  141715. /**
  141716. * Starts recording the canvas for a max duration specified in parameters.
  141717. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141718. * If null no automatic download will start and you can rely on the promise to get the data back.
  141719. * @param maxDuration Defines the maximum recording time in seconds.
  141720. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141721. * @return A promise callback at the end of the recording with the video data in Blob.
  141722. */
  141723. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141724. /**
  141725. * Releases internal resources used during the recording.
  141726. */
  141727. dispose(): void;
  141728. private _handleDataAvailable;
  141729. private _handleError;
  141730. private _handleStop;
  141731. }
  141732. }
  141733. declare module BABYLON {
  141734. /**
  141735. * Class containing a set of static utilities functions for screenshots
  141736. */
  141737. export class ScreenshotTools {
  141738. /**
  141739. * Captures a screenshot of the current rendering
  141740. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141741. * @param engine defines the rendering engine
  141742. * @param camera defines the source camera
  141743. * @param size This parameter can be set to a single number or to an object with the
  141744. * following (optional) properties: precision, width, height. If a single number is passed,
  141745. * it will be used for both width and height. If an object is passed, the screenshot size
  141746. * will be derived from the parameters. The precision property is a multiplier allowing
  141747. * rendering at a higher or lower resolution
  141748. * @param successCallback defines the callback receives a single parameter which contains the
  141749. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141750. * src parameter of an <img> to display it
  141751. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141752. * Check your browser for supported MIME types
  141753. */
  141754. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141755. /**
  141756. * Captures a screenshot of the current rendering
  141757. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141758. * @param engine defines the rendering engine
  141759. * @param camera defines the source camera
  141760. * @param size This parameter can be set to a single number or to an object with the
  141761. * following (optional) properties: precision, width, height. If a single number is passed,
  141762. * it will be used for both width and height. If an object is passed, the screenshot size
  141763. * will be derived from the parameters. The precision property is a multiplier allowing
  141764. * rendering at a higher or lower resolution
  141765. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141766. * Check your browser for supported MIME types
  141767. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141768. * to the src parameter of an <img> to display it
  141769. */
  141770. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141771. /**
  141772. * Generates an image screenshot from the specified camera.
  141773. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141774. * @param engine The engine to use for rendering
  141775. * @param camera The camera to use for rendering
  141776. * @param size This parameter can be set to a single number or to an object with the
  141777. * following (optional) properties: precision, width, height. If a single number is passed,
  141778. * it will be used for both width and height. If an object is passed, the screenshot size
  141779. * will be derived from the parameters. The precision property is a multiplier allowing
  141780. * rendering at a higher or lower resolution
  141781. * @param successCallback The callback receives a single parameter which contains the
  141782. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141783. * src parameter of an <img> to display it
  141784. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141785. * Check your browser for supported MIME types
  141786. * @param samples Texture samples (default: 1)
  141787. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141788. * @param fileName A name for for the downloaded file.
  141789. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141790. */
  141791. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141792. /**
  141793. * Generates an image screenshot from the specified camera.
  141794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141795. * @param engine The engine to use for rendering
  141796. * @param camera The camera to use for rendering
  141797. * @param size This parameter can be set to a single number or to an object with the
  141798. * following (optional) properties: precision, width, height. If a single number is passed,
  141799. * it will be used for both width and height. If an object is passed, the screenshot size
  141800. * will be derived from the parameters. The precision property is a multiplier allowing
  141801. * rendering at a higher or lower resolution
  141802. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141803. * Check your browser for supported MIME types
  141804. * @param samples Texture samples (default: 1)
  141805. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141806. * @param fileName A name for for the downloaded file.
  141807. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141808. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141809. * to the src parameter of an <img> to display it
  141810. */
  141811. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141812. /**
  141813. * Gets height and width for screenshot size
  141814. * @private
  141815. */
  141816. private static _getScreenshotSize;
  141817. }
  141818. }
  141819. declare module BABYLON {
  141820. /**
  141821. * Interface for a data buffer
  141822. */
  141823. export interface IDataBuffer {
  141824. /**
  141825. * Reads bytes from the data buffer.
  141826. * @param byteOffset The byte offset to read
  141827. * @param byteLength The byte length to read
  141828. * @returns A promise that resolves when the bytes are read
  141829. */
  141830. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141831. /**
  141832. * The byte length of the buffer.
  141833. */
  141834. readonly byteLength: number;
  141835. }
  141836. /**
  141837. * Utility class for reading from a data buffer
  141838. */
  141839. export class DataReader {
  141840. /**
  141841. * The data buffer associated with this data reader.
  141842. */
  141843. readonly buffer: IDataBuffer;
  141844. /**
  141845. * The current byte offset from the beginning of the data buffer.
  141846. */
  141847. byteOffset: number;
  141848. private _dataView;
  141849. private _dataByteOffset;
  141850. /**
  141851. * Constructor
  141852. * @param buffer The buffer to read
  141853. */
  141854. constructor(buffer: IDataBuffer);
  141855. /**
  141856. * Loads the given byte length.
  141857. * @param byteLength The byte length to load
  141858. * @returns A promise that resolves when the load is complete
  141859. */
  141860. loadAsync(byteLength: number): Promise<void>;
  141861. /**
  141862. * Read a unsigned 32-bit integer from the currently loaded data range.
  141863. * @returns The 32-bit integer read
  141864. */
  141865. readUint32(): number;
  141866. /**
  141867. * Read a byte array from the currently loaded data range.
  141868. * @param byteLength The byte length to read
  141869. * @returns The byte array read
  141870. */
  141871. readUint8Array(byteLength: number): Uint8Array;
  141872. /**
  141873. * Read a string from the currently loaded data range.
  141874. * @param byteLength The byte length to read
  141875. * @returns The string read
  141876. */
  141877. readString(byteLength: number): string;
  141878. /**
  141879. * Skips the given byte length the currently loaded data range.
  141880. * @param byteLength The byte length to skip
  141881. */
  141882. skipBytes(byteLength: number): void;
  141883. }
  141884. }
  141885. declare module BABYLON {
  141886. /**
  141887. * Options used for hit testing
  141888. */
  141889. export interface IWebXRHitTestOptions {
  141890. /**
  141891. * Only test when user interacted with the scene. Default - hit test every frame
  141892. */
  141893. testOnPointerDownOnly?: boolean;
  141894. /**
  141895. * The node to use to transform the local results to world coordinates
  141896. */
  141897. worldParentNode?: TransformNode;
  141898. }
  141899. /**
  141900. * Interface defining the babylon result of raycasting/hit-test
  141901. */
  141902. export interface IWebXRHitResult {
  141903. /**
  141904. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141905. */
  141906. transformationMatrix: Matrix;
  141907. /**
  141908. * The native hit test result
  141909. */
  141910. xrHitResult: XRHitResult;
  141911. }
  141912. /**
  141913. * The currently-working hit-test module.
  141914. * Hit test (or Ray-casting) is used to interact with the real world.
  141915. * For further information read here - https://github.com/immersive-web/hit-test
  141916. */
  141917. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141918. /**
  141919. * options to use when constructing this feature
  141920. */
  141921. readonly options: IWebXRHitTestOptions;
  141922. private _direction;
  141923. private _mat;
  141924. private _onSelectEnabled;
  141925. private _origin;
  141926. /**
  141927. * The module's name
  141928. */
  141929. static readonly Name: string;
  141930. /**
  141931. * The (Babylon) version of this module.
  141932. * This is an integer representing the implementation version.
  141933. * This number does not correspond to the WebXR specs version
  141934. */
  141935. static readonly Version: number;
  141936. /**
  141937. * Populated with the last native XR Hit Results
  141938. */
  141939. lastNativeXRHitResults: XRHitResult[];
  141940. /**
  141941. * Triggered when new babylon (transformed) hit test results are available
  141942. */
  141943. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141944. /**
  141945. * Creates a new instance of the (legacy version) hit test feature
  141946. * @param _xrSessionManager an instance of WebXRSessionManager
  141947. * @param options options to use when constructing this feature
  141948. */
  141949. constructor(_xrSessionManager: WebXRSessionManager,
  141950. /**
  141951. * options to use when constructing this feature
  141952. */
  141953. options?: IWebXRHitTestOptions);
  141954. /**
  141955. * execute a hit test with an XR Ray
  141956. *
  141957. * @param xrSession a native xrSession that will execute this hit test
  141958. * @param xrRay the ray (position and direction) to use for ray-casting
  141959. * @param referenceSpace native XR reference space to use for the hit-test
  141960. * @param filter filter function that will filter the results
  141961. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141962. */
  141963. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141964. /**
  141965. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141966. * @param event the (select) event to use to select with
  141967. * @param referenceSpace the reference space to use for this hit test
  141968. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141969. */
  141970. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141971. /**
  141972. * attach this feature
  141973. * Will usually be called by the features manager
  141974. *
  141975. * @returns true if successful.
  141976. */
  141977. attach(): boolean;
  141978. /**
  141979. * detach this feature.
  141980. * Will usually be called by the features manager
  141981. *
  141982. * @returns true if successful.
  141983. */
  141984. detach(): boolean;
  141985. /**
  141986. * Dispose this feature and all of the resources attached
  141987. */
  141988. dispose(): void;
  141989. protected _onXRFrame(frame: XRFrame): void;
  141990. private _onHitTestResults;
  141991. private _onSelect;
  141992. }
  141993. }
  141994. declare module BABYLON {
  141995. /**
  141996. * Options used in the plane detector module
  141997. */
  141998. export interface IWebXRPlaneDetectorOptions {
  141999. /**
  142000. * The node to use to transform the local results to world coordinates
  142001. */
  142002. worldParentNode?: TransformNode;
  142003. }
  142004. /**
  142005. * A babylon interface for a WebXR plane.
  142006. * A Plane is actually a polygon, built from N points in space
  142007. *
  142008. * Supported in chrome 79, not supported in canary 81 ATM
  142009. */
  142010. export interface IWebXRPlane {
  142011. /**
  142012. * a babylon-assigned ID for this polygon
  142013. */
  142014. id: number;
  142015. /**
  142016. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142017. */
  142018. polygonDefinition: Array<Vector3>;
  142019. /**
  142020. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142021. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142022. */
  142023. transformationMatrix: Matrix;
  142024. /**
  142025. * the native xr-plane object
  142026. */
  142027. xrPlane: XRPlane;
  142028. }
  142029. /**
  142030. * The plane detector is used to detect planes in the real world when in AR
  142031. * For more information see https://github.com/immersive-web/real-world-geometry/
  142032. */
  142033. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142034. private _options;
  142035. private _detectedPlanes;
  142036. private _enabled;
  142037. private _lastFrameDetected;
  142038. /**
  142039. * The module's name
  142040. */
  142041. static readonly Name: string;
  142042. /**
  142043. * The (Babylon) version of this module.
  142044. * This is an integer representing the implementation version.
  142045. * This number does not correspond to the WebXR specs version
  142046. */
  142047. static readonly Version: number;
  142048. /**
  142049. * Observers registered here will be executed when a new plane was added to the session
  142050. */
  142051. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142052. /**
  142053. * Observers registered here will be executed when a plane is no longer detected in the session
  142054. */
  142055. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142056. /**
  142057. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142058. * This can execute N times every frame
  142059. */
  142060. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142061. /**
  142062. * construct a new Plane Detector
  142063. * @param _xrSessionManager an instance of xr Session manager
  142064. * @param _options configuration to use when constructing this feature
  142065. */
  142066. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142067. /**
  142068. * Dispose this feature and all of the resources attached
  142069. */
  142070. dispose(): void;
  142071. protected _onXRFrame(frame: XRFrame): void;
  142072. private _init;
  142073. private _updatePlaneWithXRPlane;
  142074. /**
  142075. * avoiding using Array.find for global support.
  142076. * @param xrPlane the plane to find in the array
  142077. */
  142078. private findIndexInPlaneArray;
  142079. }
  142080. }
  142081. declare module BABYLON {
  142082. /**
  142083. * Configuration options of the anchor system
  142084. */
  142085. export interface IWebXRAnchorSystemOptions {
  142086. /**
  142087. * Should a new anchor be added every time a select event is triggered
  142088. */
  142089. addAnchorOnSelect?: boolean;
  142090. /**
  142091. * should the anchor system use plane detection.
  142092. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142093. */
  142094. usePlaneDetection?: boolean;
  142095. /**
  142096. * a node that will be used to convert local to world coordinates
  142097. */
  142098. worldParentNode?: TransformNode;
  142099. }
  142100. /**
  142101. * A babylon container for an XR Anchor
  142102. */
  142103. export interface IWebXRAnchor {
  142104. /**
  142105. * A babylon-assigned ID for this anchor
  142106. */
  142107. id: number;
  142108. /**
  142109. * Transformation matrix to apply to an object attached to this anchor
  142110. */
  142111. transformationMatrix: Matrix;
  142112. /**
  142113. * The native anchor object
  142114. */
  142115. xrAnchor: XRAnchor;
  142116. }
  142117. /**
  142118. * An implementation of the anchor system of WebXR.
  142119. * Note that the current documented implementation is not available in any browser. Future implementations
  142120. * will use the frame to create an anchor and not the session or a detected plane
  142121. * For further information see https://github.com/immersive-web/anchors/
  142122. */
  142123. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142124. private _options;
  142125. private _enabled;
  142126. private _hitTestModule;
  142127. private _lastFrameDetected;
  142128. private _onSelect;
  142129. private _planeDetector;
  142130. private _trackedAnchors;
  142131. /**
  142132. * The module's name
  142133. */
  142134. static readonly Name: string;
  142135. /**
  142136. * The (Babylon) version of this module.
  142137. * This is an integer representing the implementation version.
  142138. * This number does not correspond to the WebXR specs version
  142139. */
  142140. static readonly Version: number;
  142141. /**
  142142. * Observers registered here will be executed when a new anchor was added to the session
  142143. */
  142144. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142145. /**
  142146. * Observers registered here will be executed when an anchor was removed from the session
  142147. */
  142148. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142149. /**
  142150. * Observers registered here will be executed when an existing anchor updates
  142151. * This can execute N times every frame
  142152. */
  142153. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142154. /**
  142155. * constructs a new anchor system
  142156. * @param _xrSessionManager an instance of WebXRSessionManager
  142157. * @param _options configuration object for this feature
  142158. */
  142159. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142160. /**
  142161. * Add anchor at a specific XR point.
  142162. *
  142163. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142164. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142165. * @returns a promise the fulfills when the anchor was created
  142166. */
  142167. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142168. /**
  142169. * attach this feature
  142170. * Will usually be called by the features manager
  142171. *
  142172. * @returns true if successful.
  142173. */
  142174. attach(): boolean;
  142175. /**
  142176. * detach this feature.
  142177. * Will usually be called by the features manager
  142178. *
  142179. * @returns true if successful.
  142180. */
  142181. detach(): boolean;
  142182. /**
  142183. * Dispose this feature and all of the resources attached
  142184. */
  142185. dispose(): void;
  142186. /**
  142187. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142188. * @param hitTestModule the hit-test module to use.
  142189. */
  142190. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142191. /**
  142192. * set the plane detector to use in order to create anchors from frames
  142193. * @param planeDetector the plane-detector module to use
  142194. * @param enable enable plane-anchors. default is true
  142195. */
  142196. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142197. protected _onXRFrame(frame: XRFrame): void;
  142198. /**
  142199. * avoiding using Array.find for global support.
  142200. * @param xrAnchor the plane to find in the array
  142201. */
  142202. private _findIndexInAnchorArray;
  142203. private _updateAnchorWithXRFrame;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * Options interface for the background remover plugin
  142209. */
  142210. export interface IWebXRBackgroundRemoverOptions {
  142211. /**
  142212. * Further background meshes to disable when entering AR
  142213. */
  142214. backgroundMeshes?: AbstractMesh[];
  142215. /**
  142216. * flags to configure the removal of the environment helper.
  142217. * If not set, the entire background will be removed. If set, flags should be set as well.
  142218. */
  142219. environmentHelperRemovalFlags?: {
  142220. /**
  142221. * Should the skybox be removed (default false)
  142222. */
  142223. skyBox?: boolean;
  142224. /**
  142225. * Should the ground be removed (default false)
  142226. */
  142227. ground?: boolean;
  142228. };
  142229. /**
  142230. * don't disable the environment helper
  142231. */
  142232. ignoreEnvironmentHelper?: boolean;
  142233. }
  142234. /**
  142235. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142236. */
  142237. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142238. /**
  142239. * read-only options to be used in this module
  142240. */
  142241. readonly options: IWebXRBackgroundRemoverOptions;
  142242. /**
  142243. * The module's name
  142244. */
  142245. static readonly Name: string;
  142246. /**
  142247. * The (Babylon) version of this module.
  142248. * This is an integer representing the implementation version.
  142249. * This number does not correspond to the WebXR specs version
  142250. */
  142251. static readonly Version: number;
  142252. /**
  142253. * registered observers will be triggered when the background state changes
  142254. */
  142255. onBackgroundStateChangedObservable: Observable<boolean>;
  142256. /**
  142257. * constructs a new background remover module
  142258. * @param _xrSessionManager the session manager for this module
  142259. * @param options read-only options to be used in this module
  142260. */
  142261. constructor(_xrSessionManager: WebXRSessionManager,
  142262. /**
  142263. * read-only options to be used in this module
  142264. */
  142265. options?: IWebXRBackgroundRemoverOptions);
  142266. /**
  142267. * attach this feature
  142268. * Will usually be called by the features manager
  142269. *
  142270. * @returns true if successful.
  142271. */
  142272. attach(): boolean;
  142273. /**
  142274. * detach this feature.
  142275. * Will usually be called by the features manager
  142276. *
  142277. * @returns true if successful.
  142278. */
  142279. detach(): boolean;
  142280. /**
  142281. * Dispose this feature and all of the resources attached
  142282. */
  142283. dispose(): void;
  142284. protected _onXRFrame(_xrFrame: XRFrame): void;
  142285. private _setBackgroundState;
  142286. }
  142287. }
  142288. declare module BABYLON {
  142289. /**
  142290. * Options for the controller physics feature
  142291. */
  142292. export class IWebXRControllerPhysicsOptions {
  142293. /**
  142294. * Should the headset get its own impostor
  142295. */
  142296. enableHeadsetImpostor?: boolean;
  142297. /**
  142298. * Optional parameters for the headset impostor
  142299. */
  142300. headsetImpostorParams?: {
  142301. /**
  142302. * The type of impostor to create. Default is sphere
  142303. */
  142304. impostorType: number;
  142305. /**
  142306. * the size of the impostor. Defaults to 10cm
  142307. */
  142308. impostorSize?: number | {
  142309. width: number;
  142310. height: number;
  142311. depth: number;
  142312. };
  142313. /**
  142314. * Friction definitions
  142315. */
  142316. friction?: number;
  142317. /**
  142318. * Restitution
  142319. */
  142320. restitution?: number;
  142321. };
  142322. /**
  142323. * The physics properties of the future impostors
  142324. */
  142325. physicsProperties?: {
  142326. /**
  142327. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142328. * Note that this requires a physics engine that supports mesh impostors!
  142329. */
  142330. useControllerMesh?: boolean;
  142331. /**
  142332. * The type of impostor to create. Default is sphere
  142333. */
  142334. impostorType?: number;
  142335. /**
  142336. * the size of the impostor. Defaults to 10cm
  142337. */
  142338. impostorSize?: number | {
  142339. width: number;
  142340. height: number;
  142341. depth: number;
  142342. };
  142343. /**
  142344. * Friction definitions
  142345. */
  142346. friction?: number;
  142347. /**
  142348. * Restitution
  142349. */
  142350. restitution?: number;
  142351. };
  142352. /**
  142353. * the xr input to use with this pointer selection
  142354. */
  142355. xrInput: WebXRInput;
  142356. }
  142357. /**
  142358. * Add physics impostor to your webxr controllers,
  142359. * including naive calculation of their linear and angular velocity
  142360. */
  142361. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142362. private readonly _options;
  142363. private _attachController;
  142364. private _controllers;
  142365. private _debugMode;
  142366. private _delta;
  142367. private _headsetImpostor?;
  142368. private _headsetMesh?;
  142369. private _lastTimestamp;
  142370. private _tmpQuaternion;
  142371. private _tmpVector;
  142372. /**
  142373. * The module's name
  142374. */
  142375. static readonly Name: string;
  142376. /**
  142377. * The (Babylon) version of this module.
  142378. * This is an integer representing the implementation version.
  142379. * This number does not correspond to the webxr specs version
  142380. */
  142381. static readonly Version: number;
  142382. /**
  142383. * Construct a new Controller Physics Feature
  142384. * @param _xrSessionManager the corresponding xr session manager
  142385. * @param _options options to create this feature with
  142386. */
  142387. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142388. /**
  142389. * @hidden
  142390. * enable debugging - will show console outputs and the impostor mesh
  142391. */
  142392. _enablePhysicsDebug(): void;
  142393. /**
  142394. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142395. * @param xrController the controller to add
  142396. */
  142397. addController(xrController: WebXRInputSource): void;
  142398. /**
  142399. * attach this feature
  142400. * Will usually be called by the features manager
  142401. *
  142402. * @returns true if successful.
  142403. */
  142404. attach(): boolean;
  142405. /**
  142406. * detach this feature.
  142407. * Will usually be called by the features manager
  142408. *
  142409. * @returns true if successful.
  142410. */
  142411. detach(): boolean;
  142412. /**
  142413. * Get the headset impostor, if enabled
  142414. * @returns the impostor
  142415. */
  142416. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142417. /**
  142418. * Get the physics impostor of a specific controller.
  142419. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142420. * @param controller the controller or the controller id of which to get the impostor
  142421. * @returns the impostor or null
  142422. */
  142423. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142424. /**
  142425. * Update the physics properties provided in the constructor
  142426. * @param newProperties the new properties object
  142427. */
  142428. setPhysicsProperties(newProperties: {
  142429. impostorType?: number;
  142430. impostorSize?: number | {
  142431. width: number;
  142432. height: number;
  142433. depth: number;
  142434. };
  142435. friction?: number;
  142436. restitution?: number;
  142437. }): void;
  142438. protected _onXRFrame(_xrFrame: any): void;
  142439. private _detachController;
  142440. }
  142441. }
  142442. declare module BABYLON {
  142443. /**
  142444. * The motion controller class for all microsoft mixed reality controllers
  142445. */
  142446. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142447. protected readonly _mapping: {
  142448. defaultButton: {
  142449. "valueNodeName": string;
  142450. "unpressedNodeName": string;
  142451. "pressedNodeName": string;
  142452. };
  142453. defaultAxis: {
  142454. "valueNodeName": string;
  142455. "minNodeName": string;
  142456. "maxNodeName": string;
  142457. };
  142458. buttons: {
  142459. "xr-standard-trigger": {
  142460. "rootNodeName": string;
  142461. "componentProperty": string;
  142462. "states": string[];
  142463. };
  142464. "xr-standard-squeeze": {
  142465. "rootNodeName": string;
  142466. "componentProperty": string;
  142467. "states": string[];
  142468. };
  142469. "xr-standard-touchpad": {
  142470. "rootNodeName": string;
  142471. "labelAnchorNodeName": string;
  142472. "touchPointNodeName": string;
  142473. };
  142474. "xr-standard-thumbstick": {
  142475. "rootNodeName": string;
  142476. "componentProperty": string;
  142477. "states": string[];
  142478. };
  142479. };
  142480. axes: {
  142481. "xr-standard-touchpad": {
  142482. "x-axis": {
  142483. "rootNodeName": string;
  142484. };
  142485. "y-axis": {
  142486. "rootNodeName": string;
  142487. };
  142488. };
  142489. "xr-standard-thumbstick": {
  142490. "x-axis": {
  142491. "rootNodeName": string;
  142492. };
  142493. "y-axis": {
  142494. "rootNodeName": string;
  142495. };
  142496. };
  142497. };
  142498. };
  142499. /**
  142500. * The base url used to load the left and right controller models
  142501. */
  142502. static MODEL_BASE_URL: string;
  142503. /**
  142504. * The name of the left controller model file
  142505. */
  142506. static MODEL_LEFT_FILENAME: string;
  142507. /**
  142508. * The name of the right controller model file
  142509. */
  142510. static MODEL_RIGHT_FILENAME: string;
  142511. profileId: string;
  142512. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142513. protected _getFilenameAndPath(): {
  142514. filename: string;
  142515. path: string;
  142516. };
  142517. protected _getModelLoadingConstraints(): boolean;
  142518. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142519. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142520. protected _updateModel(): void;
  142521. }
  142522. }
  142523. declare module BABYLON {
  142524. /**
  142525. * The motion controller class for oculus touch (quest, rift).
  142526. * This class supports legacy mapping as well the standard xr mapping
  142527. */
  142528. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142529. private _forceLegacyControllers;
  142530. private _modelRootNode;
  142531. /**
  142532. * The base url used to load the left and right controller models
  142533. */
  142534. static MODEL_BASE_URL: string;
  142535. /**
  142536. * The name of the left controller model file
  142537. */
  142538. static MODEL_LEFT_FILENAME: string;
  142539. /**
  142540. * The name of the right controller model file
  142541. */
  142542. static MODEL_RIGHT_FILENAME: string;
  142543. /**
  142544. * Base Url for the Quest controller model.
  142545. */
  142546. static QUEST_MODEL_BASE_URL: string;
  142547. profileId: string;
  142548. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142549. protected _getFilenameAndPath(): {
  142550. filename: string;
  142551. path: string;
  142552. };
  142553. protected _getModelLoadingConstraints(): boolean;
  142554. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142555. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142556. protected _updateModel(): void;
  142557. /**
  142558. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142559. * between the touch and touch 2.
  142560. */
  142561. private _isQuest;
  142562. }
  142563. }
  142564. declare module BABYLON {
  142565. /**
  142566. * The motion controller class for the standard HTC-Vive controllers
  142567. */
  142568. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142569. private _modelRootNode;
  142570. /**
  142571. * The base url used to load the left and right controller models
  142572. */
  142573. static MODEL_BASE_URL: string;
  142574. /**
  142575. * File name for the controller model.
  142576. */
  142577. static MODEL_FILENAME: string;
  142578. profileId: string;
  142579. /**
  142580. * Create a new Vive motion controller object
  142581. * @param scene the scene to use to create this controller
  142582. * @param gamepadObject the corresponding gamepad object
  142583. * @param handness the handness of the controller
  142584. */
  142585. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142586. protected _getFilenameAndPath(): {
  142587. filename: string;
  142588. path: string;
  142589. };
  142590. protected _getModelLoadingConstraints(): boolean;
  142591. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142592. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142593. protected _updateModel(): void;
  142594. }
  142595. }
  142596. declare module BABYLON {
  142597. /**
  142598. * A cursor which tracks a point on a path
  142599. */
  142600. export class PathCursor {
  142601. private path;
  142602. /**
  142603. * Stores path cursor callbacks for when an onchange event is triggered
  142604. */
  142605. private _onchange;
  142606. /**
  142607. * The value of the path cursor
  142608. */
  142609. value: number;
  142610. /**
  142611. * The animation array of the path cursor
  142612. */
  142613. animations: Animation[];
  142614. /**
  142615. * Initializes the path cursor
  142616. * @param path The path to track
  142617. */
  142618. constructor(path: Path2);
  142619. /**
  142620. * Gets the cursor point on the path
  142621. * @returns A point on the path cursor at the cursor location
  142622. */
  142623. getPoint(): Vector3;
  142624. /**
  142625. * Moves the cursor ahead by the step amount
  142626. * @param step The amount to move the cursor forward
  142627. * @returns This path cursor
  142628. */
  142629. moveAhead(step?: number): PathCursor;
  142630. /**
  142631. * Moves the cursor behind by the step amount
  142632. * @param step The amount to move the cursor back
  142633. * @returns This path cursor
  142634. */
  142635. moveBack(step?: number): PathCursor;
  142636. /**
  142637. * Moves the cursor by the step amount
  142638. * If the step amount is greater than one, an exception is thrown
  142639. * @param step The amount to move the cursor
  142640. * @returns This path cursor
  142641. */
  142642. move(step: number): PathCursor;
  142643. /**
  142644. * Ensures that the value is limited between zero and one
  142645. * @returns This path cursor
  142646. */
  142647. private ensureLimits;
  142648. /**
  142649. * Runs onchange callbacks on change (used by the animation engine)
  142650. * @returns This path cursor
  142651. */
  142652. private raiseOnChange;
  142653. /**
  142654. * Executes a function on change
  142655. * @param f A path cursor onchange callback
  142656. * @returns This path cursor
  142657. */
  142658. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142659. }
  142660. }
  142661. declare module BABYLON {
  142662. /** @hidden */
  142663. export var blurPixelShader: {
  142664. name: string;
  142665. shader: string;
  142666. };
  142667. }
  142668. declare module BABYLON {
  142669. /** @hidden */
  142670. export var pointCloudVertexDeclaration: {
  142671. name: string;
  142672. shader: string;
  142673. };
  142674. }
  142675. // Mixins
  142676. interface Window {
  142677. mozIndexedDB: IDBFactory;
  142678. webkitIndexedDB: IDBFactory;
  142679. msIndexedDB: IDBFactory;
  142680. webkitURL: typeof URL;
  142681. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142682. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142683. WebGLRenderingContext: WebGLRenderingContext;
  142684. MSGesture: MSGesture;
  142685. CANNON: any;
  142686. AudioContext: AudioContext;
  142687. webkitAudioContext: AudioContext;
  142688. PointerEvent: any;
  142689. Math: Math;
  142690. Uint8Array: Uint8ArrayConstructor;
  142691. Float32Array: Float32ArrayConstructor;
  142692. mozURL: typeof URL;
  142693. msURL: typeof URL;
  142694. VRFrameData: any; // WebVR, from specs 1.1
  142695. DracoDecoderModule: any;
  142696. setImmediate(handler: (...args: any[]) => void): number;
  142697. }
  142698. interface HTMLCanvasElement {
  142699. requestPointerLock(): void;
  142700. msRequestPointerLock?(): void;
  142701. mozRequestPointerLock?(): void;
  142702. webkitRequestPointerLock?(): void;
  142703. /** Track wether a record is in progress */
  142704. isRecording: boolean;
  142705. /** Capture Stream method defined by some browsers */
  142706. captureStream(fps?: number): MediaStream;
  142707. }
  142708. interface CanvasRenderingContext2D {
  142709. msImageSmoothingEnabled: boolean;
  142710. }
  142711. interface MouseEvent {
  142712. mozMovementX: number;
  142713. mozMovementY: number;
  142714. webkitMovementX: number;
  142715. webkitMovementY: number;
  142716. msMovementX: number;
  142717. msMovementY: number;
  142718. }
  142719. interface Navigator {
  142720. mozGetVRDevices: (any: any) => any;
  142721. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142722. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142723. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142724. webkitGetGamepads(): Gamepad[];
  142725. msGetGamepads(): Gamepad[];
  142726. webkitGamepads(): Gamepad[];
  142727. }
  142728. interface HTMLVideoElement {
  142729. mozSrcObject: any;
  142730. }
  142731. interface Math {
  142732. fround(x: number): number;
  142733. imul(a: number, b: number): number;
  142734. }
  142735. interface WebGLRenderingContext {
  142736. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142737. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142738. vertexAttribDivisor(index: number, divisor: number): void;
  142739. createVertexArray(): any;
  142740. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142741. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142742. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142743. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142744. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142745. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142746. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142747. // Queries
  142748. createQuery(): WebGLQuery;
  142749. deleteQuery(query: WebGLQuery): void;
  142750. beginQuery(target: number, query: WebGLQuery): void;
  142751. endQuery(target: number): void;
  142752. getQueryParameter(query: WebGLQuery, pname: number): any;
  142753. getQuery(target: number, pname: number): any;
  142754. MAX_SAMPLES: number;
  142755. RGBA8: number;
  142756. READ_FRAMEBUFFER: number;
  142757. DRAW_FRAMEBUFFER: number;
  142758. UNIFORM_BUFFER: number;
  142759. HALF_FLOAT_OES: number;
  142760. RGBA16F: number;
  142761. RGBA32F: number;
  142762. R32F: number;
  142763. RG32F: number;
  142764. RGB32F: number;
  142765. R16F: number;
  142766. RG16F: number;
  142767. RGB16F: number;
  142768. RED: number;
  142769. RG: number;
  142770. R8: number;
  142771. RG8: number;
  142772. UNSIGNED_INT_24_8: number;
  142773. DEPTH24_STENCIL8: number;
  142774. MIN: number;
  142775. MAX: number;
  142776. /* Multiple Render Targets */
  142777. drawBuffers(buffers: number[]): void;
  142778. readBuffer(src: number): void;
  142779. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142780. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142781. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142782. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142783. // Occlusion Query
  142784. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142785. ANY_SAMPLES_PASSED: number;
  142786. QUERY_RESULT_AVAILABLE: number;
  142787. QUERY_RESULT: number;
  142788. }
  142789. interface WebGLProgram {
  142790. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142791. }
  142792. interface EXT_disjoint_timer_query {
  142793. QUERY_COUNTER_BITS_EXT: number;
  142794. TIME_ELAPSED_EXT: number;
  142795. TIMESTAMP_EXT: number;
  142796. GPU_DISJOINT_EXT: number;
  142797. QUERY_RESULT_EXT: number;
  142798. QUERY_RESULT_AVAILABLE_EXT: number;
  142799. queryCounterEXT(query: WebGLQuery, target: number): void;
  142800. createQueryEXT(): WebGLQuery;
  142801. beginQueryEXT(target: number, query: WebGLQuery): void;
  142802. endQueryEXT(target: number): void;
  142803. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142804. deleteQueryEXT(query: WebGLQuery): void;
  142805. }
  142806. interface WebGLUniformLocation {
  142807. _currentState: any;
  142808. }
  142809. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142810. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142811. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142812. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142813. interface WebGLRenderingContext {
  142814. readonly RASTERIZER_DISCARD: number;
  142815. readonly DEPTH_COMPONENT24: number;
  142816. readonly TEXTURE_3D: number;
  142817. readonly TEXTURE_2D_ARRAY: number;
  142818. readonly TEXTURE_COMPARE_FUNC: number;
  142819. readonly TEXTURE_COMPARE_MODE: number;
  142820. readonly COMPARE_REF_TO_TEXTURE: number;
  142821. readonly TEXTURE_WRAP_R: number;
  142822. readonly HALF_FLOAT: number;
  142823. readonly RGB8: number;
  142824. readonly RED_INTEGER: number;
  142825. readonly RG_INTEGER: number;
  142826. readonly RGB_INTEGER: number;
  142827. readonly RGBA_INTEGER: number;
  142828. readonly R8_SNORM: number;
  142829. readonly RG8_SNORM: number;
  142830. readonly RGB8_SNORM: number;
  142831. readonly RGBA8_SNORM: number;
  142832. readonly R8I: number;
  142833. readonly RG8I: number;
  142834. readonly RGB8I: number;
  142835. readonly RGBA8I: number;
  142836. readonly R8UI: number;
  142837. readonly RG8UI: number;
  142838. readonly RGB8UI: number;
  142839. readonly RGBA8UI: number;
  142840. readonly R16I: number;
  142841. readonly RG16I: number;
  142842. readonly RGB16I: number;
  142843. readonly RGBA16I: number;
  142844. readonly R16UI: number;
  142845. readonly RG16UI: number;
  142846. readonly RGB16UI: number;
  142847. readonly RGBA16UI: number;
  142848. readonly R32I: number;
  142849. readonly RG32I: number;
  142850. readonly RGB32I: number;
  142851. readonly RGBA32I: number;
  142852. readonly R32UI: number;
  142853. readonly RG32UI: number;
  142854. readonly RGB32UI: number;
  142855. readonly RGBA32UI: number;
  142856. readonly RGB10_A2UI: number;
  142857. readonly R11F_G11F_B10F: number;
  142858. readonly RGB9_E5: number;
  142859. readonly RGB10_A2: number;
  142860. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142861. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142862. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142863. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142864. readonly DEPTH_COMPONENT32F: number;
  142865. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142866. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142867. 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;
  142868. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142869. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142870. readonly TRANSFORM_FEEDBACK: number;
  142871. readonly INTERLEAVED_ATTRIBS: number;
  142872. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142873. createTransformFeedback(): WebGLTransformFeedback;
  142874. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142875. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142876. beginTransformFeedback(primitiveMode: number): void;
  142877. endTransformFeedback(): void;
  142878. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142879. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142880. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142881. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142882. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142883. }
  142884. interface ImageBitmap {
  142885. readonly width: number;
  142886. readonly height: number;
  142887. close(): void;
  142888. }
  142889. interface WebGLQuery extends WebGLObject {
  142890. }
  142891. declare var WebGLQuery: {
  142892. prototype: WebGLQuery;
  142893. new(): WebGLQuery;
  142894. };
  142895. interface WebGLSampler extends WebGLObject {
  142896. }
  142897. declare var WebGLSampler: {
  142898. prototype: WebGLSampler;
  142899. new(): WebGLSampler;
  142900. };
  142901. interface WebGLSync extends WebGLObject {
  142902. }
  142903. declare var WebGLSync: {
  142904. prototype: WebGLSync;
  142905. new(): WebGLSync;
  142906. };
  142907. interface WebGLTransformFeedback extends WebGLObject {
  142908. }
  142909. declare var WebGLTransformFeedback: {
  142910. prototype: WebGLTransformFeedback;
  142911. new(): WebGLTransformFeedback;
  142912. };
  142913. interface WebGLVertexArrayObject extends WebGLObject {
  142914. }
  142915. declare var WebGLVertexArrayObject: {
  142916. prototype: WebGLVertexArrayObject;
  142917. new(): WebGLVertexArrayObject;
  142918. };
  142919. // Type definitions for WebVR API
  142920. // Project: https://w3c.github.io/webvr/
  142921. // Definitions by: six a <https://github.com/lostfictions>
  142922. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142923. interface VRDisplay extends EventTarget {
  142924. /**
  142925. * Dictionary of capabilities describing the VRDisplay.
  142926. */
  142927. readonly capabilities: VRDisplayCapabilities;
  142928. /**
  142929. * z-depth defining the far plane of the eye view frustum
  142930. * enables mapping of values in the render target depth
  142931. * attachment to scene coordinates. Initially set to 10000.0.
  142932. */
  142933. depthFar: number;
  142934. /**
  142935. * z-depth defining the near plane of the eye view frustum
  142936. * enables mapping of values in the render target depth
  142937. * attachment to scene coordinates. Initially set to 0.01.
  142938. */
  142939. depthNear: number;
  142940. /**
  142941. * An identifier for this distinct VRDisplay. Used as an
  142942. * association point in the Gamepad API.
  142943. */
  142944. readonly displayId: number;
  142945. /**
  142946. * A display name, a user-readable name identifying it.
  142947. */
  142948. readonly displayName: string;
  142949. readonly isConnected: boolean;
  142950. readonly isPresenting: boolean;
  142951. /**
  142952. * If this VRDisplay supports room-scale experiences, the optional
  142953. * stage attribute contains details on the room-scale parameters.
  142954. */
  142955. readonly stageParameters: VRStageParameters | null;
  142956. /**
  142957. * Passing the value returned by `requestAnimationFrame` to
  142958. * `cancelAnimationFrame` will unregister the callback.
  142959. * @param handle Define the hanle of the request to cancel
  142960. */
  142961. cancelAnimationFrame(handle: number): void;
  142962. /**
  142963. * Stops presenting to the VRDisplay.
  142964. * @returns a promise to know when it stopped
  142965. */
  142966. exitPresent(): Promise<void>;
  142967. /**
  142968. * Return the current VREyeParameters for the given eye.
  142969. * @param whichEye Define the eye we want the parameter for
  142970. * @returns the eye parameters
  142971. */
  142972. getEyeParameters(whichEye: string): VREyeParameters;
  142973. /**
  142974. * Populates the passed VRFrameData with the information required to render
  142975. * the current frame.
  142976. * @param frameData Define the data structure to populate
  142977. * @returns true if ok otherwise false
  142978. */
  142979. getFrameData(frameData: VRFrameData): boolean;
  142980. /**
  142981. * Get the layers currently being presented.
  142982. * @returns the list of VR layers
  142983. */
  142984. getLayers(): VRLayer[];
  142985. /**
  142986. * Return a VRPose containing the future predicted pose of the VRDisplay
  142987. * when the current frame will be presented. The value returned will not
  142988. * change until JavaScript has returned control to the browser.
  142989. *
  142990. * The VRPose will contain the position, orientation, velocity,
  142991. * and acceleration of each of these properties.
  142992. * @returns the pose object
  142993. */
  142994. getPose(): VRPose;
  142995. /**
  142996. * Return the current instantaneous pose of the VRDisplay, with no
  142997. * prediction applied.
  142998. * @returns the current instantaneous pose
  142999. */
  143000. getImmediatePose(): VRPose;
  143001. /**
  143002. * The callback passed to `requestAnimationFrame` will be called
  143003. * any time a new frame should be rendered. When the VRDisplay is
  143004. * presenting the callback will be called at the native refresh
  143005. * rate of the HMD. When not presenting this function acts
  143006. * identically to how window.requestAnimationFrame acts. Content should
  143007. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143008. * asynchronously from other displays and at differing refresh rates.
  143009. * @param callback Define the eaction to run next frame
  143010. * @returns the request handle it
  143011. */
  143012. requestAnimationFrame(callback: FrameRequestCallback): number;
  143013. /**
  143014. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143015. * Repeat calls while already presenting will update the VRLayers being displayed.
  143016. * @param layers Define the list of layer to present
  143017. * @returns a promise to know when the request has been fulfilled
  143018. */
  143019. requestPresent(layers: VRLayer[]): Promise<void>;
  143020. /**
  143021. * Reset the pose for this display, treating its current position and
  143022. * orientation as the "origin/zero" values. VRPose.position,
  143023. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143024. * updated when calling resetPose(). This should be called in only
  143025. * sitting-space experiences.
  143026. */
  143027. resetPose(): void;
  143028. /**
  143029. * The VRLayer provided to the VRDisplay will be captured and presented
  143030. * in the HMD. Calling this function has the same effect on the source
  143031. * canvas as any other operation that uses its source image, and canvases
  143032. * created without preserveDrawingBuffer set to true will be cleared.
  143033. * @param pose Define the pose to submit
  143034. */
  143035. submitFrame(pose?: VRPose): void;
  143036. }
  143037. declare var VRDisplay: {
  143038. prototype: VRDisplay;
  143039. new(): VRDisplay;
  143040. };
  143041. interface VRLayer {
  143042. leftBounds?: number[] | Float32Array | null;
  143043. rightBounds?: number[] | Float32Array | null;
  143044. source?: HTMLCanvasElement | null;
  143045. }
  143046. interface VRDisplayCapabilities {
  143047. readonly canPresent: boolean;
  143048. readonly hasExternalDisplay: boolean;
  143049. readonly hasOrientation: boolean;
  143050. readonly hasPosition: boolean;
  143051. readonly maxLayers: number;
  143052. }
  143053. interface VREyeParameters {
  143054. /** @deprecated */
  143055. readonly fieldOfView: VRFieldOfView;
  143056. readonly offset: Float32Array;
  143057. readonly renderHeight: number;
  143058. readonly renderWidth: number;
  143059. }
  143060. interface VRFieldOfView {
  143061. readonly downDegrees: number;
  143062. readonly leftDegrees: number;
  143063. readonly rightDegrees: number;
  143064. readonly upDegrees: number;
  143065. }
  143066. interface VRFrameData {
  143067. readonly leftProjectionMatrix: Float32Array;
  143068. readonly leftViewMatrix: Float32Array;
  143069. readonly pose: VRPose;
  143070. readonly rightProjectionMatrix: Float32Array;
  143071. readonly rightViewMatrix: Float32Array;
  143072. readonly timestamp: number;
  143073. }
  143074. interface VRPose {
  143075. readonly angularAcceleration: Float32Array | null;
  143076. readonly angularVelocity: Float32Array | null;
  143077. readonly linearAcceleration: Float32Array | null;
  143078. readonly linearVelocity: Float32Array | null;
  143079. readonly orientation: Float32Array | null;
  143080. readonly position: Float32Array | null;
  143081. readonly timestamp: number;
  143082. }
  143083. interface VRStageParameters {
  143084. sittingToStandingTransform?: Float32Array;
  143085. sizeX?: number;
  143086. sizeY?: number;
  143087. }
  143088. interface Navigator {
  143089. getVRDisplays(): Promise<VRDisplay[]>;
  143090. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143091. }
  143092. interface Window {
  143093. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143094. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143095. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143096. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143097. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143098. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143099. }
  143100. interface Gamepad {
  143101. readonly displayId: number;
  143102. }
  143103. type XRSessionMode =
  143104. | "inline"
  143105. | "immersive-vr"
  143106. | "immersive-ar";
  143107. type XRReferenceSpaceType =
  143108. | "viewer"
  143109. | "local"
  143110. | "local-floor"
  143111. | "bounded-floor"
  143112. | "unbounded";
  143113. type XREnvironmentBlendMode =
  143114. | "opaque"
  143115. | "additive"
  143116. | "alpha-blend";
  143117. type XRVisibilityState =
  143118. | "visible"
  143119. | "visible-blurred"
  143120. | "hidden";
  143121. type XRHandedness =
  143122. | "none"
  143123. | "left"
  143124. | "right";
  143125. type XRTargetRayMode =
  143126. | "gaze"
  143127. | "tracked-pointer"
  143128. | "screen";
  143129. type XREye =
  143130. | "none"
  143131. | "left"
  143132. | "right";
  143133. interface XRSpace extends EventTarget {
  143134. }
  143135. interface XRRenderState {
  143136. depthNear?: number;
  143137. depthFar?: number;
  143138. inlineVerticalFieldOfView?: number;
  143139. baseLayer?: XRWebGLLayer;
  143140. }
  143141. interface XRInputSource {
  143142. handedness: XRHandedness;
  143143. targetRayMode: XRTargetRayMode;
  143144. targetRaySpace: XRSpace;
  143145. gripSpace: XRSpace | undefined;
  143146. gamepad: Gamepad | undefined;
  143147. profiles: Array<string>;
  143148. }
  143149. interface XRSessionInit {
  143150. optionalFeatures?: XRReferenceSpaceType[];
  143151. requiredFeatures?: XRReferenceSpaceType[];
  143152. }
  143153. interface XRSession extends XRAnchorCreator {
  143154. addEventListener: Function;
  143155. removeEventListener: Function;
  143156. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143157. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143158. requestAnimationFrame: Function;
  143159. end(): Promise<void>;
  143160. renderState: XRRenderState;
  143161. inputSources: Array<XRInputSource>;
  143162. // AR hit test
  143163. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143164. updateWorldTrackingState(options: {
  143165. planeDetectionState?: { enabled: boolean; }
  143166. }): void;
  143167. }
  143168. interface XRReferenceSpace extends XRSpace {
  143169. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143170. onreset: any;
  143171. }
  143172. type XRPlaneSet = Set<XRPlane>;
  143173. type XRAnchorSet = Set<XRAnchor>;
  143174. interface XRFrame {
  143175. session: XRSession;
  143176. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143177. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143178. // Anchors
  143179. trackedAnchors?: XRAnchorSet;
  143180. // Planes
  143181. worldInformation: {
  143182. detectedPlanes?: XRPlaneSet;
  143183. };
  143184. }
  143185. interface XRViewerPose extends XRPose {
  143186. views: Array<XRView>;
  143187. }
  143188. interface XRPose {
  143189. transform: XRRigidTransform;
  143190. emulatedPosition: boolean;
  143191. }
  143192. interface XRWebGLLayerOptions {
  143193. antialias?: boolean;
  143194. depth?: boolean;
  143195. stencil?: boolean;
  143196. alpha?: boolean;
  143197. multiview?: boolean;
  143198. framebufferScaleFactor?: number;
  143199. }
  143200. declare var XRWebGLLayer: {
  143201. prototype: XRWebGLLayer;
  143202. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143203. };
  143204. interface XRWebGLLayer {
  143205. framebuffer: WebGLFramebuffer;
  143206. framebufferWidth: number;
  143207. framebufferHeight: number;
  143208. getViewport: Function;
  143209. }
  143210. declare class XRRigidTransform {
  143211. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143212. position: DOMPointReadOnly;
  143213. orientation: DOMPointReadOnly;
  143214. matrix: Float32Array;
  143215. inverse: XRRigidTransform;
  143216. }
  143217. interface XRView {
  143218. eye: XREye;
  143219. projectionMatrix: Float32Array;
  143220. transform: XRRigidTransform;
  143221. }
  143222. interface XRInputSourceChangeEvent {
  143223. session: XRSession;
  143224. removed: Array<XRInputSource>;
  143225. added: Array<XRInputSource>;
  143226. }
  143227. interface XRInputSourceEvent extends Event {
  143228. readonly frame: XRFrame;
  143229. readonly inputSource: XRInputSource;
  143230. }
  143231. // Experimental(er) features
  143232. declare class XRRay {
  143233. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143234. origin: DOMPointReadOnly;
  143235. direction: DOMPointReadOnly;
  143236. matrix: Float32Array;
  143237. }
  143238. interface XRHitResult {
  143239. hitMatrix: Float32Array;
  143240. }
  143241. interface XRAnchor {
  143242. // remove?
  143243. id?: string;
  143244. anchorSpace: XRSpace;
  143245. lastChangedTime: number;
  143246. detach(): void;
  143247. }
  143248. interface XRPlane extends XRAnchorCreator {
  143249. orientation: "Horizontal" | "Vertical";
  143250. planeSpace: XRSpace;
  143251. polygon: Array<DOMPointReadOnly>;
  143252. lastChangedTime: number;
  143253. }
  143254. interface XRAnchorCreator {
  143255. // AR Anchors
  143256. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143257. }